Skip to content

Commit 3271ea0

Browse files
saschanazsandersn
authored andcommitted
Deduplicate global variables (#801)
1 parent 5a5afa5 commit 3271ea0

File tree

5 files changed

+17
-35
lines changed

5 files changed

+17
-35
lines changed

baselines/dom.generated.d.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9348,10 +9348,6 @@ declare var IDBDatabase: {
93489348
new(): IDBDatabase;
93499349
};
93509350

9351-
interface IDBEnvironment {
9352-
readonly indexedDB: IDBFactory;
9353-
}
9354-
93559351
/** In the following code snippet, we make a request to open a database, and include handlers for the success and error cases. For a full working example, see our To-do Notifications app (view example live.) */
93569352
interface IDBFactory {
93579353
/**
@@ -18536,12 +18532,10 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler
1853618532
}
1853718533

1853818534
/** A window containing a DOM document; the document property points to the DOM document loaded in that window. */
18539-
interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, IDBEnvironment, WindowBase64, WindowConsole, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage {
18535+
interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, WindowConsole, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage {
1854018536
readonly applicationCache: ApplicationCache;
18541-
readonly caches: CacheStorage;
1854218537
readonly clientInformation: Navigator;
1854318538
readonly closed: boolean;
18544-
readonly crypto: Crypto;
1854518539
customElements: CustomElementRegistry;
1854618540
defaultStatus: string;
1854718541
readonly devicePixelRatio: number;
@@ -18606,7 +18600,6 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler
1860618600
readonly pageXOffset: number;
1860718601
readonly pageYOffset: number;
1860818602
readonly parent: Window;
18609-
readonly performance: Performance;
1861018603
readonly personalbar: BarProp;
1861118604
readonly screen: Screen;
1861218605
readonly screenLeft: number;
@@ -18670,11 +18663,6 @@ declare var Window: {
1867018663
new(): Window;
1867118664
};
1867218665

18673-
interface WindowBase64 {
18674-
atob(encodedString: string): string;
18675-
btoa(rawString: string): string;
18676-
}
18677-
1867818666
interface WindowConsole {
1867918667
readonly console: Console;
1868018668
}
@@ -19536,10 +19524,8 @@ declare var Option: {
1953619524
new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement;
1953719525
};
1953819526
declare var applicationCache: ApplicationCache;
19539-
declare var caches: CacheStorage;
1954019527
declare var clientInformation: Navigator;
1954119528
declare var closed: boolean;
19542-
declare var crypto: Crypto;
1954319529
declare var customElements: CustomElementRegistry;
1954419530
declare var defaultStatus: string;
1954519531
declare var devicePixelRatio: number;
@@ -19604,7 +19590,6 @@ declare var outerWidth: number;
1960419590
declare var pageXOffset: number;
1960519591
declare var pageYOffset: number;
1960619592
declare var parent: Window;
19607-
declare var performance: Performance;
1960819593
declare var personalbar: BarProp;
1960919594
declare var screen: Screen;
1961019595
declare var screenLeft: number;
@@ -19929,9 +19914,6 @@ declare var onvolumechange: ((this: Window, ev: Event) => any) | null;
1992919914
*/
1993019915
declare var onwaiting: ((this: Window, ev: Event) => any) | null;
1993119916
declare var onwheel: ((this: Window, ev: WheelEvent) => any) | null;
19932-
declare var indexedDB: IDBFactory;
19933-
declare function atob(encodedString: string): string;
19934-
declare function btoa(rawString: string): string;
1993519917
declare function cancelAnimationFrame(handle: number): void;
1993619918
declare function requestAnimationFrame(callback: FrameRequestCallback): number;
1993719919
declare var caches: CacheStorage;
@@ -19949,8 +19931,6 @@ declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response
1994919931
declare function queueMicrotask(callback: VoidFunction): void;
1995019932
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
1995119933
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
19952-
declare var sessionStorage: Storage;
19953-
declare var localStorage: Storage;
1995419934
declare var onafterprint: ((this: Window, ev: Event) => any) | null;
1995519935
declare var onbeforeprint: ((this: Window, ev: Event) => any) | null;
1995619936
declare var onbeforeunload: ((this: Window, ev: BeforeUnloadEvent) => any) | null;

inputfiles/addedTypes.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@
296296
}
297297
}
298298
},
299-
"extends": "SVGElement",
300-
"implements": [
301-
"SVGFilterPrimitiveStandardAttributes"
302-
]
299+
"extends": "SVGElement"
303300
},
304301
"AbortSignal": {
305302
"events": {
@@ -1063,9 +1060,7 @@
10631060
},
10641061
"SVGElement": {
10651062
"implements": [
1066-
"ElementCSSInlineStyle",
1067-
"GlobalEventHandlers",
1068-
"DocumentAndElementEventHandlers"
1063+
"ElementCSSInlineStyle"
10691064
]
10701065
},
10711066
"Text": {

inputfiles/removedTypes.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,14 @@
313313
"properties": {
314314
"property": {
315315
"browser": null,
316+
"caches": null,
317+
"crypto": null,
316318
"msCredentials": null,
317319
"ontouchcancel": null,
318320
"ontouchend": null,
319321
"ontouchmove": null,
320-
"ontouchstart": null
322+
"ontouchstart": null,
323+
"performance": null
321324
}
322325
},
323326
"methods": {
@@ -328,6 +331,8 @@
328331
},
329332
"implements": [
330333
"GlobalFetch",
334+
"IDBEnvironment",
335+
"WindowBase64",
331336
"WindowTimers"
332337
]
333338
},

src/emitter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,10 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
870870

871871
printer.print(`interface ${getNameWithTypeParameter(i, processedIName)}`);
872872

873-
const finalExtends = distinct([i.extends || "Object"].concat((i.implements || []).sort())
873+
const finalExtends = [i.extends || "Object"]
874+
.concat((i.implements || []).sort())
874875
.filter(i => i !== "Object")
875-
.map(processIName));
876+
.map(processIName);
876877

877878
if (finalExtends.length) {
878879
printer.print(` extends ${finalExtends.join(", ")}`);

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ function emitDom() {
166166
for (const include of w.includes) {
167167
const target = webidl.interfaces!.interface[include.target];
168168
if (target) {
169-
if (target.implements) {
170-
target.implements.push(include.includes);
171-
}
172-
else {
169+
if (!target.implements) {
173170
target.implements = [include.includes];
171+
} else if (!target.implements.includes(include.includes)) {
172+
// This makes sure that browser.webidl.preprocessed.json
173+
// does not already have the mixin reference
174+
target.implements.push(include.includes);
174175
}
175176
}
176177
}

0 commit comments

Comments
 (0)