netsurf: branch vince/nsgenbind updated. 5496a604310b65db0513c063ed171f0168baee28
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5496a604310b65db0513c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5496a604310b65db0513c06...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5496a604310b65db0513c063e...
The branch, vince/nsgenbind has been updated
via 5496a604310b65db0513c063ed171f0168baee28 (commit)
from ede48d60748101e9795050955d934ea6e329d4c5 (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/5496a604310b65db051...
commit 5496a604310b65db0513c063ed171f0168baee28
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
console interface from IDL
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 6268548..f5c49f8 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -13,6 +13,7 @@ S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
JSAPI_BINDING_navigator := javascript/jsapi/bindings/navigator.bnd
+JSAPI_BINDING_console := javascript/jsapi/bindings/console.bnd
# 1: input file
# 2: output file
@@ -30,8 +31,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = console.c htmlelement.c
-#htmldocument.c window.c navigator.c
+S_JSAPI = htmlelement.c
+#htmldocument.c window.c navigator.c console.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/WebIDL/console.idl b/javascript/WebIDL/console.idl
new file mode 100644
index 0000000..309b976
--- /dev/null
+++ b/javascript/WebIDL/console.idl
@@ -0,0 +1,20 @@
+// de facto set of features for console object
+// https://developer.mozilla.org/en-US/docs/DOM/console
+// http://msdn.microsoft.com/en-us/library/dd565625%28v=vs.85%29.aspx#consol...
+// 31st October
+// Yay for non-standard standards
+
+interface Console {
+ void debug(DOMString msg, Substitition... subst);
+ void dir(JSObject object);
+ void error(DOMString msg, Substitition... subst);
+ void group();
+ void groupCollapsed();
+ void groupEnd();
+ void info(DOMString msg, Substitition... subst);
+ void log(DOMString msg, Substitition... subst);
+ void time(DOMString timerName);
+ void timeEnd(DOMString timerName);
+ void trace();
+ void warn(DOMString msg, Substitition... subst);
+};
\ No newline at end of file
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 2d88c00..80340a5 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -57,13 +57,14 @@ JSObject *jsapi_new_Document(JSContext *cx,
dom_document *node,
struct html_content *htmlc);
+JSObject *jsapi_InitClass_Console(JSContext *cx, JSObject *parent);
/** Create a new javascript console object
*
* @param cx The javascript context.
* @param parent The parent object, usually a global window object
* @return new javascript object or NULL on error
*/
-JSObject *jsapi_new_Console(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Console(JSContext *cx, JSObject *prototype, JSObject *parent);
JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent);
diff --git a/javascript/jsapi/bindings/console.bnd b/javascript/jsapi/bindings/console.bnd
new file mode 100644
index 0000000..6aef9dc
--- /dev/null
+++ b/javascript/jsapi/bindings/console.bnd
@@ -0,0 +1,59 @@
+/* Binding to generate Console interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+webidlfile "console.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ 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 %{
+ unsigned int argloop;
+ JSString *jsstr;
+ unsigned long jsstrlen;
+ char *txt;
+
+ for (argloop = 0; argloop < argc; argloop++) {
+ jsstr = JS_ValueToString(cx, argv[argloop]);
+
+ JSString_to_char(jsstr, txt, jsstrlen);
+ LOG(("%s", txt));
+ }
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index 9d4a844..ba2db52 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -84,6 +84,12 @@ api init %{
if (user_proto == NULL) {
return NULL;
}
+
+ user_proto = jsapi_InitClass_Console(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
@@ -112,7 +118,7 @@ api new %{
/** @todo forms, history, location */
- private->console = jsapi_new_Console(cx, newobject);
+ private->console = jsapi_new_Console(cx, NULL, newobject);
if (private->console == NULL) {
free(private);
return NULL;
-----------------------------------------------------------------------
Summary of changes:
Makefile.sources.javascript | 5 ++-
javascript/WebIDL/console.idl | 20 +++++++++++
javascript/jsapi/binding.h | 3 +-
javascript/jsapi/bindings/console.bnd | 59 +++++++++++++++++++++++++++++++++
javascript/jsapi/bindings/window.bnd | 8 ++++-
5 files changed, 91 insertions(+), 4 deletions(-)
create mode 100644 javascript/WebIDL/console.idl
create mode 100644 javascript/jsapi/bindings/console.bnd
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 6268548..f5c49f8 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -13,6 +13,7 @@ S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
JSAPI_BINDING_navigator := javascript/jsapi/bindings/navigator.bnd
+JSAPI_BINDING_console := javascript/jsapi/bindings/console.bnd
# 1: input file
# 2: output file
@@ -30,8 +31,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = console.c htmlelement.c
-#htmldocument.c window.c navigator.c
+S_JSAPI = htmlelement.c
+#htmldocument.c window.c navigator.c console.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/WebIDL/console.idl b/javascript/WebIDL/console.idl
new file mode 100644
index 0000000..309b976
--- /dev/null
+++ b/javascript/WebIDL/console.idl
@@ -0,0 +1,20 @@
+// de facto set of features for console object
+// https://developer.mozilla.org/en-US/docs/DOM/console
+// http://msdn.microsoft.com/en-us/library/dd565625%28v=vs.85%29.aspx#consol...
+// 31st October
+// Yay for non-standard standards
+
+interface Console {
+ void debug(DOMString msg, Substitition... subst);
+ void dir(JSObject object);
+ void error(DOMString msg, Substitition... subst);
+ void group();
+ void groupCollapsed();
+ void groupEnd();
+ void info(DOMString msg, Substitition... subst);
+ void log(DOMString msg, Substitition... subst);
+ void time(DOMString timerName);
+ void timeEnd(DOMString timerName);
+ void trace();
+ void warn(DOMString msg, Substitition... subst);
+};
\ No newline at end of file
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 2d88c00..80340a5 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -57,13 +57,14 @@ JSObject *jsapi_new_Document(JSContext *cx,
dom_document *node,
struct html_content *htmlc);
+JSObject *jsapi_InitClass_Console(JSContext *cx, JSObject *parent);
/** Create a new javascript console object
*
* @param cx The javascript context.
* @param parent The parent object, usually a global window object
* @return new javascript object or NULL on error
*/
-JSObject *jsapi_new_Console(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Console(JSContext *cx, JSObject *prototype, JSObject *parent);
JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent);
diff --git a/javascript/jsapi/bindings/console.bnd b/javascript/jsapi/bindings/console.bnd
new file mode 100644
index 0000000..6aef9dc
--- /dev/null
+++ b/javascript/jsapi/bindings/console.bnd
@@ -0,0 +1,59 @@
+/* Binding to generate Console interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+webidlfile "console.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ 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 %{
+ unsigned int argloop;
+ JSString *jsstr;
+ unsigned long jsstrlen;
+ char *txt;
+
+ for (argloop = 0; argloop < argc; argloop++) {
+ jsstr = JS_ValueToString(cx, argv[argloop]);
+
+ JSString_to_char(jsstr, txt, jsstrlen);
+ LOG(("%s", txt));
+ }
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index 9d4a844..ba2db52 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -84,6 +84,12 @@ api init %{
if (user_proto == NULL) {
return NULL;
}
+
+ user_proto = jsapi_InitClass_Console(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
%}
api new %{
@@ -112,7 +118,7 @@ api new %{
/** @todo forms, history, location */
- private->console = jsapi_new_Console(cx, newobject);
+ private->console = jsapi_new_Console(cx, NULL, newobject);
if (private->console == NULL) {
free(private);
return NULL;
--
NetSurf Browser
10 years, 10 months
nsgenjsbind: branch master updated. e35c777cc2d3d551d4f659e95c06b902379992aa
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/e35c777cc2d3d551d...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/e35c777cc2d3d551d4f...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/e35c777cc2d3d551d4f65...
The branch, master has been updated
via e35c777cc2d3d551d4f659e95c06b902379992aa (commit)
from 65e49e23019a97d51702077c82613c6c26e84033 (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/e35c777cc2d3d55...
commit e35c777cc2d3d551d4f659e95c06b902379992aa
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make the argv generation conditional on its use
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 4edf235..748ea4c 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -162,6 +162,13 @@ output_variable_definitions(struct binding *binding,
arg_node = webidl_node_find_type(arglist,
arg_node,
WEBIDL_NODE_TYPE_ARGUMENT);
+
+ /* at least one argument or private need to generate argv variable */
+ if ((arg_node != NULL) || binding->has_private) {
+ fprintf(binding->outfile,
+ "\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
+ }
+
while (arg_node != NULL) {
/* generate variable to hold the argument */
arg_ident = webidl_node_find_type(webidl_node_getnode(arg_node),
@@ -441,9 +448,6 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
fprintf(binding->outfile,
"{\n");
- fprintf(binding->outfile,
- "\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
-
output_variable_definitions(binding, webidl_node_getnode(node));
if (binding->has_private) {
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-operator.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 4edf235..748ea4c 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -162,6 +162,13 @@ output_variable_definitions(struct binding *binding,
arg_node = webidl_node_find_type(arglist,
arg_node,
WEBIDL_NODE_TYPE_ARGUMENT);
+
+ /* at least one argument or private need to generate argv variable */
+ if ((arg_node != NULL) || binding->has_private) {
+ fprintf(binding->outfile,
+ "\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
+ }
+
while (arg_node != NULL) {
/* generate variable to hold the argument */
arg_ident = webidl_node_find_type(webidl_node_getnode(arg_node),
@@ -441,9 +448,6 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
fprintf(binding->outfile,
"{\n");
- fprintf(binding->outfile,
- "\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
-
output_variable_definitions(binding, webidl_node_getnode(node));
if (binding->has_private) {
--
NetSurf Generator for JavaScript bindings
10 years, 10 months
netsurf: branch master updated. efbfbbc96732ba7b0b8f526b07c776908c79533b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/efbfbbc96732ba7b0b8f5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/efbfbbc96732ba7b0b8f526...
...tree http://git.netsurf-browser.org/netsurf.git/tree/efbfbbc96732ba7b0b8f526b0...
The branch, master has been updated
via efbfbbc96732ba7b0b8f526b07c776908c79533b (commit)
via 116cd6aa435a0ef81724825993c22190476e15ef (commit)
from 7c737252e0ce7276b132b4634dc615ddad508698 (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/efbfbbc96732ba7b0b8...
commit efbfbbc96732ba7b0b8f526b07c776908c79533b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix a serious crash that occurs if the underlying window is closed during a hook function invoked from it.
diff --git a/amiga/gui.c b/amiga/gui.c
index 15ac1f5..37f0547 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1927,6 +1927,16 @@ void ami_handle_msg(void)
ami_update_throbber(gwin, true);
refresh_throbber = FALSE;
}
+
+ if(ami_menu_window_close)
+ {
+ if(ami_menu_window_close == AMI_MENU_WINDOW_CLOSE_ALL)
+ ami_quit_netsurf();
+ else
+ ami_close_all_tabs(ami_menu_window_close);
+
+ ami_menu_window_close = NULL;
+ }
}
void ami_gui_appicon_remove(struct gui_window_2 *gwin)
@@ -2276,6 +2286,8 @@ void ami_quit_netsurf(void)
}
} while(node = nnode);
+
+ win_destroyed = true;
}
if(IsMinListEmpty(window_list))
diff --git a/amiga/menu.c b/amiga/menu.c
index ab8381a..b116e1b 100755
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -676,7 +676,7 @@ static void ami_menu_item_project_closewin(struct Hook *hook, APTR window, struc
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- ami_close_all_tabs(gwin);
+ ami_menu_window_close = gwin;
}
static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct IntuiMessage *msg)
@@ -736,7 +736,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
- ami_quit_netsurf();
+ ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL;
}
static void ami_menu_item_edit_cut(struct Hook *hook, APTR window, struct IntuiMessage *msg)
diff --git a/amiga/menu.h b/amiga/menu.h
index 36c6017..d692320 100755
--- a/amiga/menu.h
+++ b/amiga/menu.h
@@ -63,9 +63,14 @@
#define AMI_MENU_CLEAR FULLMENUNUM(1,5,0)
#define AMI_MENU_FIND FULLMENUNUM(2,0,0)
+/* A special value for ami_menu_window_close */
+#define AMI_MENU_WINDOW_CLOSE_ALL 1
+
struct gui_window;
struct gui_window_2;
+struct gui_window_2 *ami_menu_window_close;
+
void ami_free_menulabs(struct gui_window_2 *gwin);
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/116cd6aa435a0ef8172...
commit 116cd6aa435a0ef81724825993c22190476e15ef
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Make it a bit more obvious what is happening, as AutoInstall/CopyStore won't give us a progress bar.
diff --git a/amiga/dist/Install b/amiga/dist/Install
index 5fabf3e..7b8c5fe 100755
--- a/amiga/dist/Install
+++ b/amiga/dist/Install
@@ -448,6 +448,8 @@
(set #netsurf-name (select #cairo-version #static-filename #cairo-filename))
+(working "Installing NetSurf")
+
(if (= #AutoInstall 0)
(
(copyfiles
-----------------------------------------------------------------------
Summary of changes:
amiga/dist/Install | 2 ++
amiga/gui.c | 12 ++++++++++++
amiga/menu.c | 4 ++--
amiga/menu.h | 5 +++++
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/amiga/dist/Install b/amiga/dist/Install
index 5fabf3e..7b8c5fe 100755
--- a/amiga/dist/Install
+++ b/amiga/dist/Install
@@ -448,6 +448,8 @@
(set #netsurf-name (select #cairo-version #static-filename #cairo-filename))
+(working "Installing NetSurf")
+
(if (= #AutoInstall 0)
(
(copyfiles
diff --git a/amiga/gui.c b/amiga/gui.c
index 15ac1f5..37f0547 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1927,6 +1927,16 @@ void ami_handle_msg(void)
ami_update_throbber(gwin, true);
refresh_throbber = FALSE;
}
+
+ if(ami_menu_window_close)
+ {
+ if(ami_menu_window_close == AMI_MENU_WINDOW_CLOSE_ALL)
+ ami_quit_netsurf();
+ else
+ ami_close_all_tabs(ami_menu_window_close);
+
+ ami_menu_window_close = NULL;
+ }
}
void ami_gui_appicon_remove(struct gui_window_2 *gwin)
@@ -2276,6 +2286,8 @@ void ami_quit_netsurf(void)
}
} while(node = nnode);
+
+ win_destroyed = true;
}
if(IsMinListEmpty(window_list))
diff --git a/amiga/menu.c b/amiga/menu.c
index ab8381a..b116e1b 100755
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -676,7 +676,7 @@ static void ami_menu_item_project_closewin(struct Hook *hook, APTR window, struc
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- ami_close_all_tabs(gwin);
+ ami_menu_window_close = gwin;
}
static void ami_menu_item_project_print(struct Hook *hook, APTR window, struct IntuiMessage *msg)
@@ -736,7 +736,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
static void ami_menu_item_project_quit(struct Hook *hook, APTR window, struct IntuiMessage *msg)
{
- ami_quit_netsurf();
+ ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL;
}
static void ami_menu_item_edit_cut(struct Hook *hook, APTR window, struct IntuiMessage *msg)
diff --git a/amiga/menu.h b/amiga/menu.h
index 36c6017..d692320 100755
--- a/amiga/menu.h
+++ b/amiga/menu.h
@@ -63,9 +63,14 @@
#define AMI_MENU_CLEAR FULLMENUNUM(1,5,0)
#define AMI_MENU_FIND FULLMENUNUM(2,0,0)
+/* A special value for ami_menu_window_close */
+#define AMI_MENU_WINDOW_CLOSE_ALL 1
+
struct gui_window;
struct gui_window_2;
+struct gui_window_2 *ami_menu_window_close;
+
void ami_free_menulabs(struct gui_window_2 *gwin);
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
--
NetSurf Browser
10 years, 10 months
netsurf: branch master updated. 7c737252e0ce7276b132b4634dc615ddad508698
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7c737252e0ce7276b132b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7c737252e0ce7276b132b46...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7c737252e0ce7276b132b4634...
The branch, master has been updated
via 7c737252e0ce7276b132b4634dc615ddad508698 (commit)
via cfdf28ac93a11bc86b609d1f27277a20424d5a27 (commit)
from af2d9e8906d1d439c0c4319298843c40047dd256 (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/7c737252e0ce7276b13...
commit 7c737252e0ce7276b132b4634dc615ddad508698
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix AutoInstall
diff --git a/amiga/dist/Install b/amiga/dist/Install
index 039ccbf..5fabf3e 100755
--- a/amiga/dist/Install
+++ b/amiga/dist/Install
@@ -311,20 +311,9 @@
(set osver (/ osver 65536))
(set #versions-available 0)
-(set #static-filename "NetSurf-Static")
+(set #static-filename "NetSurf")
(set #cairo-filename "NetSurf")
-(if (exists "NetSurf-Static")
- (
- (set #static-name "Static/graphics.library")
- (set #versions-available (+ #versions-available 1))
- )
- ; else
- (
- (set #static-name "")
- )
-)
-
(if (exists "NetSurf")
(
(if (exists "SObjs")
@@ -375,8 +364,7 @@
(set #cairo-version
(askchoice
(prompt "Which version of NetSurf would you like to install?")
- (help "The Cairo/shared objects version has better rendering "
- "of some graphical elements, and supports SVG.\n\n"
+ (help "The Cairo version has anti-aliasing of graphical elements.\n\n"
@askchoice-help)
(choices #static-name #cairo-name)
(default #cairo-version)
@@ -474,18 +462,7 @@
)
;else
(
- (copyfiles
- (prompt "Please check the version of NetSurf you are copying against "
- "any which might already be installed.")
- (help @copyfiles-help)
- (source #netsurf-name)
- (dest "T:")
- (newname "NetSurf")
- (optional "force" "oknodelete")
- )
-
- (run "CopyStore T:NetSurf" @default-dest)
- (delete "T:NetSurf")
+ (run "CopyStore NetSurf" @default-dest)
)
)
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/cfdf28ac93a11bc86b6...
commit cfdf28ac93a11bc86b609d1f27277a20424d5a27
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Drop the two different names for the executable
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 61de77b..4cd76cf 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -39,9 +39,6 @@ ifeq ($(HOST),amiga)
ifeq ($(NETSURF_USE_AMIGA_CAIRO),YES)
CFLAGS += -I /SDK/local/common/include/cairo
LDFLAGS += -use-dynld -ldl -lcairo -lpixman-1 -lfreetype -lfontconfig -lpng -lexpat
- EXETARGET := NetSurf
- else
- EXETARGET := NetSurf-Static
endif
else
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
@@ -66,18 +63,14 @@ else
else
LDFLAGS += -lauto -lpbl -liconv
endif
-
- ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes)
- EXETARGET := NetSurf
- else
- EXETARGET := NetSurf-Static
- endif
endif
ifeq ($(NETSURF_USE_MOZJS),YES)
NETSURF_USE_JS:=YES
endif
+EXETARGET := NetSurf
+
# ----------------------------------------------------------------------------
# Source file setup
# ----------------------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
amiga/Makefile.target | 11 ++---------
amiga/dist/Install | 29 +++--------------------------
2 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 61de77b..4cd76cf 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -39,9 +39,6 @@ ifeq ($(HOST),amiga)
ifeq ($(NETSURF_USE_AMIGA_CAIRO),YES)
CFLAGS += -I /SDK/local/common/include/cairo
LDFLAGS += -use-dynld -ldl -lcairo -lpixman-1 -lfreetype -lfontconfig -lpng -lexpat
- EXETARGET := NetSurf
- else
- EXETARGET := NetSurf-Static
endif
else
$(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,Sprite))
@@ -66,18 +63,14 @@ else
else
LDFLAGS += -lauto -lpbl -liconv
endif
-
- ifeq ($(NETSURF_AMIGA_CAIRO_AVAILABLE),yes)
- EXETARGET := NetSurf
- else
- EXETARGET := NetSurf-Static
- endif
endif
ifeq ($(NETSURF_USE_MOZJS),YES)
NETSURF_USE_JS:=YES
endif
+EXETARGET := NetSurf
+
# ----------------------------------------------------------------------------
# Source file setup
# ----------------------------------------------------------------------------
diff --git a/amiga/dist/Install b/amiga/dist/Install
index 039ccbf..5fabf3e 100755
--- a/amiga/dist/Install
+++ b/amiga/dist/Install
@@ -311,20 +311,9 @@
(set osver (/ osver 65536))
(set #versions-available 0)
-(set #static-filename "NetSurf-Static")
+(set #static-filename "NetSurf")
(set #cairo-filename "NetSurf")
-(if (exists "NetSurf-Static")
- (
- (set #static-name "Static/graphics.library")
- (set #versions-available (+ #versions-available 1))
- )
- ; else
- (
- (set #static-name "")
- )
-)
-
(if (exists "NetSurf")
(
(if (exists "SObjs")
@@ -375,8 +364,7 @@
(set #cairo-version
(askchoice
(prompt "Which version of NetSurf would you like to install?")
- (help "The Cairo/shared objects version has better rendering "
- "of some graphical elements, and supports SVG.\n\n"
+ (help "The Cairo version has anti-aliasing of graphical elements.\n\n"
@askchoice-help)
(choices #static-name #cairo-name)
(default #cairo-version)
@@ -474,18 +462,7 @@
)
;else
(
- (copyfiles
- (prompt "Please check the version of NetSurf you are copying against "
- "any which might already be installed.")
- (help @copyfiles-help)
- (source #netsurf-name)
- (dest "T:")
- (newname "NetSurf")
- (optional "force" "oknodelete")
- )
-
- (run "CopyStore T:NetSurf" @default-dest)
- (delete "T:NetSurf")
+ (run "CopyStore NetSurf" @default-dest)
)
)
--
NetSurf Browser
10 years, 10 months
netsurf: branch vince/nsgenbind updated. ede48d60748101e9795050955d934ea6e329d4c5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ede48d60748101e979505...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ede48d60748101e97950509...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ede48d60748101e9795050955...
The branch, vince/nsgenbind has been updated
via ede48d60748101e9795050955d934ea6e329d4c5 (commit)
via 79e557bbe83845df21575b525ea8aadbea29f6ce (commit)
from 881daebce29e7c4c956a3999aa9088179aa5b655 (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/ede48d60748101e9795...
commit ede48d60748101e9795050955d934ea6e329d4c5
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add navigator interface
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index e188df6..6268548 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -12,6 +12,7 @@ S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
+JSAPI_BINDING_navigator := javascript/jsapi/bindings/navigator.bnd
# 1: input file
# 2: output file
@@ -29,8 +30,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = navigator.c console.c htmlelement.c
-#htmldocument.c window.c
+S_JSAPI = console.c htmlelement.c
+#htmldocument.c window.c navigator.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 7ead6f6..2d88c00 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -65,13 +65,15 @@ JSObject *jsapi_new_Document(JSContext *cx,
*/
JSObject *jsapi_new_Console(JSContext *cx, JSObject *parent);
+
+JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent);
/** Create a new javascript navigator object
*
* @param cx The javascript context.
* @param parent The parent object, usually a global window object
* @return new javascript object or NULL on error
*/
-JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *proto, JSObject *parent);
/** Create a new javascript element object
*
diff --git a/javascript/jsapi/bindings/example.bnd b/javascript/jsapi/bindings/example.bnd
new file mode 100644
index 0000000..897e9a5
--- /dev/null
+++ b/javascript/jsapi/bindings/example.bnd
@@ -0,0 +1,90 @@
+/* Binding to generate Navigator interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+/*
+ * navigator properties for netsurf
+ *
+ * Property | Everyone else | NetSurf | Notes
+ * ------------+-----------------+--------------+------------------------------
+ * appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
+ * | | | constant as everyone returns
+ * | | | "Mozilla" which is dumb
+ * ------------+-----------------+--------------+------------------------------
+ * appName | "<Browsername>" | "NetSurf" | Browsers named other than
+ * | | | "Netscape", "Mozilla",
+ * | | | "Netscape Navigator",
+ * | | | "Microsoft Internet Explorer"
+ * | | | often other browser have
+ * | | | "(compatible with Netscape)"
+ * | | | append.
+ * ------------+-----------------+--------------+------------------------------
+ * appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
+ * | | | number e.g "3.0".
+ * ------------+-----------------+--------------+------------------------------
+ * language | "<lang>" | "<lang>" | The language the frontend is
+ * | | | configured for
+ * ------------+-----------------+--------------+------------------------------
+ * platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
+ * | | | eg "Linux x86_64"
+ * ------------+-----------------+--------------+------------------------------
+ * userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
+ * | | | with excessive lies
+ * ------------+-----------------+--------------+------------------------------
+ */
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* 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.
+ */
+ private "dom_document *" node;
+ private "struct html_content *" htmlc;
+}
+
+operation write %{
+ LOG(("content %p parser %p writing %s",
+ private->htmlc, private->htmlc->parser, text));
+
+ if (private->htmlc->parser != NULL) {
+ dom_hubbub_parser_insert_chunk(private->htmlc->parser, (uint8_t *)text, text_len);
+ }
+%}
diff --git a/javascript/jsapi/bindings/navigator.bnd b/javascript/jsapi/bindings/navigator.bnd
new file mode 100644
index 0000000..596f1ac
--- /dev/null
+++ b/javascript/jsapi/bindings/navigator.bnd
@@ -0,0 +1,120 @@
+/* Binding to generate Navigator interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "desktop/netsurf.h"
+#include "desktop/options.h"
+
+#include "utils/config.h"
+#include "utils/useragent.h"
+#include "utils/log.h"
+#include "utils/utsname.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+/*
+ * navigator properties for netsurf
+ *
+ * Property | Everyone else | NetSurf | Notes
+ * ------------+-----------------+--------------+------------------------------
+ * appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
+ * | | | constant as everyone returns
+ * | | | "Mozilla" which is dumb
+ * ------------+-----------------+--------------+------------------------------
+ * appName | "<Browsername>" | "NetSurf" | Browsers named other than
+ * | | | "Netscape", "Mozilla",
+ * | | | "Netscape Navigator",
+ * | | | "Microsoft Internet Explorer"
+ * | | | often other browser have
+ * | | | "(compatible with Netscape)"
+ * | | | append.
+ * ------------+-----------------+--------------+------------------------------
+ * appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
+ * | | | number e.g "3.0".
+ * ------------+-----------------+--------------+------------------------------
+ * language | "<lang>" | "<lang>" | The language the frontend is
+ * | | | configured for
+ * ------------+-----------------+--------------+------------------------------
+ * platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
+ * | | | eg "Linux x86_64"
+ * ------------+-----------------+--------------+------------------------------
+ * userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
+ * | | | with excessive lies
+ * ------------+-----------------+--------------+------------------------------
+ */
+
+#define NAVIGATOR_APPNAME "NetSurf"
+#define NAVIGATOR_APPCODENAME "NetSurf"
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* Web IDL interface to generate */
+
+}
+
+getter appName %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPNAME));
+%}
+
+getter appCodeName %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPCODENAME));
+%}
+
+getter appVersion %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, netsurf_version));
+%}
+
+getter language %{
+ const char *alang = nsoption_charp(accept_language);
+
+ if (alang != NULL) {
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, alang));
+ }
+
+%}
+
+getter platform %{
+ struct utsname *cutsname;
+
+ cutsname = malloc(sizeof(struct utsname));
+
+ if ((cutsname != NULL) && (uname(cutsname) >= 0)) {
+ char *platstr;
+ int platstrlen;
+
+ platstrlen = strlen(cutsname->sysname) + strlen(cutsname->machine) + 2;
+ platstr = malloc(platstrlen);
+ if (platstr != NULL) {
+ snprintf(platstr, platstrlen, "%s %s", cutsname->sysname, cutsname->machine);
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyN(cx, platstr, platstrlen - 1));
+ free(platstr);
+ }
+ }
+%}
+
+getter userAgent %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, user_agent_string()));
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index c0b659e..9d4a844 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -79,6 +79,11 @@ api init %{
if (user_proto == NULL) {
return NULL;
}
+
+ user_proto = jsapi_InitClass_Navigator(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
%}
api new %{
@@ -99,13 +104,12 @@ api new %{
return NULL;
}
-/*
- private->navigator_obj = jsapi_new_Navigator(cx, window);
- if (private->navigator_obj == NULL) {
+ private->navigator = jsapi_new_Navigator(cx, NULL, newobject);
+ if (private->navigator == NULL) {
free(private);
return NULL;
}
-*/
+
/** @todo forms, history, location */
private->console = jsapi_new_Console(cx, newobject);
diff --git a/javascript/jsapi/window.c b/javascript/jsapi/window.c
index 476a383..062d925 100644
--- a/javascript/jsapi/window.c
+++ b/javascript/jsapi/window.c
@@ -263,13 +263,12 @@ JSObject *jsapi_new_Window(JSContext *cx,
return NULL;
}
-/*
private->navigator_obj = jsapi_new_Navigator(cx, window);
if (private->navigator_obj == NULL) {
free(private);
return NULL;
}
-*/
+
/** @todo forms, history, location */
private->console_obj = jsapi_new_Console(cx, window);
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/79e557bbe83845df215...
commit 79e557bbe83845df21575b525ea8aadbea29f6ce
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Move WebIDL to be available for all binding types not just jsapi (spidermonkey)
Add conversion message display
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index db63050..e188df6 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -21,7 +21,8 @@ define convert_jsapi_binding
S_JSAPI_BINDING += $(2)
$(2): $(1)
- $(Q)nsgenbind -I javascript/jsapi/WebIDL/ -o $(2) $(1)
+ $$(VQ)echo " GENBIND: $(1)"
+ $(Q)nsgenbind -I javascript/WebIDL/ -o $(2) $(1)
endef
diff --git a/javascript/WebIDL/Makefile b/javascript/WebIDL/Makefile
new file mode 100644
index 0000000..77d54e2
--- /dev/null
+++ b/javascript/WebIDL/Makefile
@@ -0,0 +1,38 @@
+#!/bin/make
+#
+# Create the WebIDL for core DOM and HTML spec directly from
+# downloaded specifications. The resulting IDL is pretty close but
+# carries the example text etc. and should be manually cleaned up and
+# tagged with the retrival date and source URL
+#
+# needs debin packages: curl w3m tidy html-xml-utils
+#
+# Copyright 2012 Vincent Sanders
+# MIT licenced
+
+.PHONY:all clean
+
+all: dom.idl html.idl
+
+.INTERMEDIATE:dom-spec.html dom-spec.xml dom-idl.html html-spec.html html-spec.xml html-idl.html
+
+
+dom-spec.html:
+ curl -s http://dom.spec.whatwg.org/ -o $@
+
+html-spec.html:
+ curl -s http://www.whatwg.org/specs/web-apps/current-work/ -o $@
+
+%-spec.xml: %-spec.html
+ -tidy -q -f $@.errors --new-blocklevel-tags header,hgroup,figure -o $@ -asxml $<
+
+%-idl.html: %-spec.xml
+ hxselect pre.idl < $< > $@
+
+%.idl: %-idl.html
+ cat $< | w3m -dump -T text/html >$@
+
+
+
+clean:
+ ${RM} dom.idl html.idl dom-spec.html dom-spec.xml dom-idl.html html-spec.html html-spec.xml html-idl.html
diff --git a/javascript/WebIDL/dom.idl b/javascript/WebIDL/dom.idl
new file mode 100644
index 0000000..6ba870c
--- /dev/null
+++ b/javascript/WebIDL/dom.idl
@@ -0,0 +1,446 @@
+// DOM core WebIDL
+// retrived from http://dom.spec.whatwg.org/
+// 23rd October 2012
+
+
+
+exception DOMException {
+ const unsigned short INDEX_SIZE_ERR = 1;
+ const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
+ const unsigned short HIERARCHY_REQUEST_ERR = 3;
+ const unsigned short WRONG_DOCUMENT_ERR = 4;
+ const unsigned short INVALID_CHARACTER_ERR = 5;
+ const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
+ const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
+ const unsigned short NOT_FOUND_ERR = 8;
+ const unsigned short NOT_SUPPORTED_ERR = 9;
+ const unsigned short INUSE_ATTRIBUTE_ERR = 10; // historical
+ const unsigned short INVALID_STATE_ERR = 11;
+ const unsigned short SYNTAX_ERR = 12;
+ const unsigned short INVALID_MODIFICATION_ERR = 13;
+ const unsigned short NAMESPACE_ERR = 14;
+ const unsigned short INVALID_ACCESS_ERR = 15;
+ const unsigned short VALIDATION_ERR = 16; // historical
+ const unsigned short TYPE_MISMATCH_ERR = 17;
+ const unsigned short SECURITY_ERR = 18;
+ const unsigned short NETWORK_ERR = 19;
+ const unsigned short ABORT_ERR = 20;
+ const unsigned short URL_MISMATCH_ERR = 21;
+ const unsigned short QUOTA_EXCEEDED_ERR = 22;
+ const unsigned short TIMEOUT_ERR = 23;
+ const unsigned short INVALID_NODE_TYPE_ERR = 24;
+ const unsigned short DATA_CLONE_ERR = 25;
+ unsigned short code;
+};
+
+interface DOMError {
+ readonly attribute DOMString name;
+};
+
+[Constructor(DOMString type, optional EventInit eventInitDict)]
+interface Event {
+ readonly attribute DOMString type;
+ readonly attribute EventTarget? target;
+ readonly attribute EventTarget? currentTarget;
+
+ const unsigned short NONE = 0;
+ const unsigned short CAPTURING_PHASE = 1;
+ const unsigned short AT_TARGET = 2;
+ const unsigned short BUBBLING_PHASE = 3;
+ readonly attribute unsigned short eventPhase;
+
+ void stopPropagation();
+ void stopImmediatePropagation();
+
+ readonly attribute boolean bubbles;
+ readonly attribute boolean cancelable;
+ void preventDefault();
+ readonly attribute boolean defaultPrevented;
+
+ readonly attribute boolean isTrusted;
+ readonly attribute DOMTimeStamp timeStamp;
+
+ void initEvent(DOMString type, boolean bubbles, boolean cancelable);
+};
+
+dictionary EventInit {
+ boolean bubbles;
+ boolean cancelable;
+};
+
+[Constructor(DOMString type, optional CustomEventInit eventInitDict)]
+interface CustomEvent : Event {
+ readonly attribute any detail;
+};
+
+dictionary CustomEventInit : EventInit {
+ any detail;
+};
+
+interface EventTarget {
+ void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ boolean dispatchEvent(Event event);
+};
+
+callback interface EventListener {
+ void handleEvent(Event event);
+};
+
+[Constructor(MutationCallback callback)]
+interface MutationObserver {
+ void observe(Node target, MutationObserverInit options);
+ void disconnect();
+ sequence<MutationRecord> takeRecords();
+};
+
+callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);
+
+dictionary MutationObserverInit {
+ boolean childList;
+ boolean attributes;
+ boolean characterData;
+ boolean subtree;
+ boolean attributeOldValue;
+ boolean characterDataOldValue;
+ sequence<DOMString> attributeFilter;
+};
+
+interface MutationRecord {
+ readonly attribute DOMString type;
+ readonly attribute Node target;
+ readonly attribute NodeList addedNodes;
+ readonly attribute NodeList removedNodes;
+ readonly attribute Node? previousSibling;
+ readonly attribute Node? nextSibling;
+ readonly attribute DOMString? attributeName;
+ readonly attribute DOMString? attributeNamespace;
+ readonly attribute DOMString? oldValue;
+};
+
+interface Node : EventTarget {
+ const unsigned short ELEMENT_NODE = 1;
+ const unsigned short ATTRIBUTE_NODE = 2; // historical
+ const unsigned short TEXT_NODE = 3;
+ const unsigned short CDATA_SECTION_NODE = 4; // historical
+ const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
+ const unsigned short ENTITY_NODE = 6; // historical
+ const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
+ const unsigned short COMMENT_NODE = 8;
+ const unsigned short DOCUMENT_NODE = 9;
+ const unsigned short DOCUMENT_TYPE_NODE = 10;
+ const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
+ const unsigned short NOTATION_NODE = 12; // historical
+ readonly attribute unsigned short nodeType;
+ readonly attribute DOMString nodeName;
+
+ readonly attribute DOMString? baseURI;
+
+ readonly attribute Document? ownerDocument;
+ readonly attribute Node? parentNode;
+ readonly attribute Element? parentElement;
+ boolean hasChildNodes();
+ readonly attribute NodeList childNodes;
+ readonly attribute Node? firstChild;
+ readonly attribute Node? lastChild;
+ readonly attribute Node? previousSibling;
+ readonly attribute Node? nextSibling;
+
+ attribute DOMString? nodeValue;
+ attribute DOMString? textContent;
+ Node insertBefore(Node node, Node? child);
+ Node appendChild(Node node);
+ Node replaceChild(Node node, Node child);
+ Node removeChild(Node child);
+ void normalize();
+
+
+Node cloneNode(optional boolean deep = true);
+ boolean isEqualNode(Node? node);
+
+ const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
+ const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
+ const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
+ const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
+ const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+ const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
+ unsigned short compareDocumentPosition(Node other);
+ boolean contains(Node? other);
+
+ DOMString? lookupPrefix(DOMString? namespace);
+ DOMString? lookupNamespaceURI(DOMString? prefix);
+ boolean isDefaultNamespace(DOMString? namespace);
+};
+
+[Constructor]
+interface Document : Node {
+ readonly attribute DOMImplementation implementation;
+ readonly attribute DOMString URL;
+ readonly attribute DOMString documentURI;
+ readonly attribute DOMString compatMode;
+ readonly attribute DOMString characterSet;
+ readonly attribute DOMString contentType;
+
+ readonly attribute DocumentType? doctype;
+ readonly attribute Element? documentElement;
+ HTMLCollection getElementsByTagName(DOMString localName);
+ HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
+ HTMLCollection getElementsByClassName(DOMString classNames);
+ Element? getElementById(DOMString elementId);
+
+ Element createElement(DOMString localName);
+ Element createElementNS(DOMString? namespace, DOMString qualifiedName);
+ DocumentFragment createDocumentFragment();
+ Text createTextNode(DOMString data);
+ Comment createComment(DOMString data);
+ ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
+
+ Node importNode(Node node, optional boolean deep = true);
+ Node adoptNode(Node node);
+
+ Event createEvent(DOMString interface);
+
+ Range createRange();
+
+ // NodeFilter.SHOW_ALL = 0xFFFFFFFF
+ NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
+ TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
+
+ // NEW
+ void prepend((Node or DOMString)... nodes);
+ void append((Node or DOMString)... nodes);
+};
+
+interface XMLDocument : Document {};
+
+interface DOMImplementation {
+ DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
+ XMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, DocumentType? doctype);
+ Document createHTMLDocument(optional DOMString title);
+
+ boolean hasFeature(DOMString feature, [TreatNullAs=EmptyString] DOMString version);
+};
+
+interface DocumentFragment : Node {
+ // NEW
+ void prepend((Node or DOMString)... nodes);
+ void append((Node or DOMString)... nodes);
+};
+
+interface DocumentType : Node {
+ readonly attribute DOMString name;
+ readonly attribute DOMString publicId;
+ readonly attribute DOMString systemId;
+
+ // NEW
+ void before((Node or DOMString)... nodes);
+ void after((Node or DOMString)... nodes);
+ void replace((Node or DOMString)... nodes);
+ void remove();
+};
+
+interface Element : Node {
+ readonly attribute DOMString? namespaceURI;
+ readonly attribute DOMString? prefix;
+ readonly attribute DOMString localName;
+ readonly attribute DOMString tagName;
+
+ attribute DOMString id;
+ attribute DOMString className;
+ readonly attribute DOMTokenList classList;
+
+ readonly attribute Attr[] attributes;
+ DOMString? getAttribute(DOMString name);
+ DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
+ void setAttribute(DOMString name, DOMString value);
+ void setAttributeNS(DOMString? namespace, DOMString name, DOMString value);
+ void removeAttribute(DOMString name);
+ void removeAttributeNS(DOMString? namespace, DOMString localName);
+ boolean hasAttribute(DOMString name);
+ boolean hasAttributeNS(DOMString? namespace, DOMString localName);
+
+ HTMLCollection getElementsByTagName(DOMString localName);
+ HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
+ HTMLCollection getElementsByClassName(DOMString classNames);
+
+ readonly attribute HTMLCollection children;
+ readonly attribute Element? firstElementChild;
+ readonly attribute Element? lastElementChild;
+ readonly attribute Element? previousElementSibling;
+ readonly attribute Element? nextElementSibling;
+ readonly attribute unsigned long childElementCount;
+
+
+ // NEW
+ void prepend((Node or DOMString)... nodes);
+ void append((Node or DOMString)... nodes);
+ void before((Node or DOMString)... nodes);
+ void after((Node or DOMString)... nodes);
+ void replace((Node or DOMString)... nodes);
+ void remove();
+};
+
+interface Attr {
+ readonly attribute DOMString name;
+ attribute DOMString value;
+
+ readonly attribute DOMString? namespaceURI;
+ readonly attribute DOMString? prefix;
+ readonly attribute DOMString localName;
+};
+
+interface CharacterData : Node {
+ [TreatNullAs=EmptyString] attribute DOMString data;
+ readonly attribute unsigned long length;
+ DOMString substringData(unsigned long offset, unsigned long count);
+ void appendData(DOMString data);
+ void insertData(unsigned long offset, DOMString data);
+ void deleteData(unsigned long offset, unsigned long count);
+ void replaceData(unsigned long offset, unsigned long count, DOMString data);
+
+ // NEW
+ void before((Node or DOMString)... nodes);
+ void after((Node or DOMString)... nodes);
+ void replace((Node or DOMString)... nodes);
+ void remove();
+};
+
+interface Text : CharacterData {
+ Text splitText(unsigned long offset);
+ readonly attribute DOMString wholeText;
+};
+
+interface ProcessingInstruction : CharacterData {
+ readonly attribute DOMString target;
+};
+
+interface Comment : CharacterData {
+};
+
+interface Range {
+ readonly attribute Node startContainer;
+ readonly attribute unsigned long startOffset;
+ readonly attribute Node endContainer;
+ readonly attribute unsigned long endOffset;
+ readonly attribute boolean collapsed;
+ readonly attribute Node commonAncestorContainer;
+
+ void setStart(Node refNode, unsigned long offset);
+ void setEnd(Node refNode, unsigned long offset);
+ void setStartBefore(Node refNode);
+ void setStartAfter(Node refNode);
+ void setEndBefore(Node refNode);
+ void setEndAfter(Node refNode);
+ void collapse(boolean toStart);
+ void selectNode(Node refNode);
+ void selectNodeContents(Node refNode);
+
+ const unsigned short START_TO_START = 0;
+ const unsigned short START_TO_END = 1;
+ const unsigned short END_TO_END = 2;
+ const unsigned short END_TO_START = 3;
+ short compareBoundaryPoints(unsigned short how, Range sourceRange);
+
+ void deleteContents();
+ DocumentFragment extractContents();
+ DocumentFragment cloneContents();
+ void insertNode(Node node);
+ void surroundContents(Node newParent);
+
+ Range cloneRange();
+ void detach();
+
+ boolean isPointInRange(Node node, unsigned long offset);
+ short comparePoint(Node node, unsigned long offset);
+
+ boolean intersectsNode(Node node);
+
+ stringifier;
+};
+
+interface NodeIterator {
+ readonly attribute Node root;
+ readonly attribute Node? referenceNode;
+ readonly attribute boolean pointerBeforeReferenceNode;
+ readonly attribute unsigned long whatToShow;
+ readonly attribute NodeFilter? filter;
+
+ Node? nextNode();
+ Node? previousNode();
+
+ void detach();
+};
+
+interface TreeWalker {
+ readonly attribute Node root;
+ readonly attribute unsigned long whatToShow;
+ readonly attribute NodeFilter? filter;
+
+ attribute Node currentNode;
+
+ Node? parentNode();
+ Node? firstChild();
+ Node? lastChild();
+ Node? previousSibling();
+ Node? nextSibling();
+ Node? previousNode();
+ Node? nextNode();
+};
+
+callback interface NodeFilter {
+ // Constants for acceptNode()
+ const unsigned short FILTER_ACCEPT = 1;
+ const unsigned short FILTER_REJECT = 2;
+ const unsigned short FILTER_SKIP = 3;
+
+ // Constants for whatToShow
+ const unsigned long SHOW_ALL = 0xFFFFFFFF;
+ const unsigned long SHOW_ELEMENT = 0x1;
+ const unsigned long SHOW_ATTRIBUTE = 0x2; // historical
+ const unsigned long SHOW_TEXT = 0x4;
+ const unsigned long SHOW_CDATA_SECTION = 0x8; // historical
+ const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical
+ const unsigned long SHOW_ENTITY = 0x20; // historical
+ const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40;
+ const unsigned long SHOW_COMMENT = 0x80;
+ const unsigned long SHOW_DOCUMENT = 0x100;
+ const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
+ const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
+ const unsigned long SHOW_NOTATION = 0x800; // historical
+
+ unsigned short acceptNode(Node node);
+};
+
+[ArrayClass]
+interface NodeList {
+ getter Node? item(unsigned long index);
+ readonly attribute unsigned long length;
+};
+
+interface HTMLCollection {
+ readonly attribute unsigned long length;
+ getter Element? item(unsigned long index);
+ getter object? namedItem(DOMString name); // only returns Element
+};
+
+[NoInterfaceObject]
+interface DOMStringList {
+ readonly attribute unsigned long length;
+ getter DOMString? item(unsigned long index);
+ boolean contains(DOMString string);
+};
+
+interface DOMTokenList {
+ readonly attribute unsigned long length;
+ getter DOMString? item(unsigned long index);
+ boolean contains(DOMString token);
+ void add(DOMString... tokens);
+ void remove(DOMString... tokens);
+ boolean toggle(DOMString token, optional boolean force);
+ stringifier;
+};
+
+interface DOMSettableTokenList : DOMTokenList {
+ attribute DOMString value;
+};
+
diff --git a/javascript/WebIDL/html.idl b/javascript/WebIDL/html.idl
new file mode 100644
index 0000000..94e7c75
--- /dev/null
+++ b/javascript/WebIDL/html.idl
@@ -0,0 +1,2194 @@
+// HTML WebIDL
+// retrived from http://www.whatwg.org/specs/web-apps/current-work/
+// 23rd October 2012
+
+
+interface HTMLAllCollection : HTMLCollection {
+ // inherits length and item()
+ legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
+ HTMLAllCollection tags(DOMString tagName);
+};
+
+interface HTMLFormControlsCollection : HTMLCollection {
+ // inherits length and item()
+ legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
+};
+
+interface RadioNodeList : NodeList {
+ attribute DOMString value;
+};
+
+interface HTMLOptionsCollection : HTMLCollection {
+ // inherits item()
+ attribute unsigned long length; // overrides inherited length
+ legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
+ setter creator void (unsigned long index, HTMLOptionElement? option);
+ void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
+ void remove(long index);
+ attribute long selectedIndex;
+};
+
+interface HTMLPropertiesCollection : HTMLCollection {
+ // inherits length and item()
+ getter PropertyNodeList? namedItem(DOMString name); // overrides inherited namedItem()
+ readonly attribute DOMString[] names;
+};
+
+typedef sequence<any> PropertyValueArray;
+
+interface PropertyNodeList : NodeList {
+ PropertyValueArray getValues();
+};
+
+interface DOMStringMap {
+ getter DOMString (DOMString name);
+ setter void (DOMString name, DOMString value);
+ creator void (DOMString name, DOMString value);
+ deleter void (DOMString name);
+};
+
+interface DOMElementMap {
+ getter Element (DOMString name);
+ setter void (DOMString name, Element value);
+ creator void (DOMString name, Element value);
+ deleter void (DOMString name);
+};
+
+[NoInterfaceObject]
+interface Transferable { };
+
+[OverrideBuiltins]
+partial interface Document {
+ // resource metadata management
+ [PutForwards=href] readonly attribute Location? location;
+ attribute DOMString domain;
+ readonly attribute DOMString referrer;
+ attribute DOMString cookie;
+ readonly attribute DOMString lastModified;
+ readonly attribute DOMString readyState;
+
+ // DOM tree accessors
+ getter object (DOMString name);
+ attribute DOMString title;
+ attribute DOMString dir;
+ attribute HTMLElement? body;
+ readonly attribute HTMLHeadElement? head;
+ readonly attribute HTMLCollection images;
+ readonly attribute HTMLCollection embeds;
+ readonly attribute HTMLCollection plugins;
+ readonly attribute HTMLCollection links;
+ readonly attribute HTMLCollection forms;
+ readonly attribute HTMLCollection scripts;
+ NodeList getElementsByName(DOMString elementName);
+ NodeList getItems(optional DOMString typeNames); // microdata
+ readonly attribute DOMElementMap cssElementMap;
+
+ // dynamic markup insertion
+ Document open(optional DOMString type, optional DOMString replace);
+ WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace);
+ void close();
+ void write(DOMString... text);
+ void writeln(DOMString... text);
+
+ // user interaction
+ readonly attribute WindowProxy? defaultView;
+ readonly attribute Element? activeElement;
+ boolean hasFocus();
+ attribute DOMString designMode;
+ boolean execCommand(DOMString commandId);
+ boolean execCommand(DOMString commandId, boolean showUI);
+ boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
+ boolean queryCommandEnabled(DOMString commandId);
+ boolean queryCommandIndeterm(DOMString commandId);
+ boolean queryCommandState(DOMString commandId);
+ boolean queryCommandSupported(DOMString commandId);
+ DOMString queryCommandValue(DOMString commandId);
+ readonly attribute HTMLCollection commands;
+
+ // event handler IDL attributes
+ attribute EventHandler onabort;
+ attribute EventHandler onblur;
+ attribute EventHandler oncancel;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onchange;
+ attribute EventHandler onclick;
+ attribute EventHandler onclose;
+ attribute EventHandler oncontextmenu;
+ attribute EventHandler oncuechange;
+ attribute EventHandler ondblclick;
+ attribute EventHandler ondrag;
+ attribute EventHandler ondragend;
+ attribute EventHandler ondragenter;
+ attribute EventHandler ondragleave;
+ attribute EventHandler ondragover;
+ attribute EventHandler ondragstart;
+ attribute EventHandler ondrop;
+ attribute EventHandler ondurationchange;
+ attribute EventHandler onemptied;
+ attribute EventHandler onended;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler oninput;
+ attribute EventHandler oninvalid;
+ attribute EventHandler onkeydown;
+ attribute EventHandler onkeypress;
+ attribute EventHandler onkeyup;
+ attribute EventHandler onload;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadstart;
+ attribute EventHandler onmousedown;
+ attribute EventHandler onmousemove;
+ attribute EventHandler onmouseout;
+ attribute EventHandler onmouseover;
+ attribute EventHandler onmouseup;
+ attribute EventHandler onmousewheel;
+ attribute EventHandler onpause;
+ attribute EventHandler onplay;
+ attribute EventHandler onplaying;
+ attribute EventHandler onprogress;
+ attribute EventHandler onratechange;
+ attribute EventHandler onreset;
+ attribute EventHandler onscroll;
+ attribute EventHandler onseeked;
+ attribute EventHandler onseeking;
+ attribute EventHandler onselect;
+ attribute EventHandler onshow;
+ attribute EventHandler onstalled;
+ attribute EventHandler onsubmit;
+ attribute EventHandler onsuspend;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onvolumechange;
+ attribute EventHandler onwaiting;
+
+ // special event handler IDL attributes that only apply to Document objects
+ [LenientThis] attribute EventHandler onreadystatechange;
+};
+
+partial interface XMLDocument {
+ boolean load(DOMString url);
+};
+
+interface HTMLElement : Element {
+ // metadata attributes
+ attribute DOMString title;
+ attribute DOMString lang;
+ attribute boolean translate;
+ attribute DOMString dir;
+ readonly attribute DOMStringMap dataset;
+
+ // microdata
+ attribute boolean itemScope;
+ [PutForwards=value] readonly attribute DOMSettableTokenList itemType;
+ attribute DOMString itemId;
+ [PutForwards=value] readonly attribute DOMSettableTokenList itemRef;
+ [PutForwards=value] readonly attribute DOMSettableTokenList itemProp;
+ readonly attribute HTMLPropertiesCollection properties;
+ attribute any itemValue; // acts as DOMString on setting
+
+ // user interaction
+ attribute boolean hidden;
+ void click();
+ attribute long tabIndex;
+ void focus();
+ void blur();
+ attribute DOMString accessKey;
+ readonly attribute DOMString accessKeyLabel;
+ attribute boolean draggable;
+ [PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
+ attribute DOMString contentEditable;
+ readonly attribute boolean isContentEditable;
+ attribute HTMLMenuElement? contextMenu;
+ attribute boolean spellcheck;
+ void forceSpellCheck();
+
+ // command API
+ readonly attribute DOMString? commandType;
+ readonly attribute DOMString? commandLabel;
+ readonly attribute DOMString? commandIcon;
+ readonly attribute boolean? commandHidden;
+ readonly attribute boolean? commandDisabled;
+ readonly attribute boolean? commandChecked;
+
+ // styling
+ readonly attribute CSSStyleDeclaration style;
+
+ // event handler IDL attributes
+ attribute EventHandler onabort;
+ attribute EventHandler onblur;
+ attribute EventHandler oncancel;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onchange;
+ attribute EventHandler onclick;
+ attribute EventHandler onclose;
+ attribute EventHandler oncontextmenu;
+ attribute EventHandler oncuechange;
+ attribute EventHandler ondblclick;
+ attribute EventHandler ondrag;
+ attribute EventHandler ondragend;
+ attribute EventHandler ondragenter;
+ attribute EventHandler ondragleave;
+ attribute EventHandler ondragover;
+ attribute EventHandler ondragstart;
+ attribute EventHandler ondrop;
+ attribute EventHandler ondurationchange;
+ attribute EventHandler onemptied;
+ attribute EventHandler onended;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler oninput;
+ attribute EventHandler oninvalid;
+ attribute EventHandler onkeydown;
+ attribute EventHandler onkeypress;
+ attribute EventHandler onkeyup;
+ attribute EventHandler onload;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadstart;
+ attribute EventHandler onmousedown;
+ attribute EventHandler onmousemove;
+ attribute EventHandler onmouseout;
+ attribute EventHandler onmouseover;
+ attribute EventHandler onmouseup;
+ attribute EventHandler onmousewheel;
+ attribute EventHandler onpause;
+ attribute EventHandler onplay;
+ attribute EventHandler onplaying;
+ attribute EventHandler onprogress;
+ attribute EventHandler onratechange;
+ attribute EventHandler onreset;
+ attribute EventHandler onscroll;
+ attribute EventHandler onseeked;
+ attribute EventHandler onseeking;
+ attribute EventHandler onselect;
+ attribute EventHandler onshow;
+ attribute EventHandler onstalled;
+ attribute EventHandler onsubmit;
+ attribute EventHandler onsuspend;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onvolumechange;
+ attribute EventHandler onwaiting;
+};
+
+interface HTMLUnknownElement : HTMLElement { };
+
+interface HTMLHtmlElement : HTMLElement {};
+
+interface HTMLHeadElement : HTMLElement {};
+
+interface HTMLTitleElement : HTMLElement {
+ attribute DOMString text;
+};
+
+interface HTMLBaseElement : HTMLElement {
+ attribute DOMString href;
+ attribute DOMString target;
+};
+
+interface HTMLLinkElement : HTMLElement {
+ attribute boolean disabled;
+ attribute DOMString href;
+ attribute DOMString rel;
+ readonly attribute DOMTokenList relList;
+ attribute DOMString media;
+ attribute DOMString hreflang;
+ attribute DOMString type;
+ [PutForwards=value] readonly attribute DOMSettableTokenList sizes;
+};
+HTMLLinkElement implements LinkStyle;
+
+interface HTMLMetaElement : HTMLElement {
+ attribute DOMString name;
+ attribute DOMString httpEquiv;
+ attribute DOMString content;
+};
+
+interface HTMLStyleElement : HTMLElement {
+ attribute boolean disabled;
+ attribute DOMString media;
+ attribute DOMString type;
+ attribute boolean scoped;
+};
+HTMLStyleElement implements LinkStyle;
+
+interface HTMLScriptElement : HTMLElement {
+ attribute DOMString src;
+ attribute boolean async;
+ attribute boolean defer;
+ attribute DOMString type;
+ attribute DOMString charset;
+ attribute DOMString text;
+};
+
+interface HTMLBodyElement : HTMLElement {
+ attribute EventHandler onafterprint;
+ attribute EventHandler onbeforeprint;
+ attribute EventHandler onbeforeunload;
+ attribute EventHandler onblur;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler onhashchange;
+ attribute EventHandler onload;
+ attribute EventHandler onmessage;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+ attribute EventHandler onpopstate;
+ attribute EventHandler onpagehide;
+ attribute EventHandler onpageshow;
+ attribute EventHandler onresize;
+ attribute EventHandler onscroll;
+ attribute EventHandler onstorage;
+ attribute EventHandler onunload;
+};
+
+interface HTMLHeadingElement : HTMLElement {};
+
+interface HTMLParagraphElement : HTMLElement {};
+
+interface HTMLHRElement : HTMLElement {};
+
+interface HTMLPreElement : HTMLElement {};
+
+interface HTMLQuoteElement : HTMLElement {
+ attribute DOMString cite;
+};
+
+interface HTMLOListElement : HTMLElement {
+ attribute boolean reversed;
+ attribute long start;
+ attribute DOMString type;
+};
+
+interface HTMLUListElement : HTMLElement {};
+
+interface HTMLLIElement : HTMLElement {
+ attribute long value;
+};
+
+interface HTMLDListElement : HTMLElement {};
+
+interface HTMLDivElement : HTMLElement {};
+
+interface HTMLAnchorElement : HTMLElement {
+ stringifier attribute DOMString href;
+ attribute DOMString target;
+
+ attribute DOMString download;
+ attribute DOMString ping;
+
+ attribute DOMString rel;
+ readonly attribute DOMTokenList relList;
+ attribute DOMString media;
+ attribute DOMString hreflang;
+ attribute DOMString type;
+
+ attribute DOMString text;
+
+ // URL decomposition IDL attributes
+ attribute DOMString protocol;
+ attribute DOMString host;
+ attribute DOMString hostname;
+ attribute DOMString port;
+ attribute DOMString pathname;
+ attribute DOMString search;
+ attribute DOMString hash;
+};
+
+interface HTMLDataElement : HTMLElement {
+ attribute DOMString value;
+};
+
+interface HTMLTimeElement : HTMLElement {
+ attribute DOMString datetime;
+};
+
+interface HTMLSpanElement : HTMLElement {};
+
+interface HTMLBRElement : HTMLElement {};
+
+interface HTMLModElement : HTMLElement {
+ attribute DOMString cite;
+ attribute DOMString dateTime;
+};
+
+[NamedConstructor=Image(),
+ NamedConstructor=Image(unsigned long width),
+ NamedConstructor=Image(unsigned long width, unsigned long height)]
+interface HTMLImageElement : HTMLElement {
+ attribute DOMString alt;
+ attribute DOMString src;
+ attribute DOMString srcset;
+ attribute DOMString crossOrigin;
+ attribute DOMString useMap;
+ attribute boolean isMap;
+ attribute unsigned long width;
+ attribute unsigned long height;
+ readonly attribute unsigned long naturalWidth;
+ readonly attribute unsigned long naturalHeight;
+ readonly attribute boolean complete;
+};
+
+interface HTMLIFrameElement : HTMLElement {
+ attribute DOMString src;
+ attribute DOMString srcdoc;
+ attribute DOMString name;
+ [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
+ attribute boolean seamless;
+ attribute DOMString width;
+ attribute DOMString height;
+ readonly attribute Document? contentDocument;
+ readonly attribute WindowProxy? contentWindow;
+};
+
+interface HTMLEmbedElement : HTMLElement {
+ attribute DOMString src;
+ attribute DOMString type;
+ attribute DOMString width;
+ attribute DOMString height;
+ legacycaller any (any... arguments);
+};
+
+interface HTMLObjectElement : HTMLElement {
+ attribute DOMString data;
+ attribute DOMString type;
+ attribute boolean typeMustMatch;
+ attribute DOMString name;
+ attribute DOMString useMap;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString width;
+ attribute DOMString height;
+ readonly attribute Document? contentDocument;
+ readonly attribute WindowProxy? contentWindow;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ legacycaller any (any... arguments);
+};
+
+interface HTMLParamElement : HTMLElement {
+ attribute DOMString name;
+ attribute DOMString value;
+};
+
+interface HTMLVideoElement : HTMLMediaElement {
+ attribute unsigned long width;
+ attribute unsigned long height;
+ readonly attribute unsigned long videoWidth;
+ readonly attribute unsigned long videoHeight;
+ attribute DOMString poster;
+};
+
+[NamedConstructor=Audio(),
+ NamedConstructor=Audio(DOMString src)]
+interface HTMLAudioElement : HTMLMediaElement {};
+
+interface HTMLSourceElement : HTMLElement {
+ attribute DOMString src;
+ attribute DOMString type;
+ attribute DOMString media;
+};
+
+interface HTMLTrackElement : HTMLElement {
+ attribute DOMString kind;
+ attribute DOMString src;
+ attribute DOMString srclang;
+ attribute DOMString label;
+ attribute boolean default;
+
+ const unsigned short NONE = 0;
+ const unsigned short LOADING = 1;
+ const unsigned short LOADED = 2;
+ const unsigned short ERROR = 3;
+ readonly attribute unsigned short readyState;
+
+ readonly attribute TextTrack track;
+};
+
+interface HTMLMediaElement : HTMLElement {
+
+ // error state
+ readonly attribute MediaError? error;
+
+ // network state
+ attribute DOMString src;
+ readonly attribute DOMString currentSrc;
+ attribute DOMString crossOrigin;
+ const unsigned short NETWORK_EMPTY = 0;
+ const unsigned short NETWORK_IDLE = 1;
+ const unsigned short NETWORK_LOADING = 2;
+ const unsigned short NETWORK_NO_SOURCE = 3;
+ readonly attribute unsigned short networkState;
+ attribute DOMString preload;
+ readonly attribute TimeRanges buffered;
+ void load();
+ DOMString canPlayType(DOMString type);
+
+ // ready state
+ const unsigned short HAVE_NOTHING = 0;
+ const unsigned short HAVE_METADATA = 1;
+ const unsigned short HAVE_CURRENT_DATA = 2;
+ const unsigned short HAVE_FUTURE_DATA = 3;
+ const unsigned short HAVE_ENOUGH_DATA = 4;
+ readonly attribute unsigned short readyState;
+ readonly attribute boolean seeking;
+
+ // playback state
+ attribute double currentTime;
+ void fastSeek(double time);
+ readonly attribute unrestricted double duration;
+ readonly attribute Date startDate;
+ readonly attribute boolean paused;
+ attribute double defaultPlaybackRate;
+ attribute double playbackRate;
+ readonly attribute TimeRanges played;
+ readonly attribute TimeRanges seekable;
+ readonly attribute boolean ended;
+ attribute boolean autoplay;
+ attribute boolean loop;
+ void play();
+ void pause();
+
+ // media controller
+ attribute DOMString mediaGroup;
+ attribute MediaController? controller;
+
+ // controls
+ attribute boolean controls;
+ attribute double volume;
+ attribute boolean muted;
+ attribute boolean defaultMuted;
+
+ // tracks
+ readonly attribute AudioTrackList audioTracks;
+ readonly attribute VideoTrackList videoTracks;
+ readonly attribute TextTrackList textTracks;
+ TextTrack addTextTrack(DOMString kind, optional DOMString label, optional DOMString language);
+};
+
+interface MediaError {
+ const unsigned short MEDIA_ERR_ABORTED = 1;
+ const unsigned short MEDIA_ERR_NETWORK = 2;
+ const unsigned short MEDIA_ERR_DECODE = 3;
+ const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
+ readonly attribute unsigned short code;
+};
+
+interface AudioTrackList : EventTarget {
+ readonly attribute unsigned long length;
+ getter AudioTrack (unsigned long index);
+ AudioTrack? getTrackById(DOMString id);
+
+ attribute EventHandler onchange;
+ attribute EventHandler onaddtrack;
+ attribute EventHandler onremovetrack;
+};
+
+interface AudioTrack {
+ readonly attribute DOMString id;
+ readonly attribute DOMString kind;
+ readonly attribute DOMString label;
+ readonly attribute DOMString language;
+ attribute boolean enabled;
+};
+
+interface VideoTrackList : EventTarget {
+ readonly attribute unsigned long length;
+ getter VideoTrack (unsigned long index);
+ VideoTrack? getTrackById(DOMString id);
+ readonly attribute long selectedIndex;
+
+ attribute EventHandler onchange;
+ attribute EventHandler onaddtrack;
+ attribute EventHandler onremovetrack;
+};
+
+interface VideoTrack {
+ readonly attribute DOMString id;
+ readonly attribute DOMString kind;
+ readonly attribute DOMString label;
+ readonly attribute DOMString language;
+ attribute boolean selected;
+};
+
+enum MediaControllerPlaybackState { "waiting", "playing", "ended" };
+[Constructor]
+interface MediaController : EventTarget {
+ readonly attribute unsigned short readyState; // uses HTMLMediaElement.readyState's values
+
+ readonly attribute TimeRanges buffered;
+ readonly attribute TimeRanges seekable;
+ readonly attribute unrestricted double duration;
+ attribute double currentTime;
+
+ readonly attribute boolean paused;
+ readonly attribute MediaControllerPlaybackState playbackState;
+ readonly attribute TimeRanges played;
+ void pause();
+ void unpause();
+ void play(); // calls play() on all media elements as well
+
+ attribute double defaultPlaybackRate;
+ attribute double playbackRate;
+
+ attribute double volume;
+ attribute boolean muted;
+
+ attribute EventHandler onemptied;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onplaying;
+ attribute EventHandler onended;
+ attribute EventHandler onwaiting;
+
+ attribute EventHandler ondurationchange;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onplay;
+ attribute EventHandler onpause;
+ attribute EventHandler onratechange;
+ attribute EventHandler onvolumechange;
+};
+
+interface TextTrackList : EventTarget {
+ readonly attribute unsigned long length;
+ getter TextTrack (unsigned long index);
+
+ attribute EventHandler onaddtrack;
+ attribute EventHandler onremovetrack;
+};
+
+enum TextTrackMode { "disabled", "hidden", "showing" };
+interface TextTrack : EventTarget {
+ readonly attribute DOMString kind;
+ readonly attribute DOMString label;
+ readonly attribute DOMString language;
+ readonly attribute DOMString inBandMetadataTrackDispatchType;
+
+ attribute TextTrackMode mode;
+
+ readonly attribute TextTrackCueList? cues;
+ readonly attribute TextTrackCueList? activeCues;
+
+ void addCue(TextTrackCue cue);
+ void removeCue(TextTrackCue cue);
+
+ attribute EventHandler oncuechange;
+};
+
+interface TextTrackCueList {
+ readonly attribute unsigned long length;
+ getter TextTrackCue (unsigned long index);
+ TextTrackCue? getCueById(DOMString id);
+};
+
+enum AutoKeyword { "auto" };
+[Constructor(double startTime, double endTime, DOMString text)]
+interface TextTrackCue : EventTarget {
+ readonly attribute TextTrack? track;
+
+ attribute DOMString id;
+ attribute double startTime;
+ attribute double endTime;
+ attribute boolean pauseOnExit;
+ attribute DOMString vertical;
+ attribute boolean snapToLines;
+ attribute (long or AutoKeyword) line;
+ attribute long position;
+ attribute long size;
+ attribute DOMString align;
+ attribute DOMString text;
+ DocumentFragment getCueAsHTML();
+
+ attribute EventHandler onenter;
+ attribute EventHandler onexit;
+};
+
+interface TimeRanges {
+ readonly attribute unsigned long length;
+ double start(unsigned long index);
+ double end(unsigned long index);
+};
+
+[Constructor(DOMString type, optional TrackEventInit eventInitDict)]
+interface TrackEvent : Event {
+ readonly attribute object? track;
+};
+
+dictionary TrackEventInit : EventInit {
+ object? track;
+};
+
+interface HTMLCanvasElement : HTMLElement {
+ attribute unsigned long width;
+ attribute unsigned long height;
+
+ DOMString toDataURL(optional DOMString type, any... arguments);
+ DOMString toDataURLHD(optional DOMString type, any... arguments);
+ void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
+ void toBlobHD(FileCallback? _callback, optional DOMString type, any... arguments);
+
+ object? getContext(DOMString contextId, any... arguments);
+ boolean supportsContext(DOMString contextId, any... arguments);
+};
+
+interface CanvasRenderingContext2D {
+
+ // back-reference to the canvas
+ readonly attribute HTMLCanvasElement canvas;
+
+ // state
+ void save(); // push state on state stack
+ void restore(); // pop state stack and restore state
+
+ // transformations (default transform is the identity matrix)
+ attribute SVGMatrix currentTransform;
+ void scale(unrestricted double x, unrestricted double y);
+ void rotate(unrestricted double angle);
+ void translate(unrestricted double x, unrestricted double y);
+ void transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
+ void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
+ void resetTransform();
+
+ // compositing
+ attribute unrestricted double globalAlpha; // (default 1.0)
+ attribute DOMString globalCompositeOperation; // (default source-over)
+
+ // image smoothing
+ attribute boolean imageSmoothingEnabled; // (default true)
+
+ // colors and styles (see also the CanvasDrawingStyles interface)
+ attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
+ attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
+ CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
+ CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
+ CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, DOMString repetition);
+
+ // shadows
+ attribute unrestricted double shadowOffsetX; // (default 0)
+ attribute unrestricted double shadowOffsetY; // (default 0)
+ attribute unrestricted double shadowBlur; // (default 0)
+ attribute DOMString shadowColor; // (default transparent black)
+
+ // rects
+ void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+ void fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+ void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+
+ // path API (see also CanvasPathMethods)
+ void beginPath();
+ void fill();
+ void fill(Path path);
+ void stroke();
+ void stroke(Path path);
+ void drawSystemFocusRing(Element element);
+ void drawSystemFocusRing(Path path, Element element);
+ boolean drawCustomFocusRing(Element element);
+ boolean drawCustomFocusRing(Path path, Element element);
+ void scrollPathIntoView();
+ void scrollPathIntoView(Path path);
+ void clip();
+ void clip(Path path);
+ void resetClip();
+ boolean isPointInPath(unrestricted double x, unrestricted double y);
+ boolean isPointInPath(Path path, unrestricted double x, unrestricted double y);
+
+ // text (see also the CanvasDrawingStyles interface)
+ void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
+ void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
+ TextMetrics measureText(DOMString text);
+
+ // drawing images
+ void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double dx, unrestricted double dy);
+ void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
+ void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
+
+ // hit regions
+ void addHitRegion(HitRegionOptions options);
+ void removeHitRegion(HitRegionOptions options);
+
+ // pixel manipulation
+ ImageData createImageData(double sw, double sh);
+ ImageData createImageData(ImageData imagedata);
+ ImageData createImageDataHD(double sw, double sh);
+ ImageData getImageData(double sx, double sy, double sw, double sh);
+ ImageData getImageDataHD(double sx, double sy, double sw, double sh);
+ void putImageData(ImageData imagedata, double dx, double dy);
+ void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
+ void putImageDataHD(ImageData imagedata, double dx, double dy);
+ void putImageDataHD(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
+};
+CanvasRenderingContext2D implements CanvasDrawingStyles;
+CanvasRenderingContext2D implements CanvasPathMethods;
+
+[NoInterfaceObject]
+interface CanvasDrawingStyles {
+ // line caps/joins
+ attribute unrestricted double lineWidth; // (default 1)
+ attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
+ attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
+ attribute unrestricted double miterLimit; // (default 10)
+
+ // dashed lines
+ void setLineDash(sequence<unrestricted double> segments); // default empty
+ sequence<unrestricted double> getLineDash();
+ attribute unrestricted double lineDashOffset;
+
+ // text
+ attribute DOMString font; // (default 10px sans-serif)
+ attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
+ attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
+};
+
+[NoInterfaceObject]
+interface CanvasPathMethods {
+ // shared path API methods
+ void closePath();
+ void moveTo(unrestricted double x, unrestricted double y);
+ void lineTo(unrestricted double x, unrestricted double y);
+ void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
+ void bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
+ void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
+ void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
+ void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
+ void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
+ void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, boolean anticlockwise);
+};
+
+interface CanvasGradient {
+ // opaque object
+ void addColorStop(double offset, DOMString color);
+};
+
+interface CanvasPattern {
+ // opaque object
+ void setTransform(SVGMatrix transform);
+};
+
+interface TextMetrics {
+ // x-direction
+ readonly attribute double width; // advance width
+ readonly attribute double actualBoundingBoxLeft;
+ readonly attribute double actualBoundingBoxRight;
+
+ // y-direction
+ readonly attribute double fontBoundingBoxAscent;
+ readonly attribute double fontBoundingBoxDescent;
+ readonly attribute double actualBoundingBoxAscent;
+ readonly attribute double actualBoundingBoxDescent;
+ readonly attribute double emHeightAscent;
+ readonly attribute double emHeightDescent;
+ readonly attribute double hangingBaseline;
+ readonly attribute double alphabeticBaseline;
+ readonly attribute double ideographicBaseline;
+};
+
+dictionary HitRegionOptions {
+ Path? path = null;
+ DOMString id = "";
+ DOMString? parentID = null;
+ DOMString cursor = "inherit";
+ // for control-backed regions:
+ Element? control = null;
+ // for unbacked regions:
+ DOMString? label = null;
+ DOMString? role = null;
+};
+
+interface ImageData {
+ readonly attribute unsigned long width;
+ readonly attribute unsigned long height;
+ readonly attribute Uint8ClampedArray data;
+};
+
+[Constructor(optional Element scope)]
+interface DrawingStyle { };
+DrawingStyle implements CanvasDrawingStyles;
+
+[Constructor,
+ Constructor(Path path),
+ Constructor(DOMString d)]
+interface Path {
+ void addPath(Path path, SVGMatrix? transformation);
+ void addPathByStrokingPath(Path path, CanvasDrawingStyles styles, SVGMatrix? transformation);
+ void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
+ void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
+ void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path path, optional unrestricted double maxWidth);
+ void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path path, optional unrestricted double maxWidth);
+};
+Path implements CanvasPathMethods;
+
+partial interface Screen {
+ readonly attribute double canvasResolution;
+};
+
+partial interface MouseEvent {
+ readonly attribute DOMString? region;
+};
+
+partial dictionary MouseEventInit {
+ DOMString? region;
+};
+
+interface HTMLMapElement : HTMLElement {
+ attribute DOMString name;
+ readonly attribute HTMLCollection areas;
+ readonly attribute HTMLCollection images;
+};
+
+interface HTMLAreaElement : HTMLElement {
+ attribute DOMString alt;
+ attribute DOMString coords;
+ attribute DOMString shape;
+ stringifier attribute DOMString href;
+ attribute DOMString target;
+
+ attribute DOMString download;
+ attribute DOMString ping;
+
+ attribute DOMString rel;
+ readonly attribute DOMTokenList relList;
+ attribute DOMString media;
+ attribute DOMString hreflang;
+ attribute DOMString type;
+
+ // URL decomposition IDL attributes
+ attribute DOMString protocol;
+ attribute DOMString host;
+ attribute DOMString hostname;
+ attribute DOMString port;
+ attribute DOMString pathname;
+ attribute DOMString search;
+ attribute DOMString hash;
+};
+
+interface HTMLTableElement : HTMLElement {
+ attribute HTMLTableCaptionElement? caption;
+ HTMLElement createCaption();
+ void deleteCaption();
+ attribute HTMLTableSectionElement? tHead;
+ HTMLElement createTHead();
+ void deleteTHead();
+ attribute HTMLTableSectionElement? tFoot;
+ HTMLElement createTFoot();
+ void deleteTFoot();
+ readonly attribute HTMLCollection tBodies;
+ HTMLElement createTBody();
+ readonly attribute HTMLCollection rows;
+ HTMLElement insertRow(optional long index);
+ void deleteRow(long index);
+};
+
+interface HTMLTableCaptionElement : HTMLElement {};
+
+interface HTMLTableColElement : HTMLElement {
+ attribute unsigned long span;
+};
+
+interface HTMLTableSectionElement : HTMLElement {
+ readonly attribute HTMLCollection rows;
+ HTMLElement insertRow(optional long index);
+ void deleteRow(long index);
+};
+
+interface HTMLTableRowElement : HTMLElement {
+ readonly attribute long rowIndex;
+ readonly attribute long sectionRowIndex;
+ readonly attribute HTMLCollection cells;
+ HTMLElement insertCell(optional long index);
+ void deleteCell(long index);
+};
+
+interface HTMLTableDataCellElement : HTMLTableCellElement {};
+
+interface HTMLTableHeaderCellElement : HTMLTableCellElement {
+ attribute DOMString scope;
+ attribute DOMString abbr;
+};
+
+interface HTMLTableCellElement : HTMLElement {
+ attribute unsigned long colSpan;
+ attribute unsigned long rowSpan;
+ [PutForwards=value] readonly attribute DOMSettableTokenList headers;
+ readonly attribute long cellIndex;
+};
+
+[OverrideBuiltins]
+interface HTMLFormElement : HTMLElement {
+ attribute DOMString acceptCharset;
+ attribute DOMString action;
+ attribute DOMString autocomplete;
+ attribute DOMString enctype;
+ attribute DOMString encoding;
+ attribute DOMString method;
+ attribute DOMString name;
+ attribute boolean noValidate;
+ attribute DOMString target;
+
+ readonly attribute HTMLFormControlsCollection elements;
+ readonly attribute long length;
+ getter Element (unsigned long index);
+ getter object (DOMString name);
+
+ void submit();
+ void reset();
+ boolean checkValidity();
+};
+
+interface HTMLFieldSetElement : HTMLElement {
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString name;
+
+ readonly attribute DOMString type;
+
+ readonly attribute HTMLFormControlsCollection elements;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+};
+
+interface HTMLLegendElement : HTMLElement {
+ readonly attribute HTMLFormElement? form;
+};
+
+interface HTMLLabelElement : HTMLElement {
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString htmlFor;
+ readonly attribute HTMLElement? control;
+};
+
+interface HTMLInputElement : HTMLElement {
+ attribute DOMString accept;
+ attribute DOMString alt;
+ attribute DOMString autocomplete;
+ attribute boolean autofocus;
+ attribute boolean defaultChecked;
+ attribute boolean checked;
+ attribute DOMString dirName;
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ readonly attribute FileList? files;
+ attribute DOMString formAction;
+ attribute DOMString formEnctype;
+ attribute DOMString formMethod;
+ attribute boolean formNoValidate;
+ attribute DOMString formTarget;
+ attribute unsigned long height;
+ attribute boolean indeterminate;
+ attribute DOMString inputMode;
+ readonly attribute HTMLElement? list;
+ attribute DOMString max;
+ attribute long maxLength;
+ attribute DOMString min;
+ attribute boolean multiple;
+ attribute DOMString name;
+ attribute DOMString pattern;
+ attribute DOMString placeholder;
+ attribute boolean readOnly;
+ attribute boolean required;
+ attribute unsigned long size;
+ attribute DOMString src;
+ attribute DOMString step;
+ attribute DOMString type;
+ attribute DOMString defaultValue;
+ [TreatNullAs=EmptyString] attribute DOMString value;
+ attribute Date? valueAsDate;
+ attribute unrestricted double valueAsNumber;
+ attribute unsigned long width;
+
+ void stepUp(optional long n);
+ void stepDown(optional long n);
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+
+ void select();
+ attribute unsigned long selectionStart;
+ attribute unsigned long selectionEnd;
+ attribute DOMString selectionDirection;
+
+ void setRangeText(DOMString replacement);
+ void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
+
+ void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
+};
+
+interface HTMLButtonElement : HTMLElement {
+ attribute boolean autofocus;
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString formAction;
+ attribute DOMString formEnctype;
+ attribute DOMString formMethod;
+ attribute boolean formNoValidate;
+ attribute DOMString formTarget;
+ attribute DOMString name;
+ attribute DOMString type;
+ attribute DOMString value;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+};
+
+interface HTMLSelectElement : HTMLElement {
+ attribute boolean autofocus;
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute boolean multiple;
+ attribute DOMString name;
+ attribute boolean required;
+ attribute unsigned long size;
+
+ readonly attribute DOMString type;
+
+ readonly attribute HTMLOptionsCollection options;
+ attribute unsigned long length;
+ getter Element item(unsigned long index);
+ object namedItem(DOMString name);
+ void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
+ void remove(long index);
+ setter creator void (unsigned long index, HTMLOptionElement? option);
+
+ readonly attribute HTMLCollection selectedOptions;
+ attribute long selectedIndex;
+ attribute DOMString value;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+};
+
+interface HTMLDataListElement : HTMLElement {
+ readonly attribute HTMLCollection options;
+};
+
+interface HTMLOptGroupElement : HTMLElement {
+ attribute boolean disabled;
+ attribute DOMString label;
+};
+
+[NamedConstructor=Option(),
+ NamedConstructor=Option(DOMString text),
+ NamedConstructor=Option(DOMString text, DOMString value),
+ NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected),
+ NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected, boolean selected)]
+interface HTMLOptionElement : HTMLElement {
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString label;
+ attribute boolean defaultSelected;
+ attribute boolean selected;
+ attribute DOMString value;
+
+ attribute DOMString text;
+ readonly attribute long index;
+};
+
+interface HTMLTextAreaElement : HTMLElement {
+ attribute DOMString autocomplete;
+ attribute boolean autofocus;
+ attribute unsigned long cols;
+ attribute DOMString dirName;
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString inputMode;
+ attribute long maxLength;
+ attribute DOMString name;
+ attribute DOMString placeholder;
+ attribute boolean readOnly;
+ attribute boolean required;
+ attribute unsigned long rows;
+ attribute DOMString wrap;
+
+ readonly attribute DOMString type;
+ attribute DOMString defaultValue;
+ [TreatNullAs=EmptyString] attribute DOMString value;
+ readonly attribute unsigned long textLength;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+
+ void select();
+ attribute unsigned long selectionStart;
+ attribute unsigned long selectionEnd;
+ attribute DOMString selectionDirection;
+
+ void setRangeText(DOMString replacement);
+ void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
+
+ void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
+};
+
+interface HTMLKeygenElement : HTMLElement {
+ attribute boolean autofocus;
+ attribute DOMString challenge;
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString keytype;
+ attribute DOMString name;
+
+ readonly attribute DOMString type;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+};
+
+interface HTMLOutputElement : HTMLElement {
+ [PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
+ readonly attribute HTMLFormElement? form;
+ attribute DOMString name;
+
+ readonly attribute DOMString type;
+ attribute DOMString defaultValue;
+ attribute DOMString value;
+
+ readonly attribute boolean willValidate;
+ readonly attribute ValidityState validity;
+ readonly attribute DOMString validationMessage;
+ boolean checkValidity();
+ void setCustomValidity(DOMString error);
+
+ readonly attribute NodeList labels;
+};
+
+interface HTMLProgressElement : HTMLElement {
+ attribute double value;
+ attribute double max;
+ readonly attribute double position;
+ readonly attribute NodeList labels;
+};
+
+interface HTMLMeterElement : HTMLElement {
+ attribute double value;
+ attribute double min;
+ attribute double max;
+ attribute double low;
+ attribute double high;
+ attribute double optimum;
+ readonly attribute NodeList labels;
+};
+
+interface ValidityState {
+ readonly attribute boolean valueMissing;
+ readonly attribute boolean typeMismatch;
+ readonly attribute boolean patternMismatch;
+ readonly attribute boolean tooLong;
+ readonly attribute boolean rangeUnderflow;
+ readonly attribute boolean rangeOverflow;
+ readonly attribute boolean stepMismatch;
+ readonly attribute boolean customError;
+ readonly attribute boolean valid;
+};
+
+interface HTMLDetailsElement : HTMLElement {
+ attribute boolean open;
+};
+
+interface HTMLCommandElement : HTMLElement {
+ attribute DOMString type;
+ attribute DOMString label;
+ attribute DOMString icon;
+ attribute boolean disabled;
+ attribute boolean checked;
+ attribute DOMString radiogroup;
+ readonly attribute HTMLElement? command;
+};
+
+interface HTMLMenuElement : HTMLElement {
+ attribute DOMString type;
+ attribute DOMString label;
+};
+
+interface HTMLDialogElement : HTMLElement {
+ attribute boolean open;
+ attribute DOMString returnValue;
+ void show(optional (MouseEvent or Element) anchor);
+ void showModal(optional (MouseEvent or Element) anchor);
+ void close(optional DOMString returnValue);
+};
+
+[NamedPropertiesObject]
+interface Window : EventTarget {
+ // the current browsing context
+ [Unforgeable] readonly attribute WindowProxy window;
+ [Replaceable] readonly attribute WindowProxy self;
+ [Unforgeable] readonly attribute Document document;
+ attribute DOMString name;
+ [PutForwards=href, Unforgeable] readonly attribute Location location;
+ readonly attribute History history;
+ [Replaceable] readonly attribute BarProp locationbar;
+ [Replaceable] readonly attribute BarProp menubar;
+ [Replaceable] readonly attribute BarProp personalbar;
+ [Replaceable] readonly attribute BarProp scrollbars;
+ [Replaceable] readonly attribute BarProp statusbar;
+ [Replaceable] readonly attribute BarProp toolbar;
+ attribute DOMString status;
+ void close();
+ void stop();
+ void focus();
+ void blur();
+
+ // other browsing contexts
+ [Replaceable] readonly attribute WindowProxy frames;
+ [Replaceable] readonly attribute unsigned long length;
+ [Unforgeable] readonly attribute WindowProxy top;
+ attribute WindowProxy? opener;
+ readonly attribute WindowProxy parent;
+ readonly attribute Element? frameElement;
+ WindowProxy open(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace);
+ getter WindowProxy (unsigned long index);
+ getter object (DOMString name);
+
+ // the user agent
+ readonly attribute Navigator navigator;
+
+ readonly attribute External external;
+ readonly attribute ApplicationCache applicationCache;
+
+ // user prompts
+ void alert(DOMString message);
+ boolean confirm(DOMString message);
+ DOMString? prompt(DOMString message, optional DOMString default);
+ void print();
+ any showModalDialog(DOMString url, optional any argument);
+
+ // cross-document messaging
+ void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
+
+ // event handler IDL attributes
+ attribute EventHandler onabort;
+ attribute EventHandler onafterprint;
+ attribute EventHandler onbeforeprint;
+ attribute EventHandler onbeforeunload;
+ attribute EventHandler onblur;
+ attribute EventHandler oncancel;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onchange;
+ attribute EventHandler onclick;
+ attribute EventHandler onclose;
+ attribute EventHandler oncontextmenu;
+ attribute EventHandler oncuechange;
+ attribute EventHandler ondblclick;
+ attribute EventHandler ondrag;
+ attribute EventHandler ondragend;
+ attribute EventHandler ondragenter;
+ attribute EventHandler ondragleave;
+ attribute EventHandler ondragover;
+ attribute EventHandler ondragstart;
+ attribute EventHandler ondrop;
+ attribute EventHandler ondurationchange;
+ attribute EventHandler onemptied;
+ attribute EventHandler onended;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler onhashchange;
+ attribute EventHandler oninput;
+ attribute EventHandler oninvalid;
+ attribute EventHandler onkeydown;
+ attribute EventHandler onkeypress;
+ attribute EventHandler onkeyup;
+ attribute EventHandler onload;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadstart;
+ attribute EventHandler onmessage;
+ attribute EventHandler onmousedown;
+ attribute EventHandler onmousemove;
+ attribute EventHandler onmouseout;
+ attribute EventHandler onmouseover;
+ attribute EventHandler onmouseup;
+ attribute EventHandler onmousewheel;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+ attribute EventHandler onpause;
+ attribute EventHandler onplay;
+ attribute EventHandler onplaying;
+ attribute EventHandler onpagehide;
+ attribute EventHandler onpageshow;
+ attribute EventHandler onpopstate;
+ attribute EventHandler onprogress;
+ attribute EventHandler onratechange;
+ attribute EventHandler onreset;
+ attribute EventHandler onresize;
+ attribute EventHandler onscroll;
+ attribute EventHandler onseeked;
+ attribute EventHandler onseeking;
+ attribute EventHandler onselect;
+ attribute EventHandler onshow;
+ attribute EventHandler onstalled;
+ attribute EventHandler onstorage;
+ attribute EventHandler onsubmit;
+ attribute EventHandler onsuspend;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onunload;
+ attribute EventHandler onvolumechange;
+ attribute EventHandler onwaiting;
+};
+
+interface BarProp {
+ attribute boolean visible;
+};
+
+interface History {
+ readonly attribute long length;
+ readonly attribute any state;
+ void go(optional long delta);
+ void back();
+ void forward();
+ void pushState(any data, DOMString title, optional DOMString url);
+ void replaceState(any data, DOMString title, optional DOMString url);
+};
+
+interface Location {
+ stringifier attribute DOMString href;
+ void assign(DOMString url);
+ void replace(DOMString url);
+ void reload();
+
+ // URL decomposition IDL attributes
+ attribute DOMString protocol;
+ attribute DOMString host;
+ attribute DOMString hostname;
+ attribute DOMString port;
+ attribute DOMString pathname;
+ attribute DOMString search;
+ attribute DOMString hash;
+};
+
+[Constructor(DOMString type, optional PopStateEventInit eventInitDict)]
+interface PopStateEvent : Event {
+ readonly attribute any state;
+};
+
+dictionary PopStateEventInit : EventInit {
+ any state;
+};
+
+[Constructor(DOMString type, optional HashChangeEventInit eventInitDict)]
+interface HashChangeEvent : Event {
+ readonly attribute DOMString oldURL;
+ readonly attribute DOMString newURL;
+};
+
+dictionary HashChangeEventInit : EventInit {
+ DOMString oldURL;
+ DOMString newURL;
+};
+
+[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict)]
+interface PageTransitionEvent : Event {
+ readonly attribute boolean persisted;
+};
+
+dictionary PageTransitionEventInit : EventInit {
+ boolean persisted;
+};
+
+interface BeforeUnloadEvent : Event {
+ attribute DOMString returnValue;
+};
+
+interface ApplicationCache : EventTarget {
+
+ // update status
+ const unsigned short UNCACHED = 0;
+ const unsigned short IDLE = 1;
+ const unsigned short CHECKING = 2;
+ const unsigned short DOWNLOADING = 3;
+ const unsigned short UPDATEREADY = 4;
+ const unsigned short OBSOLETE = 5;
+ readonly attribute unsigned short status;
+
+ // updates
+ void update();
+ void abort();
+ void swapCache();
+
+ // events
+ attribute EventHandler onchecking;
+ attribute EventHandler onerror;
+ attribute EventHandler onnoupdate;
+ attribute EventHandler ondownloading;
+ attribute EventHandler onprogress;
+ attribute EventHandler onupdateready;
+ attribute EventHandler oncached;
+ attribute EventHandler onobsolete;
+};
+
+[NoInterfaceObject]
+interface NavigatorOnLine {
+ readonly attribute boolean onLine;
+};
+
+[TreatNonCallableAsNull]
+callback EventHandlerNonNull = any (Event event);
+typedef EventHandlerNonNull? EventHandler;
+
+[TreatNonCallableAsNull]
+callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, DOMString source, unsigned long lineno, unsigned long column);
+typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
+
+[NoInterfaceObject]
+interface WindowBase64 {
+ DOMString btoa(DOMString btoa);
+ DOMString atob(DOMString atob);
+};
+Window implements WindowBase64;
+
+[NoInterfaceObject]
+interface WindowTimers {
+ long setTimeout(Function handler, optional long timeout, any... arguments);
+ long setTimeout(DOMString handler, optional long timeout, any... arguments);
+ void clearTimeout(long handle);
+ long setInterval(Function handler, optional long timeout, any... arguments);
+ long setInterval(DOMString handler, optional long timeout, any... arguments);
+ void clearInterval(long handle);
+};
+Window implements WindowTimers;
+
+[NoInterfaceObject] interface WindowModal {
+ readonly attribute any dialogArguments;
+ attribute DOMString returnValue;
+};
+
+interface Navigator {
+ // objects implementing this interface also implement the interfaces given below
+};
+Navigator implements NavigatorID;
+Navigator implements NavigatorOnLine;
+Navigator implements NavigatorContentUtils;
+Navigator implements NavigatorStorageUtils;
+
+[NoInterfaceObject]
+interface NavigatorID {
+ readonly attribute DOMString appName;
+ readonly attribute DOMString appVersion;
+ readonly attribute DOMString platform;
+ readonly attribute DOMString userAgent;
+};
+
+[NoInterfaceObject]
+interface NavigatorContentUtils {
+ // content handler registration
+ void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
+ void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
+ DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
+ DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
+ void unregisterProtocolHandler(DOMString scheme, DOMString url);
+ void unregisterContentHandler(DOMString mimeType, DOMString url);
+};
+
+[NoInterfaceObject]
+interface NavigatorStorageUtils {
+ void yieldForStorageUpdates();
+};
+
+interface External {
+ void AddSearchProvider(DOMString engineURL);
+ unsigned long IsSearchProviderInstalled(DOMString engineURL);
+};
+
+interface DataTransfer {
+ attribute DOMString dropEffect;
+ attribute DOMString effectAllowed;
+
+ readonly attribute DataTransferItemList items;
+
+ void setDragImage(Element image, long x, long y);
+
+ /* old interface */
+ readonly attribute DOMString[] types;
+ DOMString getData(DOMString format);
+ void setData(DOMString format, DOMString data);
+ void clearData(optional DOMString format);
+ readonly attribute FileList files;
+};
+
+interface DataTransferItemList {
+ readonly attribute unsigned long length;
+ getter DataTransferItem (unsigned long index);
+ deleter void (unsigned long index);
+ void clear();
+
+ DataTransferItem? add(DOMString data, DOMString type);
+ DataTransferItem? add(File data);
+};
+
+interface DataTransferItem {
+ readonly attribute DOMString kind;
+ readonly attribute DOMString type;
+ void getAsString(FunctionStringCallback? _callback);
+
+ File? getAsFile();
+};
+
+[Callback, NoInterfaceObject]
+interface FunctionStringCallback {
+ void handleEvent(DOMString data);
+};
+
+[Constructor(DOMString type, optional DragEventInit eventInitDict)]
+interface DragEvent : MouseEvent {
+ readonly attribute DataTransfer? dataTransfer;
+};
+
+dictionary DragEventInit : MouseEventInit {
+ DataTransfer? dataTransfer;
+};
+
+interface WorkerGlobalScope : EventTarget {
+ readonly attribute WorkerGlobalScope self;
+ readonly attribute WorkerLocation location;
+
+ void close();
+ attribute EventHandler onerror;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+};
+WorkerGlobalScope implements WorkerUtils;
+
+interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
+ void postMessage(any message, optional sequence<Transferable> transfer);
+ attribute EventHandler onmessage;
+};
+
+interface SharedWorkerGlobalScope : WorkerGlobalScope {
+ readonly attribute DOMString name;
+ readonly attribute ApplicationCache applicationCache;
+ attribute EventHandler onconnect;
+};
+
+[Constructor(DOMString type, optional ErrorEventInit eventInitDict)]
+interface ErrorEvent : Event {
+ readonly attribute DOMString message;
+ readonly attribute DOMString filename;
+ readonly attribute unsigned long lineno;
+ readonly attribute unsigned long column;
+};
+
+dictionary ErrorEventInit : EventInit {
+ DOMString message;
+ DOMString filename;
+ unsigned long lineno;
+ unsigned long column;
+};
+
+[NoInterfaceObject]
+interface AbstractWorker {
+ attribute EventHandler onerror;
+
+};
+
+[Constructor(DOMString scriptURL)]
+interface Worker : EventTarget {
+ void terminate();
+
+ void postMessage(any message, optional sequence<Transferable> transfer);
+ attribute EventHandler onmessage;
+};
+Worker implements AbstractWorker;
+
+[Constructor(DOMString scriptURL, optional DOMString name)]
+interface SharedWorker : EventTarget {
+ readonly attribute MessagePort port;
+};
+SharedWorker implements AbstractWorker;
+
+[NoInterfaceObject]
+interface WorkerUtils {
+ void importScripts(DOMString... urls);
+ readonly attribute WorkerNavigator navigator;
+};
+WorkerUtils implements WindowTimers;
+WorkerUtils implements WindowBase64;
+
+interface WorkerNavigator {};
+WorkerNavigator implements NavigatorID;
+WorkerNavigator implements NavigatorOnLine;
+
+interface WorkerLocation {
+ // URL decomposition IDL attributes
+ stringifier readonly attribute DOMString href;
+ readonly attribute DOMString protocol;
+ readonly attribute DOMString host;
+ readonly attribute DOMString hostname;
+ readonly attribute DOMString port;
+ readonly attribute DOMString pathname;
+ readonly attribute DOMString search;
+ readonly attribute DOMString hash;
+};
+
+[Constructor(DOMString type, optional MessageEventInit eventInitDict)]
+interface MessageEvent : Event {
+ readonly attribute any data;
+ readonly attribute DOMString origin;
+ readonly attribute DOMString lastEventId;
+ readonly attribute (WindowProxy or MessagePort)? source;
+ readonly attribute MessagePort[]? ports;
+};
+
+dictionary MessageEventInit : EventInit {
+ any data;
+ DOMString origin;
+ DOMString lastEventId;
+ WindowProxy? source;
+ MessagePort[]? ports;
+};
+
+[Constructor(DOMString url, optional EventSourceInit eventSourceInitDict)]
+interface EventSource : EventTarget {
+ readonly attribute DOMString url;
+ readonly attribute boolean withCredentials;
+
+ // ready state
+ const unsigned short CONNECTING = 0;
+ const unsigned short OPEN = 1;
+ const unsigned short CLOSED = 2;
+ readonly attribute unsigned short readyState;
+
+ // networking
+ attribute EventHandler onopen;
+ attribute EventHandler onmessage;
+ attribute EventHandler onerror;
+ void close();
+};
+
+dictionary EventSourceInit {
+ boolean withCredentials = false;
+};
+
+enum BinaryType { "blob", "arraybuffer" };
+[Constructor(DOMString url, optional (DOMString or DOMString[]) protocols)]
+interface WebSocket : EventTarget {
+ readonly attribute DOMString url;
+
+ // ready state
+ const unsigned short CONNECTING = 0;
+ const unsigned short OPEN = 1;
+ const unsigned short CLOSING = 2;
+ const unsigned short CLOSED = 3;
+ readonly attribute unsigned short readyState;
+ readonly attribute unsigned long bufferedAmount;
+
+ // networking
+ attribute EventHandler onopen;
+ attribute EventHandler onerror;
+ attribute EventHandler onclose;
+ readonly attribute DOMString extensions;
+ readonly attribute DOMString protocol;
+ void close([Clamp] optional unsigned short code, optional DOMString reason);
+
+ // messaging
+ attribute EventHandler onmessage;
+ attribute BinaryType binaryType;
+ void send(DOMString data);
+ void send(Blob data);
+ void send(ArrayBuffer data);
+ void send(ArrayBufferView data);
+};
+
+[Constructor(DOMString type, optional CloseEventInit eventInitDict)]
+interface CloseEvent : Event {
+ readonly attribute boolean wasClean;
+ readonly attribute unsigned short code;
+ readonly attribute DOMString reason;
+};
+
+dictionary CloseEventInit : EventInit {
+ boolean wasClean;
+ unsigned short code;
+ DOMString reason;
+};
+
+[Constructor]
+interface MessageChannel {
+ readonly attribute MessagePort port1;
+ readonly attribute MessagePort port2;
+};
+
+interface MessagePort : EventTarget {
+ void postMessage(any message, optional sequence<Transferable> transfer);
+ void start();
+ void close();
+
+ // event handlers
+ attribute EventHandler onmessage;
+};
+MessagePort implements Transferable;
+
+interface Storage {
+ readonly attribute unsigned long length;
+ DOMString? key(unsigned long index);
+ getter DOMString getItem(DOMString key);
+ setter creator void setItem(DOMString key, DOMString value);
+ deleter void removeItem(DOMString key);
+ void clear();
+};
+
+[NoInterfaceObject]
+interface WindowSessionStorage {
+ readonly attribute Storage sessionStorage;
+};
+Window implements WindowSessionStorage;
+
+[NoInterfaceObject]
+interface WindowLocalStorage {
+ readonly attribute Storage localStorage;
+};
+Window implements WindowLocalStorage;
+
+[Constructor(DOMString type, optional StorageEventInit eventInitDict)]
+interface StorageEvent : Event {
+ readonly attribute DOMString? key;
+ readonly attribute DOMString? oldValue;
+ readonly attribute DOMString? newValue;
+ readonly attribute DOMString url;
+ readonly attribute Storage? storageArea;
+};
+
+dictionary StorageEventInit : EventInit {
+ DOMString? key;
+ DOMString? oldValue;
+ DOMString? newValue;
+ DOMString url;
+ Storage? storageArea;
+};
+
+interface HTMLAppletElement : HTMLElement {
+ attribute DOMString align;
+ attribute DOMString alt;
+ attribute DOMString archive;
+ attribute DOMString code;
+ attribute DOMString codeBase;
+ attribute DOMString height;
+ attribute unsigned long hspace;
+ attribute DOMString name;
+ attribute DOMString _object; // the underscore is not part of the identifier
+ attribute unsigned long vspace;
+ attribute DOMString width;
+};
+
+interface HTMLMarqueeElement : HTMLElement {
+ attribute DOMString behavior;
+ attribute DOMString bgColor;
+ attribute DOMString direction;
+ attribute DOMString height;
+ attribute unsigned long hspace;
+ attribute long loop;
+ attribute unsigned long scrollAmount;
+ attribute unsigned long scrollDelay;
+ attribute boolean trueSpeed;
+ attribute unsigned long vspace;
+ attribute DOMString width;
+
+ attribute EventHandler onbounce;
+ attribute EventHandler onfinish;
+ attribute EventHandler onstart;
+
+ void start();
+ void stop();
+};
+
+interface HTMLFrameSetElement : HTMLElement {
+ attribute DOMString cols;
+ attribute DOMString rows;
+ attribute EventHandler onafterprint;
+ attribute EventHandler onbeforeprint;
+ attribute EventHandler onbeforeunload;
+ attribute EventHandler onblur;
+ attribute EventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler onhashchange;
+ attribute EventHandler onload;
+ attribute EventHandler onmessage;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+ attribute EventHandler onpagehide;
+ attribute EventHandler onpageshow;
+ attribute EventHandler onpopstate;
+ attribute EventHandler onresize;
+ attribute EventHandler onscroll;
+ attribute EventHandler onstorage;
+ attribute EventHandler onunload;
+};
+
+interface HTMLFrameElement : HTMLElement {
+ attribute DOMString name;
+ attribute DOMString scrolling;
+ attribute DOMString src;
+ attribute DOMString frameBorder;
+ attribute DOMString longDesc;
+ attribute boolean noResize;
+ readonly attribute Document? contentDocument;
+ readonly attribute WindowProxy? contentWindow;
+
+ [TreatNullAs=EmptyString] attribute DOMString marginHeight;
+ [TreatNullAs=EmptyString] attribute DOMString marginWidth;
+};
+
+partial interface HTMLAnchorElement {
+ attribute DOMString coords;
+ attribute DOMString charset;
+ attribute DOMString name;
+ attribute DOMString rev;
+ attribute DOMString shape;
+};
+
+partial interface HTMLAreaElement {
+ attribute boolean noHref;
+};
+
+interface HTMLBaseFontElement : HTMLElement {
+ attribute DOMString color;
+ attribute DOMString face;
+ attribute long size;
+
+};
+
+partial interface HTMLBodyElement {
+ [TreatNullAs=EmptyString] attribute DOMString text;
+ [TreatNullAs=EmptyString] attribute DOMString link;
+ [TreatNullAs=EmptyString] attribute DOMString vLink;
+ [TreatNullAs=EmptyString] attribute DOMString aLink;
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+ attribute DOMString background;
+};
+
+partial interface HTMLBRElement {
+ attribute DOMString clear;
+};
+
+partial interface HTMLTableCaptionElement {
+ attribute DOMString align;
+};
+
+partial interface HTMLTableColElement {
+ attribute DOMString align;
+ attribute DOMString ch;
+ attribute DOMString chOff;
+ attribute DOMString vAlign;
+ attribute DOMString width;
+};
+
+interface HTMLDirectoryElement : HTMLElement {
+ attribute boolean compact;
+};
+
+partial interface HTMLDivElement {
+ attribute DOMString align;
+};
+
+partial interface HTMLDListElement {
+ attribute boolean compact;
+};
+
+partial interface HTMLEmbedElement {
+ attribute DOMString align;
+ attribute DOMString name;
+};
+
+interface HTMLFontElement : HTMLElement {
+ [TreatNullAs=EmptyString] attribute DOMString color;
+ attribute DOMString face;
+ attribute DOMString size;
+
+};
+
+partial interface HTMLHeadingElement {
+ attribute DOMString align;
+};
+
+partial interface HTMLHRElement {
+ attribute DOMString align;
+ attribute DOMString color;
+ attribute boolean noShade;
+ attribute DOMString size;
+ attribute DOMString width;
+};
+
+partial interface HTMLHtmlElement {
+ attribute DOMString version;
+};
+
+partial interface HTMLIFrameElement {
+ attribute DOMString align;
+ attribute DOMString scrolling;
+ attribute DOMString frameBorder;
+ attribute DOMString longDesc;
+
+ [TreatNullAs=EmptyString] attribute DOMString marginHeight;
+ [TreatNullAs=EmptyString] attribute DOMString marginWidth;
+};
+
+partial interface HTMLImageElement {
+ attribute DOMString name;
+ attribute DOMString align;
+ attribute unsigned long hspace;
+ attribute unsigned long vspace;
+ attribute DOMString longDesc;
+
+ [TreatNullAs=EmptyString] attribute DOMString border;
+};
+
+partial interface HTMLInputElement {
+ attribute DOMString align;
+ attribute DOMString useMap;
+};
+
+partial interface HTMLLegendElement {
+ attribute DOMString align;
+};
+
+partial interface HTMLLIElement {
+ attribute DOMString type;
+};
+
+partial interface HTMLLinkElement {
+ attribute DOMString charset;
+ attribute DOMString rev;
+ attribute DOMString target;
+};
+
+partial interface HTMLMenuElement {
+ attribute boolean compact;
+};
+
+partial interface HTMLMetaElement {
+ attribute DOMString scheme;
+};
+
+partial interface HTMLObjectElement {
+ attribute DOMString align;
+ attribute DOMString archive;
+ attribute DOMString code;
+ attribute boolean declare;
+ attribute unsigned long hspace;
+ attribute DOMString standby;
+ attribute unsigned long vspace;
+ attribute DOMString codeBase;
+ attribute DOMString codeType;
+
+ [TreatNullAs=EmptyString] attribute DOMString border;
+};
+
+partial interface HTMLOListElement {
+ attribute boolean compact;
+};
+
+partial interface HTMLParagraphElement {
+ attribute DOMString align;
+};
+
+partial interface HTMLParamElement {
+ attribute DOMString type;
+ attribute DOMString valueType;
+};
+
+partial interface HTMLPreElement {
+ attribute long width;
+};
+
+partial interface HTMLScriptElement {
+ attribute DOMString event;
+ attribute DOMString htmlFor;
+};
+
+partial interface HTMLTableElement {
+ attribute DOMString align;
+ attribute DOMString border;
+ attribute DOMString frame;
+ attribute DOMString rules;
+ attribute DOMString summary;
+ attribute DOMString width;
+
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+ [TreatNullAs=EmptyString] attribute DOMString cellPadding;
+ [TreatNullAs=EmptyString] attribute DOMString cellSpacing;
+};
+
+partial interface HTMLTableSectionElement {
+ attribute DOMString align;
+ attribute DOMString ch;
+ attribute DOMString chOff;
+ attribute DOMString vAlign;
+};
+
+partial interface HTMLTableCellElement {
+ attribute DOMString abbr;
+ attribute DOMString align;
+ attribute DOMString axis;
+ attribute DOMString height;
+ attribute DOMString width;
+
+ attribute DOMString ch;
+ attribute DOMString chOff;
+ attribute boolean noWrap;
+ attribute DOMString vAlign;
+
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+};
+
+partial interface HTMLTableRowElement {
+ attribute DOMString align;
+ attribute DOMString ch;
+ attribute DOMString chOff;
+ attribute DOMString vAlign;
+
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+};
+
+partial interface HTMLUListElement {
+ attribute boolean compact;
+ attribute DOMString type;
+};
+
+partial interface Document {
+ [TreatNullAs=EmptyString] attribute DOMString fgColor;
+ [TreatNullAs=EmptyString] attribute DOMString linkColor;
+ [TreatNullAs=EmptyString] attribute DOMString vlinkColor;
+ [TreatNullAs=EmptyString] attribute DOMString alinkColor;
+ [TreatNullAs=EmptyString] attribute DOMString bgColor;
+
+ readonly attribute HTMLCollection anchors;
+ readonly attribute HTMLCollection applets;
+
+ void clear();
+
+ readonly attribute HTMLAllCollection all;
+};
+
diff --git a/javascript/jsapi/WebIDL/Makefile b/javascript/jsapi/WebIDL/Makefile
deleted file mode 100644
index 77d54e2..0000000
--- a/javascript/jsapi/WebIDL/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/make
-#
-# Create the WebIDL for core DOM and HTML spec directly from
-# downloaded specifications. The resulting IDL is pretty close but
-# carries the example text etc. and should be manually cleaned up and
-# tagged with the retrival date and source URL
-#
-# needs debin packages: curl w3m tidy html-xml-utils
-#
-# Copyright 2012 Vincent Sanders
-# MIT licenced
-
-.PHONY:all clean
-
-all: dom.idl html.idl
-
-.INTERMEDIATE:dom-spec.html dom-spec.xml dom-idl.html html-spec.html html-spec.xml html-idl.html
-
-
-dom-spec.html:
- curl -s http://dom.spec.whatwg.org/ -o $@
-
-html-spec.html:
- curl -s http://www.whatwg.org/specs/web-apps/current-work/ -o $@
-
-%-spec.xml: %-spec.html
- -tidy -q -f $@.errors --new-blocklevel-tags header,hgroup,figure -o $@ -asxml $<
-
-%-idl.html: %-spec.xml
- hxselect pre.idl < $< > $@
-
-%.idl: %-idl.html
- cat $< | w3m -dump -T text/html >$@
-
-
-
-clean:
- ${RM} dom.idl html.idl dom-spec.html dom-spec.xml dom-idl.html html-spec.html html-spec.xml html-idl.html
diff --git a/javascript/jsapi/WebIDL/dom.idl b/javascript/jsapi/WebIDL/dom.idl
deleted file mode 100644
index 6ba870c..0000000
--- a/javascript/jsapi/WebIDL/dom.idl
+++ /dev/null
@@ -1,446 +0,0 @@
-// DOM core WebIDL
-// retrived from http://dom.spec.whatwg.org/
-// 23rd October 2012
-
-
-
-exception DOMException {
- const unsigned short INDEX_SIZE_ERR = 1;
- const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
- const unsigned short HIERARCHY_REQUEST_ERR = 3;
- const unsigned short WRONG_DOCUMENT_ERR = 4;
- const unsigned short INVALID_CHARACTER_ERR = 5;
- const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
- const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
- const unsigned short NOT_FOUND_ERR = 8;
- const unsigned short NOT_SUPPORTED_ERR = 9;
- const unsigned short INUSE_ATTRIBUTE_ERR = 10; // historical
- const unsigned short INVALID_STATE_ERR = 11;
- const unsigned short SYNTAX_ERR = 12;
- const unsigned short INVALID_MODIFICATION_ERR = 13;
- const unsigned short NAMESPACE_ERR = 14;
- const unsigned short INVALID_ACCESS_ERR = 15;
- const unsigned short VALIDATION_ERR = 16; // historical
- const unsigned short TYPE_MISMATCH_ERR = 17;
- const unsigned short SECURITY_ERR = 18;
- const unsigned short NETWORK_ERR = 19;
- const unsigned short ABORT_ERR = 20;
- const unsigned short URL_MISMATCH_ERR = 21;
- const unsigned short QUOTA_EXCEEDED_ERR = 22;
- const unsigned short TIMEOUT_ERR = 23;
- const unsigned short INVALID_NODE_TYPE_ERR = 24;
- const unsigned short DATA_CLONE_ERR = 25;
- unsigned short code;
-};
-
-interface DOMError {
- readonly attribute DOMString name;
-};
-
-[Constructor(DOMString type, optional EventInit eventInitDict)]
-interface Event {
- readonly attribute DOMString type;
- readonly attribute EventTarget? target;
- readonly attribute EventTarget? currentTarget;
-
- const unsigned short NONE = 0;
- const unsigned short CAPTURING_PHASE = 1;
- const unsigned short AT_TARGET = 2;
- const unsigned short BUBBLING_PHASE = 3;
- readonly attribute unsigned short eventPhase;
-
- void stopPropagation();
- void stopImmediatePropagation();
-
- readonly attribute boolean bubbles;
- readonly attribute boolean cancelable;
- void preventDefault();
- readonly attribute boolean defaultPrevented;
-
- readonly attribute boolean isTrusted;
- readonly attribute DOMTimeStamp timeStamp;
-
- void initEvent(DOMString type, boolean bubbles, boolean cancelable);
-};
-
-dictionary EventInit {
- boolean bubbles;
- boolean cancelable;
-};
-
-[Constructor(DOMString type, optional CustomEventInit eventInitDict)]
-interface CustomEvent : Event {
- readonly attribute any detail;
-};
-
-dictionary CustomEventInit : EventInit {
- any detail;
-};
-
-interface EventTarget {
- void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
- void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
- boolean dispatchEvent(Event event);
-};
-
-callback interface EventListener {
- void handleEvent(Event event);
-};
-
-[Constructor(MutationCallback callback)]
-interface MutationObserver {
- void observe(Node target, MutationObserverInit options);
- void disconnect();
- sequence<MutationRecord> takeRecords();
-};
-
-callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);
-
-dictionary MutationObserverInit {
- boolean childList;
- boolean attributes;
- boolean characterData;
- boolean subtree;
- boolean attributeOldValue;
- boolean characterDataOldValue;
- sequence<DOMString> attributeFilter;
-};
-
-interface MutationRecord {
- readonly attribute DOMString type;
- readonly attribute Node target;
- readonly attribute NodeList addedNodes;
- readonly attribute NodeList removedNodes;
- readonly attribute Node? previousSibling;
- readonly attribute Node? nextSibling;
- readonly attribute DOMString? attributeName;
- readonly attribute DOMString? attributeNamespace;
- readonly attribute DOMString? oldValue;
-};
-
-interface Node : EventTarget {
- const unsigned short ELEMENT_NODE = 1;
- const unsigned short ATTRIBUTE_NODE = 2; // historical
- const unsigned short TEXT_NODE = 3;
- const unsigned short CDATA_SECTION_NODE = 4; // historical
- const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
- const unsigned short ENTITY_NODE = 6; // historical
- const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
- const unsigned short COMMENT_NODE = 8;
- const unsigned short DOCUMENT_NODE = 9;
- const unsigned short DOCUMENT_TYPE_NODE = 10;
- const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
- const unsigned short NOTATION_NODE = 12; // historical
- readonly attribute unsigned short nodeType;
- readonly attribute DOMString nodeName;
-
- readonly attribute DOMString? baseURI;
-
- readonly attribute Document? ownerDocument;
- readonly attribute Node? parentNode;
- readonly attribute Element? parentElement;
- boolean hasChildNodes();
- readonly attribute NodeList childNodes;
- readonly attribute Node? firstChild;
- readonly attribute Node? lastChild;
- readonly attribute Node? previousSibling;
- readonly attribute Node? nextSibling;
-
- attribute DOMString? nodeValue;
- attribute DOMString? textContent;
- Node insertBefore(Node node, Node? child);
- Node appendChild(Node node);
- Node replaceChild(Node node, Node child);
- Node removeChild(Node child);
- void normalize();
-
-
-Node cloneNode(optional boolean deep = true);
- boolean isEqualNode(Node? node);
-
- const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
- const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
- const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
- const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
- const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
- const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
- unsigned short compareDocumentPosition(Node other);
- boolean contains(Node? other);
-
- DOMString? lookupPrefix(DOMString? namespace);
- DOMString? lookupNamespaceURI(DOMString? prefix);
- boolean isDefaultNamespace(DOMString? namespace);
-};
-
-[Constructor]
-interface Document : Node {
- readonly attribute DOMImplementation implementation;
- readonly attribute DOMString URL;
- readonly attribute DOMString documentURI;
- readonly attribute DOMString compatMode;
- readonly attribute DOMString characterSet;
- readonly attribute DOMString contentType;
-
- readonly attribute DocumentType? doctype;
- readonly attribute Element? documentElement;
- HTMLCollection getElementsByTagName(DOMString localName);
- HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
- HTMLCollection getElementsByClassName(DOMString classNames);
- Element? getElementById(DOMString elementId);
-
- Element createElement(DOMString localName);
- Element createElementNS(DOMString? namespace, DOMString qualifiedName);
- DocumentFragment createDocumentFragment();
- Text createTextNode(DOMString data);
- Comment createComment(DOMString data);
- ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
-
- Node importNode(Node node, optional boolean deep = true);
- Node adoptNode(Node node);
-
- Event createEvent(DOMString interface);
-
- Range createRange();
-
- // NodeFilter.SHOW_ALL = 0xFFFFFFFF
- NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
- TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
-
- // NEW
- void prepend((Node or DOMString)... nodes);
- void append((Node or DOMString)... nodes);
-};
-
-interface XMLDocument : Document {};
-
-interface DOMImplementation {
- DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
- XMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, DocumentType? doctype);
- Document createHTMLDocument(optional DOMString title);
-
- boolean hasFeature(DOMString feature, [TreatNullAs=EmptyString] DOMString version);
-};
-
-interface DocumentFragment : Node {
- // NEW
- void prepend((Node or DOMString)... nodes);
- void append((Node or DOMString)... nodes);
-};
-
-interface DocumentType : Node {
- readonly attribute DOMString name;
- readonly attribute DOMString publicId;
- readonly attribute DOMString systemId;
-
- // NEW
- void before((Node or DOMString)... nodes);
- void after((Node or DOMString)... nodes);
- void replace((Node or DOMString)... nodes);
- void remove();
-};
-
-interface Element : Node {
- readonly attribute DOMString? namespaceURI;
- readonly attribute DOMString? prefix;
- readonly attribute DOMString localName;
- readonly attribute DOMString tagName;
-
- attribute DOMString id;
- attribute DOMString className;
- readonly attribute DOMTokenList classList;
-
- readonly attribute Attr[] attributes;
- DOMString? getAttribute(DOMString name);
- DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
- void setAttribute(DOMString name, DOMString value);
- void setAttributeNS(DOMString? namespace, DOMString name, DOMString value);
- void removeAttribute(DOMString name);
- void removeAttributeNS(DOMString? namespace, DOMString localName);
- boolean hasAttribute(DOMString name);
- boolean hasAttributeNS(DOMString? namespace, DOMString localName);
-
- HTMLCollection getElementsByTagName(DOMString localName);
- HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
- HTMLCollection getElementsByClassName(DOMString classNames);
-
- readonly attribute HTMLCollection children;
- readonly attribute Element? firstElementChild;
- readonly attribute Element? lastElementChild;
- readonly attribute Element? previousElementSibling;
- readonly attribute Element? nextElementSibling;
- readonly attribute unsigned long childElementCount;
-
-
- // NEW
- void prepend((Node or DOMString)... nodes);
- void append((Node or DOMString)... nodes);
- void before((Node or DOMString)... nodes);
- void after((Node or DOMString)... nodes);
- void replace((Node or DOMString)... nodes);
- void remove();
-};
-
-interface Attr {
- readonly attribute DOMString name;
- attribute DOMString value;
-
- readonly attribute DOMString? namespaceURI;
- readonly attribute DOMString? prefix;
- readonly attribute DOMString localName;
-};
-
-interface CharacterData : Node {
- [TreatNullAs=EmptyString] attribute DOMString data;
- readonly attribute unsigned long length;
- DOMString substringData(unsigned long offset, unsigned long count);
- void appendData(DOMString data);
- void insertData(unsigned long offset, DOMString data);
- void deleteData(unsigned long offset, unsigned long count);
- void replaceData(unsigned long offset, unsigned long count, DOMString data);
-
- // NEW
- void before((Node or DOMString)... nodes);
- void after((Node or DOMString)... nodes);
- void replace((Node or DOMString)... nodes);
- void remove();
-};
-
-interface Text : CharacterData {
- Text splitText(unsigned long offset);
- readonly attribute DOMString wholeText;
-};
-
-interface ProcessingInstruction : CharacterData {
- readonly attribute DOMString target;
-};
-
-interface Comment : CharacterData {
-};
-
-interface Range {
- readonly attribute Node startContainer;
- readonly attribute unsigned long startOffset;
- readonly attribute Node endContainer;
- readonly attribute unsigned long endOffset;
- readonly attribute boolean collapsed;
- readonly attribute Node commonAncestorContainer;
-
- void setStart(Node refNode, unsigned long offset);
- void setEnd(Node refNode, unsigned long offset);
- void setStartBefore(Node refNode);
- void setStartAfter(Node refNode);
- void setEndBefore(Node refNode);
- void setEndAfter(Node refNode);
- void collapse(boolean toStart);
- void selectNode(Node refNode);
- void selectNodeContents(Node refNode);
-
- const unsigned short START_TO_START = 0;
- const unsigned short START_TO_END = 1;
- const unsigned short END_TO_END = 2;
- const unsigned short END_TO_START = 3;
- short compareBoundaryPoints(unsigned short how, Range sourceRange);
-
- void deleteContents();
- DocumentFragment extractContents();
- DocumentFragment cloneContents();
- void insertNode(Node node);
- void surroundContents(Node newParent);
-
- Range cloneRange();
- void detach();
-
- boolean isPointInRange(Node node, unsigned long offset);
- short comparePoint(Node node, unsigned long offset);
-
- boolean intersectsNode(Node node);
-
- stringifier;
-};
-
-interface NodeIterator {
- readonly attribute Node root;
- readonly attribute Node? referenceNode;
- readonly attribute boolean pointerBeforeReferenceNode;
- readonly attribute unsigned long whatToShow;
- readonly attribute NodeFilter? filter;
-
- Node? nextNode();
- Node? previousNode();
-
- void detach();
-};
-
-interface TreeWalker {
- readonly attribute Node root;
- readonly attribute unsigned long whatToShow;
- readonly attribute NodeFilter? filter;
-
- attribute Node currentNode;
-
- Node? parentNode();
- Node? firstChild();
- Node? lastChild();
- Node? previousSibling();
- Node? nextSibling();
- Node? previousNode();
- Node? nextNode();
-};
-
-callback interface NodeFilter {
- // Constants for acceptNode()
- const unsigned short FILTER_ACCEPT = 1;
- const unsigned short FILTER_REJECT = 2;
- const unsigned short FILTER_SKIP = 3;
-
- // Constants for whatToShow
- const unsigned long SHOW_ALL = 0xFFFFFFFF;
- const unsigned long SHOW_ELEMENT = 0x1;
- const unsigned long SHOW_ATTRIBUTE = 0x2; // historical
- const unsigned long SHOW_TEXT = 0x4;
- const unsigned long SHOW_CDATA_SECTION = 0x8; // historical
- const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical
- const unsigned long SHOW_ENTITY = 0x20; // historical
- const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40;
- const unsigned long SHOW_COMMENT = 0x80;
- const unsigned long SHOW_DOCUMENT = 0x100;
- const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
- const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
- const unsigned long SHOW_NOTATION = 0x800; // historical
-
- unsigned short acceptNode(Node node);
-};
-
-[ArrayClass]
-interface NodeList {
- getter Node? item(unsigned long index);
- readonly attribute unsigned long length;
-};
-
-interface HTMLCollection {
- readonly attribute unsigned long length;
- getter Element? item(unsigned long index);
- getter object? namedItem(DOMString name); // only returns Element
-};
-
-[NoInterfaceObject]
-interface DOMStringList {
- readonly attribute unsigned long length;
- getter DOMString? item(unsigned long index);
- boolean contains(DOMString string);
-};
-
-interface DOMTokenList {
- readonly attribute unsigned long length;
- getter DOMString? item(unsigned long index);
- boolean contains(DOMString token);
- void add(DOMString... tokens);
- void remove(DOMString... tokens);
- boolean toggle(DOMString token, optional boolean force);
- stringifier;
-};
-
-interface DOMSettableTokenList : DOMTokenList {
- attribute DOMString value;
-};
-
diff --git a/javascript/jsapi/WebIDL/html.idl b/javascript/jsapi/WebIDL/html.idl
deleted file mode 100644
index 94e7c75..0000000
--- a/javascript/jsapi/WebIDL/html.idl
+++ /dev/null
@@ -1,2194 +0,0 @@
-// HTML WebIDL
-// retrived from http://www.whatwg.org/specs/web-apps/current-work/
-// 23rd October 2012
-
-
-interface HTMLAllCollection : HTMLCollection {
- // inherits length and item()
- legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
- HTMLAllCollection tags(DOMString tagName);
-};
-
-interface HTMLFormControlsCollection : HTMLCollection {
- // inherits length and item()
- legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
-};
-
-interface RadioNodeList : NodeList {
- attribute DOMString value;
-};
-
-interface HTMLOptionsCollection : HTMLCollection {
- // inherits item()
- attribute unsigned long length; // overrides inherited length
- legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem()
- setter creator void (unsigned long index, HTMLOptionElement? option);
- void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
- void remove(long index);
- attribute long selectedIndex;
-};
-
-interface HTMLPropertiesCollection : HTMLCollection {
- // inherits length and item()
- getter PropertyNodeList? namedItem(DOMString name); // overrides inherited namedItem()
- readonly attribute DOMString[] names;
-};
-
-typedef sequence<any> PropertyValueArray;
-
-interface PropertyNodeList : NodeList {
- PropertyValueArray getValues();
-};
-
-interface DOMStringMap {
- getter DOMString (DOMString name);
- setter void (DOMString name, DOMString value);
- creator void (DOMString name, DOMString value);
- deleter void (DOMString name);
-};
-
-interface DOMElementMap {
- getter Element (DOMString name);
- setter void (DOMString name, Element value);
- creator void (DOMString name, Element value);
- deleter void (DOMString name);
-};
-
-[NoInterfaceObject]
-interface Transferable { };
-
-[OverrideBuiltins]
-partial interface Document {
- // resource metadata management
- [PutForwards=href] readonly attribute Location? location;
- attribute DOMString domain;
- readonly attribute DOMString referrer;
- attribute DOMString cookie;
- readonly attribute DOMString lastModified;
- readonly attribute DOMString readyState;
-
- // DOM tree accessors
- getter object (DOMString name);
- attribute DOMString title;
- attribute DOMString dir;
- attribute HTMLElement? body;
- readonly attribute HTMLHeadElement? head;
- readonly attribute HTMLCollection images;
- readonly attribute HTMLCollection embeds;
- readonly attribute HTMLCollection plugins;
- readonly attribute HTMLCollection links;
- readonly attribute HTMLCollection forms;
- readonly attribute HTMLCollection scripts;
- NodeList getElementsByName(DOMString elementName);
- NodeList getItems(optional DOMString typeNames); // microdata
- readonly attribute DOMElementMap cssElementMap;
-
- // dynamic markup insertion
- Document open(optional DOMString type, optional DOMString replace);
- WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace);
- void close();
- void write(DOMString... text);
- void writeln(DOMString... text);
-
- // user interaction
- readonly attribute WindowProxy? defaultView;
- readonly attribute Element? activeElement;
- boolean hasFocus();
- attribute DOMString designMode;
- boolean execCommand(DOMString commandId);
- boolean execCommand(DOMString commandId, boolean showUI);
- boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
- boolean queryCommandEnabled(DOMString commandId);
- boolean queryCommandIndeterm(DOMString commandId);
- boolean queryCommandState(DOMString commandId);
- boolean queryCommandSupported(DOMString commandId);
- DOMString queryCommandValue(DOMString commandId);
- readonly attribute HTMLCollection commands;
-
- // event handler IDL attributes
- attribute EventHandler onabort;
- attribute EventHandler onblur;
- attribute EventHandler oncancel;
- attribute EventHandler oncanplay;
- attribute EventHandler oncanplaythrough;
- attribute EventHandler onchange;
- attribute EventHandler onclick;
- attribute EventHandler onclose;
- attribute EventHandler oncontextmenu;
- attribute EventHandler oncuechange;
- attribute EventHandler ondblclick;
- attribute EventHandler ondrag;
- attribute EventHandler ondragend;
- attribute EventHandler ondragenter;
- attribute EventHandler ondragleave;
- attribute EventHandler ondragover;
- attribute EventHandler ondragstart;
- attribute EventHandler ondrop;
- attribute EventHandler ondurationchange;
- attribute EventHandler onemptied;
- attribute EventHandler onended;
- attribute OnErrorEventHandler onerror;
- attribute EventHandler onfocus;
- attribute EventHandler oninput;
- attribute EventHandler oninvalid;
- attribute EventHandler onkeydown;
- attribute EventHandler onkeypress;
- attribute EventHandler onkeyup;
- attribute EventHandler onload;
- attribute EventHandler onloadeddata;
- attribute EventHandler onloadedmetadata;
- attribute EventHandler onloadstart;
- attribute EventHandler onmousedown;
- attribute EventHandler onmousemove;
- attribute EventHandler onmouseout;
- attribute EventHandler onmouseover;
- attribute EventHandler onmouseup;
- attribute EventHandler onmousewheel;
- attribute EventHandler onpause;
- attribute EventHandler onplay;
- attribute EventHandler onplaying;
- attribute EventHandler onprogress;
- attribute EventHandler onratechange;
- attribute EventHandler onreset;
- attribute EventHandler onscroll;
- attribute EventHandler onseeked;
- attribute EventHandler onseeking;
- attribute EventHandler onselect;
- attribute EventHandler onshow;
- attribute EventHandler onstalled;
- attribute EventHandler onsubmit;
- attribute EventHandler onsuspend;
- attribute EventHandler ontimeupdate;
- attribute EventHandler onvolumechange;
- attribute EventHandler onwaiting;
-
- // special event handler IDL attributes that only apply to Document objects
- [LenientThis] attribute EventHandler onreadystatechange;
-};
-
-partial interface XMLDocument {
- boolean load(DOMString url);
-};
-
-interface HTMLElement : Element {
- // metadata attributes
- attribute DOMString title;
- attribute DOMString lang;
- attribute boolean translate;
- attribute DOMString dir;
- readonly attribute DOMStringMap dataset;
-
- // microdata
- attribute boolean itemScope;
- [PutForwards=value] readonly attribute DOMSettableTokenList itemType;
- attribute DOMString itemId;
- [PutForwards=value] readonly attribute DOMSettableTokenList itemRef;
- [PutForwards=value] readonly attribute DOMSettableTokenList itemProp;
- readonly attribute HTMLPropertiesCollection properties;
- attribute any itemValue; // acts as DOMString on setting
-
- // user interaction
- attribute boolean hidden;
- void click();
- attribute long tabIndex;
- void focus();
- void blur();
- attribute DOMString accessKey;
- readonly attribute DOMString accessKeyLabel;
- attribute boolean draggable;
- [PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
- attribute DOMString contentEditable;
- readonly attribute boolean isContentEditable;
- attribute HTMLMenuElement? contextMenu;
- attribute boolean spellcheck;
- void forceSpellCheck();
-
- // command API
- readonly attribute DOMString? commandType;
- readonly attribute DOMString? commandLabel;
- readonly attribute DOMString? commandIcon;
- readonly attribute boolean? commandHidden;
- readonly attribute boolean? commandDisabled;
- readonly attribute boolean? commandChecked;
-
- // styling
- readonly attribute CSSStyleDeclaration style;
-
- // event handler IDL attributes
- attribute EventHandler onabort;
- attribute EventHandler onblur;
- attribute EventHandler oncancel;
- attribute EventHandler oncanplay;
- attribute EventHandler oncanplaythrough;
- attribute EventHandler onchange;
- attribute EventHandler onclick;
- attribute EventHandler onclose;
- attribute EventHandler oncontextmenu;
- attribute EventHandler oncuechange;
- attribute EventHandler ondblclick;
- attribute EventHandler ondrag;
- attribute EventHandler ondragend;
- attribute EventHandler ondragenter;
- attribute EventHandler ondragleave;
- attribute EventHandler ondragover;
- attribute EventHandler ondragstart;
- attribute EventHandler ondrop;
- attribute EventHandler ondurationchange;
- attribute EventHandler onemptied;
- attribute EventHandler onended;
- attribute OnErrorEventHandler onerror;
- attribute EventHandler onfocus;
- attribute EventHandler oninput;
- attribute EventHandler oninvalid;
- attribute EventHandler onkeydown;
- attribute EventHandler onkeypress;
- attribute EventHandler onkeyup;
- attribute EventHandler onload;
- attribute EventHandler onloadeddata;
- attribute EventHandler onloadedmetadata;
- attribute EventHandler onloadstart;
- attribute EventHandler onmousedown;
- attribute EventHandler onmousemove;
- attribute EventHandler onmouseout;
- attribute EventHandler onmouseover;
- attribute EventHandler onmouseup;
- attribute EventHandler onmousewheel;
- attribute EventHandler onpause;
- attribute EventHandler onplay;
- attribute EventHandler onplaying;
- attribute EventHandler onprogress;
- attribute EventHandler onratechange;
- attribute EventHandler onreset;
- attribute EventHandler onscroll;
- attribute EventHandler onseeked;
- attribute EventHandler onseeking;
- attribute EventHandler onselect;
- attribute EventHandler onshow;
- attribute EventHandler onstalled;
- attribute EventHandler onsubmit;
- attribute EventHandler onsuspend;
- attribute EventHandler ontimeupdate;
- attribute EventHandler onvolumechange;
- attribute EventHandler onwaiting;
-};
-
-interface HTMLUnknownElement : HTMLElement { };
-
-interface HTMLHtmlElement : HTMLElement {};
-
-interface HTMLHeadElement : HTMLElement {};
-
-interface HTMLTitleElement : HTMLElement {
- attribute DOMString text;
-};
-
-interface HTMLBaseElement : HTMLElement {
- attribute DOMString href;
- attribute DOMString target;
-};
-
-interface HTMLLinkElement : HTMLElement {
- attribute boolean disabled;
- attribute DOMString href;
- attribute DOMString rel;
- readonly attribute DOMTokenList relList;
- attribute DOMString media;
- attribute DOMString hreflang;
- attribute DOMString type;
- [PutForwards=value] readonly attribute DOMSettableTokenList sizes;
-};
-HTMLLinkElement implements LinkStyle;
-
-interface HTMLMetaElement : HTMLElement {
- attribute DOMString name;
- attribute DOMString httpEquiv;
- attribute DOMString content;
-};
-
-interface HTMLStyleElement : HTMLElement {
- attribute boolean disabled;
- attribute DOMString media;
- attribute DOMString type;
- attribute boolean scoped;
-};
-HTMLStyleElement implements LinkStyle;
-
-interface HTMLScriptElement : HTMLElement {
- attribute DOMString src;
- attribute boolean async;
- attribute boolean defer;
- attribute DOMString type;
- attribute DOMString charset;
- attribute DOMString text;
-};
-
-interface HTMLBodyElement : HTMLElement {
- attribute EventHandler onafterprint;
- attribute EventHandler onbeforeprint;
- attribute EventHandler onbeforeunload;
- attribute EventHandler onblur;
- attribute OnErrorEventHandler onerror;
- attribute EventHandler onfocus;
- attribute EventHandler onhashchange;
- attribute EventHandler onload;
- attribute EventHandler onmessage;
- attribute EventHandler onoffline;
- attribute EventHandler ononline;
- attribute EventHandler onpopstate;
- attribute EventHandler onpagehide;
- attribute EventHandler onpageshow;
- attribute EventHandler onresize;
- attribute EventHandler onscroll;
- attribute EventHandler onstorage;
- attribute EventHandler onunload;
-};
-
-interface HTMLHeadingElement : HTMLElement {};
-
-interface HTMLParagraphElement : HTMLElement {};
-
-interface HTMLHRElement : HTMLElement {};
-
-interface HTMLPreElement : HTMLElement {};
-
-interface HTMLQuoteElement : HTMLElement {
- attribute DOMString cite;
-};
-
-interface HTMLOListElement : HTMLElement {
- attribute boolean reversed;
- attribute long start;
- attribute DOMString type;
-};
-
-interface HTMLUListElement : HTMLElement {};
-
-interface HTMLLIElement : HTMLElement {
- attribute long value;
-};
-
-interface HTMLDListElement : HTMLElement {};
-
-interface HTMLDivElement : HTMLElement {};
-
-interface HTMLAnchorElement : HTMLElement {
- stringifier attribute DOMString href;
- attribute DOMString target;
-
- attribute DOMString download;
- attribute DOMString ping;
-
- attribute DOMString rel;
- readonly attribute DOMTokenList relList;
- attribute DOMString media;
- attribute DOMString hreflang;
- attribute DOMString type;
-
- attribute DOMString text;
-
- // URL decomposition IDL attributes
- attribute DOMString protocol;
- attribute DOMString host;
- attribute DOMString hostname;
- attribute DOMString port;
- attribute DOMString pathname;
- attribute DOMString search;
- attribute DOMString hash;
-};
-
-interface HTMLDataElement : HTMLElement {
- attribute DOMString value;
-};
-
-interface HTMLTimeElement : HTMLElement {
- attribute DOMString datetime;
-};
-
-interface HTMLSpanElement : HTMLElement {};
-
-interface HTMLBRElement : HTMLElement {};
-
-interface HTMLModElement : HTMLElement {
- attribute DOMString cite;
- attribute DOMString dateTime;
-};
-
-[NamedConstructor=Image(),
- NamedConstructor=Image(unsigned long width),
- NamedConstructor=Image(unsigned long width, unsigned long height)]
-interface HTMLImageElement : HTMLElement {
- attribute DOMString alt;
- attribute DOMString src;
- attribute DOMString srcset;
- attribute DOMString crossOrigin;
- attribute DOMString useMap;
- attribute boolean isMap;
- attribute unsigned long width;
- attribute unsigned long height;
- readonly attribute unsigned long naturalWidth;
- readonly attribute unsigned long naturalHeight;
- readonly attribute boolean complete;
-};
-
-interface HTMLIFrameElement : HTMLElement {
- attribute DOMString src;
- attribute DOMString srcdoc;
- attribute DOMString name;
- [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
- attribute boolean seamless;
- attribute DOMString width;
- attribute DOMString height;
- readonly attribute Document? contentDocument;
- readonly attribute WindowProxy? contentWindow;
-};
-
-interface HTMLEmbedElement : HTMLElement {
- attribute DOMString src;
- attribute DOMString type;
- attribute DOMString width;
- attribute DOMString height;
- legacycaller any (any... arguments);
-};
-
-interface HTMLObjectElement : HTMLElement {
- attribute DOMString data;
- attribute DOMString type;
- attribute boolean typeMustMatch;
- attribute DOMString name;
- attribute DOMString useMap;
- readonly attribute HTMLFormElement? form;
- attribute DOMString width;
- attribute DOMString height;
- readonly attribute Document? contentDocument;
- readonly attribute WindowProxy? contentWindow;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- legacycaller any (any... arguments);
-};
-
-interface HTMLParamElement : HTMLElement {
- attribute DOMString name;
- attribute DOMString value;
-};
-
-interface HTMLVideoElement : HTMLMediaElement {
- attribute unsigned long width;
- attribute unsigned long height;
- readonly attribute unsigned long videoWidth;
- readonly attribute unsigned long videoHeight;
- attribute DOMString poster;
-};
-
-[NamedConstructor=Audio(),
- NamedConstructor=Audio(DOMString src)]
-interface HTMLAudioElement : HTMLMediaElement {};
-
-interface HTMLSourceElement : HTMLElement {
- attribute DOMString src;
- attribute DOMString type;
- attribute DOMString media;
-};
-
-interface HTMLTrackElement : HTMLElement {
- attribute DOMString kind;
- attribute DOMString src;
- attribute DOMString srclang;
- attribute DOMString label;
- attribute boolean default;
-
- const unsigned short NONE = 0;
- const unsigned short LOADING = 1;
- const unsigned short LOADED = 2;
- const unsigned short ERROR = 3;
- readonly attribute unsigned short readyState;
-
- readonly attribute TextTrack track;
-};
-
-interface HTMLMediaElement : HTMLElement {
-
- // error state
- readonly attribute MediaError? error;
-
- // network state
- attribute DOMString src;
- readonly attribute DOMString currentSrc;
- attribute DOMString crossOrigin;
- const unsigned short NETWORK_EMPTY = 0;
- const unsigned short NETWORK_IDLE = 1;
- const unsigned short NETWORK_LOADING = 2;
- const unsigned short NETWORK_NO_SOURCE = 3;
- readonly attribute unsigned short networkState;
- attribute DOMString preload;
- readonly attribute TimeRanges buffered;
- void load();
- DOMString canPlayType(DOMString type);
-
- // ready state
- const unsigned short HAVE_NOTHING = 0;
- const unsigned short HAVE_METADATA = 1;
- const unsigned short HAVE_CURRENT_DATA = 2;
- const unsigned short HAVE_FUTURE_DATA = 3;
- const unsigned short HAVE_ENOUGH_DATA = 4;
- readonly attribute unsigned short readyState;
- readonly attribute boolean seeking;
-
- // playback state
- attribute double currentTime;
- void fastSeek(double time);
- readonly attribute unrestricted double duration;
- readonly attribute Date startDate;
- readonly attribute boolean paused;
- attribute double defaultPlaybackRate;
- attribute double playbackRate;
- readonly attribute TimeRanges played;
- readonly attribute TimeRanges seekable;
- readonly attribute boolean ended;
- attribute boolean autoplay;
- attribute boolean loop;
- void play();
- void pause();
-
- // media controller
- attribute DOMString mediaGroup;
- attribute MediaController? controller;
-
- // controls
- attribute boolean controls;
- attribute double volume;
- attribute boolean muted;
- attribute boolean defaultMuted;
-
- // tracks
- readonly attribute AudioTrackList audioTracks;
- readonly attribute VideoTrackList videoTracks;
- readonly attribute TextTrackList textTracks;
- TextTrack addTextTrack(DOMString kind, optional DOMString label, optional DOMString language);
-};
-
-interface MediaError {
- const unsigned short MEDIA_ERR_ABORTED = 1;
- const unsigned short MEDIA_ERR_NETWORK = 2;
- const unsigned short MEDIA_ERR_DECODE = 3;
- const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
- readonly attribute unsigned short code;
-};
-
-interface AudioTrackList : EventTarget {
- readonly attribute unsigned long length;
- getter AudioTrack (unsigned long index);
- AudioTrack? getTrackById(DOMString id);
-
- attribute EventHandler onchange;
- attribute EventHandler onaddtrack;
- attribute EventHandler onremovetrack;
-};
-
-interface AudioTrack {
- readonly attribute DOMString id;
- readonly attribute DOMString kind;
- readonly attribute DOMString label;
- readonly attribute DOMString language;
- attribute boolean enabled;
-};
-
-interface VideoTrackList : EventTarget {
- readonly attribute unsigned long length;
- getter VideoTrack (unsigned long index);
- VideoTrack? getTrackById(DOMString id);
- readonly attribute long selectedIndex;
-
- attribute EventHandler onchange;
- attribute EventHandler onaddtrack;
- attribute EventHandler onremovetrack;
-};
-
-interface VideoTrack {
- readonly attribute DOMString id;
- readonly attribute DOMString kind;
- readonly attribute DOMString label;
- readonly attribute DOMString language;
- attribute boolean selected;
-};
-
-enum MediaControllerPlaybackState { "waiting", "playing", "ended" };
-[Constructor]
-interface MediaController : EventTarget {
- readonly attribute unsigned short readyState; // uses HTMLMediaElement.readyState's values
-
- readonly attribute TimeRanges buffered;
- readonly attribute TimeRanges seekable;
- readonly attribute unrestricted double duration;
- attribute double currentTime;
-
- readonly attribute boolean paused;
- readonly attribute MediaControllerPlaybackState playbackState;
- readonly attribute TimeRanges played;
- void pause();
- void unpause();
- void play(); // calls play() on all media elements as well
-
- attribute double defaultPlaybackRate;
- attribute double playbackRate;
-
- attribute double volume;
- attribute boolean muted;
-
- attribute EventHandler onemptied;
- attribute EventHandler onloadedmetadata;
- attribute EventHandler onloadeddata;
- attribute EventHandler oncanplay;
- attribute EventHandler oncanplaythrough;
- attribute EventHandler onplaying;
- attribute EventHandler onended;
- attribute EventHandler onwaiting;
-
- attribute EventHandler ondurationchange;
- attribute EventHandler ontimeupdate;
- attribute EventHandler onplay;
- attribute EventHandler onpause;
- attribute EventHandler onratechange;
- attribute EventHandler onvolumechange;
-};
-
-interface TextTrackList : EventTarget {
- readonly attribute unsigned long length;
- getter TextTrack (unsigned long index);
-
- attribute EventHandler onaddtrack;
- attribute EventHandler onremovetrack;
-};
-
-enum TextTrackMode { "disabled", "hidden", "showing" };
-interface TextTrack : EventTarget {
- readonly attribute DOMString kind;
- readonly attribute DOMString label;
- readonly attribute DOMString language;
- readonly attribute DOMString inBandMetadataTrackDispatchType;
-
- attribute TextTrackMode mode;
-
- readonly attribute TextTrackCueList? cues;
- readonly attribute TextTrackCueList? activeCues;
-
- void addCue(TextTrackCue cue);
- void removeCue(TextTrackCue cue);
-
- attribute EventHandler oncuechange;
-};
-
-interface TextTrackCueList {
- readonly attribute unsigned long length;
- getter TextTrackCue (unsigned long index);
- TextTrackCue? getCueById(DOMString id);
-};
-
-enum AutoKeyword { "auto" };
-[Constructor(double startTime, double endTime, DOMString text)]
-interface TextTrackCue : EventTarget {
- readonly attribute TextTrack? track;
-
- attribute DOMString id;
- attribute double startTime;
- attribute double endTime;
- attribute boolean pauseOnExit;
- attribute DOMString vertical;
- attribute boolean snapToLines;
- attribute (long or AutoKeyword) line;
- attribute long position;
- attribute long size;
- attribute DOMString align;
- attribute DOMString text;
- DocumentFragment getCueAsHTML();
-
- attribute EventHandler onenter;
- attribute EventHandler onexit;
-};
-
-interface TimeRanges {
- readonly attribute unsigned long length;
- double start(unsigned long index);
- double end(unsigned long index);
-};
-
-[Constructor(DOMString type, optional TrackEventInit eventInitDict)]
-interface TrackEvent : Event {
- readonly attribute object? track;
-};
-
-dictionary TrackEventInit : EventInit {
- object? track;
-};
-
-interface HTMLCanvasElement : HTMLElement {
- attribute unsigned long width;
- attribute unsigned long height;
-
- DOMString toDataURL(optional DOMString type, any... arguments);
- DOMString toDataURLHD(optional DOMString type, any... arguments);
- void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
- void toBlobHD(FileCallback? _callback, optional DOMString type, any... arguments);
-
- object? getContext(DOMString contextId, any... arguments);
- boolean supportsContext(DOMString contextId, any... arguments);
-};
-
-interface CanvasRenderingContext2D {
-
- // back-reference to the canvas
- readonly attribute HTMLCanvasElement canvas;
-
- // state
- void save(); // push state on state stack
- void restore(); // pop state stack and restore state
-
- // transformations (default transform is the identity matrix)
- attribute SVGMatrix currentTransform;
- void scale(unrestricted double x, unrestricted double y);
- void rotate(unrestricted double angle);
- void translate(unrestricted double x, unrestricted double y);
- void transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
- void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
- void resetTransform();
-
- // compositing
- attribute unrestricted double globalAlpha; // (default 1.0)
- attribute DOMString globalCompositeOperation; // (default source-over)
-
- // image smoothing
- attribute boolean imageSmoothingEnabled; // (default true)
-
- // colors and styles (see also the CanvasDrawingStyles interface)
- attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
- attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
- CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
- CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
- CanvasPattern createPattern((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, DOMString repetition);
-
- // shadows
- attribute unrestricted double shadowOffsetX; // (default 0)
- attribute unrestricted double shadowOffsetY; // (default 0)
- attribute unrestricted double shadowBlur; // (default 0)
- attribute DOMString shadowColor; // (default transparent black)
-
- // rects
- void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
- void fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
- void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
-
- // path API (see also CanvasPathMethods)
- void beginPath();
- void fill();
- void fill(Path path);
- void stroke();
- void stroke(Path path);
- void drawSystemFocusRing(Element element);
- void drawSystemFocusRing(Path path, Element element);
- boolean drawCustomFocusRing(Element element);
- boolean drawCustomFocusRing(Path path, Element element);
- void scrollPathIntoView();
- void scrollPathIntoView(Path path);
- void clip();
- void clip(Path path);
- void resetClip();
- boolean isPointInPath(unrestricted double x, unrestricted double y);
- boolean isPointInPath(Path path, unrestricted double x, unrestricted double y);
-
- // text (see also the CanvasDrawingStyles interface)
- void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
- void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
- TextMetrics measureText(DOMString text);
-
- // drawing images
- void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double dx, unrestricted double dy);
- void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
- void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
-
- // hit regions
- void addHitRegion(HitRegionOptions options);
- void removeHitRegion(HitRegionOptions options);
-
- // pixel manipulation
- ImageData createImageData(double sw, double sh);
- ImageData createImageData(ImageData imagedata);
- ImageData createImageDataHD(double sw, double sh);
- ImageData getImageData(double sx, double sy, double sw, double sh);
- ImageData getImageDataHD(double sx, double sy, double sw, double sh);
- void putImageData(ImageData imagedata, double dx, double dy);
- void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
- void putImageDataHD(ImageData imagedata, double dx, double dy);
- void putImageDataHD(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
-};
-CanvasRenderingContext2D implements CanvasDrawingStyles;
-CanvasRenderingContext2D implements CanvasPathMethods;
-
-[NoInterfaceObject]
-interface CanvasDrawingStyles {
- // line caps/joins
- attribute unrestricted double lineWidth; // (default 1)
- attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
- attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
- attribute unrestricted double miterLimit; // (default 10)
-
- // dashed lines
- void setLineDash(sequence<unrestricted double> segments); // default empty
- sequence<unrestricted double> getLineDash();
- attribute unrestricted double lineDashOffset;
-
- // text
- attribute DOMString font; // (default 10px sans-serif)
- attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
- attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
-};
-
-[NoInterfaceObject]
-interface CanvasPathMethods {
- // shared path API methods
- void closePath();
- void moveTo(unrestricted double x, unrestricted double y);
- void lineTo(unrestricted double x, unrestricted double y);
- void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
- void bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
- void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
- void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
- void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
- void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
- void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, boolean anticlockwise);
-};
-
-interface CanvasGradient {
- // opaque object
- void addColorStop(double offset, DOMString color);
-};
-
-interface CanvasPattern {
- // opaque object
- void setTransform(SVGMatrix transform);
-};
-
-interface TextMetrics {
- // x-direction
- readonly attribute double width; // advance width
- readonly attribute double actualBoundingBoxLeft;
- readonly attribute double actualBoundingBoxRight;
-
- // y-direction
- readonly attribute double fontBoundingBoxAscent;
- readonly attribute double fontBoundingBoxDescent;
- readonly attribute double actualBoundingBoxAscent;
- readonly attribute double actualBoundingBoxDescent;
- readonly attribute double emHeightAscent;
- readonly attribute double emHeightDescent;
- readonly attribute double hangingBaseline;
- readonly attribute double alphabeticBaseline;
- readonly attribute double ideographicBaseline;
-};
-
-dictionary HitRegionOptions {
- Path? path = null;
- DOMString id = "";
- DOMString? parentID = null;
- DOMString cursor = "inherit";
- // for control-backed regions:
- Element? control = null;
- // for unbacked regions:
- DOMString? label = null;
- DOMString? role = null;
-};
-
-interface ImageData {
- readonly attribute unsigned long width;
- readonly attribute unsigned long height;
- readonly attribute Uint8ClampedArray data;
-};
-
-[Constructor(optional Element scope)]
-interface DrawingStyle { };
-DrawingStyle implements CanvasDrawingStyles;
-
-[Constructor,
- Constructor(Path path),
- Constructor(DOMString d)]
-interface Path {
- void addPath(Path path, SVGMatrix? transformation);
- void addPathByStrokingPath(Path path, CanvasDrawingStyles styles, SVGMatrix? transformation);
- void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
- void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
- void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path path, optional unrestricted double maxWidth);
- void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path path, optional unrestricted double maxWidth);
-};
-Path implements CanvasPathMethods;
-
-partial interface Screen {
- readonly attribute double canvasResolution;
-};
-
-partial interface MouseEvent {
- readonly attribute DOMString? region;
-};
-
-partial dictionary MouseEventInit {
- DOMString? region;
-};
-
-interface HTMLMapElement : HTMLElement {
- attribute DOMString name;
- readonly attribute HTMLCollection areas;
- readonly attribute HTMLCollection images;
-};
-
-interface HTMLAreaElement : HTMLElement {
- attribute DOMString alt;
- attribute DOMString coords;
- attribute DOMString shape;
- stringifier attribute DOMString href;
- attribute DOMString target;
-
- attribute DOMString download;
- attribute DOMString ping;
-
- attribute DOMString rel;
- readonly attribute DOMTokenList relList;
- attribute DOMString media;
- attribute DOMString hreflang;
- attribute DOMString type;
-
- // URL decomposition IDL attributes
- attribute DOMString protocol;
- attribute DOMString host;
- attribute DOMString hostname;
- attribute DOMString port;
- attribute DOMString pathname;
- attribute DOMString search;
- attribute DOMString hash;
-};
-
-interface HTMLTableElement : HTMLElement {
- attribute HTMLTableCaptionElement? caption;
- HTMLElement createCaption();
- void deleteCaption();
- attribute HTMLTableSectionElement? tHead;
- HTMLElement createTHead();
- void deleteTHead();
- attribute HTMLTableSectionElement? tFoot;
- HTMLElement createTFoot();
- void deleteTFoot();
- readonly attribute HTMLCollection tBodies;
- HTMLElement createTBody();
- readonly attribute HTMLCollection rows;
- HTMLElement insertRow(optional long index);
- void deleteRow(long index);
-};
-
-interface HTMLTableCaptionElement : HTMLElement {};
-
-interface HTMLTableColElement : HTMLElement {
- attribute unsigned long span;
-};
-
-interface HTMLTableSectionElement : HTMLElement {
- readonly attribute HTMLCollection rows;
- HTMLElement insertRow(optional long index);
- void deleteRow(long index);
-};
-
-interface HTMLTableRowElement : HTMLElement {
- readonly attribute long rowIndex;
- readonly attribute long sectionRowIndex;
- readonly attribute HTMLCollection cells;
- HTMLElement insertCell(optional long index);
- void deleteCell(long index);
-};
-
-interface HTMLTableDataCellElement : HTMLTableCellElement {};
-
-interface HTMLTableHeaderCellElement : HTMLTableCellElement {
- attribute DOMString scope;
- attribute DOMString abbr;
-};
-
-interface HTMLTableCellElement : HTMLElement {
- attribute unsigned long colSpan;
- attribute unsigned long rowSpan;
- [PutForwards=value] readonly attribute DOMSettableTokenList headers;
- readonly attribute long cellIndex;
-};
-
-[OverrideBuiltins]
-interface HTMLFormElement : HTMLElement {
- attribute DOMString acceptCharset;
- attribute DOMString action;
- attribute DOMString autocomplete;
- attribute DOMString enctype;
- attribute DOMString encoding;
- attribute DOMString method;
- attribute DOMString name;
- attribute boolean noValidate;
- attribute DOMString target;
-
- readonly attribute HTMLFormControlsCollection elements;
- readonly attribute long length;
- getter Element (unsigned long index);
- getter object (DOMString name);
-
- void submit();
- void reset();
- boolean checkValidity();
-};
-
-interface HTMLFieldSetElement : HTMLElement {
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute DOMString name;
-
- readonly attribute DOMString type;
-
- readonly attribute HTMLFormControlsCollection elements;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-};
-
-interface HTMLLegendElement : HTMLElement {
- readonly attribute HTMLFormElement? form;
-};
-
-interface HTMLLabelElement : HTMLElement {
- readonly attribute HTMLFormElement? form;
- attribute DOMString htmlFor;
- readonly attribute HTMLElement? control;
-};
-
-interface HTMLInputElement : HTMLElement {
- attribute DOMString accept;
- attribute DOMString alt;
- attribute DOMString autocomplete;
- attribute boolean autofocus;
- attribute boolean defaultChecked;
- attribute boolean checked;
- attribute DOMString dirName;
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- readonly attribute FileList? files;
- attribute DOMString formAction;
- attribute DOMString formEnctype;
- attribute DOMString formMethod;
- attribute boolean formNoValidate;
- attribute DOMString formTarget;
- attribute unsigned long height;
- attribute boolean indeterminate;
- attribute DOMString inputMode;
- readonly attribute HTMLElement? list;
- attribute DOMString max;
- attribute long maxLength;
- attribute DOMString min;
- attribute boolean multiple;
- attribute DOMString name;
- attribute DOMString pattern;
- attribute DOMString placeholder;
- attribute boolean readOnly;
- attribute boolean required;
- attribute unsigned long size;
- attribute DOMString src;
- attribute DOMString step;
- attribute DOMString type;
- attribute DOMString defaultValue;
- [TreatNullAs=EmptyString] attribute DOMString value;
- attribute Date? valueAsDate;
- attribute unrestricted double valueAsNumber;
- attribute unsigned long width;
-
- void stepUp(optional long n);
- void stepDown(optional long n);
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-
- void select();
- attribute unsigned long selectionStart;
- attribute unsigned long selectionEnd;
- attribute DOMString selectionDirection;
-
- void setRangeText(DOMString replacement);
- void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
-
- void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
-};
-
-interface HTMLButtonElement : HTMLElement {
- attribute boolean autofocus;
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute DOMString formAction;
- attribute DOMString formEnctype;
- attribute DOMString formMethod;
- attribute boolean formNoValidate;
- attribute DOMString formTarget;
- attribute DOMString name;
- attribute DOMString type;
- attribute DOMString value;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-};
-
-interface HTMLSelectElement : HTMLElement {
- attribute boolean autofocus;
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute boolean multiple;
- attribute DOMString name;
- attribute boolean required;
- attribute unsigned long size;
-
- readonly attribute DOMString type;
-
- readonly attribute HTMLOptionsCollection options;
- attribute unsigned long length;
- getter Element item(unsigned long index);
- object namedItem(DOMString name);
- void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
- void remove(long index);
- setter creator void (unsigned long index, HTMLOptionElement? option);
-
- readonly attribute HTMLCollection selectedOptions;
- attribute long selectedIndex;
- attribute DOMString value;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-};
-
-interface HTMLDataListElement : HTMLElement {
- readonly attribute HTMLCollection options;
-};
-
-interface HTMLOptGroupElement : HTMLElement {
- attribute boolean disabled;
- attribute DOMString label;
-};
-
-[NamedConstructor=Option(),
- NamedConstructor=Option(DOMString text),
- NamedConstructor=Option(DOMString text, DOMString value),
- NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected),
- NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected, boolean selected)]
-interface HTMLOptionElement : HTMLElement {
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute DOMString label;
- attribute boolean defaultSelected;
- attribute boolean selected;
- attribute DOMString value;
-
- attribute DOMString text;
- readonly attribute long index;
-};
-
-interface HTMLTextAreaElement : HTMLElement {
- attribute DOMString autocomplete;
- attribute boolean autofocus;
- attribute unsigned long cols;
- attribute DOMString dirName;
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute DOMString inputMode;
- attribute long maxLength;
- attribute DOMString name;
- attribute DOMString placeholder;
- attribute boolean readOnly;
- attribute boolean required;
- attribute unsigned long rows;
- attribute DOMString wrap;
-
- readonly attribute DOMString type;
- attribute DOMString defaultValue;
- [TreatNullAs=EmptyString] attribute DOMString value;
- readonly attribute unsigned long textLength;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-
- void select();
- attribute unsigned long selectionStart;
- attribute unsigned long selectionEnd;
- attribute DOMString selectionDirection;
-
- void setRangeText(DOMString replacement);
- void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
-
- void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
-};
-
-interface HTMLKeygenElement : HTMLElement {
- attribute boolean autofocus;
- attribute DOMString challenge;
- attribute boolean disabled;
- readonly attribute HTMLFormElement? form;
- attribute DOMString keytype;
- attribute DOMString name;
-
- readonly attribute DOMString type;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-};
-
-interface HTMLOutputElement : HTMLElement {
- [PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
- readonly attribute HTMLFormElement? form;
- attribute DOMString name;
-
- readonly attribute DOMString type;
- attribute DOMString defaultValue;
- attribute DOMString value;
-
- readonly attribute boolean willValidate;
- readonly attribute ValidityState validity;
- readonly attribute DOMString validationMessage;
- boolean checkValidity();
- void setCustomValidity(DOMString error);
-
- readonly attribute NodeList labels;
-};
-
-interface HTMLProgressElement : HTMLElement {
- attribute double value;
- attribute double max;
- readonly attribute double position;
- readonly attribute NodeList labels;
-};
-
-interface HTMLMeterElement : HTMLElement {
- attribute double value;
- attribute double min;
- attribute double max;
- attribute double low;
- attribute double high;
- attribute double optimum;
- readonly attribute NodeList labels;
-};
-
-interface ValidityState {
- readonly attribute boolean valueMissing;
- readonly attribute boolean typeMismatch;
- readonly attribute boolean patternMismatch;
- readonly attribute boolean tooLong;
- readonly attribute boolean rangeUnderflow;
- readonly attribute boolean rangeOverflow;
- readonly attribute boolean stepMismatch;
- readonly attribute boolean customError;
- readonly attribute boolean valid;
-};
-
-interface HTMLDetailsElement : HTMLElement {
- attribute boolean open;
-};
-
-interface HTMLCommandElement : HTMLElement {
- attribute DOMString type;
- attribute DOMString label;
- attribute DOMString icon;
- attribute boolean disabled;
- attribute boolean checked;
- attribute DOMString radiogroup;
- readonly attribute HTMLElement? command;
-};
-
-interface HTMLMenuElement : HTMLElement {
- attribute DOMString type;
- attribute DOMString label;
-};
-
-interface HTMLDialogElement : HTMLElement {
- attribute boolean open;
- attribute DOMString returnValue;
- void show(optional (MouseEvent or Element) anchor);
- void showModal(optional (MouseEvent or Element) anchor);
- void close(optional DOMString returnValue);
-};
-
-[NamedPropertiesObject]
-interface Window : EventTarget {
- // the current browsing context
- [Unforgeable] readonly attribute WindowProxy window;
- [Replaceable] readonly attribute WindowProxy self;
- [Unforgeable] readonly attribute Document document;
- attribute DOMString name;
- [PutForwards=href, Unforgeable] readonly attribute Location location;
- readonly attribute History history;
- [Replaceable] readonly attribute BarProp locationbar;
- [Replaceable] readonly attribute BarProp menubar;
- [Replaceable] readonly attribute BarProp personalbar;
- [Replaceable] readonly attribute BarProp scrollbars;
- [Replaceable] readonly attribute BarProp statusbar;
- [Replaceable] readonly attribute BarProp toolbar;
- attribute DOMString status;
- void close();
- void stop();
- void focus();
- void blur();
-
- // other browsing contexts
- [Replaceable] readonly attribute WindowProxy frames;
- [Replaceable] readonly attribute unsigned long length;
- [Unforgeable] readonly attribute WindowProxy top;
- attribute WindowProxy? opener;
- readonly attribute WindowProxy parent;
- readonly attribute Element? frameElement;
- WindowProxy open(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace);
- getter WindowProxy (unsigned long index);
- getter object (DOMString name);
-
- // the user agent
- readonly attribute Navigator navigator;
-
- readonly attribute External external;
- readonly attribute ApplicationCache applicationCache;
-
- // user prompts
- void alert(DOMString message);
- boolean confirm(DOMString message);
- DOMString? prompt(DOMString message, optional DOMString default);
- void print();
- any showModalDialog(DOMString url, optional any argument);
-
- // cross-document messaging
- void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
-
- // event handler IDL attributes
- attribute EventHandler onabort;
- attribute EventHandler onafterprint;
- attribute EventHandler onbeforeprint;
- attribute EventHandler onbeforeunload;
- attribute EventHandler onblur;
- attribute EventHandler oncancel;
- attribute EventHandler oncanplay;
- attribute EventHandler oncanplaythrough;
- attribute EventHandler onchange;
- attribute EventHandler onclick;
- attribute EventHandler onclose;
- attribute EventHandler oncontextmenu;
- attribute EventHandler oncuechange;
- attribute EventHandler ondblclick;
- attribute EventHandler ondrag;
- attribute EventHandler ondragend;
- attribute EventHandler ondragenter;
- attribute EventHandler ondragleave;
- attribute EventHandler ondragover;
- attribute EventHandler ondragstart;
- attribute EventHandler ondrop;
- attribute EventHandler ondurationchange;
- attribute EventHandler onemptied;
- attribute EventHandler onended;
- attribute OnErrorEventHandler onerror;
- attribute EventHandler onfocus;
- attribute EventHandler onhashchange;
- attribute EventHandler oninput;
- attribute EventHandler oninvalid;
- attribute EventHandler onkeydown;
- attribute EventHandler onkeypress;
- attribute EventHandler onkeyup;
- attribute EventHandler onload;
- attribute EventHandler onloadeddata;
- attribute EventHandler onloadedmetadata;
- attribute EventHandler onloadstart;
- attribute EventHandler onmessage;
- attribute EventHandler onmousedown;
- attribute EventHandler onmousemove;
- attribute EventHandler onmouseout;
- attribute EventHandler onmouseover;
- attribute EventHandler onmouseup;
- attribute EventHandler onmousewheel;
- attribute EventHandler onoffline;
- attribute EventHandler ononline;
- attribute EventHandler onpause;
- attribute EventHandler onplay;
- attribute EventHandler onplaying;
- attribute EventHandler onpagehide;
- attribute EventHandler onpageshow;
- attribute EventHandler onpopstate;
- attribute EventHandler onprogress;
- attribute EventHandler onratechange;
- attribute EventHandler onreset;
- attribute EventHandler onresize;
- attribute EventHandler onscroll;
- attribute EventHandler onseeked;
- attribute EventHandler onseeking;
- attribute EventHandler onselect;
- attribute EventHandler onshow;
- attribute EventHandler onstalled;
- attribute EventHandler onstorage;
- attribute EventHandler onsubmit;
- attribute EventHandler onsuspend;
- attribute EventHandler ontimeupdate;
- attribute EventHandler onunload;
- attribute EventHandler onvolumechange;
- attribute EventHandler onwaiting;
-};
-
-interface BarProp {
- attribute boolean visible;
-};
-
-interface History {
- readonly attribute long length;
- readonly attribute any state;
- void go(optional long delta);
- void back();
- void forward();
- void pushState(any data, DOMString title, optional DOMString url);
- void replaceState(any data, DOMString title, optional DOMString url);
-};
-
-interface Location {
- stringifier attribute DOMString href;
- void assign(DOMString url);
- void replace(DOMString url);
- void reload();
-
- // URL decomposition IDL attributes
- attribute DOMString protocol;
- attribute DOMString host;
- attribute DOMString hostname;
- attribute DOMString port;
- attribute DOMString pathname;
- attribute DOMString search;
- attribute DOMString hash;
-};
-
-[Constructor(DOMString type, optional PopStateEventInit eventInitDict)]
-interface PopStateEvent : Event {
- readonly attribute any state;
-};
-
-dictionary PopStateEventInit : EventInit {
- any state;
-};
-
-[Constructor(DOMString type, optional HashChangeEventInit eventInitDict)]
-interface HashChangeEvent : Event {
- readonly attribute DOMString oldURL;
- readonly attribute DOMString newURL;
-};
-
-dictionary HashChangeEventInit : EventInit {
- DOMString oldURL;
- DOMString newURL;
-};
-
-[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict)]
-interface PageTransitionEvent : Event {
- readonly attribute boolean persisted;
-};
-
-dictionary PageTransitionEventInit : EventInit {
- boolean persisted;
-};
-
-interface BeforeUnloadEvent : Event {
- attribute DOMString returnValue;
-};
-
-interface ApplicationCache : EventTarget {
-
- // update status
- const unsigned short UNCACHED = 0;
- const unsigned short IDLE = 1;
- const unsigned short CHECKING = 2;
- const unsigned short DOWNLOADING = 3;
- const unsigned short UPDATEREADY = 4;
- const unsigned short OBSOLETE = 5;
- readonly attribute unsigned short status;
-
- // updates
- void update();
- void abort();
- void swapCache();
-
- // events
- attribute EventHandler onchecking;
- attribute EventHandler onerror;
- attribute EventHandler onnoupdate;
- attribute EventHandler ondownloading;
- attribute EventHandler onprogress;
- attribute EventHandler onupdateready;
- attribute EventHandler oncached;
- attribute EventHandler onobsolete;
-};
-
-[NoInterfaceObject]
-interface NavigatorOnLine {
- readonly attribute boolean onLine;
-};
-
-[TreatNonCallableAsNull]
-callback EventHandlerNonNull = any (Event event);
-typedef EventHandlerNonNull? EventHandler;
-
-[TreatNonCallableAsNull]
-callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, DOMString source, unsigned long lineno, unsigned long column);
-typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
-
-[NoInterfaceObject]
-interface WindowBase64 {
- DOMString btoa(DOMString btoa);
- DOMString atob(DOMString atob);
-};
-Window implements WindowBase64;
-
-[NoInterfaceObject]
-interface WindowTimers {
- long setTimeout(Function handler, optional long timeout, any... arguments);
- long setTimeout(DOMString handler, optional long timeout, any... arguments);
- void clearTimeout(long handle);
- long setInterval(Function handler, optional long timeout, any... arguments);
- long setInterval(DOMString handler, optional long timeout, any... arguments);
- void clearInterval(long handle);
-};
-Window implements WindowTimers;
-
-[NoInterfaceObject] interface WindowModal {
- readonly attribute any dialogArguments;
- attribute DOMString returnValue;
-};
-
-interface Navigator {
- // objects implementing this interface also implement the interfaces given below
-};
-Navigator implements NavigatorID;
-Navigator implements NavigatorOnLine;
-Navigator implements NavigatorContentUtils;
-Navigator implements NavigatorStorageUtils;
-
-[NoInterfaceObject]
-interface NavigatorID {
- readonly attribute DOMString appName;
- readonly attribute DOMString appVersion;
- readonly attribute DOMString platform;
- readonly attribute DOMString userAgent;
-};
-
-[NoInterfaceObject]
-interface NavigatorContentUtils {
- // content handler registration
- void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
- void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
- DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
- DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
- void unregisterProtocolHandler(DOMString scheme, DOMString url);
- void unregisterContentHandler(DOMString mimeType, DOMString url);
-};
-
-[NoInterfaceObject]
-interface NavigatorStorageUtils {
- void yieldForStorageUpdates();
-};
-
-interface External {
- void AddSearchProvider(DOMString engineURL);
- unsigned long IsSearchProviderInstalled(DOMString engineURL);
-};
-
-interface DataTransfer {
- attribute DOMString dropEffect;
- attribute DOMString effectAllowed;
-
- readonly attribute DataTransferItemList items;
-
- void setDragImage(Element image, long x, long y);
-
- /* old interface */
- readonly attribute DOMString[] types;
- DOMString getData(DOMString format);
- void setData(DOMString format, DOMString data);
- void clearData(optional DOMString format);
- readonly attribute FileList files;
-};
-
-interface DataTransferItemList {
- readonly attribute unsigned long length;
- getter DataTransferItem (unsigned long index);
- deleter void (unsigned long index);
- void clear();
-
- DataTransferItem? add(DOMString data, DOMString type);
- DataTransferItem? add(File data);
-};
-
-interface DataTransferItem {
- readonly attribute DOMString kind;
- readonly attribute DOMString type;
- void getAsString(FunctionStringCallback? _callback);
-
- File? getAsFile();
-};
-
-[Callback, NoInterfaceObject]
-interface FunctionStringCallback {
- void handleEvent(DOMString data);
-};
-
-[Constructor(DOMString type, optional DragEventInit eventInitDict)]
-interface DragEvent : MouseEvent {
- readonly attribute DataTransfer? dataTransfer;
-};
-
-dictionary DragEventInit : MouseEventInit {
- DataTransfer? dataTransfer;
-};
-
-interface WorkerGlobalScope : EventTarget {
- readonly attribute WorkerGlobalScope self;
- readonly attribute WorkerLocation location;
-
- void close();
- attribute EventHandler onerror;
- attribute EventHandler onoffline;
- attribute EventHandler ononline;
-};
-WorkerGlobalScope implements WorkerUtils;
-
-interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
- void postMessage(any message, optional sequence<Transferable> transfer);
- attribute EventHandler onmessage;
-};
-
-interface SharedWorkerGlobalScope : WorkerGlobalScope {
- readonly attribute DOMString name;
- readonly attribute ApplicationCache applicationCache;
- attribute EventHandler onconnect;
-};
-
-[Constructor(DOMString type, optional ErrorEventInit eventInitDict)]
-interface ErrorEvent : Event {
- readonly attribute DOMString message;
- readonly attribute DOMString filename;
- readonly attribute unsigned long lineno;
- readonly attribute unsigned long column;
-};
-
-dictionary ErrorEventInit : EventInit {
- DOMString message;
- DOMString filename;
- unsigned long lineno;
- unsigned long column;
-};
-
-[NoInterfaceObject]
-interface AbstractWorker {
- attribute EventHandler onerror;
-
-};
-
-[Constructor(DOMString scriptURL)]
-interface Worker : EventTarget {
- void terminate();
-
- void postMessage(any message, optional sequence<Transferable> transfer);
- attribute EventHandler onmessage;
-};
-Worker implements AbstractWorker;
-
-[Constructor(DOMString scriptURL, optional DOMString name)]
-interface SharedWorker : EventTarget {
- readonly attribute MessagePort port;
-};
-SharedWorker implements AbstractWorker;
-
-[NoInterfaceObject]
-interface WorkerUtils {
- void importScripts(DOMString... urls);
- readonly attribute WorkerNavigator navigator;
-};
-WorkerUtils implements WindowTimers;
-WorkerUtils implements WindowBase64;
-
-interface WorkerNavigator {};
-WorkerNavigator implements NavigatorID;
-WorkerNavigator implements NavigatorOnLine;
-
-interface WorkerLocation {
- // URL decomposition IDL attributes
- stringifier readonly attribute DOMString href;
- readonly attribute DOMString protocol;
- readonly attribute DOMString host;
- readonly attribute DOMString hostname;
- readonly attribute DOMString port;
- readonly attribute DOMString pathname;
- readonly attribute DOMString search;
- readonly attribute DOMString hash;
-};
-
-[Constructor(DOMString type, optional MessageEventInit eventInitDict)]
-interface MessageEvent : Event {
- readonly attribute any data;
- readonly attribute DOMString origin;
- readonly attribute DOMString lastEventId;
- readonly attribute (WindowProxy or MessagePort)? source;
- readonly attribute MessagePort[]? ports;
-};
-
-dictionary MessageEventInit : EventInit {
- any data;
- DOMString origin;
- DOMString lastEventId;
- WindowProxy? source;
- MessagePort[]? ports;
-};
-
-[Constructor(DOMString url, optional EventSourceInit eventSourceInitDict)]
-interface EventSource : EventTarget {
- readonly attribute DOMString url;
- readonly attribute boolean withCredentials;
-
- // ready state
- const unsigned short CONNECTING = 0;
- const unsigned short OPEN = 1;
- const unsigned short CLOSED = 2;
- readonly attribute unsigned short readyState;
-
- // networking
- attribute EventHandler onopen;
- attribute EventHandler onmessage;
- attribute EventHandler onerror;
- void close();
-};
-
-dictionary EventSourceInit {
- boolean withCredentials = false;
-};
-
-enum BinaryType { "blob", "arraybuffer" };
-[Constructor(DOMString url, optional (DOMString or DOMString[]) protocols)]
-interface WebSocket : EventTarget {
- readonly attribute DOMString url;
-
- // ready state
- const unsigned short CONNECTING = 0;
- const unsigned short OPEN = 1;
- const unsigned short CLOSING = 2;
- const unsigned short CLOSED = 3;
- readonly attribute unsigned short readyState;
- readonly attribute unsigned long bufferedAmount;
-
- // networking
- attribute EventHandler onopen;
- attribute EventHandler onerror;
- attribute EventHandler onclose;
- readonly attribute DOMString extensions;
- readonly attribute DOMString protocol;
- void close([Clamp] optional unsigned short code, optional DOMString reason);
-
- // messaging
- attribute EventHandler onmessage;
- attribute BinaryType binaryType;
- void send(DOMString data);
- void send(Blob data);
- void send(ArrayBuffer data);
- void send(ArrayBufferView data);
-};
-
-[Constructor(DOMString type, optional CloseEventInit eventInitDict)]
-interface CloseEvent : Event {
- readonly attribute boolean wasClean;
- readonly attribute unsigned short code;
- readonly attribute DOMString reason;
-};
-
-dictionary CloseEventInit : EventInit {
- boolean wasClean;
- unsigned short code;
- DOMString reason;
-};
-
-[Constructor]
-interface MessageChannel {
- readonly attribute MessagePort port1;
- readonly attribute MessagePort port2;
-};
-
-interface MessagePort : EventTarget {
- void postMessage(any message, optional sequence<Transferable> transfer);
- void start();
- void close();
-
- // event handlers
- attribute EventHandler onmessage;
-};
-MessagePort implements Transferable;
-
-interface Storage {
- readonly attribute unsigned long length;
- DOMString? key(unsigned long index);
- getter DOMString getItem(DOMString key);
- setter creator void setItem(DOMString key, DOMString value);
- deleter void removeItem(DOMString key);
- void clear();
-};
-
-[NoInterfaceObject]
-interface WindowSessionStorage {
- readonly attribute Storage sessionStorage;
-};
-Window implements WindowSessionStorage;
-
-[NoInterfaceObject]
-interface WindowLocalStorage {
- readonly attribute Storage localStorage;
-};
-Window implements WindowLocalStorage;
-
-[Constructor(DOMString type, optional StorageEventInit eventInitDict)]
-interface StorageEvent : Event {
- readonly attribute DOMString? key;
- readonly attribute DOMString? oldValue;
- readonly attribute DOMString? newValue;
- readonly attribute DOMString url;
- readonly attribute Storage? storageArea;
-};
-
-dictionary StorageEventInit : EventInit {
- DOMString? key;
- DOMString? oldValue;
- DOMString? newValue;
- DOMString url;
- Storage? storageArea;
-};
-
-interface HTMLAppletElement : HTMLElement {
- attribute DOMString align;
- attribute DOMString alt;
- attribute DOMString archive;
- attribute DOMString code;
- attribute DOMString codeBase;
- attribute DOMString height;
- attribute unsigned long hspace;
- attribute DOMString name;
- attribute DOMString _object; // the underscore is not part of the identifier
- attribute unsigned long vspace;
- attribute DOMString width;
-};
-
-interface HTMLMarqueeElement : HTMLElement {
- attribute DOMString behavior;
- attribute DOMString bgColor;
- attribute DOMString direction;
- attribute DOMString height;
- attribute unsigned long hspace;
- attribute long loop;
- attribute unsigned long scrollAmount;
- attribute unsigned long scrollDelay;
- attribute boolean trueSpeed;
- attribute unsigned long vspace;
- attribute DOMString width;
-
- attribute EventHandler onbounce;
- attribute EventHandler onfinish;
- attribute EventHandler onstart;
-
- void start();
- void stop();
-};
-
-interface HTMLFrameSetElement : HTMLElement {
- attribute DOMString cols;
- attribute DOMString rows;
- attribute EventHandler onafterprint;
- attribute EventHandler onbeforeprint;
- attribute EventHandler onbeforeunload;
- attribute EventHandler onblur;
- attribute EventHandler onerror;
- attribute EventHandler onfocus;
- attribute EventHandler onhashchange;
- attribute EventHandler onload;
- attribute EventHandler onmessage;
- attribute EventHandler onoffline;
- attribute EventHandler ononline;
- attribute EventHandler onpagehide;
- attribute EventHandler onpageshow;
- attribute EventHandler onpopstate;
- attribute EventHandler onresize;
- attribute EventHandler onscroll;
- attribute EventHandler onstorage;
- attribute EventHandler onunload;
-};
-
-interface HTMLFrameElement : HTMLElement {
- attribute DOMString name;
- attribute DOMString scrolling;
- attribute DOMString src;
- attribute DOMString frameBorder;
- attribute DOMString longDesc;
- attribute boolean noResize;
- readonly attribute Document? contentDocument;
- readonly attribute WindowProxy? contentWindow;
-
- [TreatNullAs=EmptyString] attribute DOMString marginHeight;
- [TreatNullAs=EmptyString] attribute DOMString marginWidth;
-};
-
-partial interface HTMLAnchorElement {
- attribute DOMString coords;
- attribute DOMString charset;
- attribute DOMString name;
- attribute DOMString rev;
- attribute DOMString shape;
-};
-
-partial interface HTMLAreaElement {
- attribute boolean noHref;
-};
-
-interface HTMLBaseFontElement : HTMLElement {
- attribute DOMString color;
- attribute DOMString face;
- attribute long size;
-
-};
-
-partial interface HTMLBodyElement {
- [TreatNullAs=EmptyString] attribute DOMString text;
- [TreatNullAs=EmptyString] attribute DOMString link;
- [TreatNullAs=EmptyString] attribute DOMString vLink;
- [TreatNullAs=EmptyString] attribute DOMString aLink;
- [TreatNullAs=EmptyString] attribute DOMString bgColor;
- attribute DOMString background;
-};
-
-partial interface HTMLBRElement {
- attribute DOMString clear;
-};
-
-partial interface HTMLTableCaptionElement {
- attribute DOMString align;
-};
-
-partial interface HTMLTableColElement {
- attribute DOMString align;
- attribute DOMString ch;
- attribute DOMString chOff;
- attribute DOMString vAlign;
- attribute DOMString width;
-};
-
-interface HTMLDirectoryElement : HTMLElement {
- attribute boolean compact;
-};
-
-partial interface HTMLDivElement {
- attribute DOMString align;
-};
-
-partial interface HTMLDListElement {
- attribute boolean compact;
-};
-
-partial interface HTMLEmbedElement {
- attribute DOMString align;
- attribute DOMString name;
-};
-
-interface HTMLFontElement : HTMLElement {
- [TreatNullAs=EmptyString] attribute DOMString color;
- attribute DOMString face;
- attribute DOMString size;
-
-};
-
-partial interface HTMLHeadingElement {
- attribute DOMString align;
-};
-
-partial interface HTMLHRElement {
- attribute DOMString align;
- attribute DOMString color;
- attribute boolean noShade;
- attribute DOMString size;
- attribute DOMString width;
-};
-
-partial interface HTMLHtmlElement {
- attribute DOMString version;
-};
-
-partial interface HTMLIFrameElement {
- attribute DOMString align;
- attribute DOMString scrolling;
- attribute DOMString frameBorder;
- attribute DOMString longDesc;
-
- [TreatNullAs=EmptyString] attribute DOMString marginHeight;
- [TreatNullAs=EmptyString] attribute DOMString marginWidth;
-};
-
-partial interface HTMLImageElement {
- attribute DOMString name;
- attribute DOMString align;
- attribute unsigned long hspace;
- attribute unsigned long vspace;
- attribute DOMString longDesc;
-
- [TreatNullAs=EmptyString] attribute DOMString border;
-};
-
-partial interface HTMLInputElement {
- attribute DOMString align;
- attribute DOMString useMap;
-};
-
-partial interface HTMLLegendElement {
- attribute DOMString align;
-};
-
-partial interface HTMLLIElement {
- attribute DOMString type;
-};
-
-partial interface HTMLLinkElement {
- attribute DOMString charset;
- attribute DOMString rev;
- attribute DOMString target;
-};
-
-partial interface HTMLMenuElement {
- attribute boolean compact;
-};
-
-partial interface HTMLMetaElement {
- attribute DOMString scheme;
-};
-
-partial interface HTMLObjectElement {
- attribute DOMString align;
- attribute DOMString archive;
- attribute DOMString code;
- attribute boolean declare;
- attribute unsigned long hspace;
- attribute DOMString standby;
- attribute unsigned long vspace;
- attribute DOMString codeBase;
- attribute DOMString codeType;
-
- [TreatNullAs=EmptyString] attribute DOMString border;
-};
-
-partial interface HTMLOListElement {
- attribute boolean compact;
-};
-
-partial interface HTMLParagraphElement {
- attribute DOMString align;
-};
-
-partial interface HTMLParamElement {
- attribute DOMString type;
- attribute DOMString valueType;
-};
-
-partial interface HTMLPreElement {
- attribute long width;
-};
-
-partial interface HTMLScriptElement {
- attribute DOMString event;
- attribute DOMString htmlFor;
-};
-
-partial interface HTMLTableElement {
- attribute DOMString align;
- attribute DOMString border;
- attribute DOMString frame;
- attribute DOMString rules;
- attribute DOMString summary;
- attribute DOMString width;
-
- [TreatNullAs=EmptyString] attribute DOMString bgColor;
- [TreatNullAs=EmptyString] attribute DOMString cellPadding;
- [TreatNullAs=EmptyString] attribute DOMString cellSpacing;
-};
-
-partial interface HTMLTableSectionElement {
- attribute DOMString align;
- attribute DOMString ch;
- attribute DOMString chOff;
- attribute DOMString vAlign;
-};
-
-partial interface HTMLTableCellElement {
- attribute DOMString abbr;
- attribute DOMString align;
- attribute DOMString axis;
- attribute DOMString height;
- attribute DOMString width;
-
- attribute DOMString ch;
- attribute DOMString chOff;
- attribute boolean noWrap;
- attribute DOMString vAlign;
-
- [TreatNullAs=EmptyString] attribute DOMString bgColor;
-};
-
-partial interface HTMLTableRowElement {
- attribute DOMString align;
- attribute DOMString ch;
- attribute DOMString chOff;
- attribute DOMString vAlign;
-
- [TreatNullAs=EmptyString] attribute DOMString bgColor;
-};
-
-partial interface HTMLUListElement {
- attribute boolean compact;
- attribute DOMString type;
-};
-
-partial interface Document {
- [TreatNullAs=EmptyString] attribute DOMString fgColor;
- [TreatNullAs=EmptyString] attribute DOMString linkColor;
- [TreatNullAs=EmptyString] attribute DOMString vlinkColor;
- [TreatNullAs=EmptyString] attribute DOMString alinkColor;
- [TreatNullAs=EmptyString] attribute DOMString bgColor;
-
- readonly attribute HTMLCollection anchors;
- readonly attribute HTMLCollection applets;
-
- void clear();
-
- readonly attribute HTMLAllCollection all;
-};
-
-----------------------------------------------------------------------
Summary of changes:
Makefile.sources.javascript | 8 ++-
javascript/{jsapi => }/WebIDL/Makefile | 0
javascript/{jsapi => }/WebIDL/dom.idl | 0
javascript/{jsapi => }/WebIDL/html.idl | 0
javascript/jsapi/binding.h | 4 +-
javascript/jsapi/bindings/example.bnd | 90 +++++++++++++++++++++++
javascript/jsapi/bindings/navigator.bnd | 120 +++++++++++++++++++++++++++++++
javascript/jsapi/bindings/window.bnd | 12 ++-
javascript/jsapi/window.c | 3 +-
9 files changed, 227 insertions(+), 10 deletions(-)
rename javascript/{jsapi => }/WebIDL/Makefile (100%)
rename javascript/{jsapi => }/WebIDL/dom.idl (100%)
rename javascript/{jsapi => }/WebIDL/html.idl (100%)
create mode 100644 javascript/jsapi/bindings/example.bnd
create mode 100644 javascript/jsapi/bindings/navigator.bnd
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index db63050..6268548 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -12,6 +12,7 @@ S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
+JSAPI_BINDING_navigator := javascript/jsapi/bindings/navigator.bnd
# 1: input file
# 2: output file
@@ -21,15 +22,16 @@ define convert_jsapi_binding
S_JSAPI_BINDING += $(2)
$(2): $(1)
- $(Q)nsgenbind -I javascript/jsapi/WebIDL/ -o $(2) $(1)
+ $$(VQ)echo " GENBIND: $(1)"
+ $(Q)nsgenbind -I javascript/WebIDL/ -o $(2) $(1)
endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = navigator.c console.c htmlelement.c
-#htmldocument.c window.c
+S_JSAPI = console.c htmlelement.c
+#htmldocument.c window.c navigator.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/WebIDL/Makefile b/javascript/WebIDL/Makefile
similarity index 100%
rename from javascript/jsapi/WebIDL/Makefile
rename to javascript/WebIDL/Makefile
diff --git a/javascript/jsapi/WebIDL/dom.idl b/javascript/WebIDL/dom.idl
similarity index 100%
rename from javascript/jsapi/WebIDL/dom.idl
rename to javascript/WebIDL/dom.idl
diff --git a/javascript/jsapi/WebIDL/html.idl b/javascript/WebIDL/html.idl
similarity index 100%
rename from javascript/jsapi/WebIDL/html.idl
rename to javascript/WebIDL/html.idl
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index 7ead6f6..2d88c00 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -65,13 +65,15 @@ JSObject *jsapi_new_Document(JSContext *cx,
*/
JSObject *jsapi_new_Console(JSContext *cx, JSObject *parent);
+
+JSObject *jsapi_InitClass_Navigator(JSContext *cx, JSObject *parent);
/** Create a new javascript navigator object
*
* @param cx The javascript context.
* @param parent The parent object, usually a global window object
* @return new javascript object or NULL on error
*/
-JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Navigator(JSContext *cx, JSObject *proto, JSObject *parent);
/** Create a new javascript element object
*
diff --git a/javascript/jsapi/bindings/example.bnd b/javascript/jsapi/bindings/example.bnd
new file mode 100644
index 0000000..897e9a5
--- /dev/null
+++ b/javascript/jsapi/bindings/example.bnd
@@ -0,0 +1,90 @@
+/* Binding to generate Navigator interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+/*
+ * navigator properties for netsurf
+ *
+ * Property | Everyone else | NetSurf | Notes
+ * ------------+-----------------+--------------+------------------------------
+ * appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
+ * | | | constant as everyone returns
+ * | | | "Mozilla" which is dumb
+ * ------------+-----------------+--------------+------------------------------
+ * appName | "<Browsername>" | "NetSurf" | Browsers named other than
+ * | | | "Netscape", "Mozilla",
+ * | | | "Netscape Navigator",
+ * | | | "Microsoft Internet Explorer"
+ * | | | often other browser have
+ * | | | "(compatible with Netscape)"
+ * | | | append.
+ * ------------+-----------------+--------------+------------------------------
+ * appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
+ * | | | number e.g "3.0".
+ * ------------+-----------------+--------------+------------------------------
+ * language | "<lang>" | "<lang>" | The language the frontend is
+ * | | | configured for
+ * ------------+-----------------+--------------+------------------------------
+ * platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
+ * | | | eg "Linux x86_64"
+ * ------------+-----------------+--------------+------------------------------
+ * userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
+ * | | | with excessive lies
+ * ------------+-----------------+--------------+------------------------------
+ */
+
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* 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.
+ */
+ private "dom_document *" node;
+ private "struct html_content *" htmlc;
+}
+
+operation write %{
+ LOG(("content %p parser %p writing %s",
+ private->htmlc, private->htmlc->parser, text));
+
+ if (private->htmlc->parser != NULL) {
+ dom_hubbub_parser_insert_chunk(private->htmlc->parser, (uint8_t *)text, text_len);
+ }
+%}
diff --git a/javascript/jsapi/bindings/navigator.bnd b/javascript/jsapi/bindings/navigator.bnd
new file mode 100644
index 0000000..596f1ac
--- /dev/null
+++ b/javascript/jsapi/bindings/navigator.bnd
@@ -0,0 +1,120 @@
+/* Binding to generate Navigator interface
+ *
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>";
+hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
+hdrcomment "Released under the terms of the MIT License,";
+hdrcomment " http://www.opensource.org/licenses/mit-license";
+
+preamble %{
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "desktop/netsurf.h"
+#include "desktop/options.h"
+
+#include "utils/config.h"
+#include "utils/useragent.h"
+#include "utils/log.h"
+#include "utils/utsname.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+/*
+ * navigator properties for netsurf
+ *
+ * Property | Everyone else | NetSurf | Notes
+ * ------------+-----------------+--------------+------------------------------
+ * appCodeName | "Mozilla" | "NetSurf" | This is kinda a pointless
+ * | | | constant as everyone returns
+ * | | | "Mozilla" which is dumb
+ * ------------+-----------------+--------------+------------------------------
+ * appName | "<Browsername>" | "NetSurf" | Browsers named other than
+ * | | | "Netscape", "Mozilla",
+ * | | | "Netscape Navigator",
+ * | | | "Microsoft Internet Explorer"
+ * | | | often other browser have
+ * | | | "(compatible with Netscape)"
+ * | | | append.
+ * ------------+-----------------+--------------+------------------------------
+ * appVersion | "<ver> (<type>)"| "<ver>" | Actually just the version
+ * | | | number e.g "3.0".
+ * ------------+-----------------+--------------+------------------------------
+ * language | "<lang>" | "<lang>" | The language the frontend is
+ * | | | configured for
+ * ------------+-----------------+--------------+------------------------------
+ * platform | "<krn> <hw>" | "<krn> <hw>" | Efectively uname -s -i,
+ * | | | eg "Linux x86_64"
+ * ------------+-----------------+--------------+------------------------------
+ * userAgent | "Mozilla/5.0 (" | "NetSurf" | The usual useragent string
+ * | | | with excessive lies
+ * ------------+-----------------+--------------+------------------------------
+ */
+
+#define NAVIGATOR_APPNAME "NetSurf"
+#define NAVIGATOR_APPCODENAME "NetSurf"
+%}
+
+binding navigator {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* Web IDL interface to generate */
+
+}
+
+getter appName %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPNAME));
+%}
+
+getter appCodeName %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPCODENAME));
+%}
+
+getter appVersion %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, netsurf_version));
+%}
+
+getter language %{
+ const char *alang = nsoption_charp(accept_language);
+
+ if (alang != NULL) {
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, alang));
+ }
+
+%}
+
+getter platform %{
+ struct utsname *cutsname;
+
+ cutsname = malloc(sizeof(struct utsname));
+
+ if ((cutsname != NULL) && (uname(cutsname) >= 0)) {
+ char *platstr;
+ int platstrlen;
+
+ platstrlen = strlen(cutsname->sysname) + strlen(cutsname->machine) + 2;
+ platstr = malloc(platstrlen);
+ if (platstr != NULL) {
+ snprintf(platstr, platstrlen, "%s %s", cutsname->sysname, cutsname->machine);
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyN(cx, platstr, platstrlen - 1));
+ free(platstr);
+ }
+ }
+%}
+
+getter userAgent %{
+ jsretval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, user_agent_string()));
+%}
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index c0b659e..9d4a844 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -79,6 +79,11 @@ api init %{
if (user_proto == NULL) {
return NULL;
}
+
+ user_proto = jsapi_InitClass_Navigator(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
%}
api new %{
@@ -99,13 +104,12 @@ api new %{
return NULL;
}
-/*
- private->navigator_obj = jsapi_new_Navigator(cx, window);
- if (private->navigator_obj == NULL) {
+ private->navigator = jsapi_new_Navigator(cx, NULL, newobject);
+ if (private->navigator == NULL) {
free(private);
return NULL;
}
-*/
+
/** @todo forms, history, location */
private->console = jsapi_new_Console(cx, newobject);
diff --git a/javascript/jsapi/window.c b/javascript/jsapi/window.c
index 476a383..062d925 100644
--- a/javascript/jsapi/window.c
+++ b/javascript/jsapi/window.c
@@ -263,13 +263,12 @@ JSObject *jsapi_new_Window(JSContext *cx,
return NULL;
}
-/*
private->navigator_obj = jsapi_new_Navigator(cx, window);
if (private->navigator_obj == NULL) {
free(private);
return NULL;
}
-*/
+
/** @todo forms, history, location */
private->console_obj = jsapi_new_Console(cx, window);
--
NetSurf Browser
10 years, 10 months
nsgenjsbind: branch master updated. 65e49e23019a97d51702077c82613c6c26e84033
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/65e49e23019a97d51...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/65e49e23019a97d5170...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/65e49e23019a97d517020...
The branch, master has been updated
via 65e49e23019a97d51702077c82613c6c26e84033 (commit)
from 26bbe37c6f0b99f23736380ba55f156f22bdaf06 (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/65e49e23019a97d...
commit 65e49e23019a97d51702077c82613c6c26e84033
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement the "implements" webidl directive
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 303c9da..4edf235 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -1,4 +1,4 @@
-/* operator body generation
+/* function/operator generation
*
* This file is part of nsgenbind.
* Licensed under the MIT License,
@@ -17,6 +17,115 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+
+ ident_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node == NULL) {
+ /* operation without identifier - must have special keyword
+ * http://www.w3.org/TR/WebIDL/#idl-operations
+ */
+ } else {
+ fprintf(binding->outfile,
+ " JSAPI_FS(%s, 0, 0),\n",
+ webidl_node_gettext(ident_node));
+ }
+ return 0;
+}
+
+
+static int generate_function_spec(struct binding *binding, const char *interface);
+
+/* callback to emit implements operator spec */
+static int webidl_function_spec_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return generate_function_spec(binding, webidl_node_gettext(node));
+}
+
+static int
+generate_function_spec(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+ int res = 0;
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile," /**** %s ****/\n", interface);
+
+ /* for each function emit a JSAPI_FS()*/
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_OPERATION,
+ webidl_func_spec_cb,
+ binding);
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+ }
+
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ res = generate_function_spec(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_function_spec_implements_cb,
+ binding);
+ }
+
+ return res;
+}
+
+int output_function_spec(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "static JSFunctionSpec jsclass_functions[] = {\n");
+
+ res = generate_function_spec(binding, binding->interface);
+
+ fprintf(binding->outfile, " JSAPI_FS_END\n};\n\n");
+
+ return res;
+}
+
+
/** creates all the variable definitions
*
* generate functions variables (including return value) with default
@@ -261,7 +370,7 @@ output_operation_input(struct binding *binding,
case WEBIDL_TYPE_LONG:
/* int32_t */
fprintf(binding->outfile,
- "\tint32_t %s = 0;\n",
+ "\t%s = 0;\n",
webidl_node_gettext(arg_ident));
break;
@@ -333,23 +442,22 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
"{\n");
fprintf(binding->outfile,
- "\tstruct jsclass_private *private;\n");
-
- fprintf(binding->outfile,
"\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
output_variable_definitions(binding, webidl_node_getnode(node));
- fprintf(binding->outfile,
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx,\n"
- "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
- "\t\t\t&JSClass_%s,\n"
- "\t\t\targv);\n"
- "\tif (private == NULL)\n"
- "\t\treturn JS_FALSE;\n\n",
- binding->interface);
-
+ if (binding->has_private) {
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
+ "\t\t\t&JSClass_%s,\n"
+ "\t\t\targv);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+ }
output_operation_input(binding, webidl_node_getnode(node));
@@ -378,7 +486,13 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
return 0;
}
+/* callback to emit implements operator bodys */
+static int webidl_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ return output_operator_body(binding, webidl_node_gettext(node));
+}
/* exported interface documented in jsapi-libdom.h */
int
@@ -387,6 +501,7 @@ output_operator_body(struct binding *binding, const char *interface)
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -421,15 +536,21 @@ output_operator_body(struct binding *binding, const char *interface)
}
/* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ inherit_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+ WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return output_operator_body(binding,
- webidl_node_gettext(inherit_node));
+ res = output_operator_body(binding,
+ webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_implements_cb,
+ binding);
+ }
+
+ return res;
}
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index c2c6c6a..6083bb9 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -52,13 +52,22 @@ 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)
+{
+ struct binding *binding = ctx;
+
+ return generate_property_spec(binding, webidl_node_gettext(node));
+}
+
static int
generate_property_spec(struct binding *binding, const char *interface)
{
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
-
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -102,11 +111,18 @@ generate_property_spec(struct binding *binding, const char *interface)
(void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return generate_property_spec(binding,
+ res = generate_property_spec(binding,
webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_property_spec_implements_cb,
+ binding);
+ }
+
+ return res;
}
int
@@ -131,11 +147,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
struct webidl_node *modifier_node;
struct genbind_node *property_node;
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
+ 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
@@ -143,10 +157,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return 1;
}
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
@@ -170,17 +183,19 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
/* return value */
fprintf(binding->outfile, "\tjsval jsretval = JSVAL_NULL;\n");
- /* get context */
- fprintf(binding->outfile,
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx,\n"
- "\t\tobj,\n"
- "\t\t&JSClass_%s,\n"
- "\t\tNULL);\n"
- "\tif (private == NULL)\n"
- "\t\treturn JS_FALSE;\n\n",
- binding->interface);
+ if (binding->has_private) {
+ /* get context */
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\tobj,\n"
+ "\t\t&JSClass_%s,\n"
+ "\t\tNULL);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+ }
property_node = genbind_node_find_type_ident(binding->gb_ast,
NULL,
@@ -232,6 +247,13 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return 0;
}
+/* callback to emit implements property bodys */
+static int webidl_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return output_property_body(binding, webidl_node_gettext(node));
+}
int
output_property_body(struct binding *binding, const char *interface)
@@ -239,7 +261,7 @@ output_property_body(struct binding *binding, const char *interface)
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
-
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -253,11 +275,9 @@ output_property_body(struct binding *binding, const char *interface)
return -1;
}
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
+ WEBIDL_NODE_TYPE_LIST);
while (members_node != NULL) {
fprintf(binding->outfile,"/**** %s ****/\n", interface);
@@ -269,22 +289,27 @@ output_property_body(struct binding *binding, const char *interface)
binding);
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
+ WEBIDL_NODE_TYPE_LIST);
}
/* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ inherit_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+ WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return output_property_body(binding,
+ res = output_property_body(binding,
webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_implements_cb,
+ binding);
+ }
+
+ return res;
}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 36ed6b6..5a73f5e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -17,7 +17,7 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
-#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_SEP "\n * \n * "
#define HDR_COMMENT_PREABLE "Generated by nsgenbind "
@@ -80,85 +80,6 @@ static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
return 0;
}
-
-
-
-static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
-{
- struct binding *binding = ctx;
- struct webidl_node *ident_node;
-
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node == NULL) {
- /* operation without identifier - must have special keyword
- * http://www.w3.org/TR/WebIDL/#idl-operations
- */
- } else {
- fprintf(binding->outfile,
- " JSAPI_FS(%s, 0, 0),\n",
- webidl_node_gettext(ident_node));
- }
- return 0;
-}
-
-static int
-generate_function_spec(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- while (members_node != NULL) {
-
- fprintf(binding->outfile," /**** %s ****/\n", interface);
-
- /* for each function emit a JSAPI_FS()*/
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_OPERATION,
- webidl_func_spec_cb,
- binding);
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- }
-
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return generate_function_spec(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
-
-
static int webidl_private_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
@@ -237,18 +158,20 @@ output_class_operations(struct binding *binding)
{
int res = 0;
- /* finalize */
- fprintf(binding->outfile,
- "static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
- "{"
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
- "\tif (private != NULL) {\n"
- "\t\tfree(private);\n"
- "\t}\n"
- "}\n\n",
- binding->interface);
+ if (binding->has_private) {
+ /* finalizer only required if there is a private to free */
+ fprintf(binding->outfile,
+ "static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
+ "{"
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
+ "\tif (private != NULL) {\n"
+ "\t\tfree(private);\n"
+ "\t}\n"
+ "}\n\n",
+ binding->interface);
+ }
/* resolve */
fprintf(binding->outfile,
@@ -351,18 +274,22 @@ output_class_new(struct binding *binding)
fprintf(binding->outfile,
")\n"
"{\n"
- "\tJSObject *newobject;\n"
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = malloc(sizeof(struct jsclass_private));\n"
- "\tif (private == NULL) {\n"
- "\t\treturn NULL;\n"
- "\t}\n");
+ "\tJSObject *newobject;\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
- GENBIND_NODE_TYPE_BINDING_PRIVATE,
- webidl_private_assign_cb,
- binding);
+ if (binding->has_private) {
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = malloc(sizeof(struct jsclass_private));\n"
+ "\tif (private == NULL) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n");
+
+ genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ GENBIND_NODE_TYPE_BINDING_PRIVATE,
+ webidl_private_assign_cb,
+ binding);
+ }
api_node = genbind_node_find_type_ident(binding->gb_ast,
NULL,
@@ -374,22 +301,26 @@ output_class_new(struct binding *binding)
} else {
fprintf(binding->outfile,
"\n"
- "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n"
+ "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n",
+ binding->interface);
+ }
+
+ if (binding->has_private) {
+ fprintf(binding->outfile,
"\tif (newobject == NULL) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
- "\t}\n",
- binding->interface);
+ "\t}\n"
+ "\n"
+ "\t/* attach private pointer */\n"
+ "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n");
}
fprintf(binding->outfile,
"\n"
- "\t/* attach private pointer */\n"
- "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
- "\t\tfree(private);\n"
- "\t\treturn NULL;\n"
- "\t}\n"
- "\n"
"\treturn newobject;\n"
"}\n");
@@ -398,48 +329,62 @@ output_class_new(struct binding *binding)
}
-static int
-output_function_spec(struct binding *binding)
-{
- int res;
- fprintf(binding->outfile,
- "static JSFunctionSpec jsclass_functions[] = {\n");
- res = generate_function_spec(binding, binding->interface);
- fprintf(binding->outfile, " JSAPI_FS_END\n};\n\n");
+static int
+output_jsclass(struct binding *binding)
+{
+ if (binding->has_private) {
- return res;
-}
+ /* forward declare the resolver and finalizer */
+ fprintf(binding->outfile,
+ "static void jsclass_finalize(JSContext *cx, JSObject *obj);\n");
+
+ fprintf(binding->outfile,
+ "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
+ /* output the class */
+ fprintf(binding->outfile,
+ "JSClass JSClass_%1$s = {\n"
+ " \"%1$s\",\n"
+ " JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_StrictPropertyStub,\n"
+ " JS_EnumerateStub,\n"
+ " (JSResolveOp)jsclass_resolve,\n"
+ " JS_ConvertStub,\n"
+ " jsclass_finalize,\n"
+ " JSCLASS_NO_OPTIONAL_MEMBERS\n"
+ "};\n\n",
+ binding->interface);
+ } else {
+ /* forward declare the resolver */
+
+ fprintf(binding->outfile,
+ "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
-static int
-output_jsclass(struct binding *binding)
-{
- /* forward declare the resolver and finalizer */
- fprintf(binding->outfile,
- "static void jsclass_finalize(JSContext *cx, JSObject *obj);\n");
- fprintf(binding->outfile,
- "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
- /* output the class */
- fprintf(binding->outfile,
- "JSClass JSClass_%1$s = {\n"
- " \"%1$s\",\n"
- " JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,\n"
- " JS_PropertyStub,\n"
- " JS_PropertyStub,\n"
- " JS_PropertyStub,\n"
- " JS_StrictPropertyStub,\n"
- " JS_EnumerateStub,\n"
- " (JSResolveOp)jsclass_resolve,\n"
- " JS_ConvertStub,\n"
- " jsclass_finalize,\n"
- " JSCLASS_NO_OPTIONAL_MEMBERS\n"
- "};\n\n",
- binding->interface);
+ /* output the class */
+ fprintf(binding->outfile,
+ "JSClass JSClass_%1$s = {\n"
+ " \"%1$s\",\n"
+ " JSCLASS_NEW_RESOLVE,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_StrictPropertyStub,\n"
+ " JS_EnumerateStub,\n"
+ " (JSResolveOp)jsclass_resolve,\n"
+ " JS_ConvertStub,\n"
+ " JS_FinalizeStub,\n"
+ " JSCLASS_NO_OPTIONAL_MEMBERS\n"
+ "};\n\n",
+ binding->interface);
+ }
return 0;
}
@@ -449,6 +394,10 @@ 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,
@@ -512,6 +461,28 @@ output_header_comments(struct binding *binding)
return 0;
}
+static bool
+binding_has_private(struct genbind_node *binding_node)
+{
+ struct genbind_node *node;
+
+ node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_PRIVATE);
+
+ if (node != NULL) {
+ return true;
+ }
+
+ node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_INTERNAL);
+ if (node != NULL) {
+ return true;
+ }
+ return false;
+}
+
static struct binding *
binding_new(char *outfilename, struct genbind_node *genbind_ast)
{
@@ -571,7 +542,7 @@ 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);
return nb;
}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index f318b5d..a5db6ec 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -12,8 +12,12 @@
struct binding {
struct genbind_node *gb_ast;
struct webidl_node *wi_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 */
+
FILE *outfile ; /* output file */
};
@@ -36,6 +40,7 @@ void output_code_block(struct binding *binding, struct genbind_node *codelist);
* @param interface The interface to generate operator bodys for
*/
int output_operator_body(struct binding *binding, const char *interface);
+int output_function_spec(struct binding *binding);
int output_property_spec(struct binding *binding);
int output_property_body(struct binding *binding, const char *interface);
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index e633439..c14f0df 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -100,7 +100,7 @@ genbind_node_find(struct genbind_node *node,
{
struct genbind_node *ret;
- if (node == NULL) {
+ if ((node == NULL) || (node == prev)) {
return NULL;
}
@@ -139,27 +139,21 @@ genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *found_node;
struct genbind_node *ident_node;
- found_node = genbind_node_find(node,
- prev,
- genbind_cmp_node_type,
- (void *)type);
+ found_node = genbind_node_find_type(node, prev, type);
+
while (found_node != NULL) {
- ident_node = genbind_node_find(genbind_node_getnode(found_node),
+ ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_IDENT);
+ GENBIND_NODE_TYPE_IDENT);
if (ident_node != NULL) {
if (strcmp(ident_node->r.text, ident) == 0)
break;
}
/* look for next matching node */
- found_node = genbind_node_find(node,
- found_node,
- genbind_cmp_node_type,
- (void *)type);
+ found_node = genbind_node_find_type(node, found_node, type);
}
return found_node;
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index fef5f35..a1f2276 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -193,26 +193,19 @@ webidl_node_find_type_ident(struct webidl_node *root_node,
struct webidl_node *node;
struct webidl_node *ident_node;
- node = webidl_node_find(root_node,
- NULL,
- webidl_cmp_node_type,
- (void *)type);
+ node = webidl_node_find_type(root_node, NULL, type);
while (node != NULL) {
- ident_node = webidl_node_find(webidl_node_getnode(node),
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
+ WEBIDL_NODE_TYPE_IDENT);
if (ident_node != NULL) {
if (strcmp(ident_node->r.text, ident) == 0)
break;
}
- node = webidl_node_find(root_node,
- node,
- webidl_cmp_node_type,
- (void *)type);
+ node = webidl_node_find_type(root_node, node, type);
}
return node;
@@ -224,7 +217,7 @@ 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;
default:
@@ -289,6 +282,9 @@ static const char *webidl_node_type_to_str(enum webidl_node_type type)
case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
return "Inherit";
+ case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
+ return "Implements";
+
case WEBIDL_NODE_TYPE_INTERFACE:
return "Interface";
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 2117cfa..d891dec 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -21,6 +21,7 @@ enum webidl_node_type {
/* non structural node types */
WEBIDL_NODE_TYPE_INTERFACE,
WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE,
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
WEBIDL_NODE_TYPE_ATTRIBUTE,
WEBIDL_NODE_TYPE_OPERATION,
WEBIDL_NODE_TYPE_CONST,
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 3cf1b6c..53e21e1 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -167,22 +167,9 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%%
- /* default rule to add built AST to passed in one */
-Input:
- Definitions
- {
- *webidl_ast = webidl_node_prepend(*webidl_ast, $1);
- }
- |
- error
- {
- fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
- free(errtxt);
- YYABORT ;
- }
- ;
-
- /* [1] altered from original grammar to be left recusive, */
+ /* [1] default rule to add built AST to passed in one, altered from
+ * original grammar to be left recusive,
+ */
Definitions:
/* empty */
{
@@ -191,7 +178,14 @@ Definitions:
|
Definitions ExtendedAttributeList Definition
{
- $$ = webidl_node_prepend($1, $3);
+ $$ = *webidl_ast = webidl_node_prepend(*webidl_ast, $3);
+ }
+ |
+ error
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
}
;
@@ -248,6 +242,7 @@ Interface:
interface_node = webidl_node_find_type_ident(*webidl_ast,
WEBIDL_NODE_TYPE_INTERFACE,
$2);
+
if (interface_node == NULL) {
/* no existing interface - create one with ident */
members = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, members, $2);
@@ -480,7 +475,31 @@ Typedef:
ImplementsStatement:
TOK_IDENTIFIER TOK_IMPLEMENTS TOK_IDENTIFIER ';'
{
- $$ = NULL;
+ /* extend interface with implements members */
+ struct webidl_node *implements;
+ struct webidl_node *interface_node;
+
+
+ interface_node = webidl_node_find_type_ident(*webidl_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ $1);
+
+ implements = webidl_node_new(WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS, NULL, $3);
+
+ if (interface_node == NULL) {
+ /* interface doesnt already exist so create it */
+
+ implements = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, implements, $1);
+
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_INTERFACE, NULL, implements);
+ } else {
+ /* update the existing interface */
+
+ /* link implements node into interfaces_node */
+ webidl_node_add(interface_node, implements);
+
+ $$ = NULL; /* updating so no need to add a new node */
+ }
}
;
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-operator.c | 163 +++++++++++++++++++++++----
src/jsapi-libdom-property.c | 97 ++++++++++------
src/jsapi-libdom.c | 265 +++++++++++++++++++------------------------
src/jsapi-libdom.h | 5 +
src/nsgenbind-ast.c | 18 +--
src/webidl-ast.c | 20 ++--
src/webidl-ast.h | 1 +
src/webidl-parser.y | 55 ++++++---
8 files changed, 378 insertions(+), 246 deletions(-)
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 303c9da..4edf235 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -1,4 +1,4 @@
-/* operator body generation
+/* function/operator generation
*
* This file is part of nsgenbind.
* Licensed under the MIT License,
@@ -17,6 +17,115 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
+static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+
+ ident_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node == NULL) {
+ /* operation without identifier - must have special keyword
+ * http://www.w3.org/TR/WebIDL/#idl-operations
+ */
+ } else {
+ fprintf(binding->outfile,
+ " JSAPI_FS(%s, 0, 0),\n",
+ webidl_node_gettext(ident_node));
+ }
+ return 0;
+}
+
+
+static int generate_function_spec(struct binding *binding, const char *interface);
+
+/* callback to emit implements operator spec */
+static int webidl_function_spec_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return generate_function_spec(binding, webidl_node_gettext(node));
+}
+
+static int
+generate_function_spec(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+ int res = 0;
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile," /**** %s ****/\n", interface);
+
+ /* for each function emit a JSAPI_FS()*/
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_OPERATION,
+ webidl_func_spec_cb,
+ binding);
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+ }
+
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ res = generate_function_spec(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_function_spec_implements_cb,
+ binding);
+ }
+
+ return res;
+}
+
+int output_function_spec(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "static JSFunctionSpec jsclass_functions[] = {\n");
+
+ res = generate_function_spec(binding, binding->interface);
+
+ fprintf(binding->outfile, " JSAPI_FS_END\n};\n\n");
+
+ return res;
+}
+
+
/** creates all the variable definitions
*
* generate functions variables (including return value) with default
@@ -261,7 +370,7 @@ output_operation_input(struct binding *binding,
case WEBIDL_TYPE_LONG:
/* int32_t */
fprintf(binding->outfile,
- "\tint32_t %s = 0;\n",
+ "\t%s = 0;\n",
webidl_node_gettext(arg_ident));
break;
@@ -333,23 +442,22 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
"{\n");
fprintf(binding->outfile,
- "\tstruct jsclass_private *private;\n");
-
- fprintf(binding->outfile,
"\tjsval *argv = JSAPI_ARGV(cx, vp);\n");
output_variable_definitions(binding, webidl_node_getnode(node));
- fprintf(binding->outfile,
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx,\n"
- "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
- "\t\t\t&JSClass_%s,\n"
- "\t\t\targv);\n"
- "\tif (private == NULL)\n"
- "\t\treturn JS_FALSE;\n\n",
- binding->interface);
-
+ if (binding->has_private) {
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\t\tJSAPI_THIS_OBJECT(cx,vp),\n"
+ "\t\t\t&JSClass_%s,\n"
+ "\t\t\targv);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+ }
output_operation_input(binding, webidl_node_getnode(node));
@@ -378,7 +486,13 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
return 0;
}
+/* callback to emit implements operator bodys */
+static int webidl_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ return output_operator_body(binding, webidl_node_gettext(node));
+}
/* exported interface documented in jsapi-libdom.h */
int
@@ -387,6 +501,7 @@ output_operator_body(struct binding *binding, const char *interface)
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -421,15 +536,21 @@ output_operator_body(struct binding *binding, const char *interface)
}
/* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ inherit_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+ WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return output_operator_body(binding,
- webidl_node_gettext(inherit_node));
+ res = output_operator_body(binding,
+ webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_implements_cb,
+ binding);
+ }
+
+ return res;
}
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index c2c6c6a..6083bb9 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -52,13 +52,22 @@ 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)
+{
+ struct binding *binding = ctx;
+
+ return generate_property_spec(binding, webidl_node_gettext(node));
+}
+
static int
generate_property_spec(struct binding *binding, const char *interface)
{
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
-
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -102,11 +111,18 @@ generate_property_spec(struct binding *binding, const char *interface)
(void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return generate_property_spec(binding,
+ res = generate_property_spec(binding,
webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_property_spec_implements_cb,
+ binding);
+ }
+
+ return res;
}
int
@@ -131,11 +147,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
struct webidl_node *modifier_node;
struct genbind_node *property_node;
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
+ 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
@@ -143,10 +157,9 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return 1;
}
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
+ modifier_node = webidl_node_find_type(webidl_node_getnode(node),
+ NULL,
+ WEBIDL_NODE_TYPE_MODIFIER);
if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
@@ -170,17 +183,19 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
/* return value */
fprintf(binding->outfile, "\tjsval jsretval = JSVAL_NULL;\n");
- /* get context */
- fprintf(binding->outfile,
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx,\n"
- "\t\tobj,\n"
- "\t\t&JSClass_%s,\n"
- "\t\tNULL);\n"
- "\tif (private == NULL)\n"
- "\t\treturn JS_FALSE;\n\n",
- binding->interface);
+ if (binding->has_private) {
+ /* get context */
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\tobj,\n"
+ "\t\t&JSClass_%s,\n"
+ "\t\tNULL);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+ }
property_node = genbind_node_find_type_ident(binding->gb_ast,
NULL,
@@ -232,6 +247,13 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
return 0;
}
+/* callback to emit implements property bodys */
+static int webidl_implements_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+
+ return output_property_body(binding, webidl_node_gettext(node));
+}
int
output_property_body(struct binding *binding, const char *interface)
@@ -239,7 +261,7 @@ output_property_body(struct binding *binding, const char *interface)
struct webidl_node *interface_node;
struct webidl_node *members_node;
struct webidl_node *inherit_node;
-
+ int res = 0;
/* find interface in webidl with correct ident attached */
interface_node = webidl_node_find_type_ident(binding->wi_ast,
@@ -253,11 +275,9 @@ output_property_body(struct binding *binding, const char *interface)
return -1;
}
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
+ WEBIDL_NODE_TYPE_LIST);
while (members_node != NULL) {
fprintf(binding->outfile,"/**** %s ****/\n", interface);
@@ -269,22 +289,27 @@ output_property_body(struct binding *binding, const char *interface)
binding);
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node = webidl_node_find_type(webidl_node_getnode(interface_node),
members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
+ WEBIDL_NODE_TYPE_LIST);
}
/* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ inherit_node = webidl_node_find_type(webidl_node_getnode(interface_node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+ WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
if (inherit_node != NULL) {
- return output_property_body(binding,
+ res = output_property_body(binding,
webidl_node_gettext(inherit_node));
}
- return 0;
+ if (res == 0) {
+ res = webidl_node_for_each_type(webidl_node_getnode(interface_node),
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
+ webidl_implements_cb,
+ binding);
+ }
+
+ return res;
}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 36ed6b6..5a73f5e 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -17,7 +17,7 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
-#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_SEP "\n * \n * "
#define HDR_COMMENT_PREABLE "Generated by nsgenbind "
@@ -80,85 +80,6 @@ static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
return 0;
}
-
-
-
-static int webidl_func_spec_cb(struct webidl_node *node, void *ctx)
-{
- struct binding *binding = ctx;
- struct webidl_node *ident_node;
-
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node == NULL) {
- /* operation without identifier - must have special keyword
- * http://www.w3.org/TR/WebIDL/#idl-operations
- */
- } else {
- fprintf(binding->outfile,
- " JSAPI_FS(%s, 0, 0),\n",
- webidl_node_gettext(ident_node));
- }
- return 0;
-}
-
-static int
-generate_function_spec(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- while (members_node != NULL) {
-
- fprintf(binding->outfile," /**** %s ****/\n", interface);
-
- /* for each function emit a JSAPI_FS()*/
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_OPERATION,
- webidl_func_spec_cb,
- binding);
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
- }
-
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return generate_function_spec(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
-
-
static int webidl_private_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
@@ -237,18 +158,20 @@ output_class_operations(struct binding *binding)
{
int res = 0;
- /* finalize */
- fprintf(binding->outfile,
- "static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
- "{"
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
- "\tif (private != NULL) {\n"
- "\t\tfree(private);\n"
- "\t}\n"
- "}\n\n",
- binding->interface);
+ if (binding->has_private) {
+ /* finalizer only required if there is a private to free */
+ fprintf(binding->outfile,
+ "static void jsclass_finalize(JSContext *cx, JSObject *obj)\n"
+ "{"
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx, obj, &JSClass_%s, NULL);\n"
+ "\tif (private != NULL) {\n"
+ "\t\tfree(private);\n"
+ "\t}\n"
+ "}\n\n",
+ binding->interface);
+ }
/* resolve */
fprintf(binding->outfile,
@@ -351,18 +274,22 @@ output_class_new(struct binding *binding)
fprintf(binding->outfile,
")\n"
"{\n"
- "\tJSObject *newobject;\n"
- "\tstruct jsclass_private *private;\n"
- "\n"
- "\tprivate = malloc(sizeof(struct jsclass_private));\n"
- "\tif (private == NULL) {\n"
- "\t\treturn NULL;\n"
- "\t}\n");
+ "\tJSObject *newobject;\n");
- genbind_node_for_each_type(genbind_node_getnode(binding_node),
- GENBIND_NODE_TYPE_BINDING_PRIVATE,
- webidl_private_assign_cb,
- binding);
+ if (binding->has_private) {
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = malloc(sizeof(struct jsclass_private));\n"
+ "\tif (private == NULL) {\n"
+ "\t\treturn NULL;\n"
+ "\t}\n");
+
+ genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ GENBIND_NODE_TYPE_BINDING_PRIVATE,
+ webidl_private_assign_cb,
+ binding);
+ }
api_node = genbind_node_find_type_ident(binding->gb_ast,
NULL,
@@ -374,22 +301,26 @@ output_class_new(struct binding *binding)
} else {
fprintf(binding->outfile,
"\n"
- "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n"
+ "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n",
+ binding->interface);
+ }
+
+ if (binding->has_private) {
+ fprintf(binding->outfile,
"\tif (newobject == NULL) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
- "\t}\n",
- binding->interface);
+ "\t}\n"
+ "\n"
+ "\t/* attach private pointer */\n"
+ "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n");
}
fprintf(binding->outfile,
"\n"
- "\t/* attach private pointer */\n"
- "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
- "\t\tfree(private);\n"
- "\t\treturn NULL;\n"
- "\t}\n"
- "\n"
"\treturn newobject;\n"
"}\n");
@@ -398,48 +329,62 @@ output_class_new(struct binding *binding)
}
-static int
-output_function_spec(struct binding *binding)
-{
- int res;
- fprintf(binding->outfile,
- "static JSFunctionSpec jsclass_functions[] = {\n");
- res = generate_function_spec(binding, binding->interface);
- fprintf(binding->outfile, " JSAPI_FS_END\n};\n\n");
+static int
+output_jsclass(struct binding *binding)
+{
+ if (binding->has_private) {
- return res;
-}
+ /* forward declare the resolver and finalizer */
+ fprintf(binding->outfile,
+ "static void jsclass_finalize(JSContext *cx, JSObject *obj);\n");
+
+ fprintf(binding->outfile,
+ "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
+ /* output the class */
+ fprintf(binding->outfile,
+ "JSClass JSClass_%1$s = {\n"
+ " \"%1$s\",\n"
+ " JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_StrictPropertyStub,\n"
+ " JS_EnumerateStub,\n"
+ " (JSResolveOp)jsclass_resolve,\n"
+ " JS_ConvertStub,\n"
+ " jsclass_finalize,\n"
+ " JSCLASS_NO_OPTIONAL_MEMBERS\n"
+ "};\n\n",
+ binding->interface);
+ } else {
+ /* forward declare the resolver */
+
+ fprintf(binding->outfile,
+ "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
-static int
-output_jsclass(struct binding *binding)
-{
- /* forward declare the resolver and finalizer */
- fprintf(binding->outfile,
- "static void jsclass_finalize(JSContext *cx, JSObject *obj);\n");
- fprintf(binding->outfile,
- "static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);\n\n");
- /* output the class */
- fprintf(binding->outfile,
- "JSClass JSClass_%1$s = {\n"
- " \"%1$s\",\n"
- " JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,\n"
- " JS_PropertyStub,\n"
- " JS_PropertyStub,\n"
- " JS_PropertyStub,\n"
- " JS_StrictPropertyStub,\n"
- " JS_EnumerateStub,\n"
- " (JSResolveOp)jsclass_resolve,\n"
- " JS_ConvertStub,\n"
- " jsclass_finalize,\n"
- " JSCLASS_NO_OPTIONAL_MEMBERS\n"
- "};\n\n",
- binding->interface);
+ /* output the class */
+ fprintf(binding->outfile,
+ "JSClass JSClass_%1$s = {\n"
+ " \"%1$s\",\n"
+ " JSCLASS_NEW_RESOLVE,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_PropertyStub,\n"
+ " JS_StrictPropertyStub,\n"
+ " JS_EnumerateStub,\n"
+ " (JSResolveOp)jsclass_resolve,\n"
+ " JS_ConvertStub,\n"
+ " JS_FinalizeStub,\n"
+ " JSCLASS_NO_OPTIONAL_MEMBERS\n"
+ "};\n\n",
+ binding->interface);
+ }
return 0;
}
@@ -449,6 +394,10 @@ 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,
@@ -512,6 +461,28 @@ output_header_comments(struct binding *binding)
return 0;
}
+static bool
+binding_has_private(struct genbind_node *binding_node)
+{
+ struct genbind_node *node;
+
+ node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_PRIVATE);
+
+ if (node != NULL) {
+ return true;
+ }
+
+ node = genbind_node_find_type(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_INTERNAL);
+ if (node != NULL) {
+ return true;
+ }
+ return false;
+}
+
static struct binding *
binding_new(char *outfilename, struct genbind_node *genbind_ast)
{
@@ -571,7 +542,7 @@ 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);
return nb;
}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index f318b5d..a5db6ec 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -12,8 +12,12 @@
struct binding {
struct genbind_node *gb_ast;
struct webidl_node *wi_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 */
+
FILE *outfile ; /* output file */
};
@@ -36,6 +40,7 @@ void output_code_block(struct binding *binding, struct genbind_node *codelist);
* @param interface The interface to generate operator bodys for
*/
int output_operator_body(struct binding *binding, const char *interface);
+int output_function_spec(struct binding *binding);
int output_property_spec(struct binding *binding);
int output_property_body(struct binding *binding, const char *interface);
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index e633439..c14f0df 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -100,7 +100,7 @@ genbind_node_find(struct genbind_node *node,
{
struct genbind_node *ret;
- if (node == NULL) {
+ if ((node == NULL) || (node == prev)) {
return NULL;
}
@@ -139,27 +139,21 @@ genbind_node_find_type_ident(struct genbind_node *node,
struct genbind_node *found_node;
struct genbind_node *ident_node;
- found_node = genbind_node_find(node,
- prev,
- genbind_cmp_node_type,
- (void *)type);
+ found_node = genbind_node_find_type(node, prev, type);
+
while (found_node != NULL) {
- ident_node = genbind_node_find(genbind_node_getnode(found_node),
+ ident_node = genbind_node_find_type(genbind_node_getnode(found_node),
NULL,
- genbind_cmp_node_type,
- (void *)GENBIND_NODE_TYPE_IDENT);
+ GENBIND_NODE_TYPE_IDENT);
if (ident_node != NULL) {
if (strcmp(ident_node->r.text, ident) == 0)
break;
}
/* look for next matching node */
- found_node = genbind_node_find(node,
- found_node,
- genbind_cmp_node_type,
- (void *)type);
+ found_node = genbind_node_find_type(node, found_node, type);
}
return found_node;
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index fef5f35..a1f2276 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -193,26 +193,19 @@ webidl_node_find_type_ident(struct webidl_node *root_node,
struct webidl_node *node;
struct webidl_node *ident_node;
- node = webidl_node_find(root_node,
- NULL,
- webidl_cmp_node_type,
- (void *)type);
+ node = webidl_node_find_type(root_node, NULL, type);
while (node != NULL) {
- ident_node = webidl_node_find(webidl_node_getnode(node),
+ ident_node = webidl_node_find_type(webidl_node_getnode(node),
NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
+ WEBIDL_NODE_TYPE_IDENT);
if (ident_node != NULL) {
if (strcmp(ident_node->r.text, ident) == 0)
break;
}
- node = webidl_node_find(root_node,
- node,
- webidl_cmp_node_type,
- (void *)type);
+ node = webidl_node_find_type(root_node, node, type);
}
return node;
@@ -224,7 +217,7 @@ 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;
default:
@@ -289,6 +282,9 @@ static const char *webidl_node_type_to_str(enum webidl_node_type type)
case WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE:
return "Inherit";
+ case WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS:
+ return "Implements";
+
case WEBIDL_NODE_TYPE_INTERFACE:
return "Interface";
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 2117cfa..d891dec 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -21,6 +21,7 @@ enum webidl_node_type {
/* non structural node types */
WEBIDL_NODE_TYPE_INTERFACE,
WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE,
+ WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS,
WEBIDL_NODE_TYPE_ATTRIBUTE,
WEBIDL_NODE_TYPE_OPERATION,
WEBIDL_NODE_TYPE_CONST,
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 3cf1b6c..53e21e1 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -167,22 +167,9 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
%%
- /* default rule to add built AST to passed in one */
-Input:
- Definitions
- {
- *webidl_ast = webidl_node_prepend(*webidl_ast, $1);
- }
- |
- error
- {
- fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
- free(errtxt);
- YYABORT ;
- }
- ;
-
- /* [1] altered from original grammar to be left recusive, */
+ /* [1] default rule to add built AST to passed in one, altered from
+ * original grammar to be left recusive,
+ */
Definitions:
/* empty */
{
@@ -191,7 +178,14 @@ Definitions:
|
Definitions ExtendedAttributeList Definition
{
- $$ = webidl_node_prepend($1, $3);
+ $$ = *webidl_ast = webidl_node_prepend(*webidl_ast, $3);
+ }
+ |
+ error
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
}
;
@@ -248,6 +242,7 @@ Interface:
interface_node = webidl_node_find_type_ident(*webidl_ast,
WEBIDL_NODE_TYPE_INTERFACE,
$2);
+
if (interface_node == NULL) {
/* no existing interface - create one with ident */
members = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, members, $2);
@@ -480,7 +475,31 @@ Typedef:
ImplementsStatement:
TOK_IDENTIFIER TOK_IMPLEMENTS TOK_IDENTIFIER ';'
{
- $$ = NULL;
+ /* extend interface with implements members */
+ struct webidl_node *implements;
+ struct webidl_node *interface_node;
+
+
+ interface_node = webidl_node_find_type_ident(*webidl_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ $1);
+
+ implements = webidl_node_new(WEBIDL_NODE_TYPE_INTERFACE_IMPLEMENTS, NULL, $3);
+
+ if (interface_node == NULL) {
+ /* interface doesnt already exist so create it */
+
+ implements = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, implements, $1);
+
+ $$ = webidl_node_new(WEBIDL_NODE_TYPE_INTERFACE, NULL, implements);
+ } else {
+ /* update the existing interface */
+
+ /* link implements node into interfaces_node */
+ webidl_node_add(interface_node, implements);
+
+ $$ = NULL; /* updating so no need to add a new node */
+ }
}
;
--
NetSurf Generator for JavaScript bindings
10 years, 10 months
netsurf: branch master updated. af2d9e8906d1d439c0c4319298843c40047dd256
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/af2d9e8906d1d439c0c43...
...commit http://git.netsurf-browser.org/netsurf.git/commit/af2d9e8906d1d439c0c4319...
...tree http://git.netsurf-browser.org/netsurf.git/tree/af2d9e8906d1d439c0c431929...
The branch, master has been updated
via af2d9e8906d1d439c0c4319298843c40047dd256 (commit)
from 528d9315ef2335196b8e571573a4c7b1f1556683 (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/af2d9e8906d1d439c0c...
commit af2d9e8906d1d439c0c4319298843c40047dd256
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Dispose the DT object once we've finished converting it to a bitmap.
diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c
index e9b0f45..280028c 100644
--- a/amiga/dt_picture.c
+++ b/amiga/dt_picture.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2011 - 2012 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -176,8 +176,9 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
struct bitmap *bitmap;
unsigned int bm_flags = BITMAP_NEW;
int bm_format = PBPAFMT_RGBA;
+ struct amiga_dt_picture_content *adt = (struct amiga_dt_picture_content *)c;
- if(dto = amiga_dt_picture_newdtobject((struct amiga_dt_picture_content *)c))
+ if(dto = amiga_dt_picture_newdtobject(adt))
{
bitmap = bitmap_create(c->width, c->height, bm_flags);
if (!bitmap) {
@@ -193,6 +194,9 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
0, 0, c->width, c->height);
bitmap_set_opaque(bitmap, bitmap_test_opaque(bitmap));
+
+ DisposeDTObject(dto);
+ adt->dto = NULL;
}
else return NULL;
-----------------------------------------------------------------------
Summary of changes:
amiga/dt_picture.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c
index e9b0f45..280028c 100644
--- a/amiga/dt_picture.c
+++ b/amiga/dt_picture.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2011 - 2012 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -176,8 +176,9 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
struct bitmap *bitmap;
unsigned int bm_flags = BITMAP_NEW;
int bm_format = PBPAFMT_RGBA;
+ struct amiga_dt_picture_content *adt = (struct amiga_dt_picture_content *)c;
- if(dto = amiga_dt_picture_newdtobject((struct amiga_dt_picture_content *)c))
+ if(dto = amiga_dt_picture_newdtobject(adt))
{
bitmap = bitmap_create(c->width, c->height, bm_flags);
if (!bitmap) {
@@ -193,6 +194,9 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
0, 0, c->width, c->height);
bitmap_set_opaque(bitmap, bitmap_test_opaque(bitmap));
+
+ DisposeDTObject(dto);
+ adt->dto = NULL;
}
else return NULL;
--
NetSurf Browser
10 years, 10 months
netsurf: branch vince/nsgenbind updated. 881daebce29e7c4c956a3999aa9088179aa5b655
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/881daebce29e7c4c956a3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/881daebce29e7c4c956a399...
...tree http://git.netsurf-browser.org/netsurf.git/tree/881daebce29e7c4c956a3999a...
The branch, vince/nsgenbind has been updated
via 881daebce29e7c4c956a3999aa9088179aa5b655 (commit)
via ac286c4a95f280fb9546f80f0e256543faa8354a (commit)
from b5313189058a15cf3a30709875fd4ced1d3a6927 (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/881daebce29e7c4c956...
commit 881daebce29e7c4c956a3999aa9088179aa5b655
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
get minimal window property functionality working on window object
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
index c568385..c0b659e 100644
--- a/javascript/jsapi/bindings/window.bnd
+++ b/javascript/jsapi/bindings/window.bnd
@@ -30,6 +30,14 @@ operation prompt %{
warn_user(message, NULL);
%}
+getter window %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+getter self %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
api init %{
JSObject *user_proto;
@@ -119,7 +127,7 @@ binding window {
* context structure.
*
* internal are value stored in private context structure but not
- * passed to constructor.
+ * passed to constructor but are considered for property getters/setters.
*/
private "struct browser_window *" bw;
private "struct html_content *" htmlc;
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/ac286c4a95f280fb954...
commit ac286c4a95f280fb9546f80f0e256543faa8354a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add binding for window class
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 48cd1cf..db63050 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -11,6 +11,7 @@
S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
+JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
# 1: input file
# 2: output file
@@ -27,8 +28,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmlelement.c
-#htmldocument.c
+S_JSAPI = navigator.c console.c htmlelement.c
+#htmldocument.c window.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/bindings/htmldocument.bnd b/javascript/jsapi/bindings/htmldocument.bnd
index 44f8ee6..c901141 100644
--- a/javascript/jsapi/bindings/htmldocument.bnd
+++ b/javascript/jsapi/bindings/htmldocument.bnd
@@ -1,4 +1,4 @@
-/* test binding to generate htmldocument */
+/* Binding to generate htmldocument */
#include "dom.bnd"
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
new file mode 100644
index 0000000..c568385
--- /dev/null
+++ b/javascript/jsapi/bindings/window.bnd
@@ -0,0 +1,130 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+api init %{
+ JSObject *user_proto;
+
+ prototype = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (prototype == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, prototype);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, prototype)) {
+ return NULL;
+ }
+
+ /* add functions to prototype */
+ if (!JS_DefineFunctions(cx, prototype, jsclass_functions)) {
+ return NULL;
+ }
+
+ /* add properties to prototype */
+ if (!JS_DefineProperties(cx, prototype, jsclass_properties))
+ return NULL;
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ user_proto = jsapi_InitClass_Document(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+%}
+
+api new %{
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* the window object is the global so its prototype *is* the instance */
+ newobject = prototype;
+
+ /* instantiate the subclasses off the window global */
+ private->document = jsapi_new_Document(cx,
+ NULL,
+ newobject,
+ htmlc->document,
+ htmlc);
+ if (private->document == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console = jsapi_new_Console(cx, newobject);
+ if (private->console == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ LOG(("Created new window object %p", newobject));
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ 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.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+
+}
-----------------------------------------------------------------------
Summary of changes:
Makefile.sources.javascript | 5 +-
javascript/jsapi/bindings/htmldocument.bnd | 2 +-
javascript/jsapi/bindings/window.bnd | 138 ++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 3 deletions(-)
create mode 100644 javascript/jsapi/bindings/window.bnd
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 48cd1cf..db63050 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -11,6 +11,7 @@
S_JSAPI_BINDING:=
JSAPI_BINDING_htmldocument := javascript/jsapi/bindings/htmldocument.bnd
+JSAPI_BINDING_window := javascript/jsapi/bindings/window.bnd
# 1: input file
# 2: output file
@@ -27,8 +28,8 @@ endef
# Javascript sources
ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmlelement.c
-#htmldocument.c
+S_JSAPI = navigator.c console.c htmlelement.c
+#htmldocument.c window.c
S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
diff --git a/javascript/jsapi/bindings/htmldocument.bnd b/javascript/jsapi/bindings/htmldocument.bnd
index 44f8ee6..c901141 100644
--- a/javascript/jsapi/bindings/htmldocument.bnd
+++ b/javascript/jsapi/bindings/htmldocument.bnd
@@ -1,4 +1,4 @@
-/* test binding to generate htmldocument */
+/* Binding to generate htmldocument */
#include "dom.bnd"
diff --git a/javascript/jsapi/bindings/window.bnd b/javascript/jsapi/bindings/window.bnd
new file mode 100644
index 0000000..c0b659e
--- /dev/null
+++ b/javascript/jsapi/bindings/window.bnd
@@ -0,0 +1,138 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+getter window %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+getter self %{
+ jsretval = OBJECT_TO_JSVAL(obj);
+%}
+
+api init %{
+ JSObject *user_proto;
+
+ prototype = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (prototype == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, prototype);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, prototype)) {
+ return NULL;
+ }
+
+ /* add functions to prototype */
+ if (!JS_DefineFunctions(cx, prototype, jsclass_functions)) {
+ return NULL;
+ }
+
+ /* add properties to prototype */
+ if (!JS_DefineProperties(cx, prototype, jsclass_properties))
+ return NULL;
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ user_proto = jsapi_InitClass_Document(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+%}
+
+api new %{
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* the window object is the global so its prototype *is* the instance */
+ newobject = prototype;
+
+ /* instantiate the subclasses off the window global */
+ private->document = jsapi_new_Document(cx,
+ NULL,
+ newobject,
+ htmlc->document,
+ htmlc);
+ if (private->document == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console = jsapi_new_Console(cx, newobject);
+ if (private->console == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ LOG(("Created new window object %p", newobject));
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ 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;
+
+}
--
NetSurf Browser
10 years, 10 months
nsgenjsbind: branch master updated. 26bbe37c6f0b99f23736380ba55f156f22bdaf06
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/26bbe37c6f0b99f23...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/26bbe37c6f0b99f2373...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/26bbe37c6f0b99f237363...
The branch, master has been updated
via 26bbe37c6f0b99f23736380ba55f156f22bdaf06 (commit)
via 12f32ab2d843a4a70b5ebe055e7b2155270692e3 (commit)
from 2d7df44ddaf4a951c29e58de1716ce33f225ab6c (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/26bbe37c6f0b99f...
commit 26bbe37c6f0b99f23736380ba55f156f22bdaf06
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement basic property getter functionality
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index d5e037a..303c9da 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -362,6 +362,11 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
output_code_block(binding,
genbind_node_getnode(operation_node));
+ } else {
+ fprintf(stderr,
+ "Warning: function/operation %s.%s has no implementation\n",
+ binding->interface,
+ webidl_node_gettext(ident_node));
}
/* set return value an return true */
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
index 8d8afa2..c2c6c6a 100644
--- a/src/jsapi-libdom-property.c
+++ b/src/jsapi-libdom-property.c
@@ -129,6 +129,7 @@ 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;
+ struct genbind_node *property_node;
ident_node = webidl_node_find(webidl_node_getnode(node),
NULL,
@@ -160,13 +161,71 @@ static int webidl_property_body_cb(struct webidl_node *node, void *ctx)
"}\n\n");
}
+ /* property getter */
fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
webidl_node_gettext(ident_node));
+
+ /* return value */
+ fprintf(binding->outfile, "\tjsval jsretval = JSVAL_NULL;\n");
+
+ /* get context */
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\tobj,\n"
+ "\t\t&JSClass_%s,\n"
+ "\t\tNULL);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_GETTER,
+ webidl_node_gettext(ident_node));
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ } else {
+ /* examine internal variables and see if they are gettable */
+ struct genbind_node *binding_node;
+ struct genbind_node *internal_node = NULL;
+
+ binding_node = genbind_node_find_type(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING);
+
+ if (binding_node != NULL) {
+ internal_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_INTERNAL,
+ webidl_node_gettext(ident_node));
+
+ }
+
+ if (internal_node != NULL) {
+ /** @todo fetching from internal entries ought to be type sensitive */
+ fprintf(binding->outfile,
+ "\tjsretval = OBJECT_TO_JSVAL(private->%s);\n",
+ webidl_node_gettext(ident_node));
+ } else {
+ fprintf(stderr,
+ "Warning: property/attribute getter %s.%s has no implementation\n",
+ binding->interface,
+ webidl_node_gettext(ident_node));
+ }
+
+ }
+
+
fprintf(binding->outfile,
- "{\n"
- " JS_SET_RVAL(cx, vp, JSVAL_NULL);\n"
- " return JS_TRUE;\n");
+ "\tJS_SET_RVAL(cx, vp, jsretval);\n"
+ "\treturn JS_TRUE;\n");
+
fprintf(binding->outfile, "}\n\n");
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 8a688b0..36ed6b6 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -159,15 +159,6 @@ generate_function_spec(struct binding *binding, const char *interface)
}
-
-
-
-
-
-
-
-
-
static int webidl_private_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index e192d74..e633439 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -198,6 +198,8 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
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:
@@ -247,6 +249,12 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_API:
return "API";
+ case GENBIND_NODE_TYPE_GETTER:
+ return "Getter";
+
+ case GENBIND_NODE_TYPE_SETTER:
+ return "Setter";
+
case GENBIND_NODE_TYPE_CBLOCK:
return "CBlock";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 0006153..54a49d2 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -24,6 +24,8 @@ enum genbind_node_type {
GENBIND_NODE_TYPE_BINDING_INTERFACE,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
+ GENBIND_NODE_TYPE_GETTER,
+ GENBIND_NODE_TYPE_SETTER,
};
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 040d7e9..61aee7e 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -100,6 +100,10 @@ operation return TOK_OPERATION;
api return TOK_API;
+getter return TOK_GETTER;
+
+setter return TOK_SETTER;
+
{cblockopen} BEGIN(cblock);
{identifier} {
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index ea0a625..1ffab7a 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -45,6 +45,8 @@ char *errtxt;
%token TOK_API
%token TOK_BINDING
%token TOK_OPERATION
+%token TOK_GETTER
+%token TOK_SETTER
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_PRIVATE
@@ -71,6 +73,8 @@ char *errtxt;
%type <node> Interface
%type <node> Operation
%type <node> Api
+%type <node> Getter
+%type <node> Setter
%%
@@ -113,6 +117,10 @@ Statement
Operation
|
Api
+ |
+ Getter
+ |
+ Setter
;
/* [3] load a web IDL file */
@@ -189,6 +197,32 @@ Api
$2));
}
+Getter
+ :
+ TOK_GETTER TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_GETTER,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
+Setter
+ :
+ TOK_SETTER TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_SETTER,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
Binding
:
TOK_BINDING TOK_IDENTIFIER '{' BindingArgs '}'
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/12f32ab2d843a4a...
commit 12f32ab2d843a4a70b5ebe055e7b2155270692e3
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split out property generation
diff --git a/src/Makefile b/src/Makefile
index 2716fa8..e2f2eab 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := nsgenbind.c webidl-ast.c nsgenbind-ast.c jsapi-libdom.c jsapi-libdom-operator.c
+DIR_SOURCES := nsgenbind.c webidl-ast.c nsgenbind-ast.c jsapi-libdom.c jsapi-libdom-operator.c jsapi-libdom-property.c
SOURCES := $(SOURCES) $(BUILDDIR)/nsgenbind-parser.c $(BUILDDIR)/nsgenbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
new file mode 100644
index 0000000..8d8afa2
--- /dev/null
+++ b/src/jsapi-libdom-property.c
@@ -0,0 +1,231 @@
+/* property generation
+ *
+ * This file is part of nsgenbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "options.h"
+#include "nsgenbind-ast.h"
+#include "webidl-ast.h"
+#include "jsapi-libdom.h"
+
+static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+ 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);
+
+ if (ident_node == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return 1;
+ } else {
+ if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
+ fprintf(binding->outfile,
+ " JSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
+ webidl_node_gettext(ident_node));
+ } else {
+ fprintf(binding->outfile,
+ " JSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
+ webidl_node_gettext(ident_node));
+ }
+ }
+ return 0;
+}
+
+static int
+generate_property_spec(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile," /**** %s ****/\n", interface);
+
+
+ /* for each function emit a JSAPI_FS()*/
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_spec_cb,
+ binding);
+
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ }
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ return generate_property_spec(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ return 0;
+}
+
+int
+output_property_spec(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "static JSPropertySpec jsclass_properties[] = {\n");
+
+ res = generate_property_spec(binding, binding->interface);
+
+ fprintf(binding->outfile, " JSAPI_PS_END\n};\n\n");
+
+ return res;
+}
+
+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;
+
+ ident_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return 1;
+ }
+
+ modifier_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_MODIFIER);
+
+
+ if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
+ /* no readonly so a set function is required */
+
+ 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");
+ }
+
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
+ webidl_node_gettext(ident_node));
+ fprintf(binding->outfile,
+ "{\n"
+ " JS_SET_RVAL(cx, vp, JSVAL_NULL);\n"
+ " return JS_TRUE;\n");
+ fprintf(binding->outfile, "}\n\n");
+
+
+ return 0;
+}
+
+
+int
+output_property_body(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile,"/**** %s ****/\n", interface);
+
+ /* for each function emit property body */
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_body_cb,
+ binding);
+
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ }
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ return output_property_body(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ return 0;
+}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 240171b..8a688b0 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -80,97 +80,6 @@ static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
return 0;
}
-static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
-{
- struct binding *binding = ctx;
- struct webidl_node *ident_node;
- 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);
-
- if (ident_node == NULL) {
- /* properties must have an operator
- * http://www.w3.org/TR/WebIDL/#idl-attributes
- */
- return 1;
- } else {
- if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile,
- " JSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
- } else {
- fprintf(binding->outfile,
- " JSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
- }
- }
- return 0;
-}
-
-static int
-generate_property_spec(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- while (members_node != NULL) {
-
- fprintf(binding->outfile," /**** %s ****/\n", interface);
-
-
- /* for each function emit a JSAPI_FS()*/
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_ATTRIBUTE,
- webidl_property_spec_cb,
- binding);
-
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- }
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return generate_property_spec(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
@@ -256,54 +165,6 @@ generate_function_spec(struct binding *binding, const char *interface)
-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;
-
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node == NULL) {
- /* properties must have an operator
- * http://www.w3.org/TR/WebIDL/#idl-attributes
- */
- return 1;
- }
-
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
-
-
- if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
- /* no readonly so a set function is required */
-
- 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");
- }
-
- fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- webidl_node_gettext(ident_node));
- fprintf(binding->outfile,
- "{\n"
- " JS_SET_RVAL(cx, vp, JSVAL_NULL);\n"
- " return JS_TRUE;\n");
- fprintf(binding->outfile, "}\n\n");
-
-
- return 0;
-}
@@ -545,20 +406,6 @@ output_class_new(struct binding *binding)
return res;
}
-static int
-output_property_spec(struct binding *binding)
-{
- int res;
-
- fprintf(binding->outfile,
- "static JSPropertySpec jsclass_properties[] = {\n");
-
- res = generate_property_spec(binding, binding->interface);
-
- fprintf(binding->outfile, " JSAPI_PS_END\n};\n\n");
-
- return res;
-}
static int
output_function_spec(struct binding *binding)
@@ -575,61 +422,6 @@ output_function_spec(struct binding *binding)
return res;
}
-static int
-output_property_body(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- while (members_node != NULL) {
-
- fprintf(binding->outfile,"/**** %s ****/\n", interface);
-
- /* for each function emit property body */
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_ATTRIBUTE,
- webidl_property_body_cb,
- binding);
-
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- }
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return output_property_body(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
static int
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index d4c37eb..f318b5d 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -17,6 +17,9 @@ struct binding {
FILE *outfile ; /* output file */
};
+/** output code block from a node */
+void output_code_block(struct binding *binding, struct genbind_node *codelist);
+
/* Generate jsapi native function bodys
*
* web IDL describes methods as operators
@@ -34,11 +37,12 @@ struct binding {
*/
int output_operator_body(struct binding *binding, const char *interface);
+int output_property_spec(struct binding *binding);
+int output_property_body(struct binding *binding, const char *interface);
+
/** Generate binding between jsapi and netsurf libdom */
int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
-/** output code block from a node */
-void output_code_block(struct binding *binding, struct genbind_node *codelist);
#endif
-----------------------------------------------------------------------
Summary of changes:
src/Makefile | 2 +-
src/jsapi-libdom-operator.c | 5 +
src/jsapi-libdom-property.c | 290 +++++++++++++++++++++++++++++++++++++++++++
src/jsapi-libdom.c | 217 --------------------------------
src/jsapi-libdom.h | 8 +-
src/nsgenbind-ast.c | 8 ++
src/nsgenbind-ast.h | 2 +
src/nsgenbind-lexer.l | 4 +
src/nsgenbind-parser.y | 34 +++++
9 files changed, 350 insertions(+), 220 deletions(-)
create mode 100644 src/jsapi-libdom-property.c
diff --git a/src/Makefile b/src/Makefile
index 2716fa8..e2f2eab 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := nsgenbind.c webidl-ast.c nsgenbind-ast.c jsapi-libdom.c jsapi-libdom-operator.c
+DIR_SOURCES := nsgenbind.c webidl-ast.c nsgenbind-ast.c jsapi-libdom.c jsapi-libdom-operator.c jsapi-libdom-property.c
SOURCES := $(SOURCES) $(BUILDDIR)/nsgenbind-parser.c $(BUILDDIR)/nsgenbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index d5e037a..303c9da 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -362,6 +362,11 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
output_code_block(binding,
genbind_node_getnode(operation_node));
+ } else {
+ fprintf(stderr,
+ "Warning: function/operation %s.%s has no implementation\n",
+ binding->interface,
+ webidl_node_gettext(ident_node));
}
/* set return value an return true */
diff --git a/src/jsapi-libdom-property.c b/src/jsapi-libdom-property.c
new file mode 100644
index 0000000..c2c6c6a
--- /dev/null
+++ b/src/jsapi-libdom-property.c
@@ -0,0 +1,290 @@
+/* property generation
+ *
+ * This file is part of nsgenbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "options.h"
+#include "nsgenbind-ast.h"
+#include "webidl-ast.h"
+#include "jsapi-libdom.h"
+
+static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
+{
+ struct binding *binding = ctx;
+ struct webidl_node *ident_node;
+ 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);
+
+ if (ident_node == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return 1;
+ } else {
+ if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
+ fprintf(binding->outfile,
+ " JSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
+ webidl_node_gettext(ident_node));
+ } else {
+ fprintf(binding->outfile,
+ " JSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
+ webidl_node_gettext(ident_node));
+ }
+ }
+ return 0;
+}
+
+static int
+generate_property_spec(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile," /**** %s ****/\n", interface);
+
+
+ /* for each function emit a JSAPI_FS()*/
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_spec_cb,
+ binding);
+
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ }
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ return generate_property_spec(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ return 0;
+}
+
+int
+output_property_spec(struct binding *binding)
+{
+ int res;
+
+ fprintf(binding->outfile,
+ "static JSPropertySpec jsclass_properties[] = {\n");
+
+ res = generate_property_spec(binding, binding->interface);
+
+ fprintf(binding->outfile, " JSAPI_PS_END\n};\n\n");
+
+ return res;
+}
+
+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;
+ struct genbind_node *property_node;
+
+ ident_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_IDENT);
+
+ if (ident_node == NULL) {
+ /* properties must have an operator
+ * http://www.w3.org/TR/WebIDL/#idl-attributes
+ */
+ return 1;
+ }
+
+ modifier_node = webidl_node_find(webidl_node_getnode(node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_MODIFIER);
+
+
+ if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
+ /* no readonly so a set function is required */
+
+ 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");
+ }
+
+ /* property getter */
+ fprintf(binding->outfile,
+ "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n"
+ "{\n",
+ webidl_node_gettext(ident_node));
+
+ /* return value */
+ fprintf(binding->outfile, "\tjsval jsretval = JSVAL_NULL;\n");
+
+ /* get context */
+ fprintf(binding->outfile,
+ "\tstruct jsclass_private *private;\n"
+ "\n"
+ "\tprivate = JS_GetInstancePrivate(cx,\n"
+ "\t\tobj,\n"
+ "\t\t&JSClass_%s,\n"
+ "\t\tNULL);\n"
+ "\tif (private == NULL)\n"
+ "\t\treturn JS_FALSE;\n\n",
+ binding->interface);
+
+ property_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_GETTER,
+ webidl_node_gettext(ident_node));
+
+ if (property_node != NULL) {
+ /* binding source block */
+ output_code_block(binding, genbind_node_getnode(property_node));
+ } else {
+ /* examine internal variables and see if they are gettable */
+ struct genbind_node *binding_node;
+ struct genbind_node *internal_node = NULL;
+
+ binding_node = genbind_node_find_type(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_BINDING);
+
+ if (binding_node != NULL) {
+ internal_node = genbind_node_find_type_ident(genbind_node_getnode(binding_node),
+ NULL,
+ GENBIND_NODE_TYPE_BINDING_INTERNAL,
+ webidl_node_gettext(ident_node));
+
+ }
+
+ if (internal_node != NULL) {
+ /** @todo fetching from internal entries ought to be type sensitive */
+ fprintf(binding->outfile,
+ "\tjsretval = OBJECT_TO_JSVAL(private->%s);\n",
+ webidl_node_gettext(ident_node));
+ } else {
+ fprintf(stderr,
+ "Warning: property/attribute getter %s.%s has no implementation\n",
+ binding->interface,
+ webidl_node_gettext(ident_node));
+ }
+
+ }
+
+
+ fprintf(binding->outfile,
+ "\tJS_SET_RVAL(cx, vp, jsretval);\n"
+ "\treturn JS_TRUE;\n");
+
+ fprintf(binding->outfile, "}\n\n");
+
+
+ return 0;
+}
+
+
+int
+output_property_body(struct binding *binding, const char *interface)
+{
+ struct webidl_node *interface_node;
+ struct webidl_node *members_node;
+ struct webidl_node *inherit_node;
+
+
+ /* find interface in webidl with correct ident attached */
+ interface_node = webidl_node_find_type_ident(binding->wi_ast,
+ WEBIDL_NODE_TYPE_INTERFACE,
+ interface);
+
+ if (interface_node == NULL) {
+ fprintf(stderr,
+ "Unable to find interface %s in loaded WebIDL\n",
+ interface);
+ return -1;
+ }
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ while (members_node != NULL) {
+
+ fprintf(binding->outfile,"/**** %s ****/\n", interface);
+
+ /* for each function emit property body */
+ webidl_node_for_each_type(webidl_node_getnode(members_node),
+ WEBIDL_NODE_TYPE_ATTRIBUTE,
+ webidl_property_body_cb,
+ binding);
+
+
+ members_node = webidl_node_find(webidl_node_getnode(interface_node),
+ members_node,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_LIST);
+
+ }
+ /* check for inherited nodes and insert them too */
+ inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
+ NULL,
+ webidl_cmp_node_type,
+ (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
+
+ if (inherit_node != NULL) {
+ return output_property_body(binding,
+ webidl_node_gettext(inherit_node));
+ }
+
+ return 0;
+}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 240171b..36ed6b6 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -80,97 +80,6 @@ static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
return 0;
}
-static int webidl_property_spec_cb(struct webidl_node *node, void *ctx)
-{
- struct binding *binding = ctx;
- struct webidl_node *ident_node;
- 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);
-
- if (ident_node == NULL) {
- /* properties must have an operator
- * http://www.w3.org/TR/WebIDL/#idl-attributes
- */
- return 1;
- } else {
- if (webidl_node_getint(modifier_node) == WEBIDL_TYPE_READONLY) {
- fprintf(binding->outfile,
- " JSAPI_PS_RO(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
- } else {
- fprintf(binding->outfile,
- " JSAPI_PS(%s, 0, JSPROP_ENUMERATE | JSPROP_SHARED),\n",
- webidl_node_gettext(ident_node));
- }
- }
- return 0;
-}
-
-static int
-generate_property_spec(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- while (members_node != NULL) {
-
- fprintf(binding->outfile," /**** %s ****/\n", interface);
-
-
- /* for each function emit a JSAPI_FS()*/
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_ATTRIBUTE,
- webidl_property_spec_cb,
- binding);
-
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- }
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return generate_property_spec(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
@@ -250,63 +159,6 @@ generate_function_spec(struct binding *binding, const char *interface)
}
-
-
-
-
-
-
-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;
-
- ident_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_IDENT);
-
- if (ident_node == NULL) {
- /* properties must have an operator
- * http://www.w3.org/TR/WebIDL/#idl-attributes
- */
- return 1;
- }
-
- modifier_node = webidl_node_find(webidl_node_getnode(node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_MODIFIER);
-
-
- if (webidl_node_getint(modifier_node) != WEBIDL_TYPE_READONLY) {
- /* no readonly so a set function is required */
-
- 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");
- }
-
- fprintf(binding->outfile,
- "static JSBool JSAPI_PROPERTYGET(%s, JSContext *cx, JSObject *obj, jsval *vp)\n",
- webidl_node_gettext(ident_node));
- fprintf(binding->outfile,
- "{\n"
- " JS_SET_RVAL(cx, vp, JSVAL_NULL);\n"
- " return JS_TRUE;\n");
- fprintf(binding->outfile, "}\n\n");
-
-
- return 0;
-}
-
-
-
static int webidl_private_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
@@ -545,20 +397,6 @@ output_class_new(struct binding *binding)
return res;
}
-static int
-output_property_spec(struct binding *binding)
-{
- int res;
-
- fprintf(binding->outfile,
- "static JSPropertySpec jsclass_properties[] = {\n");
-
- res = generate_property_spec(binding, binding->interface);
-
- fprintf(binding->outfile, " JSAPI_PS_END\n};\n\n");
-
- return res;
-}
static int
output_function_spec(struct binding *binding)
@@ -575,61 +413,6 @@ output_function_spec(struct binding *binding)
return res;
}
-static int
-output_property_body(struct binding *binding, const char *interface)
-{
- struct webidl_node *interface_node;
- struct webidl_node *members_node;
- struct webidl_node *inherit_node;
-
-
- /* find interface in webidl with correct ident attached */
- interface_node = webidl_node_find_type_ident(binding->wi_ast,
- WEBIDL_NODE_TYPE_INTERFACE,
- interface);
-
- if (interface_node == NULL) {
- fprintf(stderr,
- "Unable to find interface %s in loaded WebIDL\n",
- interface);
- return -1;
- }
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- while (members_node != NULL) {
-
- fprintf(binding->outfile,"/**** %s ****/\n", interface);
-
- /* for each function emit property body */
- webidl_node_for_each_type(webidl_node_getnode(members_node),
- WEBIDL_NODE_TYPE_ATTRIBUTE,
- webidl_property_body_cb,
- binding);
-
-
- members_node = webidl_node_find(webidl_node_getnode(interface_node),
- members_node,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_LIST);
-
- }
- /* check for inherited nodes and insert them too */
- inherit_node = webidl_node_find(webidl_node_getnode(interface_node),
- NULL,
- webidl_cmp_node_type,
- (void *)WEBIDL_NODE_TYPE_INTERFACE_INHERITANCE);
-
- if (inherit_node != NULL) {
- return output_property_body(binding,
- webidl_node_gettext(inherit_node));
- }
-
- return 0;
-}
static int
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index d4c37eb..f318b5d 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -17,6 +17,9 @@ struct binding {
FILE *outfile ; /* output file */
};
+/** output code block from a node */
+void output_code_block(struct binding *binding, struct genbind_node *codelist);
+
/* Generate jsapi native function bodys
*
* web IDL describes methods as operators
@@ -34,11 +37,12 @@ struct binding {
*/
int output_operator_body(struct binding *binding, const char *interface);
+int output_property_spec(struct binding *binding);
+int output_property_body(struct binding *binding, const char *interface);
+
/** Generate binding between jsapi and netsurf libdom */
int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
-/** output code block from a node */
-void output_code_block(struct binding *binding, struct genbind_node *codelist);
#endif
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index e192d74..e633439 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -198,6 +198,8 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
case GENBIND_NODE_TYPE_BINDING_INTERNAL:
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:
@@ -247,6 +249,12 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_API:
return "API";
+ case GENBIND_NODE_TYPE_GETTER:
+ return "Getter";
+
+ case GENBIND_NODE_TYPE_SETTER:
+ return "Setter";
+
case GENBIND_NODE_TYPE_CBLOCK:
return "CBlock";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index 0006153..54a49d2 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -24,6 +24,8 @@ enum genbind_node_type {
GENBIND_NODE_TYPE_BINDING_INTERFACE,
GENBIND_NODE_TYPE_API,
GENBIND_NODE_TYPE_OPERATION,
+ GENBIND_NODE_TYPE_GETTER,
+ GENBIND_NODE_TYPE_SETTER,
};
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 040d7e9..61aee7e 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -100,6 +100,10 @@ operation return TOK_OPERATION;
api return TOK_API;
+getter return TOK_GETTER;
+
+setter return TOK_SETTER;
+
{cblockopen} BEGIN(cblock);
{identifier} {
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index ea0a625..1ffab7a 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -45,6 +45,8 @@ char *errtxt;
%token TOK_API
%token TOK_BINDING
%token TOK_OPERATION
+%token TOK_GETTER
+%token TOK_SETTER
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_PRIVATE
@@ -71,6 +73,8 @@ char *errtxt;
%type <node> Interface
%type <node> Operation
%type <node> Api
+%type <node> Getter
+%type <node> Setter
%%
@@ -113,6 +117,10 @@ Statement
Operation
|
Api
+ |
+ Getter
+ |
+ Setter
;
/* [3] load a web IDL file */
@@ -189,6 +197,32 @@ Api
$2));
}
+Getter
+ :
+ TOK_GETTER TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_GETTER,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
+Setter
+ :
+ TOK_SETTER TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_SETTER,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
Binding
:
TOK_BINDING TOK_IDENTIFIER '{' BindingArgs '}'
--
NetSurf Generator for JavaScript bindings
10 years, 10 months
nsgenjsbind: branch master updated. 2d7df44ddaf4a951c29e58de1716ce33f225ab6c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/2d7df44ddaf4a951c...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/2d7df44ddaf4a951c29...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/2d7df44ddaf4a951c29e5...
The branch, master has been updated
via 2d7df44ddaf4a951c29e58de1716ce33f225ab6c (commit)
via ade96212575df58bc0f714168a87d9975eea273a (commit)
from 2931cd7597b8a41941e5cc3a1f869d36446c6006 (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/2d7df44ddaf4a95...
commit 2d7df44ddaf4a951c29e58de1716ce33f225ab6c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
output class initialisor and new entries if provided in binding
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 5119a4e..d5e037a 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -308,23 +308,6 @@ output_operation_input(struct binding *binding,
}
-static void
-output_operation_code_block(struct binding *binding,
- struct genbind_node *operation_list)
-{
- struct genbind_node *code_node;
-
- code_node = genbind_node_find_type(operation_list,
- NULL,
- GENBIND_NODE_TYPE_CBLOCK);
- if (code_node != NULL) {
- fprintf(binding->outfile,
- "%s\n",
- genbind_node_gettext(code_node));
- }
-}
-
-
static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
@@ -376,8 +359,8 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
webidl_node_gettext(ident_node));
if (operation_node != NULL) {
- output_operation_code_block(binding,
- genbind_node_getnode(operation_node));
+ output_code_block(binding,
+ genbind_node_getnode(operation_node));
}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 30c8d26..240171b 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -384,16 +384,6 @@ static int
output_class_operations(struct binding *binding)
{
int res = 0;
- struct genbind_node *binding_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;
- }
/* finalize */
fprintf(binding->outfile,
@@ -418,40 +408,62 @@ output_class_operations(struct binding *binding)
return res;
}
+void
+output_code_block(struct binding *binding, struct genbind_node *codelist)
+{
+ struct genbind_node *code_node;
+
+ code_node = genbind_node_find_type(codelist,
+ NULL,
+ GENBIND_NODE_TYPE_CBLOCK);
+ if (code_node != NULL) {
+ fprintf(binding->outfile,
+ "%s\n",
+ genbind_node_gettext(code_node));
+ }
+}
+
+/** generate class initialiser which create the javascript class prototype */
static int
output_class_init(struct binding *binding)
{
int res = 0;
- struct genbind_node *binding_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;
- }
+ struct genbind_node *api_node;
/* class Initialisor */
fprintf(binding->outfile,
"JSObject *jsapi_InitClass_%1$s(JSContext *cx, JSObject *parent)\n"
"{\n"
- "\tJSObject *jsobject;\n"
- "\n"
- "\tjsobject = JS_InitClass(cx,\n"
- "\t\tparent,\n"
- "\t\tNULL,\n"
- "\t\t&JSClass_%1$s,\n"
- "\t\tNULL,\n"
- "\t\t0,\n"
- "\t\tjsclass_properties,\n"
- "\t\tjsclass_functions, \n"
- "\t\tNULL, \n"
- "\t\tNULL);\n"
- "\treturn jsobject;\n"
- "}\n\n",
+ "\tJSObject *prototype;\n",
binding->interface);
+
+ api_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_API,
+ "init");
+
+ if (api_node != NULL) {
+ output_code_block(binding, genbind_node_getnode(api_node));
+ } else {
+ fprintf(binding->outfile,
+ "\n"
+ "\tprototype = JS_InitClass(cx,\n"
+ "\t\tparent,\n"
+ "\t\tNULL,\n"
+ "\t\t&JSClass_%1$s,\n"
+ "\t\tNULL,\n"
+ "\t\t0,\n"
+ "\t\tjsclass_properties,\n"
+ "\t\tjsclass_functions, \n"
+ "\t\tNULL, \n"
+ "\t\tNULL);\n",
+ binding->interface);
+ }
+
+ fprintf(binding->outfile,
+ "\treturn prototype;\n"
+ "}\n\n");
+
return res;
}
@@ -460,6 +472,7 @@ 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,
@@ -474,7 +487,7 @@ output_class_new(struct binding *binding)
/* constructor */
fprintf(binding->outfile,
"JSObject *jsapi_new_%s(JSContext *cx,\n"
- "\t\tJSObject *proto,\n"
+ "\t\tJSObject *prototype,\n"
"\t\tJSObject *parent",
binding->interface);
@@ -486,7 +499,7 @@ output_class_new(struct binding *binding)
fprintf(binding->outfile,
")\n"
"{\n"
- "\tJSObject *jsobject;\n"
+ "\tJSObject *newobject;\n"
"\tstruct jsclass_private *private;\n"
"\n"
"\tprivate = malloc(sizeof(struct jsclass_private));\n"
@@ -499,23 +512,34 @@ output_class_new(struct binding *binding)
webidl_private_assign_cb,
binding);
+ api_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_API,
+ "new");
+
+ if (api_node != NULL) {
+ output_code_block(binding, genbind_node_getnode(api_node));
+ } else {
+ fprintf(binding->outfile,
+ "\n"
+ "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n"
+ "\tif (newobject == NULL) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n",
+ binding->interface);
+ }
+
fprintf(binding->outfile,
"\n"
- "\tjsobject = JS_NewObject(cx, &JSClass_%s, proto, parent);\n"
- "\tif (jsobject == NULL) {\n"
- "\t\tfree(private);\n"
- "\t\treturn NULL;\n"
- "\t}\n"
- "\n"
"\t/* attach private pointer */\n"
- "\tif (JS_SetPrivate(cx, jsobject, private) != JS_TRUE) {\n"
+ "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
"\t}\n"
"\n"
- "\treturn jsobject;\n"
- "}\n",
- binding->interface);
+ "\treturn newobject;\n"
+ "}\n");
return res;
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 67d4238..d4c37eb 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -37,4 +37,8 @@ int output_operator_body(struct binding *binding, const char *interface);
/** Generate binding between jsapi and netsurf libdom */
int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+/** output code block from a node */
+void output_code_block(struct binding *binding, struct genbind_node *codelist);
+
+
#endif
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/ade96212575df58...
commit ade96212575df58bc0f714168a87d9975eea273a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add internal and API to binding language
split out class operation, initialisation and new generation
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 866f8be..30c8d26 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -365,7 +365,6 @@ static int webidl_private_assign_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
struct genbind_node *ident_node;
- struct genbind_node *type_node;
ident_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
@@ -382,7 +381,7 @@ static int webidl_private_assign_cb(struct genbind_node *node, void *ctx)
static int
-output_con_de_structors(struct binding *binding)
+output_class_operations(struct binding *binding)
{
int res = 0;
struct genbind_node *binding_node;
@@ -416,6 +415,23 @@ output_con_de_structors(struct binding *binding)
"\t*objp = NULL;\n"
"\treturn JS_TRUE;\n"
"}\n\n");
+ return res;
+}
+
+static int
+output_class_init(struct binding *binding)
+{
+ int res = 0;
+ struct genbind_node *binding_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;
+ }
/* class Initialisor */
fprintf(binding->outfile,
@@ -436,6 +452,23 @@ output_con_de_structors(struct binding *binding)
"\treturn jsobject;\n"
"}\n\n",
binding->interface);
+ return res;
+}
+
+static int
+output_class_new(struct binding *binding)
+{
+ int res = 0;
+ struct genbind_node *binding_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 */
@@ -634,6 +667,11 @@ output_private_declaration(struct binding *binding)
webidl_private_cb,
binding);
+ genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ GENBIND_NODE_TYPE_BINDING_INTERNAL,
+ webidl_private_cb,
+ binding);
+
fprintf(binding->outfile, "};\n\n");
@@ -782,11 +820,21 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 12;
}
- res = output_con_de_structors(binding);
+ res = output_class_operations(binding);
if (res) {
return 13;
}
+ res = output_class_init(binding);
+ if (res) {
+ return 14;
+ }
+
+ res = output_class_new(binding);
+ if (res) {
+ return 15;
+ }
+
fclose(binding->outfile);
return 0;
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index 646548b..e192d74 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -195,7 +195,9 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
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_OPERATION:
+ case GENBIND_NODE_TYPE_API:
return node->r.node;
default:
@@ -233,12 +235,18 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
return "Private";
+ case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ return "Internal";
+
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
+ case GENBIND_NODE_TYPE_API:
+ return "API";
+
case GENBIND_NODE_TYPE_CBLOCK:
return "CBlock";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index b51e6b8..0006153 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -20,7 +20,9 @@ enum genbind_node_type {
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_API,
GENBIND_NODE_TYPE_OPERATION,
};
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 4bdc803..040d7e9 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -94,8 +94,12 @@ type return TOK_TYPE;
private return TOK_PRIVATE;
+internal return TOK_INTERNAL;
+
operation return TOK_OPERATION;
+api return TOK_API;
+
{cblockopen} BEGIN(cblock);
{identifier} {
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 500f4b8..ea0a625 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -42,11 +42,13 @@ char *errtxt;
%token TOK_HDR_COMMENT
%token TOK_PREAMBLE
+%token TOK_API
%token TOK_BINDING
%token TOK_OPERATION
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_PRIVATE
+%token TOK_INTERNAL
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -65,8 +67,10 @@ char *errtxt;
%type <node> BindingArg
%type <node> Type
%type <node> Private
+%type <node> Internal
%type <node> Interface
%type <node> Operation
+%type <node> Api
%%
@@ -107,6 +111,8 @@ Statement
Binding
|
Operation
+ |
+ Api
;
/* [3] load a web IDL file */
@@ -162,12 +168,25 @@ Operation
TOK_OPERATION TOK_IDENTIFIER CBlock
{
$$ = genbind_new_node(GENBIND_NODE_TYPE_OPERATION,
- NULL,
- genbind_new_node(GENBIND_NODE_TYPE_IDENT,
- genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
- NULL,
- $3),
- $2));
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
+Api
+ :
+ TOK_API TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_API,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
}
Binding
@@ -196,6 +215,8 @@ BindingArg
|
Private
|
+ Internal
+ |
Interface
;
@@ -217,6 +238,16 @@ Private
}
;
+Internal
+ :
+ TOK_INTERNAL TOK_STRING_LITERAL TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_INTERNAL, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_STRING, NULL, $2), $3));
+ }
+ ;
+
Interface
:
TOK_INTERFACE TOK_IDENTIFIER ';'
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
new file mode 100644
index 0000000..08493f7
--- /dev/null
+++ b/test/data/bindings/window.bnd
@@ -0,0 +1,148 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+api init %{
+ JSObject *window = NULL;
+ JSObject *proto;
+
+ window = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (window == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, window);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, window)) {
+ return NULL;
+ }
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ proto = jsapi_InitClass_Document(cx, window);
+ if (proto == NULL) {
+ return NULL;
+ }
+
+ return window;
+%}
+
+api new %{
+ struct jsclass_private *private;
+
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* create private data */
+ private = malloc(sizeof(struct jsclass_private));
+ if (private == NULL) {
+ return NULL;
+ }
+ private->bw = bw;
+ private->htmlc = htmlc;
+
+
+ /* instantiate the subclasses off the window global */
+ private->document_obj = jsapi_new_Document(cx,
+ NULL,
+ window,
+ htmlc->document,
+ htmlc);
+ if (private->document_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console_obj = jsapi_new_Console(cx, window);
+ if (private->console_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ /* private pointer to browsing context */
+ if (!JS_SetPrivate(cx, window, private))
+ return NULL;
+
+ /* functions */
+ if (!JS_DefineFunctions(cx, window, jsfunctions_window)) {
+ return NULL;
+ }
+
+ /* properties */
+ if (!JS_DefineProperties(cx, window, jsproperties_window))
+ return NULL;
+
+
+ LOG(("Created new window object %p", window));
+
+ return window;
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ 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.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+
+}
-----------------------------------------------------------------------
Summary of changes:
src/jsapi-libdom-operator.c | 21 +-----
src/jsapi-libdom.c | 150 ++++++++++++++++++++++++++++++-----------
src/jsapi-libdom.h | 4 +
src/nsgenbind-ast.c | 8 ++
src/nsgenbind-ast.h | 2 +
src/nsgenbind-lexer.l | 4 +
src/nsgenbind-parser.y | 43 ++++++++++--
test/data/bindings/window.bnd | 148 ++++++++++++++++++++++++++++++++++++++++
8 files changed, 316 insertions(+), 64 deletions(-)
create mode 100644 test/data/bindings/window.bnd
diff --git a/src/jsapi-libdom-operator.c b/src/jsapi-libdom-operator.c
index 5119a4e..d5e037a 100644
--- a/src/jsapi-libdom-operator.c
+++ b/src/jsapi-libdom-operator.c
@@ -308,23 +308,6 @@ output_operation_input(struct binding *binding,
}
-static void
-output_operation_code_block(struct binding *binding,
- struct genbind_node *operation_list)
-{
- struct genbind_node *code_node;
-
- code_node = genbind_node_find_type(operation_list,
- NULL,
- GENBIND_NODE_TYPE_CBLOCK);
- if (code_node != NULL) {
- fprintf(binding->outfile,
- "%s\n",
- genbind_node_gettext(code_node));
- }
-}
-
-
static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
{
struct binding *binding = ctx;
@@ -376,8 +359,8 @@ static int webidl_operator_body_cb(struct webidl_node *node, void *ctx)
webidl_node_gettext(ident_node));
if (operation_node != NULL) {
- output_operation_code_block(binding,
- genbind_node_getnode(operation_node));
+ output_code_block(binding,
+ genbind_node_getnode(operation_node));
}
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 866f8be..240171b 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -365,7 +365,6 @@ static int webidl_private_assign_cb(struct genbind_node *node, void *ctx)
{
struct binding *binding = ctx;
struct genbind_node *ident_node;
- struct genbind_node *type_node;
ident_node = genbind_node_find_type(genbind_node_getnode(node),
NULL,
@@ -382,19 +381,9 @@ static int webidl_private_assign_cb(struct genbind_node *node, void *ctx)
static int
-output_con_de_structors(struct binding *binding)
+output_class_operations(struct binding *binding)
{
int res = 0;
- struct genbind_node *binding_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;
- }
/* finalize */
fprintf(binding->outfile,
@@ -416,32 +405,89 @@ output_con_de_structors(struct binding *binding)
"\t*objp = NULL;\n"
"\treturn JS_TRUE;\n"
"}\n\n");
+ return res;
+}
+
+void
+output_code_block(struct binding *binding, struct genbind_node *codelist)
+{
+ struct genbind_node *code_node;
+
+ code_node = genbind_node_find_type(codelist,
+ NULL,
+ GENBIND_NODE_TYPE_CBLOCK);
+ if (code_node != NULL) {
+ fprintf(binding->outfile,
+ "%s\n",
+ genbind_node_gettext(code_node));
+ }
+}
+
+/** generate class initialiser which create the javascript class prototype */
+static int
+output_class_init(struct binding *binding)
+{
+ int res = 0;
+ struct genbind_node *api_node;
/* class Initialisor */
fprintf(binding->outfile,
"JSObject *jsapi_InitClass_%1$s(JSContext *cx, JSObject *parent)\n"
"{\n"
- "\tJSObject *jsobject;\n"
- "\n"
- "\tjsobject = JS_InitClass(cx,\n"
- "\t\tparent,\n"
- "\t\tNULL,\n"
- "\t\t&JSClass_%1$s,\n"
- "\t\tNULL,\n"
- "\t\t0,\n"
- "\t\tjsclass_properties,\n"
- "\t\tjsclass_functions, \n"
- "\t\tNULL, \n"
- "\t\tNULL);\n"
- "\treturn jsobject;\n"
- "}\n\n",
+ "\tJSObject *prototype;\n",
binding->interface);
+ api_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_API,
+ "init");
+
+ if (api_node != NULL) {
+ output_code_block(binding, genbind_node_getnode(api_node));
+ } else {
+ fprintf(binding->outfile,
+ "\n"
+ "\tprototype = JS_InitClass(cx,\n"
+ "\t\tparent,\n"
+ "\t\tNULL,\n"
+ "\t\t&JSClass_%1$s,\n"
+ "\t\tNULL,\n"
+ "\t\t0,\n"
+ "\t\tjsclass_properties,\n"
+ "\t\tjsclass_functions, \n"
+ "\t\tNULL, \n"
+ "\t\tNULL);\n",
+ binding->interface);
+ }
+
+ fprintf(binding->outfile,
+ "\treturn prototype;\n"
+ "}\n\n");
+
+ return res;
+}
+
+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"
- "\t\tJSObject *proto,\n"
+ "\t\tJSObject *prototype,\n"
"\t\tJSObject *parent",
binding->interface);
@@ -453,7 +499,7 @@ output_con_de_structors(struct binding *binding)
fprintf(binding->outfile,
")\n"
"{\n"
- "\tJSObject *jsobject;\n"
+ "\tJSObject *newobject;\n"
"\tstruct jsclass_private *private;\n"
"\n"
"\tprivate = malloc(sizeof(struct jsclass_private));\n"
@@ -466,23 +512,34 @@ output_con_de_structors(struct binding *binding)
webidl_private_assign_cb,
binding);
+ api_node = genbind_node_find_type_ident(binding->gb_ast,
+ NULL,
+ GENBIND_NODE_TYPE_API,
+ "new");
+
+ if (api_node != NULL) {
+ output_code_block(binding, genbind_node_getnode(api_node));
+ } else {
+ fprintf(binding->outfile,
+ "\n"
+ "\tnewobject = JS_NewObject(cx, &JSClass_%s, prototype, parent);\n"
+ "\tif (newobject == NULL) {\n"
+ "\t\tfree(private);\n"
+ "\t\treturn NULL;\n"
+ "\t}\n",
+ binding->interface);
+ }
+
fprintf(binding->outfile,
"\n"
- "\tjsobject = JS_NewObject(cx, &JSClass_%s, proto, parent);\n"
- "\tif (jsobject == NULL) {\n"
- "\t\tfree(private);\n"
- "\t\treturn NULL;\n"
- "\t}\n"
- "\n"
"\t/* attach private pointer */\n"
- "\tif (JS_SetPrivate(cx, jsobject, private) != JS_TRUE) {\n"
+ "\tif (JS_SetPrivate(cx, newobject, private) != JS_TRUE) {\n"
"\t\tfree(private);\n"
"\t\treturn NULL;\n"
"\t}\n"
"\n"
- "\treturn jsobject;\n"
- "}\n",
- binding->interface);
+ "\treturn newobject;\n"
+ "}\n");
return res;
@@ -634,6 +691,11 @@ output_private_declaration(struct binding *binding)
webidl_private_cb,
binding);
+ genbind_node_for_each_type(genbind_node_getnode(binding_node),
+ GENBIND_NODE_TYPE_BINDING_INTERNAL,
+ webidl_private_cb,
+ binding);
+
fprintf(binding->outfile, "};\n\n");
@@ -782,11 +844,21 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 12;
}
- res = output_con_de_structors(binding);
+ res = output_class_operations(binding);
if (res) {
return 13;
}
+ res = output_class_init(binding);
+ if (res) {
+ return 14;
+ }
+
+ res = output_class_new(binding);
+ if (res) {
+ return 15;
+ }
+
fclose(binding->outfile);
return 0;
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 67d4238..d4c37eb 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -37,4 +37,8 @@ int output_operator_body(struct binding *binding, const char *interface);
/** Generate binding between jsapi and netsurf libdom */
int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+/** output code block from a node */
+void output_code_block(struct binding *binding, struct genbind_node *codelist);
+
+
#endif
diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c
index 646548b..e192d74 100644
--- a/src/nsgenbind-ast.c
+++ b/src/nsgenbind-ast.c
@@ -195,7 +195,9 @@ struct genbind_node *genbind_node_getnode(struct genbind_node *node)
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_OPERATION:
+ case GENBIND_NODE_TYPE_API:
return node->r.node;
default:
@@ -233,12 +235,18 @@ static const char *genbind_node_type_to_str(enum genbind_node_type type)
case GENBIND_NODE_TYPE_BINDING_PRIVATE:
return "Private";
+ case GENBIND_NODE_TYPE_BINDING_INTERNAL:
+ return "Internal";
+
case GENBIND_NODE_TYPE_BINDING_INTERFACE:
return "Interface";
case GENBIND_NODE_TYPE_OPERATION:
return "Operation";
+ case GENBIND_NODE_TYPE_API:
+ return "API";
+
case GENBIND_NODE_TYPE_CBLOCK:
return "CBlock";
diff --git a/src/nsgenbind-ast.h b/src/nsgenbind-ast.h
index b51e6b8..0006153 100644
--- a/src/nsgenbind-ast.h
+++ b/src/nsgenbind-ast.h
@@ -20,7 +20,9 @@ enum genbind_node_type {
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_API,
GENBIND_NODE_TYPE_OPERATION,
};
diff --git a/src/nsgenbind-lexer.l b/src/nsgenbind-lexer.l
index 4bdc803..040d7e9 100644
--- a/src/nsgenbind-lexer.l
+++ b/src/nsgenbind-lexer.l
@@ -94,8 +94,12 @@ type return TOK_TYPE;
private return TOK_PRIVATE;
+internal return TOK_INTERNAL;
+
operation return TOK_OPERATION;
+api return TOK_API;
+
{cblockopen} BEGIN(cblock);
{identifier} {
diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y
index 500f4b8..ea0a625 100644
--- a/src/nsgenbind-parser.y
+++ b/src/nsgenbind-parser.y
@@ -42,11 +42,13 @@ char *errtxt;
%token TOK_HDR_COMMENT
%token TOK_PREAMBLE
+%token TOK_API
%token TOK_BINDING
%token TOK_OPERATION
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_PRIVATE
+%token TOK_INTERNAL
%token <text> TOK_IDENTIFIER
%token <text> TOK_STRING_LITERAL
@@ -65,8 +67,10 @@ char *errtxt;
%type <node> BindingArg
%type <node> Type
%type <node> Private
+%type <node> Internal
%type <node> Interface
%type <node> Operation
+%type <node> Api
%%
@@ -107,6 +111,8 @@ Statement
Binding
|
Operation
+ |
+ Api
;
/* [3] load a web IDL file */
@@ -162,12 +168,25 @@ Operation
TOK_OPERATION TOK_IDENTIFIER CBlock
{
$$ = genbind_new_node(GENBIND_NODE_TYPE_OPERATION,
- NULL,
- genbind_new_node(GENBIND_NODE_TYPE_IDENT,
- genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
- NULL,
- $3),
- $2));
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
+ }
+
+Api
+ :
+ TOK_API TOK_IDENTIFIER CBlock
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_API,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_CBLOCK,
+ NULL,
+ $3),
+ $2));
}
Binding
@@ -196,6 +215,8 @@ BindingArg
|
Private
|
+ Internal
+ |
Interface
;
@@ -217,6 +238,16 @@ Private
}
;
+Internal
+ :
+ TOK_INTERNAL TOK_STRING_LITERAL TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING_INTERNAL, NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_IDENT,
+ genbind_new_node(GENBIND_NODE_TYPE_STRING, NULL, $2), $3));
+ }
+ ;
+
Interface
:
TOK_INTERFACE TOK_IDENTIFIER ';'
diff --git a/test/data/bindings/window.bnd b/test/data/bindings/window.bnd
new file mode 100644
index 0000000..08493f7
--- /dev/null
+++ b/test/data/bindings/window.bnd
@@ -0,0 +1,148 @@
+/* binding to generate window */
+
+#include "dom.bnd"
+
+webidlfile "html.idl";
+
+hdrcomment "Part of NetSurf Project";
+
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+api init %{
+ JSObject *window = NULL;
+ JSObject *proto;
+
+ window = JS_NewCompartmentAndGlobalObject(cx, &JSClass_Window, NULL);
+ if (window == NULL) {
+ return NULL;
+ }
+
+ /** @todo reconsider global object handling. future
+ * editions of spidermonkey appear to be removing the
+ * idea of a global so we probably need to handle
+ * global object references internally
+ */
+
+ /* set the contexts global */
+ JS_SetGlobalObject(cx, window);
+
+ /* Populate the global object with the standard globals, like
+ * Object and Array.
+ */
+ if (!JS_InitStandardClasses(cx, window)) {
+ return NULL;
+ }
+
+ /* Initialises all the user javascript classes to make their
+ * prototypes available.
+ */
+ /** @todo should we be managing these prototype objects ourselves */
+ proto = jsapi_InitClass_Document(cx, window);
+ if (proto == NULL) {
+ return NULL;
+ }
+
+ return window;
+%}
+
+api new %{
+ struct jsclass_private *private;
+
+ /* @todo sort out windows that are not globals */
+ assert(parent == NULL);
+
+ /* create private data */
+ private = malloc(sizeof(struct jsclass_private));
+ if (private == NULL) {
+ return NULL;
+ }
+ private->bw = bw;
+ private->htmlc = htmlc;
+
+
+ /* instantiate the subclasses off the window global */
+ private->document_obj = jsapi_new_Document(cx,
+ NULL,
+ window,
+ htmlc->document,
+ htmlc);
+ if (private->document_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+
+/*
+ private->navigator_obj = jsapi_new_Navigator(cx, window);
+ if (private->navigator_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+*/
+ /** @todo forms, history, location */
+
+ private->console_obj = jsapi_new_Console(cx, window);
+ if (private->console_obj == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ /* private pointer to browsing context */
+ if (!JS_SetPrivate(cx, window, private))
+ return NULL;
+
+ /* functions */
+ if (!JS_DefineFunctions(cx, window, jsfunctions_window)) {
+ return NULL;
+ }
+
+ /* properties */
+ if (!JS_DefineProperties(cx, window, jsproperties_window))
+ return NULL;
+
+
+ LOG(("Created new window object %p", window));
+
+ return window;
+%}
+
+
+binding window {
+ type js_libdom; /* the binding type */
+
+ 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.
+ */
+ private "struct browser_window *" bw;
+ private "struct html_content *" htmlc;
+ internal "JSObject *" document;
+ internal "JSObject *" navigator;
+ internal "JSObject *" console;
+
+}
--
NetSurf Generator for JavaScript bindings
10 years, 10 months