summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.sources.javascript1
-rw-r--r--javascript/jsapi/console.c152
-rw-r--r--javascript/jsapi/document.c110
-rw-r--r--javascript/jsapi/domexception.c106
-rw-r--r--javascript/jsapi/element.c99
-rw-r--r--javascript/jsapi/eventtarget.c76
-rw-r--r--javascript/jsapi/htmldocument.c262
-rw-r--r--javascript/jsapi/htmlelement.c230
-rw-r--r--javascript/jsapi/jsclass.h39
-rw-r--r--javascript/jsapi/navigator.c206
-rw-r--r--javascript/jsapi/node.c299
-rw-r--r--javascript/jsapi/window.c297
12 files changed, 0 insertions, 1877 deletions
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
index 51db26fb4..3fb1fb275 100644
--- a/Makefile.sources.javascript
+++ b/Makefile.sources.javascript
@@ -33,7 +33,6 @@ endef
ifeq ($(NETSURF_USE_JS),YES)
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/jsapi/console.c b/javascript/jsapi/console.c
deleted file mode 100644
index 3cd51883d..000000000
--- a/javascript/jsapi/console.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "utils/log.h"
-
-#include "javascript/jsapi.h"
-
-static JSBool JSAPI_NATIVE(debug, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(dir, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(error, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(group, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(groupCollapsed, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(groupEnd, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(info, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(log, JSContext *cx, uintN argc, jsval *vp)
-{
- unsigned int argloop;
- JSString *jsstr;
- unsigned long jsstrlen;
- char *txt;
-
- for (argloop = 0; argloop < argc; argloop++) {
- jsstr = JS_ValueToString(cx, *JSAPI_ARGV(cx, vp + argloop));
-
- JSString_to_char(jsstr, txt, jsstrlen);
- LOG(("%s", txt));
- }
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(time, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(timeEnd, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(trace, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(warn, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
- return JS_TRUE;
-}
-
-static JSFunctionSpec jsfunctions_console[] = {
- JSAPI_FS(debug, 1, 0),
- JSAPI_FS(dir, 1, 0),
- JSAPI_FS(error, 1, 0),
- JSAPI_FS(group, 1, 0),
- JSAPI_FS(groupCollapsed, 1, 0),
- JSAPI_FS(groupEnd, 1, 0),
- JSAPI_FS(info, 1, 0),
- JSAPI_FS(log, 1, 0),
- JSAPI_FS(time, 1, 0),
- JSAPI_FS(timeEnd, 1, 0),
- JSAPI_FS(trace, 1, 0),
- JSAPI_FS(warn, 1, 0),
- JSAPI_FS_END
-};
-
-static JSClass jsclass_console =
-{
- "console",
- JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- JS_FinalizeStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSObject *jsapi_new_Console(JSContext *cx, JSObject *parent)
-{
- return JS_InitClass(cx,
- parent,
- NULL,
- &jsclass_console,
- NULL,
- 0,
- NULL,
- jsfunctions_console,
- NULL,
- NULL);
-}
diff --git a/javascript/jsapi/document.c b/javascript/jsapi/document.c
deleted file mode 100644
index 2d3bde41a..000000000
--- a/javascript/jsapi/document.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-document
-
-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);
-};
-
-
- */
-
-#include "jsclass.h"
-
-#include "node.c"
-
-static JSBool JSAPI_NATIVE(getElementById, JSContext *cx, uintN argc, jsval *vp)
-{
- JSString* u16_txt;
- char *txt;
- unsigned long txtlen;
- dom_string *idstr;
- dom_element *idelement;
- struct jsclass_document_priv *document;
-
- document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (document == NULL) {
- return JS_FALSE;
- }
-
- if (document->node == NULL) {
- /* no document available, this is obviously a problem
- * for finding elements
- */
- JSAPI_SET_RVAL(cx, vp, JSVAL_NULL);
-
- return JS_TRUE;
- }
-
- if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
- return JS_FALSE;
-
- JSString_to_char(u16_txt, txt, txtlen);
-
- dom_string_create((unsigned char*)txt, txtlen, &idstr);
-
- dom_document_get_element_by_id(document->node, idstr, &idelement);
-
- JSAPI_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsapi_new_element(cx, JS_GetGlobalObject(cx), document->htmlc, idelement)));
-
- return JS_TRUE;
-}
-
-#define JSAPI_FS_DOCUMENT \
- JSAPI_FS_NODE, \
- JSAPI_FS(getElementById, 1, 0) \
-
-
-#define JSAPI_PS_DOCUMENT \
- JSAPI_PS_NODE
diff --git a/javascript/jsapi/domexception.c b/javascript/jsapi/domexception.c
deleted file mode 100644
index b7c61cf45..000000000
--- a/javascript/jsapi/domexception.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <dom/dom.h>
-
-
-#include "javascript/jsapi.h"
-#include "utils/config.h"
-#include "render/html_internal.h"
-#include "utils/log.h"
-
-/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#exception-domexception
-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;
-};
-
-*/
-
-static JSClass jsclass_domexception =
-{
- "DOMException",
- JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- JS_FinalizeStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-
-JSObject *
-jsapi_new_domexception(JSContext *cx,
- JSObject *parent,
- int code)
-{
- /* create element object and return it*/
- JSObject *jsdomexception;
-
- jssomexception = JS_InitClass(cx,
- parent,
- NULL,
- &jsclass_domexception,
- NULL,
- 0,
- NULL,
- NULL,
- NULL,
- NULL);
- if (jsdomexecption == NULL) {
- return NULL;
- }
-
- LOG(("setting element private to %d", code));
- /* private pointer to browsing context */
- if (JS_SetPrivate(cx, jsdomexception, code) != JS_TRUE) {
- LOG(("failed to set content"));
- return NULL;
- }
-
- return jsdomexception;
-}
diff --git a/javascript/jsapi/element.c b/javascript/jsapi/element.c
deleted file mode 100644
index d301321d9..000000000
--- a/javascript/jsapi/element.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element
-
-
-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();
-};
-*/
-
-#include "jsclass.h"
-
-#include "node.c"
-
-static JSBool JSAPI_NATIVE(getAttribute, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_NULL);
-
- return JS_TRUE;
-}
-
-#define JSAPI_FS_ELEMENT \
- JSAPI_FS_NODE, \
- JSAPI_FS(getAttribute, 0, 0)
-
-static JSBool JSAPI_PROPERTYGET(id, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, JSVAL_NULL);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(id, JSContext *cx, JSObject *obj, jsval *vp)
-{
- return JS_FALSE;
-}
-
-#define JSAPI_PS_ELEMENT \
- JSAPI_PS_NODE, \
- JSAPI_PS(id, 0, JSPROP_ENUMERATE | JSPROP_SHARED)
diff --git a/javascript/jsapi/eventtarget.c b/javascript/jsapi/eventtarget.c
deleted file mode 100644
index e2ab6a95d..000000000
--- a/javascript/jsapi/eventtarget.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget
-
-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);
-};
-*/
-
-#include "jsclass.h"
-
-static JSBool JSAPI_NATIVE(addEventListener, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(removeEventListener, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(dispatchEvent, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-#define JSAPI_FS_EVENTTARGET \
- JSAPI_FS(addEventListener, 0, 0), \
- JSAPI_FS(removeEventListener, 0, 0), \
- JSAPI_FS(dispatchEvent, 0, 0)
diff --git a/javascript/jsapi/htmldocument.c b/javascript/jsapi/htmldocument.c
deleted file mode 100644
index 8b38acd4d..000000000
--- a/javascript/jsapi/htmldocument.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <dom/dom.h>
-
-#include "utils/config.h"
-#include "utils/log.h"
-
-#include "javascript/jsapi.h"
-
-/* IDL http://www.whatwg.org/specs/web-apps/current-work/#the-document-object
-
-[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;
-};
-
- */
-
-static void jsfinalize_document(JSContext *cx, JSObject *obj);
-static JSBool jsresove_node(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);
-
-struct jsclass_document_priv {
- struct html_content *htmlc;
- dom_document *node;
-};
-
-
-#define JSCLASS_NAME document
-
-#include "jsclass.h"
-
-static JSClass JSCLASS_OBJECT =
-{
- "document",
- JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- (JSResolveOp)jsresove_node,
- JS_ConvertStub,
- jsfinalize_document,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-#include "document.c"
-
-static JSBool jsresove_node(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
-{
- *objp = NULL;
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
-{
- JSString* u16_txt;
- char *txt;
- unsigned long length;
- struct jsclass_document_priv *document;
-
- document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (document == NULL) {
- return JS_FALSE;
- }
-
- if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) {
- return JS_FALSE;
- }
-
- JSString_to_char(u16_txt, txt, length);
-
- LOG(("content %p parser %p writing %s",
- document->htmlc, document->htmlc->parser, txt));
- if (document->htmlc->parser != NULL) {
- dom_hubbub_parser_insert_chunk(document->htmlc->parser, (uint8_t *)txt, length);
- }
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSFunctionSpec jsfunctions_document[] = {
- JSAPI_FS_DOCUMENT,
- JSAPI_FS(write, 1, 0),
- JSAPI_FS_END
-};
-
-static JSPropertySpec jsproperties_document[] =
-{
- JSAPI_PS_DOCUMENT,
- JSAPI_PS_END
-};
-
-static void jsfinalize_document(JSContext *cx, JSObject *obj)
-{
- struct jsclass_document_priv *document;
-
- document = JS_GetInstancePrivate(cx, obj, &JSCLASS_OBJECT, NULL);
- if (document != NULL) {
- free(document);
- }
-}
-
-JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc)
-{
- /* create document object and return it */
- JSObject *jsdocument;
- struct jsclass_document_priv *document;
-
- document = malloc(sizeof(*document));
- if (document == NULL) {
- return NULL;
- }
- document->htmlc = htmlc;
- document->node = htmlc->document;
-
- jsdocument = JS_InitClass(cx,
- parent,
- NULL,
- &JSCLASS_OBJECT,
- NULL,
- 0,
- jsproperties_document,
- jsfunctions_document,
- NULL,
- NULL);
- if (jsdocument == NULL) {
- free(document);
- return NULL;
- }
-
- LOG(("setting document private to %p", document));
- /* private pointer to browsing context */
- if (JS_SetPrivate(cx, jsdocument, document) != JS_TRUE) {
- LOG(("failed to set document private"));
- free(document);
- return NULL;
- }
-
- return jsdocument;
-}
diff --git a/javascript/jsapi/htmlelement.c b/javascript/jsapi/htmlelement.c
deleted file mode 100644
index a7846bacd..000000000
--- a/javascript/jsapi/htmlelement.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <dom/dom.h>
-
-#include "utils/config.h"
-#include "utils/log.h"
-#include "render/html_internal.h"
-
-#include "javascript/jsapi.h"
-
-/* IDL http://www.whatwg.org/specs/web-apps/current-work/#elements-in-the-dom
-
-CAUTION - innerHTML and outerHTML etc. are part of the DOM parsing
- specification but more can be found in:
-http://html5.org/specs/dom-parsing.html#extensions-to-the-element-interface
-
-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;
-
- // 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;
-
- // 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;
-};
-
-*/
-
-static void jsfinalize_element(JSContext *cx, JSObject *obj);
-
-struct jsclass_document_priv {
- struct html_content *htmlc;
- dom_element *node;
-};
-
-#define JSCLASS_NAME htmlelement
-
-#include "jsclass.h"
-
-static JSClass JSCLASS_OBJECT =
-{
- "HTMLElement",
- JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- jsfinalize_element,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-#include "element.c"
-
-static void jsfinalize_element(JSContext *cx, JSObject *obj)
-{
- struct jsclass_document_priv *element;
- element = JS_GetInstancePrivate(cx, obj, &JSCLASS_OBJECT, NULL);
- if (element != NULL) {
- free(element);
- }
-}
-
-
-
-static JSFunctionSpec jsfunctions_element[] = {
- JSAPI_FS_ELEMENT,
- JSAPI_FS_END
-};
-
-
-
-
-static JSPropertySpec jsproperties_element[] =
-{
- JSAPI_PS_ELEMENT,
- JSAPI_PS_END
-};
-
-JSObject *
-jsapi_new_element(JSContext *cx,
- JSObject *parent,
- struct html_content *htmlc,
- dom_element *domelement)
-{
- /* create element object and return it */
- JSObject *jselement;
- struct jsclass_document_priv *element;
-
- element = malloc(sizeof(element));
- if (element == NULL) {
- return NULL;
- }
- element->htmlc = htmlc;
- element->node = domelement;
-
- jselement = JS_InitClass(cx,
- parent,
- NULL,
- &JSCLASS_OBJECT,
- NULL,
- 0,
- jsproperties_element,
- jsfunctions_element,
- NULL,
- NULL);
- if (jselement == NULL) {
- free(element);
- return NULL;
- }
-
- LOG(("setting private to %p", element));
- /* private pointer to browsing context */
- if (JS_SetPrivate(cx, jselement, element) != JS_TRUE) {
- LOG(("failed to set private"));
- free(element);
- return NULL;
- }
-
- return jselement;
-}
diff --git a/javascript/jsapi/jsclass.h b/javascript/jsapi/jsclass.h
deleted file mode 100644
index 30b926a52..000000000
--- a/javascript/jsapi/jsclass.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * jsapi pseudo class glue.
- */
-
-#ifndef _NETSURF_JAVASCRIPT_JSAPI_JSCLASS_H_
-#define _NETSURF_JAVASCRIPT_JSAPI_JSCLASS_H_
-
-#ifndef JSCLASS_NAME
-#error "The class name must be defined"
-#endif
-
-#ifndef JSCLASS_TYPE
-#define CLASS jsclass
-#define PRIVATE priv
-#define EXPAND(a,b) PASTE(a,b)
-#define PASTE(x,y) x##_##y
-#define JSCLASS_OBJECT EXPAND(CLASS,JSCLASS_NAME)
-#define JSCLASS_TYPE EXPAND(JSCLASS_OBJECT,PRIVATE)
-#endif
-
-#endif
diff --git a/javascript/jsapi/navigator.c b/javascript/jsapi/navigator.c
deleted file mode 100644
index 88fc5351a..000000000
--- a/javascript/jsapi/navigator.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <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"
-
-/*
- * 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
- * ------------+-----------------+--------------+------------------------------
- */
-
-static JSFunctionSpec jsfunctions_navigator[] = {
- JS_FS_END
-};
-
-#define NAVIGATOR_APPNAME "NetSurf"
-#define NAVIGATOR_APPCODENAME "NetSurf"
-
-static JSBool JSAPI_PROPERTYGET(appName, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPNAME)));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(appName, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-static JSBool JSAPI_PROPERTYGET(appCodeName, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, NAVIGATOR_APPCODENAME)));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(appCodeName, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-static JSBool JSAPI_PROPERTYGET(appVersion, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, netsurf_version)));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(appVersion, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-static JSBool JSAPI_PROPERTYGET(language, JSContext *cx, JSObject *obj, jsval *vp)
-{
- const char *alang = nsoption_charp(accept_language);
-
- if (alang != NULL) {
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, alang)));
- } else {
- JS_SET_RVAL(cx, vp, JSVAL_VOID);
- }
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(language, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-static JSBool JSAPI_PROPERTYGET(platform, JSContext *cx, JSObject *obj, jsval *vp)
-{
- struct utsname *cutsname;
-
- cutsname = malloc(sizeof(struct utsname));
-
- if ((cutsname == NULL) || uname(cutsname) < 0) {
- JS_SET_RVAL(cx, vp, JSVAL_VOID);
- } else {
- 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);
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyN(cx, platstr, platstrlen - 1)));
- free(platstr);
- } else {
- JS_SET_RVAL(cx, vp, JSVAL_VOID);
- }
- }
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(platform, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-static JSBool JSAPI_PROPERTYGET(userAgent, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, user_agent_string())));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(userAgent, JSContext *cx, JSObject *obj, jsval *vp)
-{
- assert(false);
- return JS_FALSE;
-}
-
-
-static JSPropertySpec jsproperties_navigator[] =
-{
- JSAPI_PS(appName, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS(appCodeName, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS(appVersion, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS(language, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS(platform, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS(userAgent, 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_SHARED),
- JSAPI_PS_END
-};
-
-static JSClass jsclass_navigator =
-{
- "navigator",
- JSCLASS_HAS_PRIVATE,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- JS_FinalizeStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSObject *jsapi_new_navigator(JSContext *cx, JSObject *parent)
-{
- return JS_InitClass(cx,
- parent,
- NULL,
- &jsclass_navigator,
- NULL,
- 0,
- jsproperties_navigator,
- jsfunctions_navigator,
- NULL,
- NULL);
-}
diff --git a/javascript/jsapi/node.c b/javascript/jsapi/node.c
deleted file mode 100644
index b8c073752..000000000
--- a/javascript/jsapi/node.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/* IDL http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-node
-
-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;
-
- 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);
-
- 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);
-
- DOMString lookupPrefix(DOMString? namespace);
- DOMString lookupNamespaceURI(DOMString? prefix);
- boolean isDefaultNamespace(DOMString? namespace);
-};
-*/
-
-#include "jsclass.h"
-
-#include "eventtarget.c"
-
-static JSBool JSAPI_NATIVE(hasChildNodes, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(compareDocumentPosition, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(contains, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(insertBefore, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(appendChild, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(replaceChild, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(removeChild, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(normalize, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(cloneNode, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(isEqualNode, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(lookupPrefix, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(lookupNamespaceURI, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(isDefaultNamespace, JSContext *cx, uintN argc, jsval *vp)
-{
- struct JSCLASS_TYPE *priv;
-
- priv = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL);
- if (priv == NULL)
- return JS_FALSE;
-
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-#define JSAPI_FS_NODE \
- JSAPI_FS_EVENTTARGET, \
- JSAPI_FS(hasChildNodes, 0, 0), \
- JSAPI_FS(compareDocumentPosition, 0, 0), \
- JSAPI_FS(contains, 0, 0), \
- JSAPI_FS(insertBefore, 0, 0), \
- JSAPI_FS(appendChild, 0, 0), \
- JSAPI_FS(replaceChild, 0, 0), \
- JSAPI_FS(removeChild, 0, 0), \
- JSAPI_FS(normalize, 0, 0), \
- JSAPI_FS(cloneNode, 0, 0), \
- JSAPI_FS(isEqualNode, 0, 0), \
- JSAPI_FS(lookupPrefix, 0, 0), \
- JSAPI_FS(lookupNamespaceURI, 0, 0), \
- JSAPI_FS(isDefaultNamespace, 0, 0)
-
-
-static JSBool JSAPI_PROPERTYGET(nodeType, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, JSVAL_NULL);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYGET(textContent, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, JSVAL_NULL);
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYSET(textContent, JSContext *cx, JSObject *obj, jsval *vp)
-{
- return JS_FALSE;
-}
-
-#define JSAPI_PS_NODE \
- JSAPI_PS_RO(nodeType, 0, JSPROP_ENUMERATE | JSPROP_SHARED), \
- JSAPI_PS(textContent, 0, JSPROP_ENUMERATE | JSPROP_SHARED)
diff --git a/javascript/jsapi/window.c b/javascript/jsapi/window.c
deleted file mode 100644
index 062d925da..000000000
--- a/javascript/jsapi/window.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "utils/log.h"
-
-#include "javascript/jsapi.h"
-#include "javascript/jsapi/binding.h"
-
-
-struct jsclass_private {
- struct browser_window *bw;
- struct html_content *htmlc;
- JSObject *document_obj;
- JSObject *navigator_obj;
- JSObject *console_obj;
-};
-
-static void jsclass_finalize(JSContext *cx, JSObject *obj);
-static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp);
-
-JSClass JSClass_Window = {
- "Window",
- JSCLASS_NEW_RESOLVE | JSCLASS_HAS_PRIVATE | JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- (JSResolveOp)jsclass_resolve,
- JS_ConvertStub,
- jsclass_finalize,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-static JSBool JSAPI_NATIVE(alert, JSContext *cx, uintN argc, jsval *vp)
-{
- JSString* u16_txt;
- char *txt;
- unsigned long length;
-
- if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
- return JS_FALSE;
-
- JSString_to_char(u16_txt, txt, length);
-
- warn_user(txt, NULL);
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(confirm, JSContext *cx, uintN argc, jsval *vp)
-{
- JSString* u16_txt;
- char *txt;
- unsigned long length;
- JSBool result = JS_FALSE;
-
- if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
- return JS_FALSE;
-
- JSString_to_char(u16_txt, txt, length);
-
- warn_user(txt, NULL);
-
- JSAPI_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(result));
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(prompt, JSContext *cx, uintN argc, jsval *vp)
-{
- JSString* u16_txt;
- char *txt;
- unsigned long length;
-
- if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt))
- return JS_FALSE;
-
- JSString_to_char(u16_txt, txt, length);
-
- warn_user(txt, NULL);
-
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(close, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(stop, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(focus, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool JSAPI_NATIVE(blur, JSContext *cx, uintN argc, jsval *vp)
-{
- JSAPI_SET_RVAL(cx, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSFunctionSpec jsfunctions_window[] =
-{
- JSAPI_FS(close, 0, 0),
- JSAPI_FS(stop, 0, 0),
- JSAPI_FS(focus, 0, 0),
- JSAPI_FS(blur, 0, 0),
- JSAPI_FS(alert, 1, 0),
- JSAPI_FS(confirm, 1, 0),
- JSAPI_FS(prompt, 1, 0),
- JSAPI_FS_END
-};
-
-
-static JSBool JSAPI_PROPERTYGET(window, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYGET(self, JSContext *cx, JSObject *obj, jsval *vp)
-{
- JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
- return JS_TRUE;
-}
-
-static JSBool JSAPI_PROPERTYGET(document, JSContext *cx, JSObject *obj, jsval *vp)
-{
- struct jsclass_private *private;
-
- private = JS_GetInstancePrivate(cx,
- obj,
- &JSClass_Window,
- NULL);
- if (private == NULL)
- return JS_FALSE;
-
- JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(private->document_obj));
- return JS_TRUE;
-}
-
-static JSPropertySpec jsproperties_window[] =
-{
- JSAPI_PS_RO(document, 0, JSPROP_ENUMERATE | JSPROP_SHARED),
- JSAPI_PS_RO(window, 0, JSPROP_ENUMERATE | JSPROP_SHARED),
- JSAPI_PS_RO(self, 0, JSPROP_ENUMERATE | JSPROP_SHARED),
- JSAPI_PS_END
-};
-
-static JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
-{
- *objp = NULL;
- return JS_TRUE;
-}
-
-static void jsclass_finalize(JSContext *cx, JSObject *obj)
-{ struct jsclass_private *private;
-
- private = JS_GetInstancePrivate(cx, obj, &JSClass_Window, NULL);
- if (private != NULL) {
- free(private);
- }
-}
-
-JSObject *jsapi_InitClass_Window(JSContext *cx, JSObject *parent)
-{
- 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;
-}
-
-JSObject *jsapi_new_Window(JSContext *cx,
- JSObject *window,
- JSObject *parent,
- struct browser_window *bw,
- html_content *htmlc)
-{
- 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;
-}