mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Initial support for Document, EventTarget, NodeList and Iterator (#541)
* Adding document and node support * Initial support for Document, EventTarget, NodeList and Iterator * Add in support for output option type
This commit is contained in:
parent
15d0fcfcf4
commit
4b4bed5ce2
@ -517,6 +517,10 @@ impl ToTokens for ast::ImportType {
|
|||||||
fn none() -> Self::Abi { 0 }
|
fn none() -> Self::Abi { 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ::wasm_bindgen::convert::OptionIntoWasmAbi for &'a #name {
|
||||||
|
fn none() -> Self::Abi { 0 }
|
||||||
|
}
|
||||||
|
|
||||||
impl ::wasm_bindgen::convert::FromWasmAbi for #name {
|
impl ::wasm_bindgen::convert::FromWasmAbi for #name {
|
||||||
type Abi = <::wasm_bindgen::JsValue as
|
type Abi = <::wasm_bindgen::JsValue as
|
||||||
::wasm_bindgen::convert::FromWasmAbi>::Abi;
|
::wasm_bindgen::convert::FromWasmAbi>::Abi;
|
||||||
|
@ -10,6 +10,20 @@ pub enum ImportedTypeKind {
|
|||||||
Reference,
|
Reference,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> ImportedTypes for Option<T>
|
||||||
|
where
|
||||||
|
T: ImportedTypes,
|
||||||
|
{
|
||||||
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
|
where
|
||||||
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
|
{
|
||||||
|
if let Some(inner) = self {
|
||||||
|
inner.imported_types(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Iterate over definitions of and references to imported types in the AST.
|
/// Iterate over definitions of and references to imported types in the AST.
|
||||||
pub trait ImportedTypes {
|
pub trait ImportedTypes {
|
||||||
fn imported_types<F>(&self, f: &mut F)
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
@ -147,19 +161,74 @@ impl ImportedTypes for syn::TypePath {
|
|||||||
where
|
where
|
||||||
F: FnMut(&Ident, ImportedTypeKind),
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
{
|
{
|
||||||
if self.qself.is_some()
|
self.qself.imported_types(f);
|
||||||
|| self.path.leading_colon.is_some()
|
self.path.imported_types(f);
|
||||||
|| self.path.segments.len() != 1
|
}
|
||||||
{
|
}
|
||||||
return;
|
|
||||||
|
impl ImportedTypes for syn::QSelf {
|
||||||
|
fn imported_types<F>(&self, _: &mut F)
|
||||||
|
where
|
||||||
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ImportedTypes for syn::Path {
|
||||||
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
|
where
|
||||||
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
|
{
|
||||||
|
for seg in self.segments.iter() {
|
||||||
|
seg.arguments.imported_types(f);
|
||||||
}
|
}
|
||||||
f(
|
f(
|
||||||
&self.path.segments.last().unwrap().value().ident,
|
&self.segments.last().unwrap().value().ident,
|
||||||
ImportedTypeKind::Reference,
|
ImportedTypeKind::Reference,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ImportedTypes for syn::PathArguments {
|
||||||
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
|
where
|
||||||
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
syn::PathArguments::AngleBracketed(data) => {
|
||||||
|
for arg in data.args.iter() {
|
||||||
|
arg.imported_types(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TOCHECK
|
||||||
|
syn::PathArguments::Parenthesized(data) => {
|
||||||
|
for input in data.inputs.iter() {
|
||||||
|
input.imported_types(f);
|
||||||
|
}
|
||||||
|
// TODO do we need to handle output here?
|
||||||
|
// https://docs.rs/syn/0.14.0/syn/struct.ParenthesizedGenericArguments.html
|
||||||
|
}
|
||||||
|
syn::PathArguments::None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ImportedTypes for syn::GenericArgument {
|
||||||
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
|
where
|
||||||
|
F: FnMut(&Ident, ImportedTypeKind),
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
syn::GenericArgument::Lifetime(_) => {}
|
||||||
|
syn::GenericArgument::Type(ty) => ty.imported_types(f),
|
||||||
|
syn::GenericArgument::Binding(_) => {}, // TODO
|
||||||
|
syn::GenericArgument::Const(_) => {}, // TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ImportedTypes for ast::ImportFunction {
|
impl ImportedTypes for ast::ImportFunction {
|
||||||
fn imported_types<F>(&self, f: &mut F)
|
fn imported_types<F>(&self, f: &mut F)
|
||||||
where
|
where
|
||||||
|
@ -13,7 +13,11 @@ fn element() {
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn test_element(element: &web_sys::Element) {
|
pub fn test_element(element: &web_sys::Element) {
|
||||||
assert_eq!(element.local_name(), "div", "Shouldn't have a div local name");
|
/* Tests needed for:
|
||||||
|
namespace_uri
|
||||||
|
*/
|
||||||
|
assert_eq!(element.prefix(), None, "Shouldn't have a prefix");
|
||||||
|
assert_eq!(element.local_name(), "div", "Should have a div local name");
|
||||||
assert_eq!(element.tag_name(), "div", "Should be a div tag");
|
assert_eq!(element.tag_name(), "div", "Should be a div tag");
|
||||||
assert!(!element.has_attribute("id"), "Shouldn't have an id");
|
assert!(!element.has_attribute("id"), "Shouldn't have an id");
|
||||||
element.set_id("beep");
|
element.set_id("beep");
|
||||||
@ -27,7 +31,11 @@ fn element() {
|
|||||||
assert_eq!(element.class_name(), "", "Shouldn't have a class name");
|
assert_eq!(element.class_name(), "", "Shouldn't have a class name");
|
||||||
element.set_class_name("test thing");
|
element.set_class_name("test thing");
|
||||||
assert_eq!(element.class_name(), "test thing", "Should have a class name");
|
assert_eq!(element.class_name(), "test thing", "Should have a class name");
|
||||||
|
assert_eq!(element.get_attribute("class").unwrap(), "test thing", "Should have a class name");
|
||||||
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
|
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
|
||||||
|
/* Tests needed for:
|
||||||
|
get_attribute_ns
|
||||||
|
*/
|
||||||
|
|
||||||
/*TODO should we enable toggle_attribute tests? (Firefox Nightly + Chrome canary only)
|
/*TODO should we enable toggle_attribute tests? (Firefox Nightly + Chrome canary only)
|
||||||
// TODO toggle_attribute should permit a single argument when optional arguments are supported
|
// TODO toggle_attribute should permit a single argument when optional arguments are supported
|
||||||
@ -44,11 +52,19 @@ fn element() {
|
|||||||
// TODO check get_attribute here when supported
|
// TODO check get_attribute here when supported
|
||||||
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
|
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
|
||||||
assert!(!element.has_attribute("title"), "Should not have a title");
|
assert!(!element.has_attribute("title"), "Should not have a title");
|
||||||
|
/* Tests needed for:
|
||||||
|
set_attribute_ns
|
||||||
|
*/
|
||||||
|
|
||||||
assert!(!element.has_attributes(), "Should not have any attributes");
|
assert!(!element.has_attributes(), "Should not have any attributes");
|
||||||
assert_eq!(element.set_attribute("title", "boop").unwrap(), (), "Should return nothing if set correctly");
|
assert_eq!(element.set_attribute("title", "boop").unwrap(), (), "Should return nothing if set correctly");
|
||||||
assert!(element.has_attributes(), "Should have attributes");
|
assert!(element.has_attributes(), "Should have attributes");
|
||||||
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
|
assert_eq!(element.remove_attribute("title").unwrap(), (), "Should return nothing if removed");
|
||||||
|
/* Tests needed for:
|
||||||
|
remove_attribute_ns
|
||||||
|
has_attribure_ns
|
||||||
|
closest
|
||||||
|
*/
|
||||||
|
|
||||||
assert_eq!(element.matches(".this-is-a-thing").unwrap(), false, "Should not match selector");
|
assert_eq!(element.matches(".this-is-a-thing").unwrap(), false, "Should not match selector");
|
||||||
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), false, "Should not match selector");
|
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), false, "Should not match selector");
|
||||||
@ -57,15 +73,53 @@ fn element() {
|
|||||||
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), true, "Should match selector");
|
assert_eq!(element.webkit_matches_selector(".this-is-a-thing").unwrap(), true, "Should match selector");
|
||||||
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
|
assert_eq!(element.remove_attribute("class").unwrap(), (), "Should return nothing if removed");
|
||||||
|
|
||||||
|
|
||||||
// TODO non standard moz_matches_selector should we even support?
|
// TODO non standard moz_matches_selector should we even support?
|
||||||
|
|
||||||
/* Tests needed for:
|
/* Tests needed for:
|
||||||
|
insert_adjacent_element
|
||||||
insert_adjacent_text
|
insert_adjacent_text
|
||||||
set_pointer_capture
|
set_pointer_capture
|
||||||
release_pointer_capture
|
release_pointer_capture
|
||||||
has_pointer_capture
|
has_pointer_capture
|
||||||
set_capture
|
set_capture
|
||||||
release_capture
|
release_capture
|
||||||
|
scroll_top
|
||||||
|
set_scroll_top
|
||||||
|
scroll_left
|
||||||
|
set_scroll_left
|
||||||
|
scroll_width
|
||||||
|
scroll_height
|
||||||
|
scroll,
|
||||||
|
scroll_to
|
||||||
|
scroll_by
|
||||||
|
client_top
|
||||||
|
client_left
|
||||||
|
client_width
|
||||||
|
client_height
|
||||||
|
scroll_top_max
|
||||||
|
scroll_left_max
|
||||||
|
*/
|
||||||
|
assert_eq!(element.inner_html(), "", "Should return no content");
|
||||||
|
element.set_inner_html("<strong>Hey!</strong><em>Web!</em>");
|
||||||
|
assert_eq!(element.inner_html(), "<strong>Hey!</strong><em>Web!</em>", "Should return HTML conent");
|
||||||
|
assert_eq!(element.query_selector_all("strong").unwrap().length(), 1, "Should return one element");
|
||||||
|
assert!(element.query_selector("strong").unwrap().is_some(), "Should return an element");
|
||||||
|
element.set_inner_html("");
|
||||||
|
assert_eq!(element.inner_html(), "", "Should return no content");
|
||||||
|
|
||||||
|
/* Tests needed for:
|
||||||
|
outer_html
|
||||||
|
set_outer_html
|
||||||
|
insert_adjacent_html
|
||||||
|
*/
|
||||||
|
|
||||||
|
assert!(element.query_selector(".none-existant").unwrap().is_none(), "Should return no results");
|
||||||
|
assert_eq!(element.query_selector_all(".none-existant").unwrap().length(), 0, "Should return no results");
|
||||||
|
/* Tests needed for:
|
||||||
|
slot
|
||||||
|
set_slot
|
||||||
|
request_fullscreen
|
||||||
|
request_pointer_lock
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
|
* https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*TODO
|
||||||
interface WindowProxy;
|
interface WindowProxy;
|
||||||
interface nsISupports;
|
interface nsISupports;
|
||||||
interface URI;
|
interface URI;
|
||||||
@ -21,6 +22,7 @@ interface nsIDocShell;
|
|||||||
interface nsILoadGroup;
|
interface nsILoadGroup;
|
||||||
|
|
||||||
enum VisibilityState { "hidden", "visible" };
|
enum VisibilityState { "hidden", "visible" };
|
||||||
|
*/
|
||||||
|
|
||||||
/* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */
|
/* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */
|
||||||
dictionary ElementCreationOptions {
|
dictionary ElementCreationOptions {
|
||||||
@ -33,8 +35,11 @@ dictionary ElementCreationOptions {
|
|||||||
/* https://dom.spec.whatwg.org/#interface-document */
|
/* https://dom.spec.whatwg.org/#interface-document */
|
||||||
[Constructor]
|
[Constructor]
|
||||||
interface Document : Node {
|
interface Document : Node {
|
||||||
|
|
||||||
|
/*TODO
|
||||||
[Throws]
|
[Throws]
|
||||||
readonly attribute DOMImplementation implementation;
|
readonly attribute DOMImplementation implementation;
|
||||||
|
*/
|
||||||
[Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
|
[Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
|
||||||
readonly attribute DOMString URL;
|
readonly attribute DOMString URL;
|
||||||
[Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
|
[Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType]
|
||||||
@ -54,6 +59,7 @@ interface Document : Node {
|
|||||||
readonly attribute DocumentType? doctype;
|
readonly attribute DocumentType? doctype;
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute Element? documentElement;
|
readonly attribute Element? documentElement;
|
||||||
|
|
||||||
[Pure]
|
[Pure]
|
||||||
HTMLCollection getElementsByTagName(DOMString localName);
|
HTMLCollection getElementsByTagName(DOMString localName);
|
||||||
[Pure, Throws]
|
[Pure, Throws]
|
||||||
@ -73,8 +79,10 @@ interface Document : Node {
|
|||||||
Text createTextNode(DOMString data);
|
Text createTextNode(DOMString data);
|
||||||
[NewObject]
|
[NewObject]
|
||||||
Comment createComment(DOMString data);
|
Comment createComment(DOMString data);
|
||||||
|
/*TODO
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
|
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
|
||||||
|
*/
|
||||||
|
|
||||||
[CEReactions, Throws]
|
[CEReactions, Throws]
|
||||||
Node importNode(Node node, optional boolean deep = false);
|
Node importNode(Node node, optional boolean deep = false);
|
||||||
@ -84,8 +92,10 @@ interface Document : Node {
|
|||||||
[NewObject, Throws, NeedsCallerType]
|
[NewObject, Throws, NeedsCallerType]
|
||||||
Event createEvent(DOMString interface);
|
Event createEvent(DOMString interface);
|
||||||
|
|
||||||
|
/*TODO
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
Range createRange();
|
Range createRange();
|
||||||
|
*/
|
||||||
|
|
||||||
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
|
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
@ -100,22 +110,26 @@ interface Document : Node {
|
|||||||
|
|
||||||
// These are not in the spec, but leave them for now for backwards compat.
|
// These are not in the spec, but leave them for now for backwards compat.
|
||||||
// So sort of like Gecko extensions
|
// So sort of like Gecko extensions
|
||||||
|
/*TODO
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
CDATASection createCDATASection(DOMString data);
|
CDATASection createCDATASection(DOMString data);
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
Attr createAttribute(DOMString name);
|
Attr createAttribute(DOMString name);
|
||||||
[NewObject, Throws]
|
[NewObject, Throws]
|
||||||
Attr createAttributeNS(DOMString? namespace, DOMString name);
|
Attr createAttributeNS(DOMString? namespace, DOMString name);
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/dom.html#the-document-object
|
// https://html.spec.whatwg.org/multipage/dom.html#the-document-object
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
|
/*TODO
|
||||||
[PutForwards=href, Unforgeable] readonly attribute Location? location;
|
[PutForwards=href, Unforgeable] readonly attribute Location? location;
|
||||||
//(HTML only) attribute DOMString domain;
|
//(HTML only) attribute DOMString domain;
|
||||||
readonly attribute DOMString referrer;
|
readonly attribute DOMString referrer;
|
||||||
//(HTML only) attribute DOMString cookie;
|
//(HTML only) attribute DOMString cookie;
|
||||||
readonly attribute DOMString lastModified;
|
readonly attribute DOMString lastModified;
|
||||||
readonly attribute DOMString readyState;
|
readonly attribute DOMString readyState;
|
||||||
|
*/
|
||||||
|
|
||||||
// DOM tree accessors
|
// DOM tree accessors
|
||||||
//(Not proxy yet)getter object (DOMString name);
|
//(Not proxy yet)getter object (DOMString name);
|
||||||
@ -135,6 +149,7 @@ partial interface Document {
|
|||||||
[SameObject] readonly attribute HTMLCollection scripts;
|
[SameObject] readonly attribute HTMLCollection scripts;
|
||||||
[Pure]
|
[Pure]
|
||||||
NodeList getElementsByName(DOMString elementName);
|
NodeList getElementsByName(DOMString elementName);
|
||||||
|
|
||||||
//(Not implemented)readonly attribute DOMElementMap cssElementMap;
|
//(Not implemented)readonly attribute DOMElementMap cssElementMap;
|
||||||
|
|
||||||
// dynamic markup insertion
|
// dynamic markup insertion
|
||||||
@ -174,7 +189,9 @@ partial interface Document {
|
|||||||
* True if this document is synthetic : stand alone image, video, audio file,
|
* True if this document is synthetic : stand alone image, video, audio file,
|
||||||
* etc.
|
* etc.
|
||||||
*/
|
*/
|
||||||
|
/*Non standard
|
||||||
[Func="IsChromeOrXBL"] readonly attribute boolean mozSyntheticDocument;
|
[Func="IsChromeOrXBL"] readonly attribute boolean mozSyntheticDocument;
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the script element whose script is currently being processed.
|
* Returns the script element whose script is currently being processed.
|
||||||
*
|
*
|
||||||
@ -257,17 +274,23 @@ partial interface Document {
|
|||||||
// versions have it uppercase.
|
// versions have it uppercase.
|
||||||
[LenientSetter, Unscopable, Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
[LenientSetter, Unscopable, Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
||||||
readonly attribute boolean fullscreen;
|
readonly attribute boolean fullscreen;
|
||||||
|
/*Non standard
|
||||||
[BinaryName="fullscreen"]
|
[BinaryName="fullscreen"]
|
||||||
readonly attribute boolean mozFullScreen;
|
readonly attribute boolean mozFullScreen;
|
||||||
|
*/
|
||||||
[LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled", NeedsCallerType]
|
[LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled", NeedsCallerType]
|
||||||
readonly attribute boolean fullscreenEnabled;
|
readonly attribute boolean fullscreenEnabled;
|
||||||
|
/*Non standard
|
||||||
[BinaryName="fullscreenEnabled", NeedsCallerType]
|
[BinaryName="fullscreenEnabled", NeedsCallerType]
|
||||||
readonly attribute boolean mozFullScreenEnabled;
|
readonly attribute boolean mozFullScreenEnabled;
|
||||||
|
*/
|
||||||
|
|
||||||
[Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
[Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
||||||
void exitFullscreen();
|
void exitFullscreen();
|
||||||
|
/*Non standard
|
||||||
[BinaryName="exitFullscreen"]
|
[BinaryName="exitFullscreen"]
|
||||||
void mozCancelFullScreen();
|
void mozCancelFullScreen();
|
||||||
|
*/
|
||||||
|
|
||||||
// Events handlers
|
// Events handlers
|
||||||
[Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
[Func="nsDocument::IsUnprefixedFullscreenEnabled"]
|
||||||
@ -289,8 +312,11 @@ partial interface Document {
|
|||||||
// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
|
// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
readonly attribute boolean hidden;
|
readonly attribute boolean hidden;
|
||||||
|
|
||||||
|
/*TODO
|
||||||
readonly attribute VisibilityState visibilityState;
|
readonly attribute VisibilityState visibilityState;
|
||||||
attribute EventHandler onvisibilitychange;
|
attribute EventHandler onvisibilitychange;
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
|
// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface
|
||||||
@ -339,6 +365,7 @@ partial interface Document {
|
|||||||
partial interface Document {
|
partial interface Document {
|
||||||
// XBL support. Wish we could make these [ChromeOnly], but
|
// XBL support. Wish we could make these [ChromeOnly], but
|
||||||
// that would likely break bindings running with the page principal.
|
// that would likely break bindings running with the page principal.
|
||||||
|
/*Non standard
|
||||||
[Func="IsChromeOrXBL"]
|
[Func="IsChromeOrXBL"]
|
||||||
NodeList? getAnonymousNodes(Element elt);
|
NodeList? getAnonymousNodes(Element elt);
|
||||||
[Func="IsChromeOrXBL"]
|
[Func="IsChromeOrXBL"]
|
||||||
@ -348,6 +375,7 @@ partial interface Document {
|
|||||||
Element? getBindingParent(Node node);
|
Element? getBindingParent(Node node);
|
||||||
[Throws, Func="IsChromeOrXBL", NeedsSubjectPrincipal]
|
[Throws, Func="IsChromeOrXBL", NeedsSubjectPrincipal]
|
||||||
void loadBindingDocument(DOMString documentURL);
|
void loadBindingDocument(DOMString documentURL);
|
||||||
|
*/
|
||||||
|
|
||||||
// Touch bits
|
// Touch bits
|
||||||
// XXXbz I can't find the sane spec for this stuff, so just cribbing
|
// XXXbz I can't find the sane spec for this stuff, so just cribbing
|
||||||
@ -375,10 +403,12 @@ partial interface Document {
|
|||||||
// XXXbz and another hack for the fact that we can't usefully have optional
|
// XXXbz and another hack for the fact that we can't usefully have optional
|
||||||
// distinguishing arguments but need a working zero-arg form of
|
// distinguishing arguments but need a working zero-arg form of
|
||||||
// createTouchList().
|
// createTouchList().
|
||||||
|
/*TODO
|
||||||
[NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
[NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||||
TouchList createTouchList();
|
TouchList createTouchList();
|
||||||
[NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
[NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
|
||||||
TouchList createTouchList(sequence<Touch> touches);
|
TouchList createTouchList(sequence<Touch> touches);
|
||||||
|
*/
|
||||||
|
|
||||||
[ChromeOnly]
|
[ChromeOnly]
|
||||||
attribute boolean styleSheetChangeEventsEnabled;
|
attribute boolean styleSheetChangeEventsEnabled;
|
||||||
@ -458,8 +488,10 @@ partial interface Document {
|
|||||||
|
|
||||||
// http://w3c.github.io/selection-api/#extensions-to-document-interface
|
// http://w3c.github.io/selection-api/#extensions-to-document-interface
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
|
/*TODO
|
||||||
[Throws]
|
[Throws]
|
||||||
Selection? getSelection();
|
Selection? getSelection();
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extension to give chrome JS the ability to determine whether
|
// Extension to give chrome JS the ability to determine whether
|
||||||
@ -478,10 +510,12 @@ partial interface Document {
|
|||||||
// Extension to give chrome and XBL JS the ability to determine whether
|
// Extension to give chrome and XBL JS the ability to determine whether
|
||||||
// the document is sandboxed without permission to run scripts
|
// the document is sandboxed without permission to run scripts
|
||||||
// and whether inline scripts are blocked by the document's CSP.
|
// and whether inline scripts are blocked by the document's CSP.
|
||||||
|
/*Non standard
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
[Func="IsChromeOrXBL"] readonly attribute boolean hasScriptsBlockedBySandbox;
|
[Func="IsChromeOrXBL"] readonly attribute boolean hasScriptsBlockedBySandbox;
|
||||||
[Func="IsChromeOrXBL"] readonly attribute boolean inlineScriptAllowedByCSP;
|
[Func="IsChromeOrXBL"] readonly attribute boolean inlineScriptAllowedByCSP;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
// For more information on Flash classification, see
|
// For more information on Flash classification, see
|
||||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
// toolkit/components/url-classifier/flash-block-lists.rst
|
@ -29,8 +29,10 @@ interface Element : Node {
|
|||||||
attribute DOMString id;
|
attribute DOMString id;
|
||||||
[CEReactions, Pure]
|
[CEReactions, Pure]
|
||||||
attribute DOMString className;
|
attribute DOMString className;
|
||||||
|
/*TODO
|
||||||
[Constant, PutForwards=value]
|
[Constant, PutForwards=value]
|
||||||
readonly attribute DOMTokenList classList;
|
readonly attribute DOMTokenList classList;
|
||||||
|
*/
|
||||||
|
|
||||||
[SameObject]
|
[SameObject]
|
||||||
readonly attribute NamedNodeMap attributes;
|
readonly attribute NamedNodeMap attributes;
|
||||||
@ -248,10 +250,8 @@ partial interface Element {
|
|||||||
partial interface Element {
|
partial interface Element {
|
||||||
[Throws, Pure]
|
[Throws, Pure]
|
||||||
Element? querySelector(DOMString selectors);
|
Element? querySelector(DOMString selectors);
|
||||||
/*TODO
|
|
||||||
[Throws, Pure]
|
[Throws, Pure]
|
||||||
NodeList querySelectorAll(DOMString selectors);
|
NodeList querySelectorAll(DOMString selectors);
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dictdef-shadowrootinit
|
// https://dom.spec.whatwg.org/#dictdef-shadowrootinit
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
* liability, trademark and document use rules apply.
|
* liability, trademark and document use rules apply.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*TODO
|
||||||
interface Principal;
|
interface Principal;
|
||||||
interface URI;
|
interface URI;
|
||||||
|
*/
|
||||||
|
|
||||||
interface Node : EventTarget {
|
interface Node : EventTarget {
|
||||||
const unsigned short ELEMENT_NODE = 1;
|
const unsigned short ELEMENT_NODE = 1;
|
||||||
@ -38,8 +40,10 @@ interface Node : EventTarget {
|
|||||||
readonly attribute boolean isConnected;
|
readonly attribute boolean isConnected;
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute Document? ownerDocument;
|
readonly attribute Document? ownerDocument;
|
||||||
|
/*TODO
|
||||||
[Pure]
|
[Pure]
|
||||||
Node getRootNode(optional GetRootNodeOptions options);
|
Node getRootNode(optional GetRootNodeOptions options);
|
||||||
|
*/
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute Node? parentNode;
|
readonly attribute Node? parentNode;
|
||||||
[Pure]
|
[Pure]
|
||||||
@ -207,12 +211,16 @@ interface Node : EventTarget {
|
|||||||
[ChromeOnly, Throws]
|
[ChromeOnly, Throws]
|
||||||
Promise<void> localize(L10nCallback l10nCallback);
|
Promise<void> localize(L10nCallback l10nCallback);
|
||||||
|
|
||||||
|
/*Unsupported ifdef
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
[Func="mozilla::dom::AccessibleNode::IsAOMEnabled", SameObject]
|
[Func="mozilla::dom::AccessibleNode::IsAOMEnabled", SameObject]
|
||||||
readonly attribute AccessibleNode? accessibleNode;
|
readonly attribute AccessibleNode? accessibleNode;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*TODO
|
||||||
dictionary GetRootNodeOptions {
|
dictionary GetRootNodeOptions {
|
||||||
boolean composed = false;
|
boolean composed = false;
|
||||||
};
|
};
|
||||||
|
*/
|
@ -27,11 +27,11 @@ mod util;
|
|||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
use std::iter::FromIterator;
|
use std::iter::{self, FromIterator};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use backend::defined::{ImportedTypeDefinitions, RemoveUndefinedImports};
|
use backend::defined::{ImportedTypeDefinitions, RemoveUndefinedImports};
|
||||||
use backend::util::{ident_ty, rust_ident, wrap_import_function};
|
use backend::util::{ident_ty, raw_ident, rust_ident, wrap_import_function};
|
||||||
use failure::ResultExt;
|
use failure::ResultExt;
|
||||||
use heck::{CamelCase, ShoutySnakeCase};
|
use heck::{CamelCase, ShoutySnakeCase};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
@ -82,7 +82,7 @@ fn compile_ast(mut ast: backend::ast::Program) -> String {
|
|||||||
let mut defined = BTreeSet::from_iter(
|
let mut defined = BTreeSet::from_iter(
|
||||||
vec![
|
vec![
|
||||||
"str", "char", "bool", "JsValue", "u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64",
|
"str", "char", "bool", "JsValue", "u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64",
|
||||||
"usize", "isize", "f32", "f64", "Result", "String", "Vec",
|
"usize", "isize", "f32", "f64", "Result", "String", "Vec", "Option",
|
||||||
].into_iter()
|
].into_iter()
|
||||||
.map(|id| proc_macro2::Ident::new(id, proc_macro2::Span::call_site())),
|
.map(|id| proc_macro2::Ident::new(id, proc_macro2::Span::call_site())),
|
||||||
);
|
);
|
||||||
@ -401,8 +401,10 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::InterfaceMember {
|
|||||||
webidl::ast::InterfaceMember::Const(cnst) => {
|
webidl::ast::InterfaceMember::Const(cnst) => {
|
||||||
cnst.webidl_parse(program, first_pass, self_name)
|
cnst.webidl_parse(program, first_pass, self_name)
|
||||||
}
|
}
|
||||||
|
webidl::ast::InterfaceMember::Iterable(iterable) => {
|
||||||
|
iterable.webidl_parse(program, first_pass, self_name)
|
||||||
|
}
|
||||||
// TODO
|
// TODO
|
||||||
webidl::ast::InterfaceMember::Iterable(_)
|
|
||||||
| webidl::ast::InterfaceMember::Maplike(_)
|
| webidl::ast::InterfaceMember::Maplike(_)
|
||||||
| webidl::ast::InterfaceMember::Setlike(_) => {
|
| webidl::ast::InterfaceMember::Setlike(_) => {
|
||||||
warn!("Unsupported WebIDL interface member: {:?}", self);
|
warn!("Unsupported WebIDL interface member: {:?}", self);
|
||||||
@ -520,6 +522,50 @@ impl<'a> WebidlParse<&'a str> for webidl::ast::RegularAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> WebidlParse<&'a str> for webidl::ast::Iterable {
|
||||||
|
fn webidl_parse(
|
||||||
|
&self,
|
||||||
|
program: &mut backend::ast::Program,
|
||||||
|
first_pass: &FirstPassRecord<'_>,
|
||||||
|
self_name: &'a str,
|
||||||
|
) -> Result<()> {
|
||||||
|
if util::is_chrome_only(&self.extended_attributes) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
let throws = util::throws(&self.extended_attributes);
|
||||||
|
let return_value = webidl::ast::ReturnType::NonVoid(self.value_type.clone());
|
||||||
|
let args = [];
|
||||||
|
first_pass
|
||||||
|
.create_basic_method(
|
||||||
|
&args,
|
||||||
|
Some(&"values".to_string()),
|
||||||
|
&return_value,
|
||||||
|
self_name,
|
||||||
|
false,
|
||||||
|
false, // Should be false
|
||||||
|
)
|
||||||
|
.map(wrap_import_function)
|
||||||
|
.map(|import| program.imports.push(import));
|
||||||
|
|
||||||
|
first_pass
|
||||||
|
.create_basic_method(
|
||||||
|
&args,
|
||||||
|
Some(&"keys".to_string()),
|
||||||
|
&return_value, // Should be a number
|
||||||
|
self_name,
|
||||||
|
false,
|
||||||
|
false, // Should be false
|
||||||
|
)
|
||||||
|
.map(wrap_import_function)
|
||||||
|
.map(|import| program.imports.push(import));
|
||||||
|
*/
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
impl<'a> WebidlParse<&'a str> for webidl::ast::StaticAttribute {
|
||||||
fn webidl_parse(
|
fn webidl_parse(
|
||||||
&self,
|
&self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user