Implement WebIDL callback interfaces

This commit implements callback interfaces for WebIDL, the final WebIDL
construct that we were unconditionally ignoring! Callback interfaces are
implemented as dictionaries of callbacks. Single-operation callback interfaces
are also expanded when flattening to accept a `Function` as well, in accordance
with the WebIDL spec.

New features have been added to `web-sys` for all the new callback interface
types. Additionally the `EventTarget.webidl` was tweaked to not have
`EventListener?` as this is required for all functional usage and there's no
need to keep that sort of web browser compat here.

Closes #258
This commit is contained in:
Alex Crichton
2018-09-10 11:16:55 -07:00
parent 2cf82bc0b3
commit 8181f7fa95
9 changed files with 165 additions and 11 deletions

View File

@ -38,7 +38,10 @@ wasm-bindgen-futures = { path = '../futures', version = '0.2.21' }
AbortController = []
AbortSignal = []
AddEventListenerOptions = []
AesCbcParams = []
AesCtrParams = []
AesDerivedKeyParams = []
AesGcmParams = []
AesKeyAlgorithm = []
AesKeyGenParams = []
Algorithm = []
@ -289,10 +292,12 @@ Element = []
ElementCreationOptions = []
ElementDefinitionOptions = []
EndingTypes = []
ErrorCallback = []
ErrorEvent = []
ErrorEventInit = []
Event = []
EventInit = []
EventListener = []
EventListenerOptions = []
EventModifierInit = []
EventSource = []
@ -310,6 +315,7 @@ FetchReadableStreamReadDataArray = []
FetchReadableStreamReadDataDone = []
FetchState = []
File = []
FileCallback = []
FileList = []
FilePropertyBag = []
FileReader = []
@ -317,7 +323,9 @@ FileReaderSync = []
FileSystem = []
FileSystemDirectoryEntry = []
FileSystemDirectoryReader = []
FileSystemEntriesCallback = []
FileSystemEntry = []
FileSystemEntryCallback = []
FileSystemFileEntry = []
FileSystemFlags = []
FillMode = []
@ -602,6 +610,7 @@ NetworkCommandOptions = []
NetworkInformation = []
NetworkResultOptions = []
Node = []
NodeFilter = []
NodeIterator = []
NodeList = []
Notification = []
@ -611,6 +620,7 @@ NotificationEvent = []
NotificationEventInit = []
NotificationOptions = []
NotificationPermission = []
ObserverCallback = []
OfflineAudioCompletionEvent = []
OfflineAudioCompletionEventInit = []
OfflineAudioContext = []
@ -702,10 +712,13 @@ ProgressEventInit = []
PromiseRejectionEvent = []
PromiseRejectionEventInit = []
PublicKeyCredential = []
PublicKeyCredentialDescriptor = []
PublicKeyCredentialEntity = []
PublicKeyCredentialParameters = []
PublicKeyCredentialRequestOptions = []
PublicKeyCredentialRpEntity = []
PublicKeyCredentialType = []
PublicKeyCredentialUserEntity = []
PushEncryptionKeyName = []
PushEvent = []
PushEventInit = []
@ -768,6 +781,7 @@ RtcIceServer = []
RtcIceTransportPolicy = []
RtcIdentityAssertion = []
RtcIdentityAssertionResult = []
RtcIdentityProvider = []
RtcIdentityProviderDetails = []
RtcIdentityProviderOptions = []
RtcIdentityValidationResult = []
@ -1038,6 +1052,7 @@ VideoPlaybackQuality = []
VideoStreamTrack = []
VideoTrack = []
VideoTrackList = []
VoidCallback = []
VrDisplay = []
VrDisplayCapabilities = []
VrEye = []
@ -1170,6 +1185,7 @@ WorkerOptions = []
Worklet = []
WorkletGlobalScope = []
XPathExpression = []
XPathNsResolver = []
XPathResult = []
XmlDocument = []
XmlHttpRequest = []

View File

@ -29,12 +29,12 @@ interface EventTarget {
false. */
[Throws]
void addEventListener(DOMString type,
EventListener? listener,
EventListener listener,
optional (AddEventListenerOptions or boolean) options,
optional boolean? wantsUntrusted = null);
[Throws]
void removeEventListener(DOMString type,
EventListener? listener,
EventListener listener,
optional (EventListenerOptions or boolean) options);
[Throws, NeedsCallerType]
boolean dispatchEvent(Event event);