Skip to content

Add Screen Orientation types #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13760,14 +13760,11 @@ interface Screen extends EventTarget {
readonly logicalYDPI: number;
readonly msOrientation: string;
onmsorientationchange: ((this: Screen, ev: Event) => any) | null;
readonly orientation: ScreenOrientation;
readonly pixelDepth: number;
readonly systemXDPI: number;
readonly systemYDPI: number;
readonly width: number;
lockOrientation(orientations: OrientationLockType | OrientationLockType[]): boolean;
msLockOrientation(orientations: string | string[]): boolean;
msUnlockOrientation(): void;
unlockOrientation(): void;
addEventListener<K extends keyof ScreenEventMap>(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof ScreenEventMap>(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -13779,6 +13776,27 @@ declare var Screen: {
new(): Screen;
};

interface ScreenOrientationEventMap {
"change": Event;
}

interface ScreenOrientation extends EventTarget {
readonly angle: number;
onchange: ((this: ScreenOrientation, ev: Event) => any) | null;
readonly type: OrientationType;
lock(orientation: OrientationLockType): Promise<void>;
unlock(): void;
addEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}

declare var ScreenOrientation: {
prototype: ScreenOrientation;
new(): ScreenOrientation;
};

interface ScriptProcessorNodeEventMap {
"audioprocess": AudioProcessingEvent;
}
Expand Down Expand Up @@ -17143,7 +17161,6 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
type MouseWheelEvent = WheelEvent;
type ScrollRestoration = "auto" | "manual";
type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend";
type OrientationLockType = "any" | "natural" | "portrait" | "landscape" | "portrait-primary" | "portrait-secondary" | "landscape-primary"| "landscape-secondary";
type IDBValidKey = number | string | Date | BufferSource | IDBArrayKey;
type AlgorithmIdentifier = string | Algorithm;
type MutationRecordType = "attributes" | "characterData" | "childList";
Expand Down Expand Up @@ -17225,6 +17242,8 @@ type NavigationReason = "up" | "down" | "left" | "right";
type NavigationType = "navigate" | "reload" | "back_forward" | "prerender";
type NotificationDirection = "auto" | "ltr" | "rtl";
type NotificationPermission = "default" | "denied" | "granted";
type OrientationLockType = "any" | "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we have another definition of OrientationLockType in Addedtypes.json

type OrientationType = "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom";
type OverSampleType = "none" | "2x" | "4x";
type PanningModelType = "equalpower" | "HRTF";
Expand Down
23 changes: 0 additions & 23 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2123,25 +2123,6 @@
},
"no-interface-object": "1"
},
"Screen": {
"name": "Screen",
"methods": {
"method": {
"lockOrientation": {
"name": "lockOrientation",
"override-signatures": [
"lockOrientation(orientations: OrientationLockType | OrientationLockType[]): boolean"
]
},
"unlockOrientation": {
"name": "unlockOrientation",
"override-signatures": [
"unlockOrientation(): void"
]
}
}
}
},
"HTMLTableDataCellElement": {
"name": "HTMLTableDataCellElement",
"extends": "HTMLTableCellElement",
Expand Down Expand Up @@ -2384,10 +2365,6 @@
"override-type": "Headers | string[][] | Record<string, string>",
"new-type": "HeadersInit"
},
{
"override-type": "\"any\" | \"natural\" | \"portrait\" | \"landscape\" | \"portrait-primary\" | \"portrait-secondary\" | \"landscape-primary\"| \"landscape-secondary\"",
"new-type": "OrientationLockType"
},
{
"override-type": "number | string | Date | BufferSource | IDBArrayKey",
"new-type": "IDBValidKey"
Expand Down
31 changes: 31 additions & 0 deletions inputfiles/idl/Screen Orientation.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
partial interface Screen {
[SameObject]
readonly attribute ScreenOrientation orientation;
};

[Exposed=Window]
interface ScreenOrientation : EventTarget {
Promise<void> lock(OrientationLockType orientation);
void unlock();
readonly attribute OrientationType type;
readonly attribute unsigned short angle;
attribute EventHandler onchange;
};

enum OrientationType {
"portrait-primary",
"portrait-secondary",
"landscape-primary",
"landscape-secondary"
};

enum OrientationLockType {
"any",
"natural",
"landscape",
"portrait",
"portrait-primary",
"portrait-secondary",
"landscape-primary",
"landscape-secondary"
};
4 changes: 4 additions & 0 deletions inputfiles/idlSources.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
"url": "https://w3c.github.io/resource-timing/",
"title": "Resource Timing"
},
{
"url": "https://www.w3.org/TR/screen-orientation/",
"title": "Screen Orientation"
},
{
"url": "https://w3c.github.io/ServiceWorker/",
"title": "Service Workers"
Expand Down
10 changes: 9 additions & 1 deletion inputfiles/removedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
},
"MediaQueryListListener": null,
"MSStreamReader": null,
"Screen": {
"methods": {
"method": {
"msLockOrientation": null,
"msUnlockOrientation": null
}
}
},
"StorageEvent": {
"methods": {
"method": {
Expand Down Expand Up @@ -93,4 +101,4 @@
"new-type": "ArrayBufferView"
}]
}
}
}