From e58bface921c67c37f17dc3a0773a092217dee99 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 5 Jun 2019 15:47:10 +0900 Subject: [PATCH] add UI Events types --- baselines/dom.generated.d.ts | 64 +++++++------- inputfiles/addedTypes.json | 31 ++++--- inputfiles/idl/UI Events.widl | 152 ++++++++++++++++++++++++++++++++++ inputfiles/idlSources.json | 4 + 4 files changed, 202 insertions(+), 49 deletions(-) create mode 100644 inputfiles/idl/UI Events.widl diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 7b1cfbc32..e00da6ef6 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -432,7 +432,6 @@ interface EventModifierInit extends UIEventInit { modifierFnLock?: boolean; modifierHyper?: boolean; modifierNumLock?: boolean; - modifierOS?: boolean; modifierScrollLock?: boolean; modifierSuper?: boolean; modifierSymbol?: boolean; @@ -546,6 +545,12 @@ interface ImageEncodeOptions { type?: string; } +interface InputEventInit extends UIEventInit { + data?: string | null; + inputType?: string; + isComposing?: boolean; +} + interface IntersectionObserverEntryInit { boundingClientRect: DOMRectInit; intersectionRatio: number; @@ -589,6 +594,7 @@ interface KeyAlgorithm { interface KeyboardEventInit extends EventModifierInit { code?: string; + isComposing?: boolean; key?: string; location?: number; repeat?: boolean; @@ -3480,13 +3486,11 @@ declare var Comment: { /** The DOM CompositionEvent represents events that occur due to the user indirectly entering text. */ interface CompositionEvent extends UIEvent { readonly data: string; - readonly locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; } declare var CompositionEvent: { prototype: CompositionEvent; - new(typeArg: string, eventInitDict?: CompositionEventInit): CompositionEvent; + new(type: string, eventInitDict?: CompositionEventInit): CompositionEvent; }; interface ConcatParams extends Algorithm { @@ -4564,6 +4568,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par createEvent(eventInterface: "GamepadEvent"): GamepadEvent; createEvent(eventInterface: "HashChangeEvent"): HashChangeEvent; createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; createEvent(eventInterface: "ListeningStateChangedEvent"): ListeningStateChangedEvent; createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; @@ -4814,6 +4819,7 @@ interface DocumentEvent { createEvent(eventInterface: "GamepadEvent"): GamepadEvent; createEvent(eventInterface: "HashChangeEvent"): HashChangeEvent; createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; createEvent(eventInterface: "ListeningStateChangedEvent"): ListeningStateChangedEvent; createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; @@ -5417,13 +5423,12 @@ interface FileReaderProgressEvent extends ProgressEvent { /** Focus-related events like focus, blur, focusin, or focusout. */ interface FocusEvent extends UIEvent { - readonly relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; + readonly relatedTarget: EventTarget | null; } declare var FocusEvent: { prototype: FocusEvent; - new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; + new(type: string, eventInitDict?: FocusEventInit): FocusEvent; }; interface FocusNavigationEvent extends Event { @@ -9584,6 +9589,17 @@ declare var InputDeviceInfo: { new(): InputDeviceInfo; }; +interface InputEvent extends UIEvent { + readonly data: string | null; + readonly inputType: string; + readonly isComposing: boolean; +} + +declare var InputEvent: { + prototype: InputEvent; + new(type: string, eventInitDict?: InputEventInit): InputEvent; +}; + /** provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. */ interface IntersectionObserver { readonly root: Element | null; @@ -9625,6 +9641,7 @@ interface KeyboardEvent extends UIEvent { readonly charCode: number; readonly code: string; readonly ctrlKey: boolean; + readonly isComposing: boolean; readonly key: string; /** @deprecated */ readonly keyCode: number; @@ -9632,14 +9649,8 @@ interface KeyboardEvent extends UIEvent { readonly metaKey: boolean; readonly repeat: boolean; readonly shiftKey: boolean; - /** @deprecated */ - readonly which: number; getModifierState(keyArg: string): boolean; - /** @deprecated */ - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - readonly DOM_KEY_LOCATION_JOYSTICK: number; readonly DOM_KEY_LOCATION_LEFT: number; - readonly DOM_KEY_LOCATION_MOBILE: number; readonly DOM_KEY_LOCATION_NUMPAD: number; readonly DOM_KEY_LOCATION_RIGHT: number; readonly DOM_KEY_LOCATION_STANDARD: number; @@ -9647,10 +9658,8 @@ interface KeyboardEvent extends UIEvent { declare var KeyboardEvent: { prototype: KeyboardEvent; - new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; - readonly DOM_KEY_LOCATION_JOYSTICK: number; + new(type: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; readonly DOM_KEY_LOCATION_LEFT: number; - readonly DOM_KEY_LOCATION_MOBILE: number; readonly DOM_KEY_LOCATION_NUMPAD: number; readonly DOM_KEY_LOCATION_RIGHT: number; readonly DOM_KEY_LOCATION_STANDARD: number; @@ -10502,10 +10511,6 @@ interface MouseEvent extends UIEvent { readonly clientX: number; readonly clientY: number; readonly ctrlKey: boolean; - /** @deprecated */ - readonly fromElement: Element; - readonly layerX: number; - readonly layerY: number; readonly metaKey: boolean; readonly movementX: number; readonly movementY: number; @@ -10513,14 +10518,10 @@ interface MouseEvent extends UIEvent { readonly offsetY: number; readonly pageX: number; readonly pageY: number; - readonly relatedTarget: EventTarget; + readonly relatedTarget: EventTarget | null; readonly screenX: number; readonly screenY: number; readonly shiftKey: boolean; - /** @deprecated */ - readonly toElement: Element; - /** @deprecated */ - readonly which: number; readonly x: number; readonly y: number; getModifierState(keyArg: string): boolean; @@ -10529,7 +10530,7 @@ interface MouseEvent extends UIEvent { declare var MouseEvent: { prototype: MouseEvent; - new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; + new(type: string, eventInitDict?: MouseEventInit): MouseEvent; }; /** Provides event properties that are specific to modifications to the Document Object Model (DOM) hierarchy and nodes. */ @@ -15787,13 +15788,14 @@ declare var TreeWalker: { /** Simple user interface events. */ interface UIEvent extends Event { readonly detail: number; - readonly view: Window; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; + readonly view: Window | null; + /** @deprecated */ + readonly which: number; } declare var UIEvent: { prototype: UIEvent; - new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; + new(type: string, eventInitDict?: UIEventInit): UIEvent; }; /** The URL interface represents an object providing static methods used for creating object URLs. */ @@ -17159,8 +17161,6 @@ interface WheelEvent extends MouseEvent { readonly deltaX: number; readonly deltaY: number; readonly deltaZ: number; - getCurrentPoint(element: Element): void; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; readonly DOM_DELTA_LINE: number; readonly DOM_DELTA_PAGE: number; readonly DOM_DELTA_PIXEL: number; @@ -17168,7 +17168,7 @@ interface WheelEvent extends MouseEvent { declare var WheelEvent: { prototype: WheelEvent; - new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + new(type: string, eventInitDict?: WheelEventInit): WheelEvent; readonly DOM_DELTA_LINE: number; readonly DOM_DELTA_PAGE: number; readonly DOM_DELTA_PIXEL: number; diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index 40fa45518..305524130 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -1097,13 +1097,22 @@ } }, "KeyboardEvent": { - "name": "KeyboardEvent", "properties": { "property": { - "code": { - "name": "code", - "read-only": 1, - "override-type": "string" + "charCode": { + "deprecated": 1 + }, + "keyCode": { + "deprecated": 1 + } + } + } + }, + "UIEvent": { + "properties": { + "property": { + "which": { + "deprecated": 1 } } } @@ -2206,18 +2215,6 @@ } } }, - "KeyboardEventInit": { - "name": "KeyboardEventInit", - "members": { - "member": { - "code": { - "name": "code", - "override-type": "string", - "required": 0 - } - } - } - }, "EventInit": { "name": "EventInit", "members": { diff --git a/inputfiles/idl/UI Events.widl b/inputfiles/idl/UI Events.widl new file mode 100644 index 000000000..fdfc87a25 --- /dev/null +++ b/inputfiles/idl/UI Events.widl @@ -0,0 +1,152 @@ +[Constructor(DOMString type, optional UIEventInit eventInitDict), Exposed=Window] +interface UIEvent : Event { + readonly attribute Window? view; + readonly attribute long detail; +}; + +dictionary UIEventInit : EventInit { + Window? view = null; + long detail = 0; +}; + +[Constructor(DOMString type, optional FocusEventInit eventInitDict), Exposed=Window] +interface FocusEvent : UIEvent { + readonly attribute EventTarget? relatedTarget; +}; + +dictionary FocusEventInit : UIEventInit { + EventTarget? relatedTarget = null; +}; + +[Constructor(DOMString type, optional MouseEventInit eventInitDict), Exposed=Window] +interface MouseEvent : UIEvent { + readonly attribute long screenX; + readonly attribute long screenY; + readonly attribute long clientX; + readonly attribute long clientY; + + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean altKey; + readonly attribute boolean metaKey; + + readonly attribute short button; + readonly attribute unsigned short buttons; + + readonly attribute EventTarget? relatedTarget; + + boolean getModifierState(DOMString keyArg); +}; + +dictionary MouseEventInit : EventModifierInit { + long screenX = 0; + long screenY = 0; + long clientX = 0; + long clientY = 0; + + short button = 0; + unsigned short buttons = 0; + EventTarget? relatedTarget = null; +}; + +dictionary EventModifierInit : UIEventInit { + boolean ctrlKey = false; + boolean shiftKey = false; + boolean altKey = false; + boolean metaKey = false; + + boolean modifierAltGraph = false; + boolean modifierCapsLock = false; + boolean modifierFn = false; + boolean modifierFnLock = false; + boolean modifierHyper = false; + boolean modifierNumLock = false; + boolean modifierScrollLock = false; + boolean modifierSuper = false; + boolean modifierSymbol = false; + boolean modifierSymbolLock = false; +}; + +[Constructor(DOMString type, optional WheelEventInit eventInitDict), Exposed=Window] +interface WheelEvent : MouseEvent { + // DeltaModeCode + const unsigned long DOM_DELTA_PIXEL = 0x00; + const unsigned long DOM_DELTA_LINE = 0x01; + const unsigned long DOM_DELTA_PAGE = 0x02; + + readonly attribute double deltaX; + readonly attribute double deltaY; + readonly attribute double deltaZ; + readonly attribute unsigned long deltaMode; +}; + +dictionary WheelEventInit : MouseEventInit { + double deltaX = 0.0; + double deltaY = 0.0; + double deltaZ = 0.0; + unsigned long deltaMode = 0; +}; + +[Constructor(DOMString type, optional InputEventInit eventInitDict), Exposed=Window] +interface InputEvent : UIEvent { + readonly attribute DOMString? data; + readonly attribute boolean isComposing; + readonly attribute DOMString inputType; +}; + +dictionary InputEventInit : UIEventInit { + DOMString? data = ""; + boolean isComposing = false; + DOMString inputType = ""; +}; + +[Constructor(DOMString type, optional KeyboardEventInit eventInitDict), Exposed=Window] +interface KeyboardEvent : UIEvent { + // KeyLocationCode + const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00; + const unsigned long DOM_KEY_LOCATION_LEFT = 0x01; + const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02; + const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03; + + readonly attribute DOMString key; + readonly attribute DOMString code; + readonly attribute unsigned long location; + + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean altKey; + readonly attribute boolean metaKey; + + readonly attribute boolean repeat; + readonly attribute boolean isComposing; + + boolean getModifierState(DOMString keyArg); +}; + +dictionary KeyboardEventInit : EventModifierInit { + DOMString key = ""; + DOMString code = ""; + unsigned long location = 0; + boolean repeat = false; + boolean isComposing = false; +}; + +[Constructor(DOMString type, optional CompositionEventInit eventInitDict), Exposed=Window] +interface CompositionEvent : UIEvent { + readonly attribute DOMString data; +}; + +dictionary CompositionEventInit : UIEventInit { + DOMString data = ""; +}; + +partial interface UIEvent { + // The following support legacy user agents + readonly attribute unsigned long which; +}; + +partial interface KeyboardEvent { + // The following support legacy user agents + readonly attribute unsigned long charCode; + readonly attribute unsigned long keyCode; +}; diff --git a/inputfiles/idlSources.json b/inputfiles/idlSources.json index c1dea27be..8c9392d0d 100644 --- a/inputfiles/idlSources.json +++ b/inputfiles/idlSources.json @@ -335,6 +335,10 @@ "url": "https://w3c.github.io/touch-events/", "title": "Touch Events" }, + { + "url": "https://www.w3.org/TR/uievents/", + "title": "UI Events" + }, { "url": "https://url.spec.whatwg.org/", "title": "URL"