weedle-0.10.0/.gitignore010066400017500001750000000000531346706361600132620ustar0000000000000000 /target **/*.rs.bk Cargo.lock .idea/ *.imlweedle-0.10.0/.travis.yml010066400017500001750000000001061346706361600134020ustar0000000000000000language: rust rust: nightly cache: cargo script: - cargo testweedle-0.10.0/Cargo.toml.orig010066400017500001750000000005231351137447300141570ustar0000000000000000[package] name = "weedle" version = "0.10.0" authors = ["Sharad Chand "] description = "A WebIDL Parser" license = "MIT" documentation = "https://docs.rs/weedle" homepage = "https://github.com/rustwasm/weedle" repository = "https://github.com/rustwasm/weedle" readme = "./README.md" [dependencies] nom = "4.0.0" weedle-0.10.0/Cargo.toml0000644000000015460000000000000104220ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g. crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "weedle" version = "0.10.0" authors = ["Sharad Chand "] description = "A WebIDL Parser" homepage = "https://github.com/rustwasm/weedle" documentation = "https://docs.rs/weedle" readme = "./README.md" license = "MIT" repository = "https://github.com/rustwasm/weedle" [dependencies.nom] version = "4.0.0" weedle-0.10.0/Cargo.toml.orig0000644000000015470000000000000113620ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "weedle" version = "0.10.0" authors = ["Sharad Chand "] description = "A WebIDL Parser" homepage = "https://github.com/rustwasm/weedle" documentation = "https://docs.rs/weedle" readme = "./README.md" license = "MIT" repository = "https://github.com/rustwasm/weedle" [dependencies.nom] version = "4.0.0" weedle-0.10.0/LICENSE.md010066400017500001750000000020431346706361600126770ustar0000000000000000Copyright 2018-Present Sharad Chand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.weedle-0.10.0/README.md010066400017500001750000000026371347746245200125650ustar0000000000000000

Weedle

A Web IDL parser

Build Status Crates.io version Download docs.rs docs

API Docs | Chat

Built with 🦀🕸 by The Rust and WebAssembly Working Group
## About Parses valid WebIDL definitions & produces a data structure starting from [`Definitions`](https://docs.rs/weedle/latest/weedle/type.Definitions.html). ## Usage ### `Cargo.toml` ```toml [dependencies] weedle = "0.9.0" ``` ### `src/main.rs` ```rust fn main() { let parsed = weedle::parse(" interface Window { readonly attribute Storage sessionStorage; }; ").unwrap(); println!("{:?}", parsed); } ``` weedle-0.10.0/src/argument.rs010066400017500001750000000044471346706361600142640ustar0000000000000000use attribute::ExtendedAttributeList; use common::{Default, Identifier, Punctuated}; use types::{AttributedType, Type}; /// Parses a list of argument. Ex: `double v1, double v2, double v3, optional double alpha` pub type ArgumentList<'a> = Punctuated, term!(,)>; ast_types! { /// Parses an argument. Ex: `double v1|double... v1s` enum Argument<'a> { /// Parses `[attributes]? optional? attributedtype identifier ( = default )?` /// /// Note: `= default` is only allowed if `optional` is present Single(struct SingleArgument<'a> { attributes: Option>, optional: Option, type_: AttributedType<'a>, identifier: Identifier<'a>, default: Option> = map!( cond!(optional.is_some(), weedle!(Option>)), |default| default.unwrap_or(None) ), }), /// Parses `[attributes]? type... identifier` Variadic(struct VariadicArgument<'a> { attributes: Option>, type_: Type<'a>, ellipsis: term!(...), identifier: Identifier<'a>, }), } } #[cfg(test)] mod test { use super::*; use literal::{DecLit, DefaultValue, IntegerLit}; use Parse; test!(should_parse_single_argument { "short a" => ""; SingleArgument; attributes.is_none(); optional.is_none(); identifier.0 == "a"; default.is_none(); }); test!(should_parse_variadic_argument { "short... a" => ""; VariadicArgument; attributes.is_none(); identifier.0 == "a"; }); test!(should_parse_optional_single_argument { "optional short a" => ""; SingleArgument; attributes.is_none(); optional.is_some(); identifier.0 == "a"; default.is_none(); }); test!(should_parse_optional_single_argument_with_default { "optional short a = 5" => ""; SingleArgument; attributes.is_none(); optional.is_some(); identifier.0 == "a"; default == Some(Default { assign: term!(=), value: DefaultValue::Integer(IntegerLit::Dec(DecLit("5"))), }); }); } weedle-0.10.0/src/attribute.rs010066400017500001750000000061631351137446600144400ustar0000000000000000use argument::ArgumentList; use common::{Bracketed, Identifier, Parenthesized, Punctuated}; use literal::StringLit; /// Parses a list of attributes. Ex: `[ attribute1, attribute2 ]` pub type ExtendedAttributeList<'a> = Bracketed, term!(,)>>; /// Matches comma separated identifier list pub type IdentifierList<'a> = Punctuated, term!(,)>; ast_types! { /// Parses on of the forms of attribute enum ExtendedAttribute<'a> { /// Parses an argument list. Ex: `Constructor((double x, double y))` /// /// (( )) means ( ) chars ArgList(struct ExtendedAttributeArgList<'a> { identifier: Identifier<'a>, args: Parenthesized>, }), /// Parses a named argument list. Ex: `NamedConstructor=Image((DOMString src))` /// /// (( )) means ( ) chars NamedArgList(struct ExtendedAttributeNamedArgList<'a> { lhs_identifier: Identifier<'a>, assign: term!(=), rhs_identifier: Identifier<'a>, args: Parenthesized>, }), /// Parses an identifier list. Ex: `Exposed=((Window,Worker))` /// /// (( )) means ( ) chars IdentList(struct ExtendedAttributeIdentList<'a> { identifier: Identifier<'a>, assign: term!(=), list: Parenthesized>, }), /// Parses an attribute with an identifier. Ex: `PutForwards=name` #[derive(Copy)] Ident(struct ExtendedAttributeIdent<'a> { lhs_identifier: Identifier<'a>, assign: term!(=), rhs: IdentifierOrString<'a>, }), /// Parses a plain attribute. Ex: `Replaceable` #[derive(Copy)] NoArgs(struct ExtendedAttributeNoArgs<'a>( Identifier<'a>, )), } /// Parses `stringifier|static` #[derive(Copy)] enum IdentifierOrString<'a> { Identifier(Identifier<'a>), String(StringLit<'a>), } } #[cfg(test)] mod test { use super::*; use Parse; test!(should_parse_attribute_no_args { "Replaceable" => ""; ExtendedAttributeNoArgs => ExtendedAttributeNoArgs(Identifier("Replaceable")) }); test!(should_parse_attribute_arg_list { "Constructor(double x, double y)" => ""; ExtendedAttributeArgList; identifier.0 == "Constructor"; args.body.list.len() == 2; }); test!(should_parse_attribute_ident { "PutForwards=name" => ""; ExtendedAttributeIdent; lhs_identifier.0 == "PutForwards"; rhs == IdentifierOrString::Identifier(Identifier("name")); }); test!(should_parse_ident_list { "Exposed=(Window,Worker)" => ""; ExtendedAttributeIdentList; identifier.0 == "Exposed"; list.body.list.len() == 2; }); test!(should_parse_named_arg_list { "NamedConstructor=Image(DOMString src)" => ""; ExtendedAttributeNamedArgList; lhs_identifier.0 == "NamedConstructor"; rhs_identifier.0 == "Image"; args.body.list.len() == 1; }); } weedle-0.10.0/src/common.rs010066400017500001750000000120441351137446600137200ustar0000000000000000use literal::DefaultValue; use term; use Parse; impl<'a, T: Parse<'a>> Parse<'a> for Option { parser!(opt!(weedle!(T))); } impl<'a, T: Parse<'a>> Parse<'a> for Box { parser!(do_parse!(inner: weedle!(T) >> (Box::new(inner)))); } /// Parses `item1 item2 item3...` impl<'a, T: Parse<'a>> Parse<'a> for Vec { parser!(many0!(weedle!(T))); } impl<'a, T: Parse<'a>, U: Parse<'a>> Parse<'a> for (T, U) { parser!(do_parse!(t: weedle!(T) >> u: weedle!(U) >> ((t, u)))); } impl<'a, T: Parse<'a>, U: Parse<'a>, V: Parse<'a>> Parse<'a> for (T, U, V) { parser!(do_parse!( t: weedle!(T) >> u: weedle!(U) >> v: weedle!(V) >> ((t, u, v)) )); } ast_types! { /// Parses `( body )` #[derive(Copy, Default)] struct Parenthesized where [T: Parse<'a>] { open_paren: term::OpenParen, body: T, close_paren: term::CloseParen, } /// Parses `[ body ]` #[derive(Copy, Default)] struct Bracketed where [T: Parse<'a>] { open_bracket: term::OpenBracket, body: T, close_bracket: term::CloseBracket, } /// Parses `{ body }` #[derive(Copy, Default)] struct Braced where [T: Parse<'a>] { open_brace: term::OpenBrace, body: T, close_brace: term::CloseBrace, } /// Parses `< body >` #[derive(Copy, Default)] struct Generics where [T: Parse<'a>] { open_angle: term::LessThan, body: T, close_angle: term::GreaterThan, } /// Parses `(item1, item2, item3,...)?` struct Punctuated where [T: Parse<'a>, S: Parse<'a> + ::std::default::Default] { list: Vec = separated_list!(weedle!(S), weedle!(T)), separator: S = marker, } /// Parses `item1, item2, item3, ...` struct PunctuatedNonEmpty where [T: Parse<'a>, S: Parse<'a> + ::std::default::Default] { list: Vec = terminated!( separated_nonempty_list!(weedle!(S), weedle!(T)), opt!(weedle!(S)) ), separator: S = marker, } /// Represents an identifier /// /// Follows `/_?[A-Za-z][0-9A-Z_a-z-]*/` #[derive(Copy)] struct Identifier<'a>( // See https://heycam.github.io/webidl/#idl-names for why the leading // underscore is trimmed &'a str = ws!(do_parse!( opt!(char!('_')) >> id: recognize!(do_parse!( take_while1!(|c: char| c.is_ascii_alphabetic()) >> take_while!(|c: char| c.is_ascii_alphanumeric() || c == '_' || c == '-') >> (()) )) >> (id.0) )), ) /// Parses rhs of an assignment expression. Ex: `= 45` #[derive(Copy)] struct Default<'a> { assign: term!(=), value: DefaultValue<'a>, } } #[cfg(test)] mod test { use super::*; test!(should_parse_optional_present { "one" => ""; Option; is_some(); }); test!(should_parse_optional_not_present { "" => ""; Option; is_none(); }); test!(should_parse_boxed { "one" => ""; Box; }); test!(should_parse_vec { "one two three" => ""; Vec; len() == 3; }); test!(should_parse_parenthesized { "( one )" => ""; Parenthesized; body.0 == "one"; }); test!(should_parse_bracketed { "[ one ]" => ""; Bracketed; body.0 == "one"; }); test!(should_parse_braced { "{ one }" => ""; Braced; body.0 == "one"; }); test!(should_parse_generics { "" => ""; Generics; body.0 == "one"; }); test!(should_parse_generics_two { "" => ""; Generics<(Identifier, term!(,), Identifier)> => Generics { open_angle: term!(<), body: (Identifier("one"), term!(,), Identifier("two")), close_angle: term!(>), } }); test!(should_parse_comma_separated_values { "one, two, three" => ""; Punctuated; list.len() == 3; }); test!(err should_not_parse_comma_separated_values_empty { "" => PunctuatedNonEmpty }); test!(should_parse_identifier { "hello" => ""; Identifier; 0 == "hello"; }); test!(should_parse_numbered_identifier { "hello5" => ""; Identifier; 0 == "hello5"; }); test!(should_parse_underscored_identifier { "_hello_" => ""; Identifier; 0 == "hello_"; }); test!(should_parse_identifier_surrounding_with_spaces { " hello " => ""; Identifier; 0 == "hello"; }); test!(should_parse_identifier_preceeding_others { "hello note" => "note"; Identifier; 0 == "hello"; }); test!(should_parse_identifier_attached_to_symbol { "hello=" => "="; Identifier; 0 == "hello"; }); } weedle-0.10.0/src/dictionary.rs010066400017500001750000000015211346706361600145750ustar0000000000000000use attribute::ExtendedAttributeList; use common::{Default, Identifier}; use types::Type; /// Parses dictionary members pub type DictionaryMembers<'a> = Vec>; ast_types! { /// Parses dictionary member `[attributes]? required? type identifier ( = default )?;` struct DictionaryMember<'a> { attributes: Option>, required: Option, type_: Type<'a>, identifier: Identifier<'a>, default: Option>, semi_colon: term!(;), } } #[cfg(test)] mod test { use super::*; use Parse; test!(should_parse_dictionary_member { "required long num = 5;" => ""; DictionaryMember; attributes.is_none(); required.is_some(); identifier.0 == "num"; default.is_some(); }); } weedle-0.10.0/src/interface.rs010066400017500001750000000144011351137446600143670ustar0000000000000000use argument::ArgumentList; use attribute::ExtendedAttributeList; use common::{Generics, Identifier, Parenthesized}; use literal::ConstValue; use types::{AttributedType, ConstType, ReturnType}; /// Parses interface members pub type InterfaceMembers<'a> = Vec>; ast_types! { /// Parses inheritance clause `: identifier` #[derive(Copy)] struct Inheritance<'a> { colon: term!(:), identifier: Identifier<'a>, } /// Parses one of the interface member variants enum InterfaceMember<'a> { /// Parses a const interface member `[attributes]? const type identifier = value;` Const(struct ConstMember<'a> { attributes: Option>, const_: term!(const), const_type: ConstType<'a>, identifier: Identifier<'a>, assign: term!(=), const_value: ConstValue<'a>, semi_colon: term!(;), }), /// Parses `[attributes]? (stringifier|inherit|static)? readonly? attribute attributedtype identifier;` Attribute(struct AttributeInterfaceMember<'a> { attributes: Option>, modifier: Option, readonly: Option, attribute: term!(attribute), type_: AttributedType<'a>, identifier: Identifier<'a>, semi_colon: term!(;), }), /// Parses `[attributes]? (stringifier|static)? special? returntype identifier? (( args ));` /// /// (( )) means ( ) chars Operation(struct OperationInterfaceMember<'a> { attributes: Option>, modifier: Option, special: Option, return_type: ReturnType<'a>, identifier: Option>, args: Parenthesized>, semi_colon: term!(;), }), /// Parses an iterable declaration `[attributes]? (iterable | iterable) ;` Iterable(enum IterableInterfaceMember<'a> { /// Parses an iterable declaration `[attributes]? iterable;` Single(struct SingleTypedIterable<'a> { attributes: Option>, iterable: term!(iterable), generics: Generics>, semi_colon: term!(;), }), /// Parses an iterable declaration `[attributes]? iterable;` Double(struct DoubleTypedIterable<'a> { attributes: Option>, iterable: term!(iterable), generics: Generics<(AttributedType<'a>, term!(,), AttributedType<'a>)>, semi_colon: term!(;), }), }), /// Parses an maplike declaration `[attributes]? readonly? maplike;` Maplike(struct MaplikeInterfaceMember<'a> { attributes: Option>, readonly: Option, maplike: term!(maplike), generics: Generics<(AttributedType<'a>, term!(,), AttributedType<'a>)>, semi_colon: term!(;), }), Setlike(struct SetlikeInterfaceMember<'a> { attributes: Option>, readonly: Option, setlike: term!(setlike), generics: Generics>, semi_colon: term!(;), }), /// Parses `stringifier;` #[derive(Default)] Stringifier(struct StringifierMember<'a> { attributes: Option>, stringifier: term!(stringifier), semi_colon: term!(;), }), } /// Parses one of the special keyword `getter|setter|deleter` #[derive(Copy)] enum Special { Getter(term!(getter)), Setter(term!(setter)), Deleter(term!(deleter)), LegacyCaller(term!(legacycaller)), } /// Parses `stringifier|inherit|static` #[derive(Copy)] enum StringifierOrInheritOrStatic { Stringifier(term!(stringifier)), Inherit(term!(inherit)), Static(term!(static)), } /// Parses `stringifier|static` #[derive(Copy)] enum StringifierOrStatic { Stringifier(term!(stringifier)), Static(term!(static)), } } #[cfg(test)] mod test { use super::*; use Parse; test!(should_parse_stringifier_member { "stringifier;" => ""; StringifierMember; }); test!(should_parse_stringifier_or_static { "static" => ""; StringifierOrStatic; }); test!(should_parse_stringifier_or_inherit_or_static { "inherit" => ""; StringifierOrInheritOrStatic; }); test!(should_parse_setlike_interface_member { "readonly setlike;" => ""; SetlikeInterfaceMember; attributes.is_none(); readonly == Some(term!(readonly)); }); test!(should_parse_maplike_interface_member { "readonly maplike;" => ""; MaplikeInterfaceMember; attributes.is_none(); readonly == Some(term!(readonly)); }); test!(should_parse_attribute_interface_member { "readonly attribute unsigned long width;" => ""; AttributeInterfaceMember; attributes.is_none(); readonly == Some(term!(readonly)); identifier.0 == "width"; }); test!(should_parse_double_typed_iterable { "iterable;" => ""; DoubleTypedIterable; attributes.is_none(); }); test!(should_parse_single_typed_iterable { "iterable;" => ""; SingleTypedIterable; attributes.is_none(); }); test!(should_parse_operation_interface_member { "void readString(long a, long b);" => ""; OperationInterfaceMember; attributes.is_none(); modifier.is_none(); special.is_none(); identifier.is_some(); }); test!(should_parse_const_member { "const long name = 5;" => ""; ConstMember; attributes.is_none(); identifier.0 == "name"; }); } weedle-0.10.0/src/lib.rs010066400017500001750000000316171351137446600132050ustar0000000000000000//! Weedle - A WebIDL Parser //! //! Parses valid WebIDL definitions & produces a data structure starting from //! [`Definitions`](struct.Definitions.html). //! //! ### Example //! //! ``` //! extern crate weedle; //! //! let parsed = weedle::parse(" //! interface Window { //! readonly attribute Storage sessionStorage; //! }; //! ").unwrap(); //! println!("{:?}", parsed); //! ``` //! //! Note: //! This parser follows the grammar given at [WebIDL](https://heycam.github.io/webidl). //! //! If any flaws found when parsing string with a valid grammar, create an issue. // need a higher recusion limit for macros #![recursion_limit = "128"] #[macro_use] extern crate nom; use argument::ArgumentList; use attribute::ExtendedAttributeList; use common::{Braced, Identifier, Parenthesized, PunctuatedNonEmpty}; use dictionary::DictionaryMembers; use interface::{Inheritance, InterfaceMembers}; use literal::StringLit; use mixin::MixinMembers; use namespace::NamespaceMembers; pub use nom::{types::CompleteStr, Err, Context, IResult}; use types::{AttributedType, ReturnType}; #[macro_use] mod whitespace; #[macro_use] mod macros; #[macro_use] pub mod term; pub mod argument; pub mod attribute; pub mod common; pub mod dictionary; pub mod interface; pub mod literal; pub mod mixin; pub mod namespace; pub mod types; /// A convenient parse function /// /// ### Example /// /// ``` /// extern crate weedle; /// /// let parsed = weedle::parse(" /// interface Window { /// readonly attribute Storage sessionStorage; /// }; /// ").unwrap(); /// /// println!("{:?}", parsed); /// ``` pub fn parse<'a>(raw: &'a str) -> Result, Err, u32>> { let (remaining, parsed) = Definitions::parse(CompleteStr(raw))?; if remaining.len() > 0 { Result::Err(Err::Failure(nom::Context::Code(remaining, nom::ErrorKind::Custom(0)))) } else { Ok(parsed) } } pub trait Parse<'a>: Sized { fn parse(input: CompleteStr<'a>) -> IResult, Self>; } /// Parses WebIDL definitions. It is the root struct for a complete WebIDL definition. /// /// ### Example /// ``` /// use weedle::{Definitions, CompleteStr, Parse}; /// /// let (_, parsed) = Definitions::parse(CompleteStr(" /// interface Window { /// readonly attribute Storage sessionStorage; /// }; /// ")).unwrap(); /// /// println!("{:?}", parsed); /// ``` /// /// It is recommended to use [`parse`](fn.parse.html) instead. pub type Definitions<'a> = Vec>; ast_types! { /// Parses a definition enum Definition<'a> { /// Parses `[attributes]? callback identifier = type ( (arg1, arg2, ..., argN)? );` Callback(struct CallbackDefinition<'a> { attributes: Option>, callback: term!(callback), identifier: Identifier<'a>, assign: term!(=), return_type: ReturnType<'a>, arguments: Parenthesized>, semi_colon: term!(;), }), /// Parses `[attributes]? callback interface identifier ( : inheritance )? { members };` CallbackInterface(struct CallbackInterfaceDefinition<'a> { attributes: Option>, callback: term!(callback), interface: term!(interface), identifier: Identifier<'a>, inheritance: Option>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? interface identifier ( : inheritance )? { members };` Interface(struct InterfaceDefinition<'a> { attributes: Option>, interface: term!(interface), identifier: Identifier<'a>, inheritance: Option>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? interface mixin identifier { members };` InterfaceMixin(struct InterfaceMixinDefinition<'a> { attributes: Option>, interface: term!(interface), mixin: term!(mixin), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? namespace identifier { members };` Namespace(struct NamespaceDefinition<'a> { attributes: Option>, namespace: term!(namespace), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? dictionary identifier ( : inheritance )? { members };` Dictionary(struct DictionaryDefinition<'a> { attributes: Option>, dictionary: term!(dictionary), identifier: Identifier<'a>, inheritance: Option>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? partial interface identifier { members };` PartialInterface(struct PartialInterfaceDefinition<'a> { attributes: Option>, partial: term!(partial), interface: term!(interface), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? partial interface mixin identifier { members };` PartialInterfaceMixin(struct PartialInterfaceMixinDefinition<'a> { attributes: Option>, partial: term!(partial), interface: term!(interface), mixin: term!(mixin), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? partial dictionary identifier { members };` PartialDictionary(struct PartialDictionaryDefinition<'a> { attributes: Option>, partial: term!(partial), dictionary: term!(dictionary), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? partial namespace identifier { members };` PartialNamespace(struct PartialNamespaceDefinition<'a> { attributes: Option>, partial: term!(partial), namespace: term!(namespace), identifier: Identifier<'a>, members: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? enum identifier { values };` Enum(struct EnumDefinition<'a> { attributes: Option>, enum_: term!(enum), identifier: Identifier<'a>, values: Braced>, semi_colon: term!(;), }), /// Parses `[attributes]? typedef attributedtype identifier;` Typedef(struct TypedefDefinition<'a> { attributes: Option>, typedef: term!(typedef), type_: AttributedType<'a>, identifier: Identifier<'a>, semi_colon: term!(;), }), /// Parses `[attributes]? identifier includes identifier;` IncludesStatement(struct IncludesStatementDefinition<'a> { attributes: Option>, lhs_identifier: Identifier<'a>, includes: term!(includes), rhs_identifier: Identifier<'a>, semi_colon: term!(;), }), /// Parses `[attributes]? identifier implements identifier;` Implements(struct ImplementsDefinition<'a> { attributes: Option>, lhs_identifier: Identifier<'a>, includes: term!(implements), rhs_identifier: Identifier<'a>, semi_colon: term!(;), }), } } /// Parses a non-empty enum value list pub type EnumValueList<'a> = PunctuatedNonEmpty, term!(,)>; #[cfg(test)] mod test { use super::*; test!(should_parse_includes_statement { "first includes second;" => ""; IncludesStatementDefinition; attributes.is_none(); lhs_identifier.0 == "first"; rhs_identifier.0 == "second"; }); test!(should_parse_typedef { "typedef short Short;" => ""; TypedefDefinition; attributes.is_none(); identifier.0 == "Short"; }); test!(should_parse_enum { r#"enum name { "first", "second" }; "# => ""; EnumDefinition; attributes.is_none(); identifier.0 == "name"; values.body.list.len() == 2; }); test!(should_parse_dictionary { "dictionary A { long c; long g; };" => ""; DictionaryDefinition; attributes.is_none(); identifier.0 == "A"; inheritance.is_none(); members.body.len() == 2; }); test!(should_parse_dictionary_inherited { "dictionary C : B { long e; long f; };" => ""; DictionaryDefinition; attributes.is_none(); identifier.0 == "C"; inheritance.is_some(); members.body.len() == 2; }); test!(should_parse_partial_namespace { " partial namespace VectorUtils { readonly attribute Vector unit; double dotProduct(Vector x, Vector y); Vector crossProduct(Vector x, Vector y); }; " => ""; PartialNamespaceDefinition; attributes.is_none(); identifier.0 == "VectorUtils"; members.body.len() == 3; }); test!(should_parse_partial_dictionary { "partial dictionary C { long e; long f; };" => ""; PartialDictionaryDefinition; attributes.is_none(); identifier.0 == "C"; members.body.len() == 2; }); test!(should_parse_partial_interface_mixin { " partial interface mixin WindowSessionStorage { readonly attribute Storage sessionStorage; }; " => ""; PartialInterfaceMixinDefinition; attributes.is_none(); identifier.0 == "WindowSessionStorage"; members.body.len() == 1; }); test!(should_parse_partial_interface { " partial interface Window { readonly attribute Storage sessionStorage; }; " => ""; PartialInterfaceDefinition; attributes.is_none(); identifier.0 == "Window"; members.body.len() == 1; }); test!(should_parse_namespace { " namespace VectorUtils { readonly attribute Vector unit; double dotProduct(Vector x, Vector y); Vector crossProduct(Vector x, Vector y); }; " => ""; NamespaceDefinition; attributes.is_none(); identifier.0 == "VectorUtils"; members.body.len() == 3; }); test!(should_parse_interface_mixin { " interface mixin WindowSessionStorage { readonly attribute Storage sessionStorage; }; " => ""; InterfaceMixinDefinition; attributes.is_none(); identifier.0 == "WindowSessionStorage"; members.body.len() == 1; }); test!(should_parse_interface { " interface Window { readonly attribute Storage sessionStorage; }; " => ""; InterfaceDefinition; attributes.is_none(); identifier.0 == "Window"; members.body.len() == 1; }); test!(should_parse_callback_interface {" callback interface Options { attribute DOMString? option1; attribute DOMString? option2; attribute long? option3; }; " => ""; CallbackInterfaceDefinition; attributes.is_none(); identifier.0 == "Options"; members.body.len() == 3; }); test!(should_parse_callback { "callback AsyncOperationCallback = void (DOMString status);" => ""; CallbackDefinition; attributes.is_none(); identifier.0 == "AsyncOperationCallback"; arguments.body.list.len() == 1; }); test!(should_parse_with_line_comments { " // This is a comment callback AsyncOperationCallback = void (DOMString status); " => ""; CallbackDefinition; }); test!(should_parse_with_block_comments { " /* This is a comment */ callback AsyncOperationCallback = void (DOMString status); " => ""; CallbackDefinition; }); test!(should_parse_with_multiple_comments { " // This is a comment // This is a comment // This is a comment // This is a comment callback AsyncOperationCallback = void (DOMString status); " => ""; CallbackDefinition; }); } weedle-0.10.0/src/literal.rs010066400017500001750000000211221351137446600140610ustar0000000000000000ast_types! { /// Represents an integer value #[derive(Copy)] enum IntegerLit<'a> { /// Parses `-?[1-9][0-9]*` #[derive(Copy)] Dec(struct DecLit<'a>( &'a str = map!( ws!(recognize!(do_parse!( opt!(char!('-')) >> one_of!("123456789") >> take_while!(|c: char| c.is_ascii_digit()) >> (()) ))), |inner| inner.0 ), )), /// Parses `-?0[Xx][0-9A-Fa-f]+)` #[derive(Copy)] Hex(struct HexLit<'a>( &'a str = map!( ws!(recognize!(do_parse!( opt!(char!('-')) >> char!('0') >> alt!(char!('x') | char!('X')) >> take_while!(|c: char| c.is_ascii_hexdigit()) >> (()) ))), |inner| inner.0 ), )), /// Parses `-?0[0-7]*` #[derive(Copy)] Oct(struct OctLit<'a>( &'a str = map!( ws!(recognize!(do_parse!( opt!(char!('-')) >> char!('0') >> take_while!(|c| '0' <= c && c <= '7') >> (()) ))), |inner| inner.0 ), )), } /// Represents a string value /// /// Follow `/"[^"]*"/` #[derive(Copy)] struct StringLit<'a>( &'a str = ws!(do_parse!( char!('"') >> s: take_while!(|c| c != '"') >> char!('"') >> (s.0) )), ) /// Represents a default literal value. Ex: `34|34.23|"value"|[ ]|true|false|null` #[derive(Copy)] enum DefaultValue<'a> { Boolean(BooleanLit), /// Represents `[ ]` #[derive(Copy, Default)] EmptyArray(struct EmptyArrayLit { open_bracket: term!(OpenBracket), close_bracket: term!(CloseBracket), }), /// Represents `{ }` #[derive(Copy, Default)] EmptyDictionary(struct EmptyDictionaryLit { open_brace: term!(OpenBrace), close_brace: term!(CloseBrace), }), Float(FloatLit<'a>), Integer(IntegerLit<'a>), Null(term!(null)), String(StringLit<'a>), } /// Represents `true`, `false`, `34.23`, `null`, `56`, ... #[derive(Copy)] enum ConstValue<'a> { Boolean(BooleanLit), Float(FloatLit<'a>), Integer(IntegerLit<'a>), Null(term!(null)), } /// Represents either `true` or `false` #[derive(Copy)] struct BooleanLit( bool = alt!( weedle!(term!(true)) => {|_| true} | weedle!(term!(false)) => {|_| false} ), ) /// Represents a floating point value, `NaN`, `Infinity`, '+Infinity` #[derive(Copy)] enum FloatLit<'a> { /// Parses `/-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/` #[derive(Copy)] Value(struct FloatValueLit<'a>( &'a str = map!( ws!(recognize!(do_parse!( opt!(char!('-')) >> alt!( do_parse!( // (?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+) alt!( do_parse!( take_while1!(|c: char| c.is_ascii_digit()) >> char!('.') >> take_while!(|c: char| c.is_ascii_digit()) >> (()) ) | do_parse!( take_while!(|c: char| c.is_ascii_digit()) >> char!('.') >> take_while1!(|c: char| c.is_ascii_digit()) >> (()) ) ) >> // (?:[Ee][+-]?[0-9]+)? opt!(do_parse!( alt!(char!('e') | char!('E')) >> opt!(alt!(char!('+') | char!('-'))) >> take_while1!(|c: char| c.is_ascii_digit()) >> (()) )) >> (()) ) | // [0-9]+[Ee][+-]?[0-9]+ do_parse!( take_while1!(|c: char| c.is_ascii_digit()) >> alt!(char!('e') | char!('E')) >> opt!(alt!(char!('+') | char!('-'))) >> take_while1!(|c: char| c.is_ascii_digit()) >> (()) ) ) >> (()) ))), |inner| inner.0 ), )), NegInfinity(term!(-Infinity)), Infinity(term!(Infinity)), NaN(term!(NaN)), } } #[cfg(test)] mod test { use super::*; use term::*; use Parse; test!(should_parse_integer { "45" => ""; IntegerLit => IntegerLit::Dec(DecLit("45")) }); test!(should_parse_integer_surrounding_with_spaces { " 123123 " => ""; IntegerLit => IntegerLit::Dec(DecLit("123123")) }); test!(should_parse_integer_preceeding_others { "3453 string" => "string"; IntegerLit => IntegerLit::Dec(DecLit("3453")) }); test!(should_parse_neg_integer { "-435" => ""; IntegerLit => IntegerLit::Dec(DecLit("-435")) }); test!(should_parse_hex_number { "0X08" => ""; IntegerLit => IntegerLit::Hex(HexLit("0X08")) }); test!(should_parse_hex_large_number { "0xA" => ""; IntegerLit => IntegerLit::Hex(HexLit("0xA")) }); test!(should_parse_zero { "0" => ""; IntegerLit => IntegerLit::Oct(OctLit("0")) }); test!(should_parse_oct_number { "-07561" => ""; IntegerLit => IntegerLit::Oct(OctLit("-07561")) }); test!(should_parse_float { "45.434" => ""; FloatLit => FloatLit::Value(FloatValueLit("45.434")) }); test!(should_parse_float_surrounding_with_spaces { " 2345.2345 " => ""; FloatLit => FloatLit::Value(FloatValueLit("2345.2345")) }); test!(should_parse_float_preceeding_others { "3453.32334 string" => "string"; FloatLit => FloatLit::Value(FloatValueLit("3453.32334")) }); test!(should_parse_neg_float { "-435.3435" => ""; FloatLit => FloatLit::Value(FloatValueLit("-435.3435")) }); test!(should_parse_float_exp { "5.3434e23" => ""; FloatLit => FloatLit::Value(FloatValueLit("5.3434e23")) }); test!(should_parse_float_exp_with_decimal { "3e23" => ""; FloatLit => FloatLit::Value(FloatValueLit("3e23")) }); test!(should_parse_neg_infinity { "-Infinity" => ""; FloatLit => FloatLit::NegInfinity(term!(-Infinity)) }); test!(should_parse_infinity { "Infinity" => ""; FloatLit => FloatLit::Infinity(term!(Infinity)) }); test!(should_parse_string { r#""this is a string""# => ""; StringLit => StringLit("this is a string") }); test!(should_parse_string_surround_with_spaces { r#" "this is a string" "# => ""; StringLit => StringLit("this is a string") }); test!(should_parse_string_followed_by_string { r#" "this is first" "this is second" "# => r#""this is second" "#; StringLit => StringLit("this is first") }); test!(should_parse_string_with_spaces { r#" " this is a string " "# => ""; StringLit => StringLit(" this is a string ") }); test!(should_parse_string_with_comment { r#" "// this is still a string" "# => ""; StringLit => StringLit("// this is still a string") }); test!(should_parse_string_with_multiline_comment { r#" "/*" "*/" "# => r#""*/" "#; StringLit => StringLit("/*") }); test!(should_parse_null { "null" => ""; Null => Null }); test!(should_parse_empty_array { "[]" => ""; EmptyArrayLit => Default::default() }); test!(should_parse_bool_true { "true" => ""; BooleanLit => BooleanLit(true) }); test!(should_parse_bool_false { "false" => ""; BooleanLit => BooleanLit(false) }); } weedle-0.10.0/src/macros.rs010066400017500001750000000343111346706361600137170ustar0000000000000000macro_rules! parser { ($submac:ident!( $($args:tt)* )) => { fn parse(input: $crate::CompleteStr<'a>) -> $crate::IResult<$crate::CompleteStr<'a>, Self> { $submac!(input, $($args)*) } }; } macro_rules! weedle { ($i:expr, $t:ty) => { <$t as $crate::Parse<'a>>::parse($i) }; } macro_rules! ast_types { (@extract_type struct $name:ident<'a> $($rest:tt)*) => ($name<'a>); (@extract_type struct $name:ident $($rest:tt)*) => ($name); (@extract_type enum $name:ident<'a> $($rest:tt)*) => ($name<'a>); (@extract_type enum $name:ident $($rest:tt)*) => ($name); () => (); ( $(#[$attr:meta])* struct $name:ident<'a> { $($fields:tt)* } $($rest:tt)* ) => ( __ast_struct! { @launch_pad $(#[$attr])* $name [ 'a ] [ ] { $($fields)* } } ast_types!($($rest)*); ); ( $(#[$attr:meta])* struct $name:ident<$($generics:ident),+> where [$($bounds:tt)+] { $($fields:tt)* } $($rest:tt)* ) => ( __ast_struct! { @launch_pad $(#[$attr])* $name [$($generics)+] [$($bounds)+] { $($fields)* } } ast_types!($($rest)*); ); ( $(#[$attr:meta])* struct $name:ident { $($fields:tt)* } $($rest:tt)* ) => ( __ast_struct! { @launch_pad $(#[$attr])* $name [ ] [ ] { $($fields)* } } ast_types!($($rest)*); ); ( $(#[$attr:meta])* struct $name:ident<'a> ( $($fields:tt)* ) $($rest:tt)* ) => ( __ast_tuple_struct! { @launch_pad $(#[$attr])* $name [ 'a ] ( $($fields)* ) } ast_types!($($rest)*); ); ( $(#[$attr:meta])* struct $name:ident ( $($fields:tt)* ) $($rest:tt)* ) => ( __ast_tuple_struct! { @launch_pad $(#[$attr])* $name [ ] ( $($fields)* ) } ast_types!($($rest)*); ); ( $(#[$attr:meta])* enum $name:ident<'a> { $($variants:tt)* } $($rest:tt)* ) => ( __ast_enum! { @launch_pad $(#[$attr])* $name [ 'a ] { $($variants)* } } ast_types!($($rest)*); ); ( $(#[$attr:meta])* enum $name:ident { $($variants:tt)* } $($rest:tt)* ) => ( __ast_enum! { @launch_pad $(#[$attr])* $name [ ] { $($variants)* } } ast_types!($($rest)*); ); } macro_rules! __ast_tuple_struct { (@launch_pad $(#[$attr:meta])* $name:ident [ $($maybe_a:tt)* ] ( $inner:ty = $submac:ident!( $($args:tt)* ), ) ) => ( $(#[$attr])* #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct $name<$($maybe_a)*>(pub $inner); impl<'a> $crate::Parse<'a> for $name<$($maybe_a)*> { fn parse(input: $crate::CompleteStr<'a>) -> $crate::IResult<$crate::CompleteStr<'a>, Self> { use $crate::nom::lib::std::result::Result::*; match $submac!(input, $($args)*) { Err(e) => Err(e), Ok((i, inner)) => Ok((i, $name(inner))), } } } ); (@launch_pad $(#[$attr:meta])* $name:ident [ $($maybe_a:tt)* ] ( $inner:ty, ) ) => ( __ast_tuple_struct! { @launch_pad $(#[$attr])* $name [ $($maybe_a)* ] ( $inner = weedle!($inner), ) } ); } macro_rules! __ast_struct { (@build_struct_decl { $(#[$attr:meta])* $name:ident [ $($generics:tt)* ] $($field:ident : $type:ty)* } { } ) => { $(#[$attr])* #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct $name<$($generics)*> { $(pub $field : $type,)* } }; (@build_struct_decl { $($prev:tt)* } { $field:ident : $type:ty, $($rest:tt)* } ) => ( __ast_struct! { @build_struct_decl { $($prev)* $field : $type } { $($rest)* } } ); (@build_struct_decl { $($prev:tt)* } { $field:ident : $type:ty = $submac:ident!( $($args:tt)* ), $($rest:tt)* } ) => ( __ast_struct! { @build_struct_decl { $($prev)* $field : $type } { $($rest)* } } ); (@build_struct_decl { $($prev:tt)* } { $field:ident : $type:ty = marker, $($rest:tt)* } ) => ( __ast_struct! { @build_struct_decl { $($prev)* $field : $type } { $($rest)* } } ); (@build_parser { $i:expr, $($field:ident)* } { } ) => ({ use $crate::nom::lib::std::result::Result::Ok; Ok(($i, Self { $($field,)* })) }); (@build_parser { $i:expr, $($prev:tt)* } { $field:ident : $type:ty = $submac:ident!( $($args:tt)* ), $($rest:tt)* } ) => ({ use $crate::nom::lib::std::result::Result::*; match $submac!($i, $($args)*) { Err(e) => Err(e), Ok((i, $field)) => { __ast_struct! { @build_parser { i, $($prev)* $field } { $($rest)* } } }, } }); (@build_parser { $($prev:tt)* } { $field:ident : $type:ty = marker, $($rest:tt)* } ) => ({ let $field = $crate::std::default::Default::default(); __ast_struct! { @build_parser { $($prev)* $field } { $($rest)* } } }); (@build_parser { $($prev:tt)* } { $field:ident : $type:ty, $($rest:tt)* } ) => ( __ast_struct! { @build_parser { $($prev)* } { $field : $type = weedle!($type), $($rest)* } } ); ( @launch_pad $(#[$attr:meta])* $name:ident [ ] [ ] { $($fields:tt)* } ) => { __ast_struct! { @build_struct_decl { $(#[$attr])* $name [ ] } { $($fields)* } } impl<'a> $crate::Parse<'a> for $name { fn parse(input: $crate::CompleteStr<'a>) -> $crate::IResult<$crate::CompleteStr<'a>, Self> { __ast_struct! { @build_parser { input, } { $($fields)* } } } } }; ( @launch_pad $(#[$attr:meta])* $name:ident [ 'a ] [ ] { $($fields:tt)* } ) => { __ast_struct! { @build_struct_decl { $(#[$attr])* $name [ 'a ] } { $($fields)* } } impl<'a> $crate::Parse<'a> for $name<'a> { fn parse(input: $crate::CompleteStr<'a>) -> $crate::IResult<$crate::CompleteStr<'a>, Self> { __ast_struct! { @build_parser { input, } { $($fields)* } } } } }; ( @launch_pad $(#[$attr:meta])* $name:ident [$($generics:ident)+] [$($bounds:tt)+] { $($fields:tt)* } ) => { __ast_struct! { @build_struct_decl { $(#[$attr])* $name [$($generics),+] } { $($fields)* } } impl<'a, $($generics),+> $crate::Parse<'a> for $name<$($generics),+> where $($bounds)+ { fn parse(input: $crate::CompleteStr<'a>) -> $crate::IResult<$crate::CompleteStr<'a>, Self> { __ast_struct! { @build_parser { input, } { $($fields)* } } } } }; } macro_rules! __ast_enum { (@build_enum_decl { $(#[$attr:meta])* $name:ident [ $($maybe_a:tt)* ] $($variant:ident($member:ty))* } { } ) => ( $(#[$attr])* #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum $name<$($maybe_a)*> { $($variant($member),)* } ); (@build_enum_decl { $($prev:tt)* } { $variant:ident($member:ty), $($rest:tt)* } ) => ( __ast_enum! { @build_enum_decl { $($prev)* $variant($member) } { $($rest)* } } ); (@build_enum_decl { $($prev:tt)* } { $(#[$attr:meta])* $variant:ident( $($member:tt)* ), $($rest:tt)* } ) => ( __ast_enum! { @build_enum_decl { $($prev)* $variant(ast_types! { @extract_type $($member)* }) } { $($rest)* } } ); (@build_sub_types { }) => (); (@build_sub_types { $variant:ident($member:ty), $($rest:tt)* } ) => ( __ast_enum! { @build_sub_types { $($rest)* } } ); (@build_sub_types { $(#[$attr:meta])* $variant:ident( $($member:tt)* ), $($rest:tt)* } ) => ( ast_types! { $(#[$attr])* $($member)* } __ast_enum! { @build_sub_types { $($rest)* } } ); (@build_conversions $name:ident [ $($maybe_a:tt)* ] { }) => (); (@build_conversions $name:ident [ $($maybe_a:tt)* ] { $variant:ident($member:ty), $($rest:tt)* } ) => ( impl<$($maybe_a)*> From<$member> for $name<$($maybe_a)*> { fn from(x: $member) -> Self { $name::$variant(x) } } __ast_enum! { @build_conversions $name [ $($maybe_a)* ] { $($rest)* } } ); (@build_conversions $name:ident [ $($maybe_a:tt)* ] { $(#[$attr:meta])* $variant:ident( $($member:tt)* ), $($rest:tt)* } ) => ( __ast_enum! { @build_conversions $name [ $($maybe_a)* ] { $variant(ast_types! { @extract_type $($member)* }), $($rest)* } } ); (@build_parse { $name:ident [ $($maybe_a:tt)* ] $($member:ty)* } { } ) => ( impl<'a> $crate::Parse<'a> for $name<$($maybe_a)*> { parser!(alt!( $(weedle!($member) => {From::from})|* )); } ); (@build_parse { $($prev:tt)* } { $variant:ident($member:ty), $($rest:tt)* } ) => ( __ast_enum! { @build_parse { $($prev)* $member } { $($rest)* } } ); (@build_parse { $($prev:tt)* } { $(#[$attr:meta])* $variant:ident( $($member:tt)* ), $($rest:tt)* } ) => ( __ast_enum! { @build_parse { $($prev)* ast_types! { @extract_type $($member)* } } { $($rest)* } } ); (@launch_pad $(#[$attr:meta])* $name:ident [ $($maybe_a:tt)* ] { $($variants:tt)* } ) => ( __ast_enum! { @build_enum_decl { $(#[$attr])* $name [ $($maybe_a)* ] } { $($variants)* } } __ast_enum! { @build_sub_types { $($variants)* } } __ast_enum! { @build_conversions $name [ $($maybe_a)* ] { $($variants)* } } __ast_enum! { @build_parse { $name [ $($maybe_a)* ] } { $($variants)* } } ); } #[cfg(test)] macro_rules! test { (@arg $parsed:ident) => {}; (@arg $parsed:ident $($lhs:tt).+ == $rhs:expr; $($rest:tt)*) => { assert_eq!($parsed.$($lhs).+, $rhs); test!(@arg $parsed $($rest)*); }; (@arg $parsed:ident $($lhs:tt).+(); $($rest:tt)*) => { assert!($parsed.$($lhs).+()); test!(@arg $parsed $($rest)*); }; (@arg $parsed:ident $($lhs:tt).+() == $rhs:expr; $($rest:tt)*) => { assert_eq!($parsed.$($lhs).+(), $rhs); test!(@arg $parsed $($rest)*); }; (err $name:ident { $raw:expr => $typ:ty }) => { #[test] fn $name() { <$typ>::parse($crate::nom::types::CompleteStr($raw)).unwrap_err(); } }; ($name:ident { $raw:expr => $rem:expr; $typ:ty => $val:expr }) => { #[test] fn $name() { let (rem, parsed) = <$typ>::parse($crate::nom::types::CompleteStr($raw)).unwrap(); assert_eq!(rem, $crate::nom::types::CompleteStr($rem)); assert_eq!(parsed, $val); } }; ($name:ident { $raw:expr => $rem:expr; $typ:ty; $($body:tt)* }) => { #[test] fn $name() { let (_rem, _parsed) = <$typ>::parse($crate::nom::types::CompleteStr($raw)).unwrap(); assert_eq!(_rem, $crate::nom::types::CompleteStr($rem)); test!(@arg _parsed $($body)*); } }; } #[cfg(test)] macro_rules! test_variants { ($struct_:ident { $( $variant:ident == $value:expr ),* $(,)* }) => { #[allow(non_snake_case)] mod $struct_ { $( mod $variant { use $crate::types::*; use $crate::nom::types::CompleteStr; #[test] fn should_parse() { let (rem, parsed) = $struct_::parse(CompleteStr($value)).unwrap(); assert_eq!(rem, CompleteStr("")); match parsed { $struct_::$variant(_) => {}, _ => { panic!("Failed to parse"); } } } } )* } }; } weedle-0.10.0/src/mixin.rs010066400017500001750000000036611351137446600135610ustar0000000000000000use argument::ArgumentList; use attribute::ExtendedAttributeList; use common::{Identifier, Parenthesized}; use interface::{ConstMember, StringifierMember}; use types::{AttributedType, ReturnType}; /// Parses the members declarations of a mixin pub type MixinMembers<'a> = Vec>; ast_types! { /// Parses one of the variants of a mixin member enum MixinMember<'a> { Const(ConstMember<'a>), /// Parses `[attributes]? stringifier? returntype identifier? (( args ));` /// /// (( )) means ( ) chars Operation(struct OperationMixinMember<'a> { attributes: Option>, stringifier: Option, return_type: ReturnType<'a>, identifier: Option>, args: Parenthesized>, semi_colon: term!(;), }), /// Parses `[attributes]? stringifier? readonly? attribute attributedtype identifier;` Attribute(struct AttributeMixinMember<'a> { attributes: Option>, stringifier: Option, readonly: Option, attribute: term!(attribute), type_: AttributedType<'a>, identifier: Identifier<'a>, semi_colon: term!(;), }), Stringifier(StringifierMember<'a>), } } #[cfg(test)] mod test { use super::*; use Parse; test!(should_parse_attribute_mixin_member { "stringifier readonly attribute short name;" => ""; AttributeMixinMember; attributes.is_none(); stringifier.is_some(); readonly.is_some(); identifier.0 == "name"; }); test!(should_parse_operation_mixin_member { "short fnName(long a);" => ""; OperationMixinMember; attributes.is_none(); stringifier.is_none(); identifier.is_some(); }); } weedle-0.10.0/src/namespace.rs010066400017500001750000000031211351137446600143600ustar0000000000000000use argument::ArgumentList; use attribute::ExtendedAttributeList; use common::{Identifier, Parenthesized}; use types::{AttributedType, ReturnType}; /// Parses namespace members declaration pub type NamespaceMembers<'a> = Vec>; ast_types! { /// Parses namespace member declaration enum NamespaceMember<'a> { /// Parses `[attributes]? returntype identifier? (( args ));` /// /// (( )) means ( ) chars Operation(struct OperationNamespaceMember<'a> { attributes: Option>, return_type: ReturnType<'a>, identifier: Option>, args: Parenthesized>, semi_colon: term!(;), }), /// Parses `[attribute]? readonly attributetype type identifier;` Attribute(struct AttributeNamespaceMember<'a> { attributes: Option>, readonly: term!(readonly), attribute: term!(attribute), type_: AttributedType<'a>, identifier: Identifier<'a>, semi_colon: term!(;), }), } } #[cfg(test)] mod test { use super::*; use Parse; test!(should_parse_attribute_namespace_member { "readonly attribute short name;" => ""; AttributeNamespaceMember; attributes.is_none(); identifier.0 == "name"; }); test!(should_parse_operation_namespace_member { "short (long a, long b);" => ""; OperationNamespaceMember; attributes.is_none(); identifier.is_none(); }); } weedle-0.10.0/src/term.rs010066400017500001750000000420761351137446600134070ustar0000000000000000macro_rules! generate_terms { ($( $(#[$attr:meta])* $typ:ident => $tok:expr ),*) => { $( $(#[$attr])* #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct $typ; impl<'a> $crate::Parse<'a> for $typ { parser!(do_parse!( ws!(tag!($tok)) >> ($typ) )); } )* }; } macro_rules! ident_tag ( ($i:expr, $tok:expr) => ( { match tag!($i, $tok) { Err(e) => Err(e), Ok((i, o)) => { let mut res = Ok((i, o)); if let Some(&c) = i.as_bytes().first() { use $crate::nom::{Context, Err, ErrorKind, is_alphanumeric}; if is_alphanumeric(c) || c == b'_' || c == b'-' { res = Err(Err::Error(Context::Code($i, ErrorKind::Tag::))); } } res }, } } ) ); macro_rules! generate_terms_for_names { ($( $(#[$attr:meta])* $typ:ident => $tok:expr,)*) => { $( $(#[$attr])* #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct $typ; impl<'a> $crate::Parse<'a> for $typ { parser!(do_parse!( ws!(ident_tag!($tok)) >> ($typ) )); } )* }; } generate_terms! { /// Represents the terminal symbol `(` OpenParen => "(", /// Represents the terminal symbol `)` CloseParen => ")", /// Represents the terminal symbol `[` OpenBracket => "[", /// Represents the terminal symbol `]` CloseBracket => "]", /// Represents the terminal symbol `{` OpenBrace => "{", /// Represents the terminal symbol `}` CloseBrace => "}", /// Represents the terminal symbol `,` Comma => ",", /// Represents the terminal symbol `-` Minus => "-", /// Represents the terminal symbol `.` Dot => ".", /// Represents the terminal symbol `...` Ellipsis => "...", /// Represents the terminal symbol `:` Colon => ":", /// Represents the terminal symbol `;` SemiColon => ";", /// Represents the terminal symbol `<` LessThan => "<", /// Represents the terminal symbol `=` Assign => "=", /// Represents the terminal symbol `>` GreaterThan => ">", /// Represents the terminal symbol `?` QMark => "?" } generate_terms_for_names! { /// Represents the terminal symbol `or` Or => "or", /// Represents the terminal symbol `optional` Optional => "optional", /// Represents the terminal symbol `attribute` Attribute => "attribute", /// Represents the terminal symbol `callback` Callback => "callback", /// Represents the terminal symbol `const` Const => "const", /// Represents the terminal symbol `deleter` Deleter => "deleter", /// Represents the terminal symbol `dictionary` Dictionary => "dictionary", /// Represents the terminal symbol `enum` Enum => "enum", /// Represents the terminal symbol `getter` Getter => "getter", /// Represents the terminal symbol `includes` Includes => "includes", /// Represents the terminal symbol `inherit` Inherit => "inherit", /// Represents the terminal symbol `interface` Interface => "interface", /// Represents the terminal symbol `iterable` Iterable => "iterable", /// Represents the terminal symbol `maplike` Maplike => "maplike", /// Represents the terminal symbol `namespace` Namespace => "namespace", /// Represents the terminal symbol `partial` Partial => "partial", /// Represents the terminal symbol `required` Required => "required", /// Represents the terminal symbol `setlike` Setlike => "setlike", /// Represents the terminal symbol `setter` Setter => "setter", /// Represents the terminal symbol `static` Static => "static", /// Represents the terminal symbol `stringifier` Stringifier => "stringifier", /// Represents the terminal symbol `typedef` Typedef => "typedef", /// Represents the terminal symbol `unrestricted` Unrestricted => "unrestricted", /// Represents the terminal symbol `symbol` Symbol => "symbol", /// Represents the terminal symbol `Infinity` NegInfinity => "-Infinity", /// Represents the terminal symbol `ByteString` ByteString => "ByteString", /// Represents the terminal symbol `DOMString` DOMString => "DOMString", /// Represents the terminal symbol `FrozenArray` FrozenArray => "FrozenArray", /// Represents the terminal symbol `Infinity` Infinity => "Infinity", /// Represents the terminal symbol `NaN` NaN => "NaN", /// Represents the terminal symbol `USVString` USVString => "USVString", /// Represents the terminal symbol `any` Any => "any", /// Represents the terminal symbol `boolean` Boolean => "boolean", /// Represents the terminal symbol `byte` Byte => "byte", /// Represents the terminal symbol `double` Double => "double", /// Represents the terminal symbol `false` False => "false", /// Represents the terminal symbol `float` Float => "float", /// Represents the terminal symbol `long` Long => "long", /// Represents the terminal symbol `null` Null => "null", /// Represents the terminal symbol `object` Object => "object", /// Represents the terminal symbol `octet` Octet => "octet", /// Represents the terminal symbol `sequence` Sequence => "sequence", /// Represents the terminal symbol `short` Short => "short", /// Represents the terminal symbol `true` True => "true", /// Represents the terminal symbol `unsigned` Unsigned => "unsigned", /// Represents the terminal symbol `void` Void => "void", /// Represents the terminal symbol `record` Record => "record", /// Represents the terminal symbol `ArrayBuffer` ArrayBuffer => "ArrayBuffer", /// Represents the terminal symbol `DataView` DataView => "DataView", /// Represents the terminal symbol `Int8Array` Int8Array => "Int8Array", /// Represents the terminal symbol `Int16Array` Int16Array => "Int16Array", /// Represents the terminal symbol `Int32Array` Int32Array => "Int32Array", /// Represents the terminal symbol `Uint8Array` Uint8Array => "Uint8Array", /// Represents the terminal symbol `Uint16Array` Uint16Array => "Uint16Array", /// Represents the terminal symbol `Uint32Array` Uint32Array => "Uint32Array", /// Represents the terminal symbol `Uint8ClampedArray` Uint8ClampedArray => "Uint8ClampedArray", /// Represents the terminal symbol `Float32Array` Float32Array => "Float32Array", /// Represents the terminal symbol `Float64Array` Float64Array => "Float64Array", /// Represents the terminal symbol `ArrayBufferView` ArrayBufferView => "ArrayBufferView", /// Represents the terminal symbol `BufferSource BufferSource => "BufferSource", /// Represents the terminal symbol `Promise` Promise => "Promise", /// Represents the terminal symbol `Error` Error => "Error", /// Represents the terminal symbol `readonly` ReadOnly => "readonly", /// Represents the terminal symbol `mixin` Mixin => "mixin", /// Represents the terminal symbol `implements` Implements => "implements", /// Represents the terminal symbol `legacycaller` LegacyCaller => "legacycaller", } #[macro_export] macro_rules! term { (OpenParen) => { $crate::term::OpenParen }; (CloseParen) => { $crate::term::CloseParen }; (OpenBracket) => { $crate::term::OpenBracket }; (CloseBracket) => { $crate::term::CloseBracket }; (OpenBrace) => { $crate::term::OpenBrace }; (CloseBrace) => { $crate::term::CloseBrace }; (,) => { $crate::term::Comma }; (-) => { $crate::term::Minus }; (.) => { $crate::term::Dot }; (...) => { $crate::term::Ellipsis }; (:) => { $crate::term::Colon }; (;) => { $crate::term::SemiColon }; (<) => { $crate::term::LessThan }; (=) => { $crate::term::Assign }; (>) => { $crate::term::GreaterThan }; (?) => { $crate::term::QMark }; (or) => { $crate::term::Or }; (optional) => { $crate::term::Optional }; (attribute) => { $crate::term::Attribute }; (callback) => { $crate::term::Callback }; (const) => { $crate::term::Const }; (deleter) => { $crate::term::Deleter }; (dictionary) => { $crate::term::Dictionary }; (enum) => { $crate::term::Enum }; (getter) => { $crate::term::Getter }; (includes) => { $crate::term::Includes }; (inherit) => { $crate::term::Inherit }; (interface) => { $crate::term::Interface }; (iterable) => { $crate::term::Iterable }; (maplike) => { $crate::term::Maplike }; (namespace) => { $crate::term::Namespace }; (partial) => { $crate::term::Partial }; (required) => { $crate::term::Required }; (setlike) => { $crate::term::Setlike }; (setter) => { $crate::term::Setter }; (static) => { $crate::term::Static }; (stringifier) => { $crate::term::Stringifier }; (typedef) => { $crate::term::Typedef }; (unrestricted) => { $crate::term::Unrestricted }; (symbol) => { $crate::term::Symbol }; (- Infinity) => { $crate::term::NegInfinity }; (ByteString) => { $crate::term::ByteString }; (DOMString) => { $crate::term::DOMString }; (FrozenArray) => { $crate::term::FrozenArray }; (Infinity) => { $crate::term::Infinity }; (NaN) => { $crate::term::NaN }; (USVString) => { $crate::term::USVString }; (any) => { $crate::term::Any }; (boolean) => { $crate::term::Boolean }; (byte) => { $crate::term::Byte }; (double) => { $crate::term::Double }; (false) => { $crate::term::False }; (float) => { $crate::term::Float }; (long) => { $crate::term::Long }; (null) => { $crate::term::Null }; (object) => { $crate::term::Object }; (octet) => { $crate::term::Octet }; (sequence) => { $crate::term::Sequence }; (short) => { $crate::term::Short }; (true) => { $crate::term::True }; (unsigned) => { $crate::term::Unsigned }; (void) => { $crate::term::Void }; (record) => { $crate::term::Record }; (ArrayBuffer) => { $crate::term::ArrayBuffer }; (DataView) => { $crate::term::DataView }; (Int8Array) => { $crate::term::Int8Array }; (Int16Array) => { $crate::term::Int16Array }; (Int32Array) => { $crate::term::Int32Array }; (Uint8Array) => { $crate::term::Uint8Array }; (Uint16Array) => { $crate::term::Uint16Array }; (Uint32Array) => { $crate::term::Uint32Array }; (Uint8ClampedArray) => { $crate::term::Uint8ClampedArray }; (Float32Array) => { $crate::term::Float32Array }; (Float64Array) => { $crate::term::Float64Array }; (ArrayBufferView) => { $crate::term::ArrayBufferView }; (BufferSource) => { $crate::term::BufferSource }; (Promise) => { $crate::term::Promise }; (Error) => { $crate::term::Error }; (readonly) => { $crate::term::ReadOnly }; (mixin) => { $crate::term::Mixin }; (implements) => { $crate::term::Implements }; (legacycaller) => { $crate::term::LegacyCaller }; } #[cfg(test)] mod test { macro_rules! generate_tests { ($($m:ident, $typ:ident, $string:expr;)*) => { $( mod $m { use super::super::$typ; use Parse; use nom::types::CompleteStr; #[test] fn should_parse() { let (rem, parsed) = $typ::parse(CompleteStr(concat!($string))).unwrap(); assert_eq!(rem, CompleteStr("")); assert_eq!(parsed, $typ); } #[test] fn should_parse_with_preceding_spaces() { let (rem, parsed) = $typ::parse(CompleteStr(concat!(" ", $string))).unwrap(); assert_eq!(rem, CompleteStr("")); assert_eq!(parsed, $typ); } #[test] fn should_parse_with_succeeding_spaces() { let (rem, parsed) = $typ::parse(CompleteStr(concat!($string, " "))).unwrap(); assert_eq!(rem, CompleteStr("")); assert_eq!(parsed, $typ); } #[test] fn should_parse_with_surrounding_spaces() { let (rem, parsed) = $typ::parse(CompleteStr(concat!(" ", $string, " "))).unwrap(); assert_eq!(rem, CompleteStr("")); assert_eq!(parsed, $typ); } #[test] fn should_parse_if_anything_next() { let (rem, parsed) = $typ::parse(CompleteStr(concat!($string, " anything"))).unwrap(); assert_eq!(rem, CompleteStr("anything")); assert_eq!(parsed, $typ); } } )* }; } generate_tests![ openparen, OpenParen, "("; closeparen, CloseParen, ")"; openbracket, OpenBracket, "["; closebracket, CloseBracket, "]"; openbrace, OpenBrace, "{"; closebrace, CloseBrace, "}"; comma, Comma, ","; minus, Minus, "-"; dot, Dot, "."; ellipsis, Ellipsis, "..."; colon, Colon, ":"; semicolon, SemiColon, ";"; lessthan, LessThan, "<"; assign, Assign, "="; greaterthan, GreaterThan, ">"; qmark, QMark, "?"; or, Or, "or"; optional, Optional, "optional"; attribute, Attribute, "attribute"; callback, Callback, "callback"; const_, Const, "const"; deleter, Deleter, "deleter"; dictionary, Dictionary, "dictionary"; enum_, Enum, "enum"; getter, Getter, "getter"; includes, Includes, "includes"; inherit, Inherit, "inherit"; interface, Interface, "interface"; iterable, Iterable, "iterable"; maplike, Maplike, "maplike"; namespace, Namespace, "namespace"; partial, Partial, "partial"; required, Required, "required"; setlike, Setlike, "setlike"; setter, Setter, "setter"; static_, Static, "static"; stringifier, Stringifier, "stringifier"; typedef, Typedef, "typedef"; unrestricted, Unrestricted, "unrestricted"; symbol, Symbol, "symbol"; neginfinity, NegInfinity, "-Infinity"; bytestring, ByteString, "ByteString"; domstring, DOMString, "DOMString"; frozenarray, FrozenArray, "FrozenArray"; infinity, Infinity, "Infinity"; nan, NaN, "NaN"; usvstring, USVString, "USVString"; any, Any, "any"; boolean, Boolean, "boolean"; byte, Byte, "byte"; double, Double, "double"; false_, False, "false"; float, Float, "float"; long, Long, "long"; null, Null, "null"; object, Object, "object"; octet, Octet, "octet"; sequence, Sequence, "sequence"; short, Short, "short"; true_, True, "true"; unsigned, Unsigned, "unsigned"; void, Void, "void"; record, Record, "record"; arraybuffer, ArrayBuffer, "ArrayBuffer"; dataview, DataView, "DataView"; int8array, Int8Array, "Int8Array"; int16array, Int16Array, "Int16Array"; int32array, Int32Array, "Int32Array"; uint8array, Uint8Array, "Uint8Array"; uint16array, Uint16Array, "Uint16Array"; uint32array, Uint32Array, "Uint32Array"; uint8clampedarray, Uint8ClampedArray, "Uint8ClampedArray"; float32array, Float32Array, "Float32Array"; float64array, Float64Array, "Float64Array"; promise, Promise, "Promise"; error, Error, "Error"; implements, Implements, "implements"; legacycaller, LegacyCaller, "legacycaller"; ]; } weedle-0.10.0/src/types.rs010066400017500001750000000246451351137446600136060ustar0000000000000000use attribute::ExtendedAttributeList; use common::{Generics, Identifier, Parenthesized, Punctuated}; use term; use Parse; /// Parses a union of types pub type UnionType<'a> = Parenthesized, term!(or)>>; ast_types! { /// Parses either single type or a union type enum Type<'a> { /// Parses one of the single types Single(enum SingleType<'a> { Any(term!(any)), NonAny(NonAnyType<'a>), }), Union(MayBeNull>), } // Parses any single non-any type enum NonAnyType<'a> { Promise(PromiseType<'a>), Integer(MayBeNull), FloatingPoint(MayBeNull), Boolean(MayBeNull), Byte(MayBeNull), Octet(MayBeNull), ByteString(MayBeNull), DOMString(MayBeNull), USVString(MayBeNull), Sequence(MayBeNull>), Object(MayBeNull), Symbol(MayBeNull), Error(MayBeNull), ArrayBuffer(MayBeNull), DataView(MayBeNull), Int8Array(MayBeNull), Int16Array(MayBeNull), Int32Array(MayBeNull), Uint8Array(MayBeNull), Uint16Array(MayBeNull), Uint32Array(MayBeNull), Uint8ClampedArray(MayBeNull), Float32Array(MayBeNull), Float64Array(MayBeNull), ArrayBufferView(MayBeNull), BufferSource(MayBeNull), FrozenArrayType(MayBeNull>), RecordType(MayBeNull>), Identifier(MayBeNull>), } /// Parses `sequence` struct SequenceType<'a> { sequence: term!(sequence), generics: Generics>>, } /// Parses `FrozenArray` struct FrozenArrayType<'a> { frozen_array: term!(FrozenArray), generics: Generics>>, } /// Parses a nullable type. Ex: `object | object??` /// /// `??` means an actual ? not an optional requirement #[derive(Copy)] struct MayBeNull where [T: Parse<'a>] { type_: T, q_mark: Option, } /// Parses a `Promise` type struct PromiseType<'a> { promise: term!(Promise), generics: Generics>>, } /// Parses `unsigned? short|long|(long long)` #[derive(Copy)] enum IntegerType { /// Parses `unsigned? long long` #[derive(Copy)] LongLong(struct LongLongType { unsigned: Option, long_long: (term!(long), term!(long)), }), /// Parses `unsigned? long` #[derive(Copy)] Long(struct LongType { unsigned: Option, long: term!(long), }), /// Parses `unsigned? short` #[derive(Copy)] Short(struct ShortType { unsigned: Option, short: term!(short), }), } /// Parses `unrestricted? float|double` #[derive(Copy)] enum FloatingPointType { /// Parses `unrestricted? float` #[derive(Copy)] Float(struct FloatType { unrestricted: Option, float: term!(float), }), /// Parses `unrestricted? double` #[derive(Copy)] Double(struct DoubleType { unrestricted: Option, double: term!(double), }), } /// Parses `record` struct RecordType<'a> { record: term!(record), generics: Generics<(StringType, term!(,), Box>)>, } /// Parses one of the string types `ByteString|DOMString|USVString` #[derive(Copy)] enum StringType { Byte(term!(ByteString)), DOM(term!(DOMString)), USV(term!(USVString)), } /// Parses one of the member of a union type enum UnionMemberType<'a> { Single(AttributedNonAnyType<'a>), Union(MayBeNull>), } /// Parses a const type enum ConstType<'a> { Integer(MayBeNull), FloatingPoint(MayBeNull), Boolean(MayBeNull), Byte(MayBeNull), Octet(MayBeNull), Identifier(MayBeNull>), } /// Parses the return type which may be `void` or any given Type enum ReturnType<'a> { Void(term!(void)), Type(Type<'a>), } /// Parses `[attributes]? type` struct AttributedType<'a> { attributes: Option>, type_: Type<'a>, } /// Parses `[attributes]? type` where the type is a single non-any type struct AttributedNonAnyType<'a> { attributes: Option>, type_: NonAnyType<'a>, } } #[cfg(test)] mod test { use super::*; test!(should_parse_may_be_null { "short" => ""; MayBeNull<::types::IntegerType>; q_mark.is_none(); }); test!(should_parse_nullable { "short?" => ""; MayBeNull<::types::IntegerType>; q_mark.is_some(); }); test_variants!( ReturnType { Void == "void", Type == "any", } ); test_variants!( ConstType { Integer == "short", FloatingPoint == "float", Boolean == "boolean", Byte == "byte", Octet == "octet", Identifier == "name", } ); test_variants!( NonAnyType { Promise == "Promise", Integer == "long", FloatingPoint == "float", Boolean == "boolean", Byte == "byte", Octet == "octet", ByteString == "ByteString", DOMString == "DOMString", USVString == "USVString", Sequence == "sequence", Object == "object", Symbol == "symbol", Error == "Error", ArrayBuffer == "ArrayBuffer", DataView == "DataView", Int8Array == "Int8Array", Int16Array == "Int16Array", Int32Array == "Int32Array", Uint8Array == "Uint8Array", Uint16Array == "Uint16Array", Uint32Array == "Uint32Array", Uint8ClampedArray == "Uint8ClampedArray", Float32Array == "Float32Array", Float64Array == "Float64Array", ArrayBufferView == "ArrayBufferView", BufferSource == "BufferSource", FrozenArrayType == "FrozenArray", RecordType == "record", Identifier == "mango" } ); test_variants!( UnionMemberType { Single == "byte", Union == "([Clamp] unsigned long or byte)" } ); test_variants!( StringType { DOM == "DOMString", USV == "USVString", Byte == "ByteString" } ); test!(should_parse_record_type { "record" => ""; RecordType; }); test!(should_parse_double_type { "double" => ""; DoubleType; }); test!(should_parse_float_type { "float" => ""; FloatType; }); test_variants!( FloatingPointType { Float == "float", Double == "double" } ); test!(should_parse_long_long_type { "long long" => ""; LongLongType; }); test!(should_parse_long_type { "long" => ""; LongType; }); test!(should_parse_short_type { "short" => ""; ShortType; }); test_variants!( IntegerType { Short == "short", Long == "long", LongLong == "long long" } ); test!(should_parse_promise_type { "Promise" => ""; PromiseType; }); test!(should_parse_frozen_array_type { "FrozenArray" => ""; FrozenArrayType; }); test!(should_parse_sequence_type { "sequence" => ""; SequenceType; }); test_variants!( SingleType { Any == "any", NonAny == "Promise", } ); test_variants!( Type { Single == "short", Union == "(short or float)" } ); test!(should_parse_attributed_type { "[Named] short" => ""; AttributedType; attributes.is_some(); }); test!(should_parse_type_as_identifier { "DOMStringMap" => // if type is not parsed as identifier, it is parsed as `DOMString` and 'Map' is left ""; ::types::Type; }); #[test] fn should_parse_union_member_type_attributed_union() { use crate::types::UnionMemberType; let (rem, parsed) = UnionMemberType::parse(nom::types::CompleteStr("([Clamp] byte or [Named] byte)")) .unwrap(); assert_eq!(rem, nom::types::CompleteStr("")); match parsed { UnionMemberType::Union(MayBeNull { type_: Parenthesized { body: Punctuated { list, .. }, .. }, .. }) => { assert_eq!(list.len(), 2); match list[0] { UnionMemberType::Single(AttributedNonAnyType { ref attributes, .. }) => { assert!(attributes.is_some()); } _ => { panic!("Failed to parse list[0] attributes"); } }; match list[1] { UnionMemberType::Single(AttributedNonAnyType { ref attributes, .. }) => { assert!(attributes.is_some()); } _ => { panic!("Failed to parse list[1] attributes"); } }; } _ => { panic!("Failed to parse"); } } } } weedle-0.10.0/src/whitespace.rs010066400017500001750000000016061346706361600145700ustar0000000000000000use {CompleteStr, IResult}; pub fn sp(input: CompleteStr) -> IResult { recognize!( input, many0!( alt!( do_parse!(tag!("//") >> take_until!("\n") >> char!('\n') >> (())) | map!( take_while1!(|c| c == '\t' || c == '\n' || c == '\r' || c == ' '), |_| () ) | do_parse!( tag!("/*") >> take_until!("*/") >> tag!("*/") >> (()) ) ) ) ) } /// ws! also ignores line & block comments macro_rules! ws ( ($i:expr, $($args:tt)*) => ({ use $crate::whitespace::sp; do_parse!($i, sp >> s: $($args)* >> sp >> (s) ) }); ); weedle-0.10.0/tests/defs/dom.webidl010066400017500001750000000445361346706361600153420ustar0000000000000000[Constructor(DOMString type, optional EventInit eventInitDict), Exposed=(Window,Worker,AudioWorklet)] interface Event { readonly attribute DOMString type; readonly attribute EventTarget? target; readonly attribute EventTarget? srcElement; // historical readonly attribute EventTarget? currentTarget; sequence composedPath(); 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(); attribute boolean cancelBubble; // historical alias of .stopPropagation void stopImmediatePropagation(); readonly attribute boolean bubbles; readonly attribute boolean cancelable; attribute boolean returnValue; // historical void preventDefault(); readonly attribute boolean defaultPrevented; readonly attribute boolean composed; [Unforgeable] readonly attribute boolean isTrusted; readonly attribute DOMHighResTimeStamp timeStamp; void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // historical }; dictionary EventInit { boolean bubbles = false; boolean cancelable = false; boolean composed = false; }; [Constructor(DOMString type, optional CustomEventInit eventInitDict), Exposed=(Window,Worker)] interface CustomEvent : Event { readonly attribute any detail; void initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); }; dictionary CustomEventInit : EventInit { any detail = null; }; [Constructor, Exposed=(Window,Worker,AudioWorklet)] interface EventTarget { void addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options); void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options); boolean dispatchEvent(Event event); }; callback interface EventListener { void handleEvent(Event event); }; dictionary EventListenerOptions { boolean capture = false; }; dictionary AddEventListenerOptions : EventListenerOptions { boolean passive = false; boolean once = false; }; [Constructor, Exposed=(Window,Worker)] interface AbortController { [SameObject] readonly attribute AbortSignal signal; void abort(); }; [Exposed=(Window,Worker)] interface AbortSignal : EventTarget { readonly attribute boolean aborted; attribute EventHandler onabort; }; interface mixin NonElementParentNode { Element? getElementById(DOMString elementId); }; Document includes NonElementParentNode; DocumentFragment includes NonElementParentNode; interface mixin DocumentOrShadowRoot { }; Document includes DocumentOrShadowRoot; ShadowRoot includes DocumentOrShadowRoot; interface mixin ParentNode { [SameObject] readonly attribute HTMLCollection children; readonly attribute Element? firstElementChild; readonly attribute Element? lastElementChild; readonly attribute unsigned long childElementCount; [CEReactions, Unscopable] void prepend((Node or DOMString)... nodes); [CEReactions, Unscopable] void append((Node or DOMString)... nodes); Element? querySelector(DOMString selectors); [NewObject] NodeList querySelectorAll(DOMString selectors); }; Document includes ParentNode; DocumentFragment includes ParentNode; Element includes ParentNode; interface mixin NonDocumentTypeChildNode { readonly attribute Element? previousElementSibling; readonly attribute Element? nextElementSibling; }; Element includes NonDocumentTypeChildNode; CharacterData includes NonDocumentTypeChildNode; interface mixin ChildNode { [CEReactions, Unscopable] void before((Node or DOMString)... nodes); [CEReactions, Unscopable] void after((Node or DOMString)... nodes); [CEReactions, Unscopable] void replaceWith((Node or DOMString)... nodes); [CEReactions, Unscopable] void remove(); }; DocumentType includes ChildNode; Element includes ChildNode; CharacterData includes ChildNode; interface mixin Slotable { readonly attribute HTMLSlotElement? assignedSlot; }; Element includes Slotable; Text includes Slotable; [Exposed=Window] interface NodeList { getter Node? item(unsigned long index); readonly attribute unsigned long length; iterable; }; [Exposed=Window, LegacyUnenumerableNamedProperties] interface HTMLCollection { readonly attribute unsigned long length; getter Element? item(unsigned long index); getter Element? namedItem(DOMString name); }; [Constructor(MutationCallback callback), Exposed=Window] interface MutationObserver { void observe(Node target, optional MutationObserverInit options); void disconnect(); sequence takeRecords(); }; callback MutationCallback = void (sequence mutations, MutationObserver observer); dictionary MutationObserverInit { boolean childList = false; boolean attributes; boolean characterData; boolean subtree = false; boolean attributeOldValue; boolean characterDataOldValue; sequence attributeFilter; }; [Exposed=Window] interface MutationRecord { readonly attribute DOMString type; [SameObject] readonly attribute Node target; [SameObject] readonly attribute NodeList addedNodes; [SameObject] readonly attribute NodeList removedNodes; readonly attribute Node? previousSibling; readonly attribute Node? nextSibling; readonly attribute DOMString? attributeName; readonly attribute DOMString? attributeNamespace; readonly attribute DOMString? oldValue; }; [Exposed=Window] interface Node : EventTarget { const unsigned short ELEMENT_NODE = 1; const unsigned short ATTRIBUTE_NODE = 2; const unsigned short TEXT_NODE = 3; const unsigned short CDATA_SECTION_NODE = 4; 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 USVString baseURI; readonly attribute boolean isConnected; readonly attribute Document? ownerDocument; Node getRootNode(optional GetRootNodeOptions options); readonly attribute Node? parentNode; readonly attribute Element? parentElement; boolean hasChildNodes(); [SameObject] readonly attribute NodeList childNodes; readonly attribute Node? firstChild; readonly attribute Node? lastChild; readonly attribute Node? previousSibling; readonly attribute Node? nextSibling; [CEReactions] attribute DOMString? nodeValue; [CEReactions] attribute DOMString? textContent; [CEReactions] void normalize(); [CEReactions, NewObject] Node cloneNode(optional boolean deep = false); boolean isEqualNode(Node? otherNode); boolean isSameNode(Node? otherNode); // historical alias of === 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; unsigned short compareDocumentPosition(Node other); boolean contains(Node? other); DOMString? lookupPrefix(DOMString? namespace); DOMString? lookupNamespaceURI(DOMString? prefix); boolean isDefaultNamespace(DOMString? namespace); [CEReactions] Node insertBefore(Node node, Node? child); [CEReactions] Node appendChild(Node node); [CEReactions] Node replaceChild(Node node, Node child); [CEReactions] Node removeChild(Node child); }; dictionary GetRootNodeOptions { boolean composed = false; }; [Constructor, Exposed=Window] interface Document : Node { [SameObject] readonly attribute DOMImplementation implementation; readonly attribute USVString URL; readonly attribute USVString documentURI; readonly attribute USVString origin; readonly attribute DOMString compatMode; readonly attribute DOMString characterSet; readonly attribute DOMString charset; // historical alias of .characterSet readonly attribute DOMString inputEncoding; // historical alias of .characterSet readonly attribute DOMString contentType; readonly attribute DocumentType? doctype; readonly attribute Element? documentElement; HTMLCollection getElementsByTagName(DOMString qualifiedName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); [CEReactions, NewObject] Element createElement(DOMString localName, optional (DOMString or ElementCreationOptions) options); [CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options); [NewObject] DocumentFragment createDocumentFragment(); [NewObject] Text createTextNode(DOMString data); [NewObject] CDATASection createCDATASection(DOMString data); [NewObject] Comment createComment(DOMString data); [NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); [CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false); [CEReactions] Node adoptNode(Node node); [NewObject] Attr createAttribute(DOMString localName); [NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName); [NewObject] Event createEvent(DOMString interface); [NewObject] Range createRange(); // NodeFilter.SHOW_ALL = 0xFFFFFFFF [NewObject] NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); [NewObject] TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); }; [Exposed=Window] interface XMLDocument : Document {}; dictionary ElementCreationOptions { DOMString is; }; [Exposed=Window] interface DOMImplementation { [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId); [NewObject] XMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); [NewObject] Document createHTMLDocument(optional DOMString title); boolean hasFeature(); // useless; always returns true }; [Exposed=Window] interface DocumentType : Node { readonly attribute DOMString name; readonly attribute DOMString publicId; readonly attribute DOMString systemId; }; [Constructor, Exposed=Window] interface DocumentFragment : Node { }; [Exposed=Window] interface ShadowRoot : DocumentFragment { readonly attribute ShadowRootMode mode; readonly attribute Element host; }; enum ShadowRootMode { "open", "closed" }; [Exposed=Window] interface Element : Node { readonly attribute DOMString? namespaceURI; readonly attribute DOMString? prefix; readonly attribute DOMString localName; readonly attribute DOMString tagName; [CEReactions] attribute DOMString id; [CEReactions] attribute DOMString className; [SameObject, PutForwards=value] readonly attribute DOMTokenList classList; [CEReactions, Unscopable] attribute DOMString slot; boolean hasAttributes(); [SameObject] readonly attribute NamedNodeMap attributes; sequence getAttributeNames(); DOMString? getAttribute(DOMString qualifiedName); DOMString? getAttributeNS(DOMString? namespace, DOMString localName); [CEReactions] void setAttribute(DOMString qualifiedName, DOMString value); [CEReactions] void setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value); [CEReactions] void removeAttribute(DOMString qualifiedName); [CEReactions] void removeAttributeNS(DOMString? namespace, DOMString localName); boolean hasAttribute(DOMString qualifiedName); boolean hasAttributeNS(DOMString? namespace, DOMString localName); Attr? getAttributeNode(DOMString qualifiedName); Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName); [CEReactions] Attr? setAttributeNode(Attr attr); [CEReactions] Attr? setAttributeNodeNS(Attr attr); [CEReactions] Attr removeAttributeNode(Attr attr); ShadowRoot attachShadow(ShadowRootInit init); readonly attribute ShadowRoot? shadowRoot; Element? closest(DOMString selectors); boolean matches(DOMString selectors); boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches HTMLCollection getElementsByTagName(DOMString qualifiedName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // historical void insertAdjacentText(DOMString where, DOMString data); // historical }; dictionary ShadowRootInit { required ShadowRootMode mode; }; [Exposed=Window, LegacyUnenumerableNamedProperties] interface NamedNodeMap { readonly attribute unsigned long length; getter Attr? item(unsigned long index); getter Attr? getNamedItem(DOMString qualifiedName); Attr? getNamedItemNS(DOMString? namespace, DOMString localName); [CEReactions] Attr? setNamedItem(Attr attr); [CEReactions] Attr? setNamedItemNS(Attr attr); [CEReactions] Attr removeNamedItem(DOMString qualifiedName); [CEReactions] Attr removeNamedItemNS(DOMString? namespace, DOMString localName); }; [Exposed=Window] interface Attr : Node { readonly attribute DOMString? namespaceURI; readonly attribute DOMString? prefix; readonly attribute DOMString localName; readonly attribute DOMString name; [CEReactions] attribute DOMString value; readonly attribute Element? ownerElement; readonly attribute boolean specified; // useless; always returns true }; [Exposed=Window] interface CharacterData : Node { attribute [TreatNullAs=EmptyString] 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); }; [Constructor(optional DOMString data = ""), Exposed=Window] interface Text : CharacterData { [NewObject] Text splitText(unsigned long offset); readonly attribute DOMString wholeText; }; [Exposed=Window] interface CDATASection : Text { }; [Exposed=Window] interface ProcessingInstruction : CharacterData { readonly attribute DOMString target; }; [Constructor(optional DOMString data = ""), Exposed=Window] interface Comment : CharacterData { }; [Exposed=Window] interface AbstractRange { readonly attribute Node startContainer; readonly attribute unsigned long startOffset; readonly attribute Node endContainer; readonly attribute unsigned long endOffset; readonly attribute boolean collapsed; }; [Exposed=Window] interface StaticRange : AbstractRange { }; [Constructor, Exposed=Window] interface Range : AbstractRange { readonly attribute Node commonAncestorContainer; void setStart(Node node, unsigned long offset); void setEnd(Node node, unsigned long offset); void setStartBefore(Node node); void setStartAfter(Node node); void setEndBefore(Node node); void setEndAfter(Node node); void collapse(optional boolean toStart = false); void selectNode(Node node); void selectNodeContents(Node node); 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); [CEReactions] void deleteContents(); [CEReactions, NewObject] DocumentFragment extractContents(); [CEReactions, NewObject] DocumentFragment cloneContents(); [CEReactions] void insertNode(Node node); [CEReactions] void surroundContents(Node newParent); [NewObject] Range cloneRange(); void detach(); boolean isPointInRange(Node node, unsigned long offset); short comparePoint(Node node, unsigned long offset); boolean intersectsNode(Node node); stringifier; }; [Exposed=Window] interface NodeIterator { [SameObject] 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(); }; [Exposed=Window] interface TreeWalker { [SameObject] 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(); }; [Exposed=Window] 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; const unsigned long SHOW_TEXT = 0x4; const unsigned long SHOW_CDATA_SECTION = 0x8; 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); }; [Exposed=Window] interface DOMTokenList { readonly attribute unsigned long length; getter DOMString? item(unsigned long index); boolean contains(DOMString token); [CEReactions] void add(DOMString... tokens); [CEReactions] void remove(DOMString... tokens); [CEReactions] boolean toggle(DOMString token, optional boolean force); [CEReactions] boolean replace(DOMString token, DOMString newToken); boolean supports(DOMString token); [CEReactions] stringifier attribute DOMString value; iterable; }; weedle-0.10.0/tests/defs/html.webidl010066400017500001750000002326161351137446600155230ustar0000000000000000[Exposed=Window, LegacyUnenumerableNamedProperties] interface HTMLAllCollection { readonly attribute unsigned long length; getter Element (unsigned long index); getter (HTMLCollection or Element)? namedItem(DOMString name); (HTMLCollection or Element)? item(optional DOMString nameOrIndex); // Note: HTMLAllCollection objects have a custom [[Call]] internal method and an [[IsHTMLDDA]] internal slot. }; [Exposed=Window] interface HTMLFormControlsCollection : HTMLCollection { // inherits length and item() getter (RadioNodeList or Element)? namedItem(DOMString name); // shadows inherited namedItem() }; [Exposed=Window] interface RadioNodeList : NodeList { attribute DOMString value; }; [Exposed=Window] interface HTMLOptionsCollection : HTMLCollection { // inherits item(), namedItem() [CEReactions] attribute unsigned long length; // shadows inherited length [CEReactions] setter void (unsigned long index, HTMLOptionElement? option); [CEReactions] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); [CEReactions] void remove(long index); attribute long selectedIndex; }; [Exposed=(Window,Worker)] interface DOMStringList { readonly attribute unsigned long length; getter DOMString? item(unsigned long index); boolean contains(DOMString string); }; enum DocumentReadyState { "loading", "interactive", "complete" }; typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement; [OverrideBuiltins] partial interface Document { // resource metadata management [PutForwards=href, Unforgeable] readonly attribute Location? location; attribute USVString domain; readonly attribute USVString referrer; attribute USVString cookie; readonly attribute DOMString lastModified; readonly attribute DocumentReadyState readyState; // DOM tree accessors getter object (DOMString name); [CEReactions] attribute DOMString title; [CEReactions] attribute DOMString dir; [CEReactions] attribute HTMLElement? body; readonly attribute HTMLHeadElement? head; [SameObject] readonly attribute HTMLCollection images; [SameObject] readonly attribute HTMLCollection embeds; [SameObject] readonly attribute HTMLCollection plugins; [SameObject] readonly attribute HTMLCollection links; [SameObject] readonly attribute HTMLCollection forms; [SameObject] readonly attribute HTMLCollection scripts; NodeList getElementsByName(DOMString elementName); readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only // dynamic markup insertion [CEReactions] Document open(optional DOMString type, optional DOMString replace = ""); // type is ignored WindowProxy open(USVString url, DOMString name, DOMString features); [CEReactions] void close(); [CEReactions] void write(DOMString... text); [CEReactions] void writeln(DOMString... text); // user interaction readonly attribute WindowProxy? defaultView; readonly attribute Element? activeElement; boolean hasFocus(); [CEReactions] attribute DOMString designMode; [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); boolean queryCommandEnabled(DOMString commandId); boolean queryCommandIndeterm(DOMString commandId); boolean queryCommandState(DOMString commandId); boolean queryCommandSupported(DOMString commandId); DOMString queryCommandValue(DOMString commandId); // special event handler IDL attributes that only apply to Document objects [LenientThis] attribute EventHandler onreadystatechange; }; Document includes GlobalEventHandlers; Document includes DocumentAndElementEventHandlers; [Exposed=Window, HTMLConstructor] interface HTMLElement : Element { // metadata attributes [CEReactions] attribute DOMString title; [CEReactions] attribute DOMString lang; [CEReactions] attribute boolean translate; [CEReactions] attribute DOMString dir; // user interaction [CEReactions] attribute boolean hidden; void click(); [CEReactions] attribute DOMString accessKey; readonly attribute DOMString accessKeyLabel; [CEReactions] attribute boolean draggable; [CEReactions] attribute boolean spellcheck; [CEReactions] attribute DOMString autocapitalize; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString innerText; }; HTMLElement includes GlobalEventHandlers; HTMLElement includes DocumentAndElementEventHandlers; HTMLElement includes ElementContentEditable; // Note: intentionally not [HTMLConstructor] [Exposed=Window] interface HTMLUnknownElement : HTMLElement { }; interface mixin HTMLOrSVGElement { [SameObject] readonly attribute DOMStringMap dataset; attribute DOMString nonce; [CEReactions] attribute long tabIndex; void focus(optional FocusOptions options = {}); void blur(); }; HTMLElement includes HTMLOrSVGElement; SVGElement includes HTMLOrSVGElement; [Exposed=Window, OverrideBuiltins] interface DOMStringMap { getter DOMString (DOMString name); [CEReactions] setter void (DOMString name, DOMString value); [CEReactions] deleter void (DOMString name); }; [Exposed=Window, HTMLConstructor] interface HTMLHtmlElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLHeadElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLTitleElement : HTMLElement { [CEReactions] attribute DOMString text; }; [Exposed=Window, HTMLConstructor] interface HTMLBaseElement : HTMLElement { [CEReactions] attribute USVString href; [CEReactions] attribute DOMString target; }; [Exposed=Window, HTMLConstructor] interface HTMLLinkElement : HTMLElement { [CEReactions] attribute USVString href; [CEReactions] attribute DOMString? crossOrigin; [CEReactions] attribute DOMString rel; [CEReactions] attribute DOMString as; // (default "") [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; [CEReactions] attribute DOMString media; [CEReactions] attribute DOMString integrity; [CEReactions] attribute DOMString hreflang; [CEReactions] attribute DOMString type; [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes; [CEReactions] attribute DOMString referrerPolicy; }; HTMLLinkElement includes LinkStyle; [Exposed=Window, HTMLConstructor] interface HTMLMetaElement : HTMLElement { [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString httpEquiv; [CEReactions] attribute DOMString content; }; [Exposed=Window, HTMLConstructor] interface HTMLStyleElement : HTMLElement { [CEReactions] attribute DOMString media; }; HTMLStyleElement includes LinkStyle; [Exposed=Window, HTMLConstructor] interface HTMLBodyElement : HTMLElement {}; HTMLBodyElement includes WindowEventHandlers; [Exposed=Window, HTMLConstructor] interface HTMLHeadingElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLParagraphElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLHRElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLPreElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLQuoteElement : HTMLElement { [CEReactions] attribute USVString cite; }; [Exposed=Window, HTMLConstructor] interface HTMLOListElement : HTMLElement { [CEReactions] attribute boolean reversed; [CEReactions] attribute long start; [CEReactions] attribute DOMString type; }; [Exposed=Window, HTMLConstructor] interface HTMLUListElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLMenuElement : HTMLElement { }; [Exposed=Window, HTMLConstructor] interface HTMLLIElement : HTMLElement { [CEReactions] attribute long value; }; [Exposed=Window, HTMLConstructor] interface HTMLDListElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLDivElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLAnchorElement : HTMLElement { [CEReactions] attribute DOMString target; [CEReactions] attribute DOMString download; [CEReactions] attribute USVString ping; [CEReactions] attribute DOMString rel; [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; [CEReactions] attribute DOMString hreflang; [CEReactions] attribute DOMString type; [CEReactions] attribute DOMString text; [CEReactions] attribute DOMString referrerPolicy; }; HTMLAnchorElement includes HTMLHyperlinkElementUtils; [Exposed=Window, HTMLConstructor] interface HTMLDataElement : HTMLElement { [CEReactions] attribute DOMString value; }; [Exposed=Window, HTMLConstructor] interface HTMLTimeElement : HTMLElement { [CEReactions] attribute DOMString dateTime; }; [Exposed=Window, HTMLConstructor] interface HTMLSpanElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLBRElement : HTMLElement {}; interface mixin HTMLHyperlinkElementUtils { [CEReactions] stringifier attribute USVString href; readonly attribute USVString origin; [CEReactions] attribute USVString protocol; [CEReactions] attribute USVString username; [CEReactions] attribute USVString password; [CEReactions] attribute USVString host; [CEReactions] attribute USVString hostname; [CEReactions] attribute USVString port; [CEReactions] attribute USVString pathname; [CEReactions] attribute USVString search; [CEReactions] attribute USVString hash; }; [Exposed=Window, HTMLConstructor] interface HTMLModElement : HTMLElement { [CEReactions] attribute USVString cite; [CEReactions] attribute DOMString dateTime; }; [Exposed=Window, HTMLConstructor] interface HTMLPictureElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLSourceElement : HTMLElement { [CEReactions] attribute USVString src; [CEReactions] attribute DOMString type; [CEReactions] attribute USVString srcset; [CEReactions] attribute DOMString sizes; [CEReactions] attribute DOMString media; }; [Exposed=Window, HTMLConstructor, NamedConstructor=Image(optional unsigned long width, optional unsigned long height)] interface HTMLImageElement : HTMLElement { [CEReactions] attribute DOMString alt; [CEReactions] attribute USVString src; [CEReactions] attribute USVString srcset; [CEReactions] attribute DOMString sizes; [CEReactions] attribute DOMString? crossOrigin; [CEReactions] attribute DOMString useMap; [CEReactions] attribute boolean isMap; [CEReactions] attribute unsigned long width; [CEReactions] attribute unsigned long height; readonly attribute unsigned long naturalWidth; readonly attribute unsigned long naturalHeight; readonly attribute boolean complete; readonly attribute USVString currentSrc; [CEReactions] attribute DOMString referrerPolicy; [CEReactions] attribute DOMString decoding; Promise decode(); }; [Exposed=Window, HTMLConstructor] interface HTMLIFrameElement : HTMLElement { [CEReactions] attribute USVString src; [CEReactions] attribute DOMString srcdoc; [CEReactions] attribute DOMString name; [SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox; [CEReactions] attribute boolean allowFullscreen; [CEReactions] attribute boolean allowPaymentRequest; [CEReactions] attribute boolean allowUserMedia; [CEReactions] attribute DOMString width; [CEReactions] attribute DOMString height; [CEReactions] attribute DOMString referrerPolicy; readonly attribute Document? contentDocument; readonly attribute WindowProxy? contentWindow; Document? getSVGDocument(); }; [Exposed=Window, HTMLConstructor] interface HTMLEmbedElement : HTMLElement { [CEReactions] attribute USVString src; [CEReactions] attribute DOMString type; [CEReactions] attribute DOMString width; [CEReactions] attribute DOMString height; Document? getSVGDocument(); }; [Exposed=Window, HTMLConstructor] interface HTMLObjectElement : HTMLElement { [CEReactions] attribute USVString data; [CEReactions] attribute DOMString type; [CEReactions] attribute boolean typeMustMatch; [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString useMap; readonly attribute HTMLFormElement? form; [CEReactions] attribute DOMString width; [CEReactions] attribute DOMString height; readonly attribute Document? contentDocument; readonly attribute WindowProxy? contentWindow; Document? getSVGDocument(); readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); void setCustomValidity(DOMString error); }; [Exposed=Window, HTMLConstructor] interface HTMLParamElement : HTMLElement { [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString value; }; [Exposed=Window, HTMLConstructor] interface HTMLVideoElement : HTMLMediaElement { [CEReactions] attribute unsigned long width; [CEReactions] attribute unsigned long height; readonly attribute unsigned long videoWidth; readonly attribute unsigned long videoHeight; [CEReactions] attribute USVString poster; [CEReactions] attribute boolean playsInline; }; [Exposed=Window, HTMLConstructor, NamedConstructor=Audio(optional DOMString src)] interface HTMLAudioElement : HTMLMediaElement {}; [Exposed=Window, HTMLConstructor] interface HTMLTrackElement : HTMLElement { [CEReactions] attribute DOMString kind; [CEReactions] attribute USVString src; [CEReactions] attribute DOMString srclang; [CEReactions] attribute DOMString label; [CEReactions] 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; }; enum CanPlayTypeResult { "" /* empty string */, "maybe", "probably" }; typedef (MediaStream or MediaSource or Blob) MediaProvider; [Exposed=Window] interface HTMLMediaElement : HTMLElement { // error state readonly attribute MediaError? error; // network state [CEReactions] attribute USVString src; attribute MediaProvider? srcObject; readonly attribute USVString currentSrc; [CEReactions] 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; [CEReactions] attribute DOMString preload; readonly attribute TimeRanges buffered; void load(); CanPlayTypeResult 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; object getStartDate(); readonly attribute boolean paused; attribute double defaultPlaybackRate; attribute double playbackRate; readonly attribute TimeRanges played; readonly attribute TimeRanges seekable; readonly attribute boolean ended; [CEReactions] attribute boolean autoplay; [CEReactions] attribute boolean loop; Promise play(); void pause(); // controls [CEReactions] attribute boolean controls; attribute double volume; attribute boolean muted; [CEReactions] attribute boolean defaultMuted; // tracks [SameObject] readonly attribute AudioTrackList audioTracks; [SameObject] readonly attribute VideoTrackList videoTracks; [SameObject] readonly attribute TextTrackList textTracks; TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = ""); }; [Exposed=Window] 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; readonly attribute DOMString message; }; [Exposed=Window] 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; }; [Exposed=Window] interface AudioTrack { readonly attribute DOMString id; readonly attribute DOMString kind; readonly attribute DOMString label; readonly attribute DOMString language; attribute boolean enabled; }; [Exposed=Window] 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; }; [Exposed=Window] interface VideoTrack { readonly attribute DOMString id; readonly attribute DOMString kind; readonly attribute DOMString label; readonly attribute DOMString language; attribute boolean selected; }; [Exposed=Window] interface TextTrackList : EventTarget { readonly attribute unsigned long length; getter TextTrack (unsigned long index); TextTrack? getTrackById(DOMString id); attribute EventHandler onchange; attribute EventHandler onaddtrack; attribute EventHandler onremovetrack; }; enum TextTrackMode { "disabled", "hidden", "showing" }; enum TextTrackKind { "subtitles", "captions", "descriptions", "chapters", "metadata" }; [Exposed=Window] interface TextTrack : EventTarget { readonly attribute TextTrackKind kind; readonly attribute DOMString label; readonly attribute DOMString language; readonly attribute DOMString id; 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; }; [Exposed=Window] interface TextTrackCueList { readonly attribute unsigned long length; getter TextTrackCue (unsigned long index); TextTrackCue? getCueById(DOMString id); }; [Exposed=Window] interface TextTrackCue : EventTarget { readonly attribute TextTrack? track; attribute DOMString id; attribute double startTime; attribute double endTime; attribute boolean pauseOnExit; attribute EventHandler onenter; attribute EventHandler onexit; }; [Exposed=Window] interface TimeRanges { readonly attribute unsigned long length; double start(unsigned long index); double end(unsigned long index); }; [Exposed=Window, Constructor(DOMString type, optional TrackEventInit eventInitDict = {})] interface TrackEvent : Event { readonly attribute (VideoTrack or AudioTrack or TextTrack)? track; }; dictionary TrackEventInit : EventInit { (VideoTrack or AudioTrack or TextTrack)? track = null; }; [Exposed=Window, HTMLConstructor] interface HTMLMapElement : HTMLElement { [CEReactions] attribute DOMString name; [SameObject] readonly attribute HTMLCollection areas; }; [Exposed=Window, HTMLConstructor] interface HTMLAreaElement : HTMLElement { [CEReactions] attribute DOMString alt; [CEReactions] attribute DOMString coords; [CEReactions] attribute DOMString shape; [CEReactions] attribute DOMString target; [CEReactions] attribute DOMString download; [CEReactions] attribute USVString ping; [CEReactions] attribute DOMString rel; [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; [CEReactions] attribute DOMString referrerPolicy; }; HTMLAreaElement includes HTMLHyperlinkElementUtils; [Exposed=Window, HTMLConstructor] interface HTMLTableElement : HTMLElement { [CEReactions] attribute HTMLTableCaptionElement? caption; HTMLTableCaptionElement createCaption(); [CEReactions] void deleteCaption(); [CEReactions] attribute HTMLTableSectionElement? tHead; HTMLTableSectionElement createTHead(); [CEReactions] void deleteTHead(); [CEReactions] attribute HTMLTableSectionElement? tFoot; HTMLTableSectionElement createTFoot(); [CEReactions] void deleteTFoot(); [SameObject] readonly attribute HTMLCollection tBodies; HTMLTableSectionElement createTBody(); [SameObject] readonly attribute HTMLCollection rows; HTMLTableRowElement insertRow(optional long index = -1); [CEReactions] void deleteRow(long index); }; [Exposed=Window, HTMLConstructor] interface HTMLTableCaptionElement : HTMLElement {}; [Exposed=Window, HTMLConstructor] interface HTMLTableColElement : HTMLElement { [CEReactions] attribute unsigned long span; }; [Exposed=Window, HTMLConstructor] interface HTMLTableSectionElement : HTMLElement { [SameObject] readonly attribute HTMLCollection rows; HTMLTableRowElement insertRow(optional long index = -1); [CEReactions] void deleteRow(long index); }; [Exposed=Window, HTMLConstructor] interface HTMLTableRowElement : HTMLElement { readonly attribute long rowIndex; readonly attribute long sectionRowIndex; [SameObject] readonly attribute HTMLCollection cells; HTMLTableCellElement insertCell(optional long index = -1); [CEReactions] void deleteCell(long index); }; [Exposed=Window, HTMLConstructor] interface HTMLTableCellElement : HTMLElement { [CEReactions] attribute unsigned long colSpan; [CEReactions] attribute unsigned long rowSpan; [CEReactions] attribute DOMString headers; readonly attribute long cellIndex; [CEReactions] attribute DOMString scope; // only conforming for th elements [CEReactions] attribute DOMString abbr; // only conforming for th elements }; [Exposed=Window, OverrideBuiltins, LegacyUnenumerableNamedProperties, HTMLConstructor] interface HTMLFormElement : HTMLElement { [CEReactions] attribute DOMString acceptCharset; [CEReactions] attribute USVString action; [CEReactions] attribute DOMString autocomplete; [CEReactions] attribute DOMString enctype; [CEReactions] attribute DOMString encoding; [CEReactions] attribute DOMString method; [CEReactions] attribute DOMString name; [CEReactions] attribute boolean noValidate; [CEReactions] attribute DOMString target; [SameObject] readonly attribute HTMLFormControlsCollection elements; readonly attribute unsigned long length; getter Element (unsigned long index); getter (RadioNodeList or Element) (DOMString name); void submit(); [CEReactions] void reset(); boolean checkValidity(); boolean reportValidity(); }; [Exposed=Window, HTMLConstructor] interface HTMLLabelElement : HTMLElement { readonly attribute HTMLFormElement? form; [CEReactions] attribute DOMString htmlFor; readonly attribute HTMLElement? control; }; [Exposed=Window, HTMLConstructor] interface HTMLInputElement : HTMLElement { [CEReactions] attribute DOMString accept; [CEReactions] attribute DOMString alt; [CEReactions] attribute DOMString autocomplete; [CEReactions] attribute boolean autofocus; [CEReactions] attribute boolean defaultChecked; attribute boolean checked; [CEReactions] attribute DOMString dirName; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; attribute FileList? files; [CEReactions] attribute USVString formAction; [CEReactions] attribute DOMString formEnctype; [CEReactions] attribute DOMString formMethod; [CEReactions] attribute boolean formNoValidate; [CEReactions] attribute DOMString formTarget; [CEReactions] attribute unsigned long height; attribute boolean indeterminate; readonly attribute HTMLElement? list; [CEReactions] attribute DOMString max; [CEReactions] attribute long maxLength; [CEReactions] attribute DOMString min; [CEReactions] attribute long minLength; [CEReactions] attribute boolean multiple; [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString pattern; [CEReactions] attribute DOMString placeholder; [CEReactions] attribute boolean readOnly; [CEReactions] attribute boolean required; [CEReactions] attribute unsigned long size; [CEReactions] attribute USVString src; [CEReactions] attribute DOMString step; [CEReactions] attribute DOMString type; [CEReactions] attribute DOMString defaultValue; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString value; attribute object? valueAsDate; attribute unrestricted double valueAsNumber; [CEReactions] attribute unsigned long width; void stepUp(optional long n = 1); void stepDown(optional long n = 1); readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); 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 = "preserve"); void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); }; [Exposed=Window, HTMLConstructor] interface HTMLButtonElement : HTMLElement { [CEReactions] attribute boolean autofocus; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute USVString formAction; [CEReactions] attribute DOMString formEnctype; [CEReactions] attribute DOMString formMethod; [CEReactions] attribute boolean formNoValidate; [CEReactions] attribute DOMString formTarget; [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString type; [CEReactions] attribute DOMString value; readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); void setCustomValidity(DOMString error); readonly attribute NodeList labels; }; [Exposed=Window, HTMLConstructor] interface HTMLSelectElement : HTMLElement { [CEReactions] attribute DOMString autocomplete; [CEReactions] attribute boolean autofocus; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute boolean multiple; [CEReactions] attribute DOMString name; [CEReactions] attribute boolean required; [CEReactions] attribute unsigned long size; readonly attribute DOMString type; [SameObject] readonly attribute HTMLOptionsCollection options; [CEReactions] attribute unsigned long length; getter Element? item(unsigned long index); HTMLOptionElement? namedItem(DOMString name); [CEReactions] void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); [CEReactions] void remove(); // ChildNode overload [CEReactions] void remove(long index); [CEReactions] setter void (unsigned long index, HTMLOptionElement? option); [SameObject] readonly attribute HTMLCollection selectedOptions; attribute long selectedIndex; attribute DOMString value; readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); void setCustomValidity(DOMString error); readonly attribute NodeList labels; }; [Exposed=Window, HTMLConstructor] interface HTMLDataListElement : HTMLElement { [SameObject] readonly attribute HTMLCollection options; }; [Exposed=Window, HTMLConstructor] interface HTMLOptGroupElement : HTMLElement { [CEReactions] attribute boolean disabled; [CEReactions] attribute DOMString label; }; [Exposed=Window, HTMLConstructor, NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] interface HTMLOptionElement : HTMLElement { [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute DOMString label; [CEReactions] attribute boolean defaultSelected; attribute boolean selected; [CEReactions] attribute DOMString value; [CEReactions] attribute DOMString text; readonly attribute long index; }; [Exposed=Window, HTMLConstructor] interface HTMLTextAreaElement : HTMLElement { [CEReactions] attribute DOMString autocomplete; [CEReactions] attribute boolean autofocus; [CEReactions] attribute unsigned long cols; [CEReactions] attribute DOMString dirName; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute long maxLength; [CEReactions] attribute long minLength; [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString placeholder; [CEReactions] attribute boolean readOnly; [CEReactions] attribute boolean required; [CEReactions] attribute unsigned long rows; [CEReactions] attribute DOMString wrap; readonly attribute DOMString type; [CEReactions] attribute DOMString defaultValue; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString value; readonly attribute unsigned long textLength; readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); 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 = "preserve"); void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); }; [Exposed=Window, HTMLConstructor] interface HTMLOutputElement : HTMLElement { [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor; readonly attribute HTMLFormElement? form; [CEReactions] attribute DOMString name; readonly attribute DOMString type; [CEReactions] attribute DOMString defaultValue; [CEReactions] attribute DOMString value; readonly attribute boolean willValidate; readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); void setCustomValidity(DOMString error); readonly attribute NodeList labels; }; [Exposed=Window, HTMLConstructor] interface HTMLProgressElement : HTMLElement { [CEReactions] attribute double value; [CEReactions] attribute double max; readonly attribute double position; readonly attribute NodeList labels; }; [Exposed=Window, HTMLConstructor] interface HTMLMeterElement : HTMLElement { [CEReactions] attribute double value; [CEReactions] attribute double min; [CEReactions] attribute double max; [CEReactions] attribute double low; [CEReactions] attribute double high; [CEReactions] attribute double optimum; readonly attribute NodeList labels; }; [Exposed=Window, HTMLConstructor] interface HTMLFieldSetElement : HTMLElement { [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; [CEReactions] attribute DOMString name; readonly attribute DOMString type; [SameObject] readonly attribute HTMLCollection elements; readonly attribute boolean willValidate; [SameObject] readonly attribute ValidityState validity; readonly attribute DOMString validationMessage; boolean checkValidity(); boolean reportValidity(); void setCustomValidity(DOMString error); }; [Exposed=Window, HTMLConstructor] interface HTMLLegendElement : HTMLElement { readonly attribute HTMLFormElement? form; }; enum SelectionMode { "select", "start", "end", "preserve" // default }; [Exposed=Window] interface ValidityState { readonly attribute boolean valueMissing; readonly attribute boolean typeMismatch; readonly attribute boolean patternMismatch; readonly attribute boolean tooLong; readonly attribute boolean tooShort; readonly attribute boolean rangeUnderflow; readonly attribute boolean rangeOverflow; readonly attribute boolean stepMismatch; readonly attribute boolean badInput; readonly attribute boolean customError; readonly attribute boolean valid; }; [Exposed=Window, HTMLConstructor] interface HTMLDetailsElement : HTMLElement { [CEReactions] attribute boolean open; }; [Exposed=Window, HTMLConstructor] interface HTMLDialogElement : HTMLElement { [CEReactions] attribute boolean open; attribute DOMString returnValue; [CEReactions] void show(); [CEReactions] void showModal(); [CEReactions] void close(optional DOMString returnValue); }; [Exposed=Window, HTMLConstructor] interface HTMLScriptElement : HTMLElement { [CEReactions] attribute USVString src; [CEReactions] attribute DOMString type; [CEReactions] attribute boolean noModule; [CEReactions] attribute boolean async; [CEReactions] attribute boolean defer; [CEReactions] attribute DOMString? crossOrigin; [CEReactions] attribute DOMString text; [CEReactions] attribute DOMString integrity; }; [Exposed=Window, HTMLConstructor] interface HTMLTemplateElement : HTMLElement { readonly attribute DocumentFragment content; }; [Exposed=Window, HTMLConstructor] interface HTMLSlotElement : HTMLElement { [CEReactions] attribute DOMString name; sequence assignedNodes(optional AssignedNodesOptions options = {}); sequence assignedElements(optional AssignedNodesOptions options = {}); }; dictionary AssignedNodesOptions { boolean flatten = false; }; typedef (CanvasRenderingContext2D or ImageBitmapRenderingContext or WebGLRenderingContext) RenderingContext; [Exposed=Window, HTMLConstructor] interface HTMLCanvasElement : HTMLElement { [CEReactions] attribute unsigned long width; [CEReactions] attribute unsigned long height; RenderingContext? getContext(DOMString contextId, optional any options = null); USVString toDataURL(optional DOMString type, optional any quality); void toBlob(BlobCallback _callback, optional DOMString type, optional any quality); OffscreenCanvas transferControlToOffscreen(); }; callback BlobCallback = void (Blob? blob); typedef (HTMLImageElement or SVGImageElement) HTMLOrSVGImageElement; typedef (HTMLOrSVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas) CanvasImageSource; enum CanvasFillRule { "nonzero", "evenodd" }; dictionary CanvasRenderingContext2DSettings { boolean alpha = true; }; enum ImageSmoothingQuality { "low", "medium", "high" }; [Exposed=Window] interface CanvasRenderingContext2D { // back-reference to the canvas readonly attribute HTMLCanvasElement canvas; }; CanvasRenderingContext2D includes CanvasState; CanvasRenderingContext2D includes CanvasTransform; CanvasRenderingContext2D includes CanvasCompositing; CanvasRenderingContext2D includes CanvasImageSmoothing; CanvasRenderingContext2D includes CanvasFillStrokeStyles; CanvasRenderingContext2D includes CanvasShadowStyles; CanvasRenderingContext2D includes CanvasFilters; CanvasRenderingContext2D includes CanvasRect; CanvasRenderingContext2D includes CanvasDrawPath; CanvasRenderingContext2D includes CanvasUserInterface; CanvasRenderingContext2D includes CanvasText; CanvasRenderingContext2D includes CanvasDrawImage; CanvasRenderingContext2D includes CanvasImageData; CanvasRenderingContext2D includes CanvasPathDrawingStyles; CanvasRenderingContext2D includes CanvasTextDrawingStyles; CanvasRenderingContext2D includes CanvasPath; interface mixin CanvasState { // state void save(); // push state on state stack void restore(); // pop state stack and restore state }; interface mixin CanvasTransform { // transformations (default transform is the identity matrix) 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); [NewObject] DOMMatrix getTransform(); void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f); void setTransform(optional DOMMatrix2DInit transform = {}); void resetTransform(); }; interface mixin CanvasCompositing { // compositing attribute unrestricted double globalAlpha; // (default 1.0) attribute DOMString globalCompositeOperation; // (default source-over) }; interface mixin CanvasImageSmoothing { // image smoothing attribute boolean imageSmoothingEnabled; // (default true) attribute ImageSmoothingQuality imageSmoothingQuality; // (default low) }; interface mixin CanvasFillStrokeStyles { // colors and styles (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) 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(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition); }; interface mixin CanvasShadowStyles { // 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) }; interface mixin CanvasFilters { // filters attribute DOMString filter; // (default "none") }; interface mixin CanvasRect { // 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); }; interface mixin CanvasDrawPath { // path API (see also CanvasPath) void beginPath(); void fill(optional CanvasFillRule fillRule = "nonzero"); void fill(Path2D path, optional CanvasFillRule fillRule = "nonzero"); void stroke(); void stroke(Path2D path); void clip(optional CanvasFillRule fillRule = "nonzero"); void clip(Path2D path, optional CanvasFillRule fillRule = "nonzero"); void resetClip(); boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero"); boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero"); boolean isPointInStroke(unrestricted double x, unrestricted double y); boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); }; interface mixin CanvasUserInterface { void drawFocusIfNeeded(Element element); void drawFocusIfNeeded(Path2D path, Element element); void scrollPathIntoView(); void scrollPathIntoView(Path2D path); }; interface mixin CanvasText { // text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) 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); }; interface mixin CanvasDrawImage { // drawing images void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy); void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh); void drawImage(CanvasImageSource 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); }; interface mixin CanvasImageData { // pixel manipulation ImageData createImageData(long sw, long sh); ImageData createImageData(ImageData imagedata); ImageData getImageData(long sx, long sy, long sw, long sh); void putImageData(ImageData imagedata, long dx, long dy); void putImageData(ImageData imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight); }; enum CanvasLineCap { "butt", "round", "square" }; enum CanvasLineJoin { "round", "bevel", "miter" }; enum CanvasTextAlign { "start", "end", "left", "right", "center" }; enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" }; enum CanvasDirection { "ltr", "rtl", "inherit" }; interface mixin CanvasPathDrawingStyles { // line caps/joins attribute unrestricted double lineWidth; // (default 1) attribute CanvasLineCap lineCap; // (default "butt") attribute CanvasLineJoin lineJoin; // (default "miter") attribute unrestricted double miterLimit; // (default 10) // dashed lines void setLineDash(sequence segments); // default empty sequence getLineDash(); attribute unrestricted double lineDashOffset; }; interface mixin CanvasTextDrawingStyles { // text attribute DOMString font; // (default 10px sans-serif) attribute CanvasTextAlign textAlign; // (default: "start") attribute CanvasTextBaseline textBaseline; // (default: "alphabetic") attribute CanvasDirection direction; // (default: "inherit") }; interface mixin CanvasPath { // 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 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, optional boolean anticlockwise = false); }; [Exposed=(Window,Worker)] interface CanvasGradient { // opaque object void addColorStop(double offset, DOMString color); }; [Exposed=(Window,Worker)] interface CanvasPattern { // opaque object void setTransform(optional DOMMatrix2DInit transform = {}); }; [Exposed=Window] 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; }; [Constructor(unsigned long sw, unsigned long sh), Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh), Exposed=(Window,Worker), Serializable] interface ImageData { readonly attribute unsigned long width; readonly attribute unsigned long height; readonly attribute Uint8ClampedArray data; }; [Constructor(optional (Path2D or DOMString) path), Exposed=(Window,Worker)] interface Path2D { void addPath(Path2D path, optional DOMMatrix2DInit transform = {}); }; Path2D includes CanvasPath; [Exposed=Window] interface ImageBitmapRenderingContext { readonly attribute HTMLCanvasElement canvas; void transferFromImageBitmap(ImageBitmap? bitmap); }; dictionary ImageBitmapRenderingContextSettings { boolean alpha = true; }; typedef (OffscreenCanvasRenderingContext2D or WebGLRenderingContext) OffscreenRenderingContext; dictionary ImageEncodeOptions { DOMString type = "image/png"; unrestricted double quality = 1.0; }; enum OffscreenRenderingContextId { "2d", "webgl" }; [Constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height), Exposed=(Window,Worker), Transferable] interface OffscreenCanvas : EventTarget { attribute unsigned long long width; attribute unsigned long long height; OffscreenRenderingContext? getContext(OffscreenRenderingContextId contextId, optional any options = null); ImageBitmap transferToImageBitmap(); Promise convertToBlob(optional ImageEncodeOptions options = {}); }; [Exposed=(Window,Worker)] interface OffscreenCanvasRenderingContext2D { void commit(); readonly attribute OffscreenCanvas canvas; }; OffscreenCanvasRenderingContext2D includes CanvasState; OffscreenCanvasRenderingContext2D includes CanvasTransform; OffscreenCanvasRenderingContext2D includes CanvasCompositing; OffscreenCanvasRenderingContext2D includes CanvasImageSmoothing; OffscreenCanvasRenderingContext2D includes CanvasFillStrokeStyles; OffscreenCanvasRenderingContext2D includes CanvasShadowStyles; OffscreenCanvasRenderingContext2D includes CanvasFilters; OffscreenCanvasRenderingContext2D includes CanvasRect; OffscreenCanvasRenderingContext2D includes CanvasDrawPath; OffscreenCanvasRenderingContext2D includes CanvasDrawImage; OffscreenCanvasRenderingContext2D includes CanvasImageData; OffscreenCanvasRenderingContext2D includes CanvasPathDrawingStyles; OffscreenCanvasRenderingContext2D includes CanvasPath; [Exposed=Window] interface CustomElementRegistry { [CEReactions] void define(DOMString name, Function constructor, optional ElementDefinitionOptions options = {}); any get(DOMString name); Promise whenDefined(DOMString name); [CEReactions] void upgrade(Node root); }; dictionary ElementDefinitionOptions { DOMString extends; }; dictionary FocusOptions { boolean preventScroll = false; }; interface mixin ElementContentEditable { [CEReactions] attribute DOMString contentEditable; readonly attribute boolean isContentEditable; [CEReactions] attribute DOMString inputMode; }; [Exposed=Window, Constructor] interface DataTransfer { attribute DOMString dropEffect; attribute DOMString effectAllowed; [SameObject] readonly attribute DataTransferItemList items; void setDragImage(Element image, long x, long y); /* old interface */ readonly attribute FrozenArray types; DOMString getData(DOMString format); void setData(DOMString format, DOMString data); void clearData(optional DOMString format); [SameObject] readonly attribute FileList files; }; [Exposed=Window] interface DataTransferItemList { readonly attribute unsigned long length; getter DataTransferItem (unsigned long index); DataTransferItem? add(DOMString data, DOMString type); DataTransferItem? add(File data); void remove(unsigned long index); void clear(); }; [Exposed=Window] interface DataTransferItem { readonly attribute DOMString kind; readonly attribute DOMString type; void getAsString(FunctionStringCallback? _callback); File? getAsFile(); }; callback FunctionStringCallback = void (DOMString data); [Exposed=Window, Constructor(DOMString type, optional DragEventInit eventInitDict = {})] interface DragEvent : MouseEvent { readonly attribute DataTransfer? dataTransfer; }; dictionary DragEventInit : MouseEventInit { DataTransfer? dataTransfer = null; }; [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties] 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; readonly attribute CustomElementRegistry customElements; [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(); readonly attribute boolean closed; 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 any opener; [Replaceable] readonly attribute WindowProxy? parent; readonly attribute Element? frameElement; WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = ""); getter object (DOMString name); // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic // object on the prototype chain. Indeed, this does not make the global object an exotic object. // Indexed access is taken care of by the WindowProxy exotic object. // the user agent readonly attribute Navigator navigator; readonly attribute ApplicationCache applicationCache; // user prompts void alert(); void alert(DOMString message); boolean confirm(optional DOMString message = ""); DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); void print(); unsigned long requestAnimationFrame(FrameRequestCallback callback); void cancelAnimationFrame(unsigned long handle); void postMessage(any message, USVString targetOrigin, optional sequence transfer = []); }; Window includes GlobalEventHandlers; Window includes WindowEventHandlers; callback FrameRequestCallback = void (DOMHighResTimeStamp time); [Exposed=Window] interface BarProp { readonly attribute boolean visible; }; enum ScrollRestoration { "auto", "manual" }; [Exposed=Window] interface History { readonly attribute unsigned long length; attribute ScrollRestoration scrollRestoration; readonly attribute any state; void go(optional long delta = 0); void back(); void forward(); void pushState(any data, DOMString title, optional USVString? url = null); void replaceState(any data, DOMString title, optional USVString? url = null); }; [Exposed=Window] interface Location { // but see also additional creation steps and overridden internal methods [Unforgeable] stringifier attribute USVString href; [Unforgeable] readonly attribute USVString origin; [Unforgeable] attribute USVString protocol; [Unforgeable] attribute USVString host; [Unforgeable] attribute USVString hostname; [Unforgeable] attribute USVString port; [Unforgeable] attribute USVString pathname; [Unforgeable] attribute USVString search; [Unforgeable] attribute USVString hash; [Unforgeable] void assign(USVString url); [Unforgeable] void replace(USVString url); [Unforgeable] void reload(); [Unforgeable, SameObject] readonly attribute DOMStringList ancestorOrigins; }; [Exposed=Window, Constructor(DOMString type, optional PopStateEventInit eventInitDict = {})] interface PopStateEvent : Event { readonly attribute any state; }; dictionary PopStateEventInit : EventInit { any state = null; }; [Exposed=Window, Constructor(DOMString type, optional HashChangeEventInit eventInitDict = {})] interface HashChangeEvent : Event { readonly attribute USVString oldURL; readonly attribute USVString newURL; }; dictionary HashChangeEventInit : EventInit { USVString oldURL = ""; USVString newURL = ""; }; [Exposed=Window, Constructor(DOMString type, optional PageTransitionEventInit eventInitDict = {})] interface PageTransitionEvent : Event { readonly attribute boolean persisted; }; dictionary PageTransitionEventInit : EventInit { boolean persisted = false; }; [Exposed=Window] interface BeforeUnloadEvent : Event { attribute DOMString returnValue; }; [Exposed=Window] 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; }; interface mixin NavigatorOnLine { readonly attribute boolean onLine; }; [Constructor(DOMString type, optional ErrorEventInit eventInitDict = {}), Exposed=(Window,Worker)] interface ErrorEvent : Event { readonly attribute DOMString message; readonly attribute USVString filename; readonly attribute unsigned long lineno; readonly attribute unsigned long colno; readonly attribute any error; }; dictionary ErrorEventInit : EventInit { DOMString message = ""; USVString filename = ""; unsigned long lineno = 0; unsigned long colno = 0; any error = null; }; [Constructor(DOMString type, PromiseRejectionEventInit eventInitDict), Exposed=(Window,Worker)] interface PromiseRejectionEvent : Event { readonly attribute Promise promise; readonly attribute any reason; }; dictionary PromiseRejectionEventInit : EventInit { required Promise promise; any reason; }; [TreatNonObjectAsNull] callback EventHandlerNonNull = any (Event event); typedef EventHandlerNonNull? EventHandler; [TreatNonObjectAsNull] callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long colno, optional any error); typedef OnErrorEventHandlerNonNull? OnErrorEventHandler; [TreatNonObjectAsNull] callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event); typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler; interface mixin GlobalEventHandlers { attribute EventHandler onabort; attribute EventHandler onauxclick; 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 ondragexit; 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 onloadend; attribute EventHandler onloadstart; attribute EventHandler onmousedown; [LenientThis] attribute EventHandler onmouseenter; [LenientThis] attribute EventHandler onmouseleave; attribute EventHandler onmousemove; attribute EventHandler onmouseout; attribute EventHandler onmouseover; attribute EventHandler onmouseup; attribute EventHandler onwheel; attribute EventHandler onpause; attribute EventHandler onplay; attribute EventHandler onplaying; attribute EventHandler onprogress; attribute EventHandler onratechange; attribute EventHandler onreset; attribute EventHandler onresize; attribute EventHandler onscroll; attribute EventHandler onsecuritypolicyviolation; attribute EventHandler onseeked; attribute EventHandler onseeking; attribute EventHandler onselect; attribute EventHandler onstalled; attribute EventHandler onsubmit; attribute EventHandler onsuspend; attribute EventHandler ontimeupdate; attribute EventHandler ontoggle; attribute EventHandler onvolumechange; attribute EventHandler onwaiting; }; interface mixin WindowEventHandlers { attribute EventHandler onafterprint; attribute EventHandler onbeforeprint; attribute OnBeforeUnloadEventHandler onbeforeunload; attribute EventHandler onhashchange; attribute EventHandler onlanguagechange; attribute EventHandler onmessage; attribute EventHandler onmessageerror; attribute EventHandler onoffline; attribute EventHandler ononline; attribute EventHandler onpagehide; attribute EventHandler onpageshow; attribute EventHandler onpopstate; attribute EventHandler onrejectionhandled; attribute EventHandler onstorage; attribute EventHandler onunhandledrejection; attribute EventHandler onunload; }; interface mixin DocumentAndElementEventHandlers { attribute EventHandler oncopy; attribute EventHandler oncut; attribute EventHandler onpaste; }; typedef (DOMString or Function) TimerHandler; interface mixin WindowOrWorkerGlobalScope { [Replaceable] readonly attribute USVString origin; // base64 utility methods DOMString btoa(DOMString data); ByteString atob(DOMString data); // timers long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments); void clearTimeout(optional long handle = 0); long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments); void clearInterval(optional long handle = 0); // ImageBitmap Promise createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options = {}); Promise createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options = {}); }; Window includes WindowOrWorkerGlobalScope; WorkerGlobalScope includes WindowOrWorkerGlobalScope; [Exposed=Window] interface Navigator { // objects implementing this interface also implement the interfaces given below }; Navigator includes NavigatorID; Navigator includes NavigatorLanguage; Navigator includes NavigatorOnLine; Navigator includes NavigatorContentUtils; Navigator includes NavigatorCookies; Navigator includes NavigatorPlugins; Navigator includes NavigatorConcurrentHardware; interface mixin NavigatorID { readonly attribute DOMString appCodeName; // constant "Mozilla" readonly attribute DOMString appName; // constant "Netscape" readonly attribute DOMString appVersion; readonly attribute DOMString platform; readonly attribute DOMString product; // constant "Gecko" [Exposed=Window] readonly attribute DOMString productSub; readonly attribute DOMString userAgent; [Exposed=Window] readonly attribute DOMString vendor; [Exposed=Window] readonly attribute DOMString vendorSub; // constant "" }; partial interface NavigatorID { [Exposed=Window] boolean taintEnabled(); // constant false [Exposed=Window] readonly attribute DOMString oscpu; }; interface mixin NavigatorLanguage { readonly attribute DOMString language; readonly attribute FrozenArray languages; }; interface mixin NavigatorContentUtils { void registerProtocolHandler(DOMString scheme, USVString url, DOMString title); void unregisterProtocolHandler(DOMString scheme, USVString url); }; interface mixin NavigatorCookies { readonly attribute boolean cookieEnabled; }; interface mixin NavigatorPlugins { [SameObject] readonly attribute PluginArray plugins; [SameObject] readonly attribute MimeTypeArray mimeTypes; boolean javaEnabled(); }; [Exposed=Window, LegacyUnenumerableNamedProperties] interface PluginArray { void refresh(optional boolean reload = false); readonly attribute unsigned long length; getter Plugin? item(unsigned long index); getter Plugin? namedItem(DOMString name); }; [Exposed=Window, LegacyUnenumerableNamedProperties] interface MimeTypeArray { readonly attribute unsigned long length; getter MimeType? item(unsigned long index); getter MimeType? namedItem(DOMString name); }; [Exposed=Window, LegacyUnenumerableNamedProperties] interface Plugin { readonly attribute DOMString name; readonly attribute DOMString description; readonly attribute DOMString filename; readonly attribute unsigned long length; getter MimeType? item(unsigned long index); getter MimeType? namedItem(DOMString name); }; [Exposed=Window] interface MimeType { readonly attribute DOMString type; readonly attribute DOMString description; readonly attribute DOMString suffixes; // comma-separated readonly attribute Plugin enabledPlugin; }; [Exposed=(Window,Worker), Serializable, Transferable] interface ImageBitmap { readonly attribute unsigned long width; readonly attribute unsigned long height; void close(); }; typedef (CanvasImageSource or Blob or ImageData) ImageBitmapSource; enum ImageOrientation { "none", "flipY" }; enum PremultiplyAlpha { "none", "premultiply", "default" }; enum ColorSpaceConversion { "none", "default" }; enum ResizeQuality { "pixelated", "low", "medium", "high" }; dictionary ImageBitmapOptions { ImageOrientation imageOrientation = "none"; PremultiplyAlpha premultiplyAlpha = "default"; ColorSpaceConversion colorSpaceConversion = "default"; [EnforceRange] unsigned long resizeWidth; [EnforceRange] unsigned long resizeHeight; ResizeQuality resizeQuality = "low"; }; [Constructor(DOMString type, optional MessageEventInit eventInitDict = {}), Exposed=(Window,Worker,AudioWorklet)] interface MessageEvent : Event { readonly attribute any data; readonly attribute USVString origin; readonly attribute DOMString lastEventId; readonly attribute MessageEventSource? source; readonly attribute FrozenArray ports; void initMessageEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any data = null, optional USVString origin = "", optional DOMString lastEventId = "", optional MessageEventSource? source = null, optional sequence ports = []); }; dictionary MessageEventInit : EventInit { any data = null; USVString origin = ""; DOMString lastEventId = ""; MessageEventSource? source = null; sequence ports = []; }; typedef (WindowProxy or MessagePort or ServiceWorker) MessageEventSource; [Constructor(USVString url, optional EventSourceInit eventSourceInitDict = {}), Exposed=(Window,Worker)] interface EventSource : EventTarget { readonly attribute USVString 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(USVString url, optional (DOMString or sequence) protocols = []), Exposed=(Window,Worker)] interface WebSocket : EventTarget { readonly attribute USVString 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 long bufferedAmount; // networking attribute EventHandler onopen; attribute EventHandler onerror; attribute EventHandler onclose; readonly attribute DOMString extensions; readonly attribute DOMString protocol; void close(optional [Clamp] unsigned short code, optional USVString reason); // messaging attribute EventHandler onmessage; attribute BinaryType binaryType; void send(USVString data); void send(Blob data); void send(ArrayBuffer data); void send(ArrayBufferView data); }; [Constructor(DOMString type, optional CloseEventInit eventInitDict = {}), Exposed=(Window,Worker)] interface CloseEvent : Event { readonly attribute boolean wasClean; readonly attribute unsigned short code; readonly attribute USVString reason; }; dictionary CloseEventInit : EventInit { boolean wasClean = false; unsigned short code = 0; USVString reason = ""; }; [Constructor, Exposed=(Window,Worker)] interface MessageChannel { readonly attribute MessagePort port1; readonly attribute MessagePort port2; }; [Exposed=(Window,Worker,AudioWorklet), Transferable] interface MessagePort : EventTarget { void postMessage(any message, optional sequence transfer = []); void start(); void close(); // event handlers attribute EventHandler onmessage; attribute EventHandler onmessageerror; }; [Constructor(DOMString name), Exposed=(Window,Worker)] interface BroadcastChannel : EventTarget { readonly attribute DOMString name; void postMessage(any message); void close(); attribute EventHandler onmessage; attribute EventHandler onmessageerror; }; [Exposed=Worker] interface WorkerGlobalScope : EventTarget { readonly attribute WorkerGlobalScope self; readonly attribute WorkerLocation location; readonly attribute WorkerNavigator navigator; void importScripts(USVString... urls); attribute OnErrorEventHandler onerror; attribute EventHandler onlanguagechange; attribute EventHandler onoffline; attribute EventHandler ononline; attribute EventHandler onrejectionhandled; attribute EventHandler onunhandledrejection; }; [Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker] interface DedicatedWorkerGlobalScope : WorkerGlobalScope { [Replaceable] readonly attribute DOMString name; void postMessage(any message, optional sequence transfer = []); void close(); attribute EventHandler onmessage; attribute EventHandler onmessageerror; }; [Global=(Worker,SharedWorker),Exposed=SharedWorker] interface SharedWorkerGlobalScope : WorkerGlobalScope { [Replaceable] readonly attribute DOMString name; void close(); attribute EventHandler onconnect; }; interface mixin AbstractWorker { attribute EventHandler onerror; }; [Constructor(USVString scriptURL, optional WorkerOptions options = {}), Exposed=(Window,Worker)] interface Worker : EventTarget { void terminate(); void postMessage(any message, optional sequence transfer = []); attribute EventHandler onmessage; attribute EventHandler onmessageerror; }; dictionary WorkerOptions { WorkerType type = "classic"; RequestCredentials credentials = "omit"; // credentials is only used if type is "module" DOMString name = ""; }; enum WorkerType { "classic", "module" }; Worker includes AbstractWorker; [Constructor(USVString scriptURL, optional (DOMString or WorkerOptions) options = {}), Exposed=(Window,Worker)] interface SharedWorker : EventTarget { readonly attribute MessagePort port; }; SharedWorker includes AbstractWorker; interface mixin NavigatorConcurrentHardware { readonly attribute unsigned long long hardwareConcurrency; }; [Exposed=Worker] interface WorkerNavigator {}; WorkerNavigator includes NavigatorID; WorkerNavigator includes NavigatorLanguage; WorkerNavigator includes NavigatorOnLine; WorkerNavigator includes NavigatorConcurrentHardware; [Exposed=Worker] interface WorkerLocation { stringifier readonly attribute USVString href; readonly attribute USVString origin; readonly attribute USVString protocol; readonly attribute USVString host; readonly attribute USVString hostname; readonly attribute USVString port; readonly attribute USVString pathname; readonly attribute USVString search; readonly attribute USVString hash; }; [Exposed=Window] interface Storage { readonly attribute unsigned long length; DOMString? key(unsigned long index); getter DOMString? getItem(DOMString key); setter void setItem(DOMString key, DOMString value); deleter void removeItem(DOMString key); void clear(); }; interface mixin WindowSessionStorage { readonly attribute Storage sessionStorage; }; Window includes WindowSessionStorage; interface mixin WindowLocalStorage { readonly attribute Storage localStorage; }; Window includes WindowLocalStorage; [Exposed=Window, Constructor(DOMString type, optional StorageEventInit eventInitDict = {})] interface StorageEvent : Event { readonly attribute DOMString? key; readonly attribute DOMString? oldValue; readonly attribute DOMString? newValue; readonly attribute USVString url; readonly attribute Storage? storageArea; }; dictionary StorageEventInit : EventInit { DOMString? key = null; DOMString? oldValue = null; DOMString? newValue = null; USVString url = ""; Storage? storageArea = null; }; [Exposed=Window, HTMLConstructor] interface HTMLMarqueeElement : HTMLElement { [CEReactions] attribute DOMString behavior; [CEReactions] attribute DOMString bgColor; [CEReactions] attribute DOMString direction; [CEReactions] attribute DOMString height; [CEReactions] attribute unsigned long hspace; [CEReactions] attribute long loop; [CEReactions] attribute unsigned long scrollAmount; [CEReactions] attribute unsigned long scrollDelay; [CEReactions] attribute boolean trueSpeed; [CEReactions] attribute unsigned long vspace; [CEReactions] attribute DOMString width; attribute EventHandler onbounce; attribute EventHandler onfinish; attribute EventHandler onstart; void start(); void stop(); }; [Exposed=Window, HTMLConstructor] interface HTMLFrameSetElement : HTMLElement { [CEReactions] attribute DOMString cols; [CEReactions] attribute DOMString rows; }; HTMLFrameSetElement includes WindowEventHandlers; [Exposed=Window, HTMLConstructor] interface HTMLFrameElement : HTMLElement { [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString scrolling; [CEReactions] attribute USVString src; [CEReactions] attribute DOMString frameBorder; [CEReactions] attribute USVString longDesc; [CEReactions] attribute boolean noResize; readonly attribute Document? contentDocument; readonly attribute WindowProxy? contentWindow; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString marginHeight; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString marginWidth; }; partial interface HTMLAnchorElement { [CEReactions] attribute DOMString coords; [CEReactions] attribute DOMString charset; [CEReactions] attribute DOMString name; [CEReactions] attribute DOMString rev; [CEReactions] attribute DOMString shape; }; partial interface HTMLAreaElement { [CEReactions] attribute boolean noHref; }; partial interface HTMLBodyElement { [CEReactions] attribute [TreatNullAs=EmptyString] DOMString text; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString link; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString vLink; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString aLink; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; [CEReactions] attribute DOMString background; }; partial interface HTMLBRElement { [CEReactions] attribute DOMString clear; }; partial interface HTMLTableCaptionElement { [CEReactions] attribute DOMString align; }; partial interface HTMLTableColElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString ch; [CEReactions] attribute DOMString chOff; [CEReactions] attribute DOMString vAlign; [CEReactions] attribute DOMString width; }; [Exposed=Window, HTMLConstructor] interface HTMLDirectoryElement : HTMLElement { [CEReactions] attribute boolean compact; }; partial interface HTMLDivElement { [CEReactions] attribute DOMString align; }; partial interface HTMLDListElement { [CEReactions] attribute boolean compact; }; partial interface HTMLEmbedElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString name; }; [Exposed=Window, HTMLConstructor] interface HTMLFontElement : HTMLElement { [CEReactions] attribute [TreatNullAs=EmptyString] DOMString color; [CEReactions] attribute DOMString face; [CEReactions] attribute DOMString size; }; partial interface HTMLHeadingElement { [CEReactions] attribute DOMString align; }; partial interface HTMLHRElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString color; [CEReactions] attribute boolean noShade; [CEReactions] attribute DOMString size; [CEReactions] attribute DOMString width; }; partial interface HTMLHtmlElement { [CEReactions] attribute DOMString version; }; partial interface HTMLIFrameElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString scrolling; [CEReactions] attribute DOMString frameBorder; [CEReactions] attribute USVString longDesc; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString marginHeight; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString marginWidth; }; partial interface HTMLImageElement { [CEReactions] attribute DOMString name; [CEReactions] attribute USVString lowsrc; [CEReactions] attribute DOMString align; [CEReactions] attribute unsigned long hspace; [CEReactions] attribute unsigned long vspace; [CEReactions] attribute USVString longDesc; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString border; }; partial interface HTMLInputElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString useMap; }; partial interface HTMLLegendElement { [CEReactions] attribute DOMString align; }; partial interface HTMLLIElement { [CEReactions] attribute DOMString type; }; partial interface HTMLLinkElement { [CEReactions] attribute DOMString charset; [CEReactions] attribute DOMString rev; [CEReactions] attribute DOMString target; }; partial interface HTMLMenuElement { [CEReactions] attribute boolean compact; }; partial interface HTMLMetaElement { [CEReactions] attribute DOMString scheme; }; partial interface HTMLObjectElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString archive; [CEReactions] attribute DOMString code; [CEReactions] attribute boolean declare; [CEReactions] attribute unsigned long hspace; [CEReactions] attribute DOMString standby; [CEReactions] attribute unsigned long vspace; [CEReactions] attribute DOMString codeBase; [CEReactions] attribute DOMString codeType; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString border; }; partial interface HTMLOListElement { [CEReactions] attribute boolean compact; }; partial interface HTMLParagraphElement { [CEReactions] attribute DOMString align; }; partial interface HTMLParamElement { [CEReactions] attribute DOMString type; [CEReactions] attribute DOMString valueType; }; partial interface HTMLPreElement { [CEReactions] attribute long width; }; partial interface HTMLStyleElement { [CEReactions] attribute DOMString type; }; partial interface HTMLScriptElement { [CEReactions] attribute DOMString charset; [CEReactions] attribute DOMString event; [CEReactions] attribute DOMString htmlFor; }; partial interface HTMLTableElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString border; [CEReactions] attribute DOMString frame; [CEReactions] attribute DOMString rules; [CEReactions] attribute DOMString summary; [CEReactions] attribute DOMString width; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString cellPadding; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString cellSpacing; }; partial interface HTMLTableSectionElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString ch; [CEReactions] attribute DOMString chOff; [CEReactions] attribute DOMString vAlign; }; partial interface HTMLTableCellElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString axis; [CEReactions] attribute DOMString height; [CEReactions] attribute DOMString width; [CEReactions] attribute DOMString ch; [CEReactions] attribute DOMString chOff; [CEReactions] attribute boolean noWrap; [CEReactions] attribute DOMString vAlign; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; }; partial interface HTMLTableRowElement { [CEReactions] attribute DOMString align; [CEReactions] attribute DOMString ch; [CEReactions] attribute DOMString chOff; [CEReactions] attribute DOMString vAlign; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; }; partial interface HTMLUListElement { [CEReactions] attribute boolean compact; [CEReactions] attribute DOMString type; }; partial interface Document { [CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString linkColor; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString vlinkColor; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString alinkColor; [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; [SameObject] readonly attribute HTMLCollection anchors; [SameObject] readonly attribute HTMLCollection applets; void clear(); void captureEvents(); void releaseEvents(); [SameObject] readonly attribute HTMLAllCollection all; }; partial interface Window { void captureEvents(); void releaseEvents(); [Replaceable, SameObject] readonly attribute External external; }; [Exposed=Window, NoInterfaceObject] interface External { void AddSearchProvider(); void IsSearchProviderInstalled(); }; weedle-0.10.0/tests/defs/mediacapture-streams.webidl010066400017500001750000000163131351137446600206700ustar0000000000000000[Exposed=Window, Constructor, Constructor(MediaStream stream), Constructor(sequence tracks)] interface MediaStream : EventTarget { readonly attribute DOMString id; sequence getAudioTracks(); sequence getVideoTracks(); sequence getTracks(); MediaStreamTrack? getTrackById(DOMString trackId); void addTrack(MediaStreamTrack track); void removeTrack(MediaStreamTrack track); MediaStream clone(); readonly attribute boolean active; attribute EventHandler onaddtrack; attribute EventHandler onremovetrack; }; [Exposed=Window] interface MediaStreamTrack : EventTarget { readonly attribute DOMString kind; readonly attribute DOMString id; readonly attribute DOMString label; attribute boolean enabled; readonly attribute boolean muted; attribute EventHandler onmute; attribute EventHandler onunmute; readonly attribute MediaStreamTrackState readyState; attribute EventHandler onended; MediaStreamTrack clone(); void stop(); MediaTrackCapabilities getCapabilities(); MediaTrackConstraints getConstraints(); MediaTrackSettings getSettings(); Promise applyConstraints(optional MediaTrackConstraints constraints = {}); }; enum MediaStreamTrackState { "live", "ended" }; dictionary MediaTrackSupportedConstraints { boolean width = true; boolean height = true; boolean aspectRatio = true; boolean frameRate = true; boolean facingMode = true; boolean resizeMode = true; boolean volume = true; boolean sampleRate = true; boolean sampleSize = true; boolean echoCancellation = true; boolean autoGainControl = true; boolean noiseSuppression = true; boolean latency = true; boolean channelCount = true; boolean deviceId = true; boolean groupId = true; }; dictionary MediaTrackCapabilities { ULongRange width; ULongRange height; DoubleRange aspectRatio; DoubleRange frameRate; sequence facingMode; sequence resizeMode; DoubleRange volume; ULongRange sampleRate; ULongRange sampleSize; sequence echoCancellation; sequence autoGainControl; sequence noiseSuppression; DoubleRange latency; ULongRange channelCount; DOMString deviceId; DOMString groupId; }; dictionary MediaTrackConstraints : MediaTrackConstraintSet { sequence advanced; }; dictionary MediaTrackConstraintSet { ConstrainULong width; ConstrainULong height; ConstrainDouble aspectRatio; ConstrainDouble frameRate; ConstrainDOMString facingMode; ConstrainDOMString resizeMode; ConstrainDouble volume; ConstrainULong sampleRate; ConstrainULong sampleSize; ConstrainBoolean echoCancellation; ConstrainBoolean autoGainControl; ConstrainBoolean noiseSuppression; ConstrainDouble latency; ConstrainULong channelCount; ConstrainDOMString deviceId; ConstrainDOMString groupId; }; dictionary MediaTrackSettings { long width; long height; double aspectRatio; double frameRate; DOMString facingMode; DOMString resizeMode; double volume; long sampleRate; long sampleSize; boolean echoCancellation; boolean autoGainControl; boolean noiseSuppression; double latency; long channelCount; DOMString deviceId; DOMString groupId; }; enum VideoFacingModeEnum { "user", "environment", "left", "right" }; enum VideoResizeModeEnum { "none", "crop-and-scale" }; [Exposed=Window, Constructor(DOMString type, MediaStreamTrackEventInit eventInitDict)] interface MediaStreamTrackEvent : Event { [SameObject] readonly attribute MediaStreamTrack track; }; dictionary MediaStreamTrackEventInit : EventInit { required MediaStreamTrack track; }; partial interface Navigator { [SameObject, SecureContext] readonly attribute MediaDevices mediaDevices; }; [Exposed=Window, SecureContext] interface MediaDevices : EventTarget { attribute EventHandler ondevicechange; Promise> enumerateDevices(); }; [Exposed=Window, SecureContext] interface MediaDeviceInfo { readonly attribute DOMString deviceId; readonly attribute MediaDeviceKind kind; readonly attribute DOMString label; readonly attribute DOMString groupId; [Default] object toJSON(); }; enum MediaDeviceKind { "audioinput", "audiooutput", "videoinput" }; [Exposed=Window] interface InputDeviceInfo : MediaDeviceInfo { MediaTrackCapabilities getCapabilities(); }; partial interface Navigator { [SecureContext] void getUserMedia(MediaStreamConstraints constraints, NavigatorUserMediaSuccessCallback successCallback, NavigatorUserMediaErrorCallback errorCallback); }; partial interface MediaDevices { MediaTrackSupportedConstraints getSupportedConstraints(); Promise getUserMedia(optional MediaStreamConstraints constraints = {}); }; dictionary MediaStreamConstraints { (boolean or MediaTrackConstraints) video = false; (boolean or MediaTrackConstraints) audio = false; }; callback NavigatorUserMediaSuccessCallback = void (MediaStream stream); callback NavigatorUserMediaErrorCallback = void (MediaStreamError error); typedef object MediaStreamError; dictionary DoubleRange { double max; double min; }; dictionary ConstrainDoubleRange : DoubleRange { double exact; double ideal; }; dictionary ULongRange { [Clamp] unsigned long max; [Clamp] unsigned long min; }; dictionary ConstrainULongRange : ULongRange { [Clamp] unsigned long exact; [Clamp] unsigned long ideal; }; dictionary ConstrainBooleanParameters { boolean exact; boolean ideal; }; dictionary ConstrainDOMStringParameters { (DOMString or sequence) exact; (DOMString or sequence) ideal; }; typedef ([Clamp] unsigned long or ConstrainULongRange) ConstrainULong; typedef (double or ConstrainDoubleRange) ConstrainDouble; typedef (boolean or ConstrainBooleanParameters) ConstrainBoolean; typedef (DOMString or sequence or ConstrainDOMStringParameters) ConstrainDOMString; dictionary Capabilities { }; dictionary Settings { }; dictionary ConstraintSet { }; dictionary Constraints : ConstraintSet { sequence advanced; }; weedle-0.10.0/tests/webidl.rs010066400017500001750000000015211346706361600142510ustar0000000000000000extern crate weedle; use std::fs; use std::io::Read; fn read_file(path: &str) -> String { let mut file = fs::File::open(path).unwrap(); let mut file_content = String::new(); file.read_to_string(&mut file_content).unwrap(); file_content } #[test] pub fn should_parse_dom_webidl() { let content = read_file("./tests/defs/dom.webidl"); let parsed = weedle::parse(&content).unwrap(); assert_eq!(parsed.len(), 62); } #[test] fn should_parse_html_webidl() { let content = read_file("./tests/defs/html.webidl"); let parsed = weedle::parse(&content).unwrap(); assert_eq!(parsed.len(), 325); } #[test] fn should_parse_mediacapture_streams_webidl() { let content = read_file("./tests/defs/mediacapture-streams.webidl"); let parsed = weedle::parse(&content).unwrap(); assert_eq!(parsed.len(), 37); } weedle-0.10.0/.cargo_vcs_info.json0000644000000001120000000000000124100ustar00{ "git": { "sha1": "c8a26d11a785e66665e3108382b15a6fc9996305" } }