Skip to content

Commit 125f496

Browse files
authored
Merge pull request #487 from saschanaz/orientation
Add Screen Orientation types
2 parents ef0353a + 656b958 commit 125f496

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

Diff for: baselines/dom.generated.d.ts

+24-5
Original file line numberDiff line numberDiff line change
@@ -13760,14 +13760,11 @@ interface Screen extends EventTarget {
1376013760
readonly logicalYDPI: number;
1376113761
readonly msOrientation: string;
1376213762
onmsorientationchange: ((this: Screen, ev: Event) => any) | null;
13763+
readonly orientation: ScreenOrientation;
1376313764
readonly pixelDepth: number;
1376413765
readonly systemXDPI: number;
1376513766
readonly systemYDPI: number;
1376613767
readonly width: number;
13767-
lockOrientation(orientations: OrientationLockType | OrientationLockType[]): boolean;
13768-
msLockOrientation(orientations: string | string[]): boolean;
13769-
msUnlockOrientation(): void;
13770-
unlockOrientation(): void;
1377113768
addEventListener<K extends keyof ScreenEventMap>(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
1377213769
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1377313770
removeEventListener<K extends keyof ScreenEventMap>(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -13779,6 +13776,27 @@ declare var Screen: {
1377913776
new(): Screen;
1378013777
};
1378113778

13779+
interface ScreenOrientationEventMap {
13780+
"change": Event;
13781+
}
13782+
13783+
interface ScreenOrientation extends EventTarget {
13784+
readonly angle: number;
13785+
onchange: ((this: ScreenOrientation, ev: Event) => any) | null;
13786+
readonly type: OrientationType;
13787+
lock(orientation: OrientationLockType): Promise<void>;
13788+
unlock(): void;
13789+
addEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
13790+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
13791+
removeEventListener<K extends keyof ScreenOrientationEventMap>(type: K, listener: (this: ScreenOrientation, ev: ScreenOrientationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
13792+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
13793+
}
13794+
13795+
declare var ScreenOrientation: {
13796+
prototype: ScreenOrientation;
13797+
new(): ScreenOrientation;
13798+
};
13799+
1378213800
interface ScriptProcessorNodeEventMap {
1378313801
"audioprocess": AudioProcessingEvent;
1378413802
}
@@ -17143,7 +17161,6 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
1714317161
type MouseWheelEvent = WheelEvent;
1714417162
type ScrollRestoration = "auto" | "manual";
1714517163
type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend";
17146-
type OrientationLockType = "any" | "natural" | "portrait" | "landscape" | "portrait-primary" | "portrait-secondary" | "landscape-primary"| "landscape-secondary";
1714717164
type IDBValidKey = number | string | Date | BufferSource | IDBArrayKey;
1714817165
type AlgorithmIdentifier = string | Algorithm;
1714917166
type MutationRecordType = "attributes" | "characterData" | "childList";
@@ -17225,6 +17242,8 @@ type NavigationReason = "up" | "down" | "left" | "right";
1722517242
type NavigationType = "navigate" | "reload" | "back_forward" | "prerender";
1722617243
type NotificationDirection = "auto" | "ltr" | "rtl";
1722717244
type NotificationPermission = "default" | "denied" | "granted";
17245+
type OrientationLockType = "any" | "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
17246+
type OrientationType = "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
1722817247
type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom";
1722917248
type OverSampleType = "none" | "2x" | "4x";
1723017249
type PanningModelType = "equalpower" | "HRTF";

Diff for: inputfiles/addedTypes.json

-23
Original file line numberDiff line numberDiff line change
@@ -2123,25 +2123,6 @@
21232123
},
21242124
"no-interface-object": "1"
21252125
},
2126-
"Screen": {
2127-
"name": "Screen",
2128-
"methods": {
2129-
"method": {
2130-
"lockOrientation": {
2131-
"name": "lockOrientation",
2132-
"override-signatures": [
2133-
"lockOrientation(orientations: OrientationLockType | OrientationLockType[]): boolean"
2134-
]
2135-
},
2136-
"unlockOrientation": {
2137-
"name": "unlockOrientation",
2138-
"override-signatures": [
2139-
"unlockOrientation(): void"
2140-
]
2141-
}
2142-
}
2143-
}
2144-
},
21452126
"HTMLTableDataCellElement": {
21462127
"name": "HTMLTableDataCellElement",
21472128
"extends": "HTMLTableCellElement",
@@ -2384,10 +2365,6 @@
23842365
"override-type": "Headers | string[][] | Record<string, string>",
23852366
"new-type": "HeadersInit"
23862367
},
2387-
{
2388-
"override-type": "\"any\" | \"natural\" | \"portrait\" | \"landscape\" | \"portrait-primary\" | \"portrait-secondary\" | \"landscape-primary\"| \"landscape-secondary\"",
2389-
"new-type": "OrientationLockType"
2390-
},
23912368
{
23922369
"override-type": "number | string | Date | BufferSource | IDBArrayKey",
23932370
"new-type": "IDBValidKey"

Diff for: inputfiles/idl/Screen Orientation.widl

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
partial interface Screen {
2+
[SameObject]
3+
readonly attribute ScreenOrientation orientation;
4+
};
5+
6+
[Exposed=Window]
7+
interface ScreenOrientation : EventTarget {
8+
Promise<void> lock(OrientationLockType orientation);
9+
void unlock();
10+
readonly attribute OrientationType type;
11+
readonly attribute unsigned short angle;
12+
attribute EventHandler onchange;
13+
};
14+
15+
enum OrientationType {
16+
"portrait-primary",
17+
"portrait-secondary",
18+
"landscape-primary",
19+
"landscape-secondary"
20+
};
21+
22+
enum OrientationLockType {
23+
"any",
24+
"natural",
25+
"landscape",
26+
"portrait",
27+
"portrait-primary",
28+
"portrait-secondary",
29+
"landscape-primary",
30+
"landscape-secondary"
31+
};

Diff for: inputfiles/idlSources.json

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
"url": "https://w3c.github.io/resource-timing/",
8181
"title": "Resource Timing"
8282
},
83+
{
84+
"url": "https://www.w3.org/TR/screen-orientation/",
85+
"title": "Screen Orientation"
86+
},
8387
{
8488
"url": "https://w3c.github.io/ServiceWorker/",
8589
"title": "Service Workers"

Diff for: inputfiles/removedTypes.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
},
4141
"MediaQueryListListener": null,
4242
"MSStreamReader": null,
43+
"Screen": {
44+
"methods": {
45+
"method": {
46+
"msLockOrientation": null,
47+
"msUnlockOrientation": null
48+
}
49+
}
50+
},
4351
"StorageEvent": {
4452
"methods": {
4553
"method": {
@@ -93,4 +101,4 @@
93101
"new-type": "ArrayBufferView"
94102
}]
95103
}
96-
}
104+
}

0 commit comments

Comments
 (0)