Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/895134c35d155d865e9192076bca1aa7cbc22ebc
...commit
http://git.netsurf-browser.org/netsurf.git/commit/895134c35d155d865e9192076bca1aa7cbc22ebc
...tree
http://git.netsurf-browser.org/netsurf.git/tree/895134c35d155d865e9192076bca1aa7cbc22ebc
The branch, master has been updated
via 895134c35d155d865e9192076bca1aa7cbc22ebc (commit)
via d0e775e901cc7ba88c7173c5c797ad1844745a69 (commit)
via b23063bb5200bb1fc6a64e9e811ab1191d114fd9 (commit)
from 2325062ff1429ab9a19ff2db251fa13b0799a276 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=895134c35d155d865e9192076bca1aa7cbc22ebc
commit 895134c35d155d865e9192076bca1aa7cbc22ebc
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
doc: Update UnimplementJavascript.md
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/docs/UnimplementedJavascript.md b/docs/UnimplementedJavascript.md
index f03da37..b9e4234 100644
--- a/docs/UnimplementedJavascript.md
+++ b/docs/UnimplementedJavascript.md
@@ -171,9 +171,6 @@ getter | Element::prefix(string);
getter | Element::localName(string);
getter | Element::tagName(string);
getter | Element::classList(user);
-getter | Element::attributes(user);
-getter | Element::innerHTML(string);
-setter | Element::innerHTML(string);
getter | Element::outerHTML(string);
setter | Element::outerHTML(string);
getter | Element::children(user);
@@ -1443,17 +1440,13 @@ getter | Attr::textContent(string);
setter | Attr::textContent(string);
getter | Attr::ownerElement(user);
getter | Attr::specified(boolean);
-method | NamedNodeMap::item();
-method | NamedNodeMap::getNamedItem();
method | NamedNodeMap::getNamedItemNS();
method | NamedNodeMap::setNamedItem();
method | NamedNodeMap::setNamedItemNS();
method | NamedNodeMap::removeNamedItem();
method | NamedNodeMap::removeNamedItemNS();
-getter | NamedNodeMap::length(unsigned long);
method | DOMImplementation::createDocumentType();
method | DOMImplementation::createDocument();
-method | DOMImplementation::createHTMLDocument();
method | DOMImplementation::hasFeature();
method | Document::getElementsByTagNameNS();
method | Document::getElementsByClassName();
@@ -1486,7 +1479,6 @@ method | Document::query();
method | Document::queryAll();
method | Document::querySelector();
method | Document::querySelectorAll();
-getter | Document::implementation(user);
getter | Document::URL(string);
getter | Document::documentURI(string);
getter | Document::origin(string);
@@ -1578,5 +1570,5 @@ method | EventListener::handleEvent();
method | CustomEvent::initCustomEvent();
getter | CustomEvent::detail(any);
- 1572 unimplemented bindings
+ 1564 unimplemented bindings
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=d0e775e901cc7ba88c7173c5c797ad1844745a69
commit d0e775e901cc7ba88c7173c5c797ad1844745a69
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
JS: Add Element::attributes and NamedNodeMap to handle it
This is a *very* rudimentary implementation lacking most of the
functionality of NamedNodeMap but it's enough to get jQuery 1.12.4 up.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/content/handlers/javascript/duktape/Element.bnd
b/content/handlers/javascript/duktape/Element.bnd
index 35157d5..a965a6c 100644
--- a/content/handlers/javascript/duktape/Element.bnd
+++ b/content/handlers/javascript/duktape/Element.bnd
@@ -514,3 +514,31 @@ out:
}
return 0;
%}
+
+getter Element::attributes()
+%{
+ dom_exception exc;
+ dom_namednodemap *nmap = NULL;
+ duk_set_top(ctx, 0);
+ duk_push_this(ctx);
+ duk_get_prop_string(ctx, 0, MAGIC(attributes));
+ if (duk_is_undefined(ctx, -1)) {
+ duk_pop(ctx);
+ exc = dom_node_get_attributes(priv->parent.node, &nmap);
+ if (exc != DOM_NO_ERR) return 0;
+ dukky_push_generics(ctx, "makeNodeMapProxy");
+ duk_push_pointer(ctx, nmap);
+ if (dukky_create_object(ctx, PROTO_NAME(NAMEDNODEMAP), 1) !=
DUK_EXEC_SUCCESS) {
+ dom_namednodemap_unref(nmap);
+ return 0;
+ }
+ dom_namednodemap_unref(nmap);
+ if (dukky_pcall(ctx, 1, false) != 0) {
+ NSLOG(dukky, DEBUG, "Unable to construct nodelist?");
+ return 0; /* coerced to undefined */
+ }
+ duk_dup(ctx, -1);
+ duk_put_prop_string(ctx, 0, MAGIC(attributes));
+ }
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/NamedNodeMap.bnd
b/content/handlers/javascript/duktape/NamedNodeMap.bnd
new file mode 100644
index 0000000..c81993c
--- /dev/null
+++ b/content/handlers/javascript/duktape/NamedNodeMap.bnd
@@ -0,0 +1,74 @@
+/* NamedNodeMap binding for browser using duktape and libdom
+ *
+ * Copyright 2020 Daniel Silverstone <[email protected]>
+ *
+ * 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
+ */
+
+class NamedNodeMap {
+ private struct dom_namednodemap *map;
+};
+
+init NamedNodeMap(struct dom_namednodemap *map)
+%{
+ priv->map = map;
+ dom_namednodemap_ref(map);
+%}
+
+fini NamedNodeMap()
+%{
+ dom_namednodemap_unref(priv->map);
+%}
+
+getter NamedNodeMap::length()
+%{
+ dom_exception err;
+ uint32_t len;
+
+ err = dom_namednodemap_get_length(priv->map, &len);
+
+ if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ duk_push_uint(ctx, (duk_uint_t)len);
+
+ return 1;
+%}
+
+method NamedNodeMap::item()
+%{
+ unsigned long i = duk_to_uint(ctx, 0);
+ dom_exception err;
+ dom_node *node;
+
+ err = dom_namednodemap_item(priv->map, i, &node);
+
+ if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ dukky_push_node(ctx, node);
+ dom_node_unref(node);
+
+ return 1;
+%}
+
+method NamedNodeMap::getNamedItem()
+%{
+ duk_size_t size;
+ const char *s = duk_safe_to_lstring(ctx, 0, &size);
+ dom_exception exc;
+ dom_node *attr = NULL;
+ dom_string *name = NULL;
+
+ exc = dom_string_create((const uint8_t*)s, size, &name);
+ if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ exc = dom_namednodemap_get_named_item(priv->map, name, &attr);
+ dom_string_unref(name);
+ if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ dukky_push_node(ctx, attr);
+ dom_node_unref(attr);
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/netsurf.bnd
b/content/handlers/javascript/duktape/netsurf.bnd
index 30b3d4a..6dbdb70 100644
--- a/content/handlers/javascript/duktape/netsurf.bnd
+++ b/content/handlers/javascript/duktape/netsurf.bnd
@@ -60,6 +60,7 @@ struct dom_html_br_element;
#include "Document.bnd"
#include "Node.bnd"
#include "NodeList.bnd"
+#include "NamedNodeMap.bnd"
#include "Element.bnd"
#include "HTMLCollection.bnd"
#include "Location.bnd"
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b23063bb5200bb1fc6a64e9e811ab1191d114fd9
commit b23063bb5200bb1fc6a64e9e811ab1191d114fd9
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
JS Generics: Add a NodeMap proxy builder
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/content/handlers/javascript/duktape/generics.js
b/content/handlers/javascript/duktape/generics.js
index 29beffc..e6e952a 100644
--- a/content/handlers/javascript/duktape/generics.js
+++ b/content/handlers/javascript/duktape/generics.js
@@ -27,6 +27,29 @@ var NetSurf = {
},
});
},
+ /* The make-proxy call for nodemap-type objects */
+ makeNodeMapProxy: function(inner) {
+ return new Proxy(inner, {
+ has: function(target, key) {
+ if (typeof key == 'number') {
+ return (key >= 0) && (key < target.length);
+ } else {
+ return target.getNamedItem(key) || (key in target);
+ }
+ },
+ get: function(target, key) {
+ if (typeof key == 'number') {
+ return target.item(key);
+ } else {
+ var attr = target.getNamedItem(key);
+ if (attr) {
+ return attr;
+ }
+ return target[key];
+ }
+ },
+ });
+ },
consoleFormatter: function Formatter() {
if (arguments.length == 0) {
-----------------------------------------------------------------------
Summary of changes:
content/handlers/javascript/duktape/Element.bnd | 28 ++++++++
.../handlers/javascript/duktape/NamedNodeMap.bnd | 74 ++++++++++++++++++++
content/handlers/javascript/duktape/generics.js | 23 ++++++
content/handlers/javascript/duktape/netsurf.bnd | 1 +
docs/UnimplementedJavascript.md | 10 +--
5 files changed, 127 insertions(+), 9 deletions(-)
create mode 100644 content/handlers/javascript/duktape/NamedNodeMap.bnd
diff --git a/content/handlers/javascript/duktape/Element.bnd
b/content/handlers/javascript/duktape/Element.bnd
index 35157d5..a965a6c 100644
--- a/content/handlers/javascript/duktape/Element.bnd
+++ b/content/handlers/javascript/duktape/Element.bnd
@@ -514,3 +514,31 @@ out:
}
return 0;
%}
+
+getter Element::attributes()
+%{
+ dom_exception exc;
+ dom_namednodemap *nmap = NULL;
+ duk_set_top(ctx, 0);
+ duk_push_this(ctx);
+ duk_get_prop_string(ctx, 0, MAGIC(attributes));
+ if (duk_is_undefined(ctx, -1)) {
+ duk_pop(ctx);
+ exc = dom_node_get_attributes(priv->parent.node, &nmap);
+ if (exc != DOM_NO_ERR) return 0;
+ dukky_push_generics(ctx, "makeNodeMapProxy");
+ duk_push_pointer(ctx, nmap);
+ if (dukky_create_object(ctx, PROTO_NAME(NAMEDNODEMAP), 1) !=
DUK_EXEC_SUCCESS) {
+ dom_namednodemap_unref(nmap);
+ return 0;
+ }
+ dom_namednodemap_unref(nmap);
+ if (dukky_pcall(ctx, 1, false) != 0) {
+ NSLOG(dukky, DEBUG, "Unable to construct nodelist?");
+ return 0; /* coerced to undefined */
+ }
+ duk_dup(ctx, -1);
+ duk_put_prop_string(ctx, 0, MAGIC(attributes));
+ }
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/NamedNodeMap.bnd
b/content/handlers/javascript/duktape/NamedNodeMap.bnd
new file mode 100644
index 0000000..c81993c
--- /dev/null
+++ b/content/handlers/javascript/duktape/NamedNodeMap.bnd
@@ -0,0 +1,74 @@
+/* NamedNodeMap binding for browser using duktape and libdom
+ *
+ * Copyright 2020 Daniel Silverstone <[email protected]>
+ *
+ * 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
+ */
+
+class NamedNodeMap {
+ private struct dom_namednodemap *map;
+};
+
+init NamedNodeMap(struct dom_namednodemap *map)
+%{
+ priv->map = map;
+ dom_namednodemap_ref(map);
+%}
+
+fini NamedNodeMap()
+%{
+ dom_namednodemap_unref(priv->map);
+%}
+
+getter NamedNodeMap::length()
+%{
+ dom_exception err;
+ uint32_t len;
+
+ err = dom_namednodemap_get_length(priv->map, &len);
+
+ if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ duk_push_uint(ctx, (duk_uint_t)len);
+
+ return 1;
+%}
+
+method NamedNodeMap::item()
+%{
+ unsigned long i = duk_to_uint(ctx, 0);
+ dom_exception err;
+ dom_node *node;
+
+ err = dom_namednodemap_item(priv->map, i, &node);
+
+ if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ dukky_push_node(ctx, node);
+ dom_node_unref(node);
+
+ return 1;
+%}
+
+method NamedNodeMap::getNamedItem()
+%{
+ duk_size_t size;
+ const char *s = duk_safe_to_lstring(ctx, 0, &size);
+ dom_exception exc;
+ dom_node *attr = NULL;
+ dom_string *name = NULL;
+
+ exc = dom_string_create((const uint8_t*)s, size, &name);
+ if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ exc = dom_namednodemap_get_named_item(priv->map, name, &attr);
+ dom_string_unref(name);
+ if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ dukky_push_node(ctx, attr);
+ dom_node_unref(attr);
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/generics.js
b/content/handlers/javascript/duktape/generics.js
index 29beffc..e6e952a 100644
--- a/content/handlers/javascript/duktape/generics.js
+++ b/content/handlers/javascript/duktape/generics.js
@@ -27,6 +27,29 @@ var NetSurf = {
},
});
},
+ /* The make-proxy call for nodemap-type objects */
+ makeNodeMapProxy: function(inner) {
+ return new Proxy(inner, {
+ has: function(target, key) {
+ if (typeof key == 'number') {
+ return (key >= 0) && (key < target.length);
+ } else {
+ return target.getNamedItem(key) || (key in target);
+ }
+ },
+ get: function(target, key) {
+ if (typeof key == 'number') {
+ return target.item(key);
+ } else {
+ var attr = target.getNamedItem(key);
+ if (attr) {
+ return attr;
+ }
+ return target[key];
+ }
+ },
+ });
+ },
consoleFormatter: function Formatter() {
if (arguments.length == 0) {
diff --git a/content/handlers/javascript/duktape/netsurf.bnd
b/content/handlers/javascript/duktape/netsurf.bnd
index 30b3d4a..6dbdb70 100644
--- a/content/handlers/javascript/duktape/netsurf.bnd
+++ b/content/handlers/javascript/duktape/netsurf.bnd
@@ -60,6 +60,7 @@ struct dom_html_br_element;
#include "Document.bnd"
#include "Node.bnd"
#include "NodeList.bnd"
+#include "NamedNodeMap.bnd"
#include "Element.bnd"
#include "HTMLCollection.bnd"
#include "Location.bnd"
diff --git a/docs/UnimplementedJavascript.md b/docs/UnimplementedJavascript.md
index f03da37..b9e4234 100644
--- a/docs/UnimplementedJavascript.md
+++ b/docs/UnimplementedJavascript.md
@@ -171,9 +171,6 @@ getter | Element::prefix(string);
getter | Element::localName(string);
getter | Element::tagName(string);
getter | Element::classList(user);
-getter | Element::attributes(user);
-getter | Element::innerHTML(string);
-setter | Element::innerHTML(string);
getter | Element::outerHTML(string);
setter | Element::outerHTML(string);
getter | Element::children(user);
@@ -1443,17 +1440,13 @@ getter | Attr::textContent(string);
setter | Attr::textContent(string);
getter | Attr::ownerElement(user);
getter | Attr::specified(boolean);
-method | NamedNodeMap::item();
-method | NamedNodeMap::getNamedItem();
method | NamedNodeMap::getNamedItemNS();
method | NamedNodeMap::setNamedItem();
method | NamedNodeMap::setNamedItemNS();
method | NamedNodeMap::removeNamedItem();
method | NamedNodeMap::removeNamedItemNS();
-getter | NamedNodeMap::length(unsigned long);
method | DOMImplementation::createDocumentType();
method | DOMImplementation::createDocument();
-method | DOMImplementation::createHTMLDocument();
method | DOMImplementation::hasFeature();
method | Document::getElementsByTagNameNS();
method | Document::getElementsByClassName();
@@ -1486,7 +1479,6 @@ method | Document::query();
method | Document::queryAll();
method | Document::querySelector();
method | Document::querySelectorAll();
-getter | Document::implementation(user);
getter | Document::URL(string);
getter | Document::documentURI(string);
getter | Document::origin(string);
@@ -1578,5 +1570,5 @@ method | EventListener::handleEvent();
method | CustomEvent::initCustomEvent();
getter | CustomEvent::detail(any);
- 1572 unimplemented bindings
+ 1564 unimplemented bindings
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org