summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.sources12
-rw-r--r--Makefile.sources.javascript53
-rw-r--r--amiga/Makefile.target4
-rw-r--r--gtk/Makefile.target4
-rw-r--r--javascript/WebIDL/Makefile38
-rw-r--r--javascript/WebIDL/console.idl20
-rw-r--r--javascript/WebIDL/dom.idl446
-rw-r--r--javascript/WebIDL/html.idl2194
-rw-r--r--javascript/jsapi.c51
-rw-r--r--javascript/jsapi.h62
-rw-r--r--javascript/jsapi/binding.h99
-rw-r--r--javascript/jsapi/console.bnd59
-rw-r--r--javascript/jsapi/console.c152
-rw-r--r--javascript/jsapi/document.c110
-rw-r--r--javascript/jsapi/dom.bnd26
-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/example.bnd229
-rw-r--r--javascript/jsapi/htmldocument.bnd40
-rw-r--r--javascript/jsapi/htmldocument.c262
-rw-r--r--javascript/jsapi/htmlelement.bnd51
-rw-r--r--javascript/jsapi/htmlelement.c230
-rw-r--r--javascript/jsapi/jsclass.h39
-rw-r--r--javascript/jsapi/location.bnd53
-rw-r--r--javascript/jsapi/navigator.bnd120
-rw-r--r--javascript/jsapi/navigator.c206
-rw-r--r--javascript/jsapi/node.c299
-rw-r--r--javascript/jsapi/window.bnd167
-rw-r--r--javascript/jsapi/window.c327
-rw-r--r--monkey/Makefile.target2
-rw-r--r--test/js/doc-dom2.html12
-rw-r--r--test/js/index.html2
33 files changed, 3642 insertions, 2008 deletions
diff --git a/Makefile.sources b/Makefile.sources
index 0c2356c0b..32db5e666 100644
--- a/Makefile.sources
+++ b/Makefile.sources
@@ -29,13 +29,8 @@ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \
scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \
tree_url_node.c version.c
-# Javascript sources
-ifeq ($(NETSURF_USE_JS),YES)
-S_JSAPI = window.c navigator.c console.c htmldocument.c htmlelement.c
-S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
-else
-S_JAVASCRIPT += none.c
-endif
+# Javascript source
+include Makefile.sources.javascript
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
@@ -45,7 +40,8 @@ S_COMMON := $(addprefix content/,$(S_CONTENT)) \
$(addprefix utils/,$(S_UTILS)) \
$(addprefix utils/http/,$(S_HTTP)) \
$(addprefix desktop/,$(S_DESKTOP)) \
- $(addprefix javascript/,$(S_JAVASCRIPT))
+ $(addprefix javascript/,$(S_JAVASCRIPT)) \
+ $(S_JSAPI_BINDING)
# S_IMAGE are sources related to image management
S_IMAGE_YES := image.c image_cache.c
diff --git a/Makefile.sources.javascript b/Makefile.sources.javascript
new file mode 100644
index 000000000..9803f7a83
--- /dev/null
+++ b/Makefile.sources.javascript
@@ -0,0 +1,53 @@
+#
+# NetSurf javascript source file inclusion
+#
+# Included by Makefile.sources
+#
+
+# ----------------------------------------------------------------------------
+# JSAPI binding
+# ----------------------------------------------------------------------------
+
+S_JSAPI_BINDING:=
+
+JSAPI_BINDING_htmldocument := javascript/jsapi/htmldocument.bnd
+JSAPI_BINDING_htmlelement := javascript/jsapi/htmlelement.bnd
+JSAPI_BINDING_window := javascript/jsapi/window.bnd
+JSAPI_BINDING_navigator := javascript/jsapi/navigator.bnd
+JSAPI_BINDING_console := javascript/jsapi/console.bnd
+JSAPI_BINDING_location := javascript/jsapi/location.bnd
+
+# 1: input file
+# 2: output file
+# 3: binding name
+define convert_jsapi_binding
+
+S_JSAPI_BINDING += $(2)
+
+$(2): $(1)
+ $$(VQ)echo " GENBIND: $(1)"
+ $(Q)nsgenbind -I javascript/WebIDL/ -o $(2) $(1)
+
+endef
+
+# Javascript sources
+ifeq ($(NETSURF_USE_JS),YES)
+WANT_JS_SOURCE := YES
+endif
+
+ifeq ($(NETSURF_USE_MOZJS),YES)
+WANT_JS_SOURCE := YES
+endif
+
+ifeq ($(WANT_JS_SOURCE),YES)
+
+S_JSAPI =
+
+S_JAVASCRIPT += content.c jsapi.c $(addprefix jsapi/,$(S_JSAPI))
+
+$(eval $(foreach V,$(filter JSAPI_BINDING_%,$(.VARIABLES)),$(call convert_jsapi_binding,$($(V)),$(OBJROOT)/$(patsubst JSAPI_BINDING_%,%,$(V)).c,$(patsubst JSAPI_BINDING_%,%,$(V))_jsapi)))
+
+
+else
+S_JAVASCRIPT += none.c
+endif
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index bd1fcb0a7..c4db9a373 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -65,10 +65,6 @@ else
endif
endif
-ifeq ($(NETSURF_USE_MOZJS),YES)
- NETSURF_USE_JS:=YES
-endif
-
EXETARGET := NetSurf
# ----------------------------------------------------------------------------
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index 76d33b5b6..c60247392 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -35,10 +35,6 @@ $(eval $(call pkg_config_find_and_add,MOZJS,mozjs185,JavaScript))
$(eval $(call pkg_config_find_and_add,JS,mozilla-js,JavaScript))
$(eval $(call pkg_config_find_and_add,VIDEO,gstreamer-0.10,Video))
-ifeq ($(NETSURF_USE_MOZJS),YES)
-NETSURF_USE_JS:=YES
-endif
-
# GTK and GLIB flags to disable depricated usage
GTKDEPFLAGS := -DG_DISABLE_SINGLE_INCLUDES \
-DG_DISABLE_DEPRECATED \
diff --git a/javascript/WebIDL/Makefile b/javascript/WebIDL/Makefile
new file mode 100644
index 000000000..77d54e21e
--- /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/console.idl b/javascript/WebIDL/console.idl
new file mode 100644
index 000000000..309b976da
--- /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#consolelogging
+// 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/WebIDL/dom.idl b/javascript/WebIDL/dom.idl
new file mode 100644
index 000000000..6ba870c41
--- /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 000000000..94e7c75db
--- /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.c b/javascript/jsapi.c
index fa8726b42..03e7ff5e3 100644
--- a/javascript/jsapi.c
+++ b/javascript/jsapi.c
@@ -17,6 +17,7 @@
*/
#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
#include "content/content.h"
#include "javascript/content.h"
@@ -90,43 +91,31 @@ void js_destroycontext(jscontext *ctx)
}
-
+/** Create new compartment to run scripts within
+ *
+ * This performs the following actions
+ * 1. constructs a new global object by initialising a window class
+ * 2. Instantiate the global a window object
+ */
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
{
JSContext *cx = (JSContext *)ctx;
- JSObject *window_obj = NULL;
- JSObject *document_obj;
- JSObject *navigator_obj;
- JSObject *console_obj;
-
- if (cx == NULL)
- goto js_newcompartment_fail;
-
- /* create the window object as the global */
- window_obj = jsapi_new_window(cx, NULL, win_priv);
- if (window_obj == NULL)
- goto js_newcompartment_fail;
-
- /* attach the subclasses off the window global */
- document_obj = jsapi_new_document(cx, window_obj, doc_priv);
- if (document_obj == NULL)
- goto js_newcompartment_fail;
-
- navigator_obj = jsapi_new_navigator(cx, window_obj);
- if (navigator_obj == NULL)
- goto js_newcompartment_fail;
+ JSObject *window_proto;
+ JSObject *window;
- /* @todo forms, history, location */
-
- console_obj = jsapi_new_console(cx, window_obj);
- if (console_obj == NULL)
- goto js_newcompartment_fail;
-
- return (jsobject *)window_obj;
+ if (cx == NULL) {
+ return NULL;
+ }
-js_newcompartment_fail:
+ window_proto = jsapi_InitClass_Window(cx, NULL);
+ if (window_proto == NULL) {
+ LOG(("Unable to initialise window class"));
+ return NULL;
+ }
- return NULL;
+ window = jsapi_new_Window(cx, window_proto, NULL, win_priv, doc_priv);
+
+ return (jsobject *)window;
}
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
diff --git a/javascript/jsapi.h b/javascript/jsapi.h
index c4c1ed099..e7c10c139 100644
--- a/javascript/jsapi.h
+++ b/javascript/jsapi.h
@@ -17,7 +17,7 @@
*/
/** \file
- * spidermonkey jsapi bindings and compatability glue.
+ * spidermonkey jsapi compatability glue.
*/
#ifndef _NETSURF_JAVASCRIPT_JSAPI_H_
@@ -29,19 +29,17 @@
#include "mozjs/jsapi.h"
#endif
-#include "render/html_internal.h"
-
#if JS_VERSION <= 180
#include <string.h>
-/* *CAUTION* these macros introduce and use jsthis and jsrval
+/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
* parameters, native function code should not conflict with these
*/
/* five parameter jsapi native call */
#define JSAPI_NATIVE(name, cx, argc, vp) \
- jsapi_native_##name(cx, JSObject *jsthis, argc, vp, jsval *jsrval)
+ jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
/* five parameter function descriptor */
#define JSAPI_FS(name, nargs, flags) \
@@ -51,14 +49,17 @@
#define JSAPI_FS_END JS_FS_END
/* return value */
-#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsrval)
+#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsapi_rval)
/* return value setter */
-#define JSAPI_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsrval, v)
+#define JSAPI_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsapi_rval, v)
/* arguments */
#define JSAPI_ARGV(cx, vp) (vp)
+/* The object instance in a native call */
+#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
+
/* proprty native calls */
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
jsapi_property_##name##_get(cx, obj, jsval id, vp)
@@ -93,8 +94,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
outchar = JS_GetStringBytes(injsstring); \
outlen = strlen(outchar)
+
#else /* #if JS_VERSION <= 180 */
+
/* three parameter jsapi native call */
#define JSAPI_NATIVE(name, cx, argc, vp) jsapi_native_##name(cx, argc, vp)
@@ -114,6 +117,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
/* arguments */
#define JSAPI_ARGV(cx, vp) JS_ARGV(cx,vp)
+/* The object instance in a native call */
+#define JSAPI_THIS_OBJECT(cx,vp) JS_THIS_OBJECT(cx,vp)
+
/* proprty native calls */
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
jsapi_property_##name##_get(cx, obj, jsid id, vp)
@@ -149,47 +155,5 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
#endif
-/** Create a new javascript window object
- *
- * @param cx The javascript context.
- * @param parent The parent object or NULL for new global
- * @param win_priv The private context to set on the object
- * @return new javascript object or NULL on error
- */
-JSObject *jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv);
-
-/** Create a new javascript document object
- *
- * @param cx The javascript context.
- * @param parent The parent object, usually a global window object
- * @param doc_priv The private context to set on the object
- * @return new javascript object or NULL on error
- */
-JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, struct html_content *htmlc);
-
-/** 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);
-
-/** 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);
-
-/** Create a new javascript element object
- *
- * @param cx The javascript context.
- * @param parent The parent object, usually a global window object
- * @param doc_priv The private context to set on the object
- * @return new javascript object or NULL on error
- */
-JSObject *jsapi_new_element(JSContext *cx, JSObject *parent, struct html_content *htmlc, struct dom_element *domelement);
#endif
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
new file mode 100644
index 000000000..68ab6d1ed
--- /dev/null
+++ b/javascript/jsapi/binding.h
@@ -0,0 +1,99 @@
+/*
+ * 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
+ * spidermonkey jsapi class bindings
+ */
+
+#ifndef _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_
+#define _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_
+
+
+#include "render/html_internal.h"
+
+JSObject *jsapi_InitClass_Window(JSContext *cx, JSObject *parent);
+
+/** Create a new javascript window object
+ *
+ * @param cx The javascript context.
+ * @param parent The parent object or NULL for new global
+ * @param win_priv The private context to set on the object
+ * @return new javascript object or NULL on error
+ */
+JSObject *jsapi_new_Window(JSContext *cx,
+ JSObject *window,
+ JSObject *parent,
+ struct browser_window *bw,
+ html_content *htmlc);
+
+JSObject *jsapi_InitClass_Location(JSContext *cx, JSObject *parent);
+JSObject *jsapi_new_Location(JSContext *cx,
+ JSObject *window,
+ JSObject *parent,
+ struct browser_window *bw);
+
+
+JSObject *jsapi_InitClass_Document(JSContext *cx, JSObject *parent);
+
+/** Create a new javascript document object
+ *
+ * @param cx The javascript context.
+ * @param parent The parent object, usually a global window object
+ * @param doc_priv The private context to set on the object
+ * @return new javascript object or NULL on error
+ */
+JSObject *jsapi_new_Document(JSContext *cx,
+ JSObject *proto,
+ JSObject *parent,
+ 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 *prototype, 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 *proto, JSObject *parent);
+
+JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent);
+/** Create a new javascript element object
+ *
+ * @param cx The javascript context.
+ * @param parent The parent object, usually a global window object
+ * @param doc_priv The private context to set on the object
+ * @return new javascript object or NULL on error
+ */
+JSObject *jsapi_new_HTMLElement(JSContext *cx,
+ JSObject *prototype,
+ JSObject *parent,
+ dom_element *node,
+ struct html_content *htmlc);
+
+#endif
diff --git a/javascript/jsapi/console.bnd b/javascript/jsapi/console.bnd
new file mode 100644
index 000000000..6aef9dcb8
--- /dev/null
+++ b/javascript/jsapi/console.bnd
@@ -0,0 +1,59 @@
+/* Binding to generate Console interface
+ *
+ * Copyright 2012 Vincent Sanders <vince@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@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/console.c b/javascript/jsapi/console.c
deleted file mode 100644
index 6a6d7d3c3..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/dom.bnd b/javascript/jsapi/dom.bnd
new file mode 100644
index 000000000..362c828f6
--- /dev/null
+++ b/javascript/jsapi/dom.bnd
@@ -0,0 +1,26 @@
+/* DOM bindings entries */
+
+webidlfile "dom.idl";
+
+operation getElementById %{
+ dom_string *elementId_dom;
+ dom_element *element;
+ dom_exception exc;
+
+ dom_string_create((unsigned char*)elementId, elementId_len, &elementId_dom);
+
+ exc = dom_document_get_element_by_id(private->node, elementId_dom, &element);
+ if ((exc == DOM_NO_ERR) && (element != NULL)) {
+ jsret = jsapi_new_HTMLElement(cx, NULL, NULL, element, private->htmlc);
+ }
+%}
+
+getter textContent %{
+ dom_exception exc;
+ dom_string *content;
+
+ exc = dom_node_get_text_content(private->node, &content);
+ if ((exc == DOM_NO_ERR) && (content != NULL)) {
+ jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content));
+ }
+%}
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/example.bnd b/javascript/jsapi/example.bnd
new file mode 100644
index 000000000..f2f81fb2d
--- /dev/null
+++ b/javascript/jsapi/example.bnd
@@ -0,0 +1,229 @@
+/* Example binding to generate Example interface
+ *
+ * The js_libdom (javascript to libdom) binding type is currently the
+ * only one implemented and this principly describes that binding.
+ *
+ * Copyright 2012 Vincent Sanders <vince@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
+ */
+
+/* additional binding fragments may be included
+ * Note: this is not preprocessed despite the #include name, the
+ * parser will simply switch input to the included file and carry on
+ * cosntructing the bindings Abstract Syntax Tree (AST)
+ */
+#include "dom.bnd"
+
+/* directive to read WebIDL file and add its contents to the webidl AST */
+webidlfile "html.idl";
+
+/* The hdrcomment are added into the geenrated output comment header */
+hdrcomment "Copyright 2012 Vincent Sanders <vince@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";
+
+/* the preamble block is copied verbatum into the generated output
+ *
+ * This can be used for includes, comments or whatever else is desired
+ */
+preamble %{
+
+#include <dom/dom.h>
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+/* this block describes the binding to be generated
+ *
+ * Depending on the type of binding being generated multiple blocks
+ * may be allowed.
+ *
+ * Note: the js_libdom (javascript to libdom) binding as currently
+ * implemented only allows for a single binding per file, this may
+ * be improved in future.
+ */
+binding example {
+ type js_libdom; /* the binding type */
+
+ interface Navigator; /* The WebIDL interface to generate a binding for */
+
+ /* private members:
+ * - stored in private context structure.
+ * - passed as parameters to constructor and stored automatically.
+ * - are *not* considered for property getters/setters.
+ */
+ private "dom_document *" node;
+
+ /* 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 *" fluff;
+
+}
+
+/* operation implementation code.
+ *
+ * The body is copied verbatum into operation binding
+ *
+ * several values are generated automatically:
+ *
+ * - The generated operations use a macro to create a JSNative JSAPI
+ * callback. The interface allows a uniform interface despite the
+ * evolution of the interface over differing spidermonkey versions.
+ *
+ * - The above implies the javascript context is in a variable called cx
+ *
+ * - If private or internal binding members are present they may be
+ * accessed through a structure named "private"
+ *
+ * - if there are arguemnts they may be accesed via an argc/argv jsval
+ * vector.
+ *
+ * - Arguments are automatically converted into c variables (named as
+ * per the WebIDL names.
+ *
+ * - Return values (excepting void return types where its omitted) are
+ * always named "retval" and are of the appropriate c type. The
+ * initial value is set appropriately.
+ */
+operation foo %{
+ retval = JS_NewStringCopyN(cx, "foo", SLEN("foo"));
+%}
+
+/* property getter implementation code.
+ *
+ * The body is copied verbatum into property getter binding
+ *
+ * several values are generated automatically:
+ *
+ * - The generated operations use a macro to create a JSPropertyOp
+ * JSAPI callback. The interface allows a uniform interface despite
+ * the evolution of the interface over differing spidermonkey
+ * versions.
+ *
+ * - The above implies the javascript context is available in a
+ * variable called "cx".
+ *
+ * - If private or internal binding members are present they may be
+ * accessed through a structure named "private"
+ *
+ * - Return values (void on a getter is not possible) are always named
+ * "retval" and are of the appropriate c type. The initial value is
+ * set appropriately.
+ *
+ * - If the getter is omitted altogether but an internal or private
+ * value of the same name appears in the private structure a getter
+ * is automatically constructed to return that value.
+ */
+getter bar %{
+ retval = JS_NewStringCopyN(cx, "bar", SLEN("bar"));
+%}
+
+/* property setter implementation code.
+ *
+ * The body is copied verbatum into property getter binding
+ *
+ * several values are generated automatically:
+ *
+ * - The generated operations use a macro to create a JSPropertyOp
+ * JSAPI callback. The interface allows a uniform interface despite
+ * the evolution of the interface over differing spidermonkey
+ * versions.
+ *
+ * - The above implies the javascript context is available in a
+ * variable called "cx".
+ *
+ * - If private or internal binding members are present they may be
+ * accessed through a structure named "private"
+ *
+ * - Value to set is placed in a c variable named "setval" of the
+ * appropriate type.
+ *
+ * - Return value, named retval" is a boolean (default true) which
+ * indicates if the set was performed.
+ *
+ * - If the setter is omitted altogether but an internal or private
+ * value of the same name appears in the private structure a setter
+ * is automatically constructed to assign that value.
+ */
+setter baz %{
+ printf("%s\n", setval);
+%}
+
+/* implementation of the class initilisation
+ *
+ * This allows the default JS_InitClass to be overriden - currently
+ * only used for the window (global) object to cause all the other class
+ * initialisors to be called.
+ *
+ * function prototype is:
+ * JSObject *jsapi_InitClass_HTMLElement(JSContext *cx, JSObject *parent)
+ */
+api init %{
+ %}
+
+/* implementation of the c instance creation
+ *
+ * This allows the overriding of the construction of an interface instance.
+ *
+ * The body is copied verbatum and must return the new object in the
+ * "newobject" variable.
+ *
+ * The base prototype is
+ * JSObject *jsapi_new_HTMLElement(JSContext *cx, JSObject *prototype, JSObject *parent, ...)
+ * The varadic elements are private variables as specified in the binding
+ *
+ * If there are private or internal values the private struct is
+ * constructed and instantiated. The struct is available during the
+ * new function and is automatically attached as the private value to
+ * the object.
+ *
+ * The default implemenattion simply calls JS_NewObject()
+ *
+ * Note this does *not* rely upon (or even call) the instances
+ * javascript constructor allowing the c code to create objects that
+ * cannot be instantiated from javascript.
+ *
+ */
+api new %{
+ %}
+
+/* additional code in the instance finalise operation.
+ *
+ * The body is copied verbatum into the output
+ *
+ * Prototype is
+ * void jsclass_finalize(JSContext *cx, JSObject *obj)
+ *
+ * private is available (if appropriate) and freed after the body
+ */
+api finalise %{
+ %}
+
+/* resolver code
+ *
+ * A resolver is only generated if this api is provided. This is a
+ * JSResolveOp with JSCLASS_NEW_RESOLVE specified and must provide a
+ * complete implementation.
+ *
+ * The body is copied verbatum into the output
+ *
+ * Prototype is:
+ * JSBool jsclass_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp)
+ *
+ */
+api resolve %{
+ %}
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
new file mode 100644
index 000000000..c90114162
--- /dev/null
+++ b/javascript/jsapi/htmldocument.bnd
@@ -0,0 +1,40 @@
+/* Binding to generate htmldocument */
+
+#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 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);
+ }
+%}
+
+binding document {
+ type js_libdom; /* the binding type */
+
+ /* parameters to constructor value stored in private
+ * context structure.
+ */
+ private "dom_document *" node;
+ private "struct html_content *" htmlc;
+
+ interface Document; /* Web IDL interface to generate */
+}
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.bnd b/javascript/jsapi/htmlelement.bnd
new file mode 100644
index 000000000..596bb7de0
--- /dev/null
+++ b/javascript/jsapi/htmlelement.bnd
@@ -0,0 +1,51 @@
+/* Binding to generate HTMLElement interface
+ *
+ * Copyright 2012 Vincent Sanders <vince@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@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"
+
+%}
+
+binding htmlelement {
+ type js_libdom; /* the binding type */
+
+ interface HTMLElement; /* 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_element *" node;
+ private "struct html_content *" htmlc;
+}
+
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/location.bnd b/javascript/jsapi/location.bnd
new file mode 100644
index 000000000..c83fe46e3
--- /dev/null
+++ b/javascript/jsapi/location.bnd
@@ -0,0 +1,53 @@
+/* Binding to generate Location interface
+ *
+ * Copyright 2012 Vincent Sanders <vince@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@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 "desktop/browser.h"
+
+#include "utils/config.h"
+#include "utils/log.h"
+
+#include "javascript/jsapi.h"
+#include "javascript/jsapi/binding.h"
+
+%}
+
+binding location {
+ type js_libdom; /* the binding type */
+
+ interface Location; /* Web IDL interface to generate */
+
+ /* private members:
+ * - stored in private context structure.
+ * - passed as parameters to constructor and stored automatically.
+ * - are *not* considered for property getters/setters.
+ *
+ * internal members:
+ * - value stored in private context structure
+ * - not passed to constructor
+ * - must be instantiated by constructor
+ * - are considered for property getters/setters.
+ */
+ private "struct browser_window *" bw;
+}
+
+operation reload %{
+ browser_window_reload(private->bw, false);
+%}
diff --git a/javascript/jsapi/navigator.bnd b/javascript/jsapi/navigator.bnd
new file mode 100644
index 000000000..e63e9a9fd
--- /dev/null
+++ b/javascript/jsapi/navigator.bnd
@@ -0,0 +1,120 @@
+/* Binding to generate Navigator interface
+ *
+ * Copyright 2012 Vincent Sanders <vince@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@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 %{
+ jsret = JS_NewStringCopyZ(cx, NAVIGATOR_APPNAME);
+%}
+
+getter appCodeName %{
+ jsret = JS_NewStringCopyZ(cx, NAVIGATOR_APPCODENAME);
+%}
+
+getter appVersion %{
+ jsret = JS_NewStringCopyZ(cx, netsurf_version);
+%}
+
+getter language %{
+ const char *alang = nsoption_charp(accept_language);
+
+ if (alang != NULL) {
+ jsret = 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);
+ jsret = JS_NewStringCopyN(cx, platstr, platstrlen - 1);
+ free(platstr);
+ }
+ }
+%}
+
+getter userAgent %{
+ jsret = JS_NewStringCopyZ(cx, user_agent_string());
+%}
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.bnd b/javascript/jsapi/window.bnd
new file mode 100644
index 000000000..da6400332
--- /dev/null
+++ b/javascript/jsapi/window.bnd
@@ -0,0 +1,167 @@
+/* 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"
+
+%}
+
+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;
+ internal "JSObject *" location;
+}
+
+api global %{
+%}
+
+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;
+ }
+
+ user_proto = jsapi_InitClass_Navigator(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Location(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_Console(cx, prototype);
+ if (user_proto == NULL) {
+ return NULL;
+ }
+
+ user_proto = jsapi_InitClass_HTMLElement(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 = jsapi_new_Navigator(cx, NULL, newobject);
+ if (private->navigator == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ private->location = jsapi_new_Location(cx, NULL, newobject, bw);
+ if (private->location == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ private->console = jsapi_new_Console(cx, NULL, newobject);
+ if (private->console == NULL) {
+ free(private);
+ return NULL;
+ }
+
+ /** @todo forms, history */
+
+ LOG(("Created new window object %p", newobject));
+%}
+
+operation confirm %{
+ warn_user(message, NULL);
+%}
+
+operation alert %{
+ warn_user(message, NULL);
+%}
+
+operation prompt %{
+ warn_user(message, NULL);
+%}
+
+getter window %{
+ jsret = obj;
+%}
+
+getter self %{
+ jsret = obj;
+%}
diff --git a/javascript/jsapi/window.c b/javascript/jsapi/window.c
deleted file mode 100644
index 72d3837d9..000000000
--- a/javascript/jsapi/window.c
+++ /dev/null
@@ -1,327 +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"
-
-/* IDL
-
-[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;
-
- boolean find(optional DOMString aString, optional boolean aCaseSensitive, optional boolean aBackwards, optional boolean aWrapAround, optional boolean aWholeWord, optional boolean aSearchInFrames, optional boolean aShowDialog);
-
- [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
- [TreatNonCallableAsNull] attribute Function? onabort;
- [TreatNonCallableAsNull] attribute Function? onafterprint;
- [TreatNonCallableAsNull] attribute Function? onbeforeprint;
- [TreatNonCallableAsNull] attribute Function? onbeforeunload;
- [TreatNonCallableAsNull] attribute Function? onblur;
- [TreatNonCallableAsNull] attribute Function? oncancel;
- [TreatNonCallableAsNull] attribute Function? oncanplay;
- [TreatNonCallableAsNull] attribute Function? oncanplaythrough;
- [TreatNonCallableAsNull] attribute Function? onchange;
- [TreatNonCallableAsNull] attribute Function? onclick;
- [TreatNonCallableAsNull] attribute Function? onclose;
- [TreatNonCallableAsNull] attribute Function? oncontextmenu;
- [TreatNonCallableAsNull] attribute Function? oncuechange;
- [TreatNonCallableAsNull] attribute Function? ondblclick;
- [TreatNonCallableAsNull] attribute Function? ondrag;
- [TreatNonCallableAsNull] attribute Function? ondragend;
- [TreatNonCallableAsNull] attribute Function? ondragenter;
- [TreatNonCallableAsNull] attribute Function? ondragleave;
- [TreatNonCallableAsNull] attribute Function? ondragover;
- [TreatNonCallableAsNull] attribute Function? ondragstart;
- [TreatNonCallableAsNull] attribute Function? ondrop;
- [TreatNonCallableAsNull] attribute Function? ondurationchange;
- [TreatNonCallableAsNull] attribute Function? onemptied;
- [TreatNonCallableAsNull] attribute Function? onended;
- [TreatNonCallableAsNull] attribute Function? onerror;
- [TreatNonCallableAsNull] attribute Function? onfocus;
- [TreatNonCallableAsNull] attribute Function? onhashchange;
- [TreatNonCallableAsNull] attribute Function? oninput;
- [TreatNonCallableAsNull] attribute Function? oninvalid;
- [TreatNonCallableAsNull] attribute Function? onkeydown;
- [TreatNonCallableAsNull] attribute Function? onkeypress;
- [TreatNonCallableAsNull] attribute Function? onkeyup;
- [TreatNonCallableAsNull] attribute Function? onload;
- [TreatNonCallableAsNull] attribute Function? onloadeddata;
- [TreatNonCallableAsNull] attribute Function? onloadedmetadata;
- [TreatNonCallableAsNull] attribute Function? onloadstart;
- [TreatNonCallableAsNull] attribute Function? onmessage;
- [TreatNonCallableAsNull] attribute Function? onmousedown;
- [TreatNonCallableAsNull] attribute Function? onmousemove;
- [TreatNonCallableAsNull] attribute Function? onmouseout;
- [TreatNonCallableAsNull] attribute Function? onmouseover;
- [TreatNonCallableAsNull] attribute Function? onmouseup;
- [TreatNonCallableAsNull] attribute Function? onmousewheel;
- [TreatNonCallableAsNull] attribute Function? onoffline;
- [TreatNonCallableAsNull] attribute Function? ononline;
- [TreatNonCallableAsNull] attribute Function? onpause;
- [TreatNonCallableAsNull] attribute Function? onplay;
- [TreatNonCallableAsNull] attribute Function? onplaying;
- [TreatNonCallableAsNull] attribute Function? onpagehide;
- [TreatNonCallableAsNull] attribute Function? onpageshow;
- [TreatNonCallableAsNull] attribute Function? onpopstate;
- [TreatNonCallableAsNull] attribute Function? onprogress;
- [TreatNonCallableAsNull] attribute Function? onratechange;
- [TreatNonCallableAsNull] attribute Function? onreset;
- [TreatNonCallableAsNull] attribute Function? onresize;
- [TreatNonCallableAsNull] attribute Function? onscroll;
- [TreatNonCallableAsNull] attribute Function? onseeked;
- [TreatNonCallableAsNull] attribute Function? onseeking;
- [TreatNonCallableAsNull] attribute Function? onselect;
- [TreatNonCallableAsNull] attribute Function? onshow;
- [TreatNonCallableAsNull] attribute Function? onstalled;
- [TreatNonCallableAsNull] attribute Function? onstorage;
- [TreatNonCallableAsNull] attribute Function? onsubmit;
- [TreatNonCallableAsNull] attribute Function? onsuspend;
- [TreatNonCallableAsNull] attribute Function? ontimeupdate;
- [TreatNonCallableAsNull] attribute Function? onunload;
- [TreatNonCallableAsNull] attribute Function? onvolumechange;
- [TreatNonCallableAsNull] attribute Function? onwaiting;
-};
-
-*/
-
-
-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 JSPropertySpec jsproperties_window[] =
-{
- JSAPI_PS_RO(window, 0, JSPROP_ENUMERATE | JSPROP_SHARED),
- JSAPI_PS_RO(self, 0, JSPROP_ENUMERATE | JSPROP_SHARED),
- JSAPI_PS_END
-};
-
-/* The class of the global object. */
-static JSClass jsclass_window = {
- "window",
- JSCLASS_HAS_PRIVATE | JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_PropertyStub,
- JS_StrictPropertyStub,
- JS_EnumerateStub,
- JS_ResolveStub,
- JS_ConvertStub,
- JS_FinalizeStub,
- JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSObject * jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv)
-{
- JSObject *window = NULL;
-
- if (parent == NULL) {
- 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;
- }
-
- } else {
- /* @todo sort out windows that are not globals */
- assert(false);
- }
-
- /* private pointer to browsing context */
- if (!JS_SetPrivate(cx, window, win_priv))
- 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;
-}
diff --git a/monkey/Makefile.target b/monkey/Makefile.target
index 569837bac..8ca03b582 100644
--- a/monkey/Makefile.target
+++ b/monkey/Makefile.target
@@ -47,7 +47,7 @@ $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp)))
MONKEYLDFLAGS := -lm $(shell $(PKG_CONFIG) --cflags --libs glib-2.0 lcms)
- CFLAGS += $(MONKEYCFLAGS) -Werror
+ CFLAGS += $(MONKEYCFLAGS) -Werror -Wno-unused-but-set-variable
LDFLAGS += $(MONKEYLDFLAGS)
# ---------------------------------------------------------------------------
diff --git a/test/js/doc-dom2.html b/test/js/doc-dom2.html
index 17a916c81..a55962bed 100644
--- a/test/js/doc-dom2.html
+++ b/test/js/doc-dom2.html
@@ -4,9 +4,13 @@
<link rel="stylesheet" type="text/css" href="tst.css">
</head>
<body>
-<h1 id="heading">Direct DOM element reference</h1>
-<p>Before</p>
-<script>document.write(document.getElementById("heading").textContent);</script>
-<p>Afterwards</p>
+<h1>DOM getElementById element reference</h1>
+<p>This shows the text content of an element obtained using <a href="http://dom.spec.whatwg.org/#dom-document-getelementbyid">document.getElementById</a></p>
+<p>Referenced text</p>
+<p id="reftext">DOM getElementById element referenced test text</p>
+<p>Inserted text</p>
+<p><script>document.write(document.getElementById("reftext").textContent);</script></p>
+<p>After inserted text</p>
+
</body>
</html>
diff --git a/test/js/index.html b/test/js/index.html
index a7d34f5a1..f618e93c5 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -10,7 +10,7 @@
</ul>
<h2>Document write tests</h2>
<ul>
-<li><a href="inline-doc-write-simple.html">Simple docuemnt write</a></li>
+<li><a href="inline-doc-write-simple.html">Simple document write</a></li>
<li><a href="noscript-inline-doc-write.html">Script within inline script document write with noscript alternative</a></li>
<li><a href="inline-doc-write.html">Script within inline script</a></li>
<li><a href="sync-script.html">External syncronous script</a></li>