From 15485d2d580274cffa49269def2fab86e2dcd042 Mon Sep 17 00:00:00 2001 From: Qiyu8 Date: Tue, 31 Mar 2020 20:52:37 +0800 Subject: [PATCH] Support web API VisualViewport --- baselines/dom.generated.d.ts | 28 ++++++++++++++++++++++ inputfiles/idl/Web VisualViewport API.widl | 20 ++++++++++++++++ inputfiles/idlSources.json | 4 ++++ 3 files changed, 52 insertions(+) create mode 100644 inputfiles/idl/Web VisualViewport API.widl diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index b847b7ca8..fc11b6742 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -16146,6 +16146,32 @@ declare var VideoPlaybackQuality: { new(): VideoPlaybackQuality; }; +interface VisualViewportEventMap { + "resize": UIEvent; + "scroll": Event; +} + +interface VisualViewport extends EventTarget { + readonly height: number; + readonly offsetLeft: number; + readonly offsetTop: number; + onresize: ((this: VisualViewport, ev: UIEvent) => any) | null; + onscroll: ((this: VisualViewport, ev: Event) => any) | null; + readonly pageLeft: number; + readonly pageTop: number; + readonly scale: number; + readonly width: number; + addEventListener(type: K, listener: (this: VisualViewport, ev: VisualViewportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: VisualViewport, ev: VisualViewportEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var VisualViewport: { + prototype: VisualViewport; + new(): VisualViewport; +}; + interface WEBGL_color_buffer_float { readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum; readonly RGBA32F_EXT: GLenum; @@ -18454,6 +18480,7 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler readonly styleMedia: StyleMedia; readonly toolbar: BarProp; readonly top: Window; + readonly visualViewport: VisualViewport; readonly window: Window & typeof globalThis; alert(message?: any): void; blur(): void; @@ -19482,6 +19509,7 @@ declare var statusbar: BarProp; declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; +declare var visualViewport: VisualViewport; declare var window: Window & typeof globalThis; declare function alert(message?: any): void; declare function blur(): void; diff --git a/inputfiles/idl/Web VisualViewport API.widl b/inputfiles/idl/Web VisualViewport API.widl new file mode 100644 index 000000000..fe488bee2 --- /dev/null +++ b/inputfiles/idl/Web VisualViewport API.widl @@ -0,0 +1,20 @@ +partial interface Window { + [SameObject, Replaceable] readonly attribute VisualViewport visualViewport; +}; + +[Exposed=Window] +interface VisualViewport : EventTarget { + readonly attribute double offsetLeft; + readonly attribute double offsetTop; + + readonly attribute double pageLeft; + readonly attribute double pageTop; + + readonly attribute double width; + readonly attribute double height; + + readonly attribute double scale; + + attribute EventHandler onresize; + attribute EventHandler onscroll; +}; diff --git a/inputfiles/idlSources.json b/inputfiles/idlSources.json index da35b2b38..c094042bb 100644 --- a/inputfiles/idlSources.json +++ b/inputfiles/idlSources.json @@ -643,6 +643,10 @@ "url": "https://w3c.github.io/speech-api/", "title": "Web Speech API" }, + { + "url": "https://wicg.github.io/visual-viewport/", + "title": "Web VisualViewport API" + }, { "url": "https://www.w3.org/TR/webvtt1/", "title": "WebVTT"