forked from whatwg/webidl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.bs
15106 lines (12275 loc) · 653 KB
/
index.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class="metadata">
Group: WHATWG
H1: Web IDL
Shortname: webidl
Text Macro: TWITTER webidl
Abstract: This standard defines an interface definition language, Web IDL, that can be used to describe interfaces that
Abstract: are intended to be implemented in web browsers.
Translation: ja https://triple-underscore.github.io/WebIDL-ja.html
Complain About: accidental-2119 no
</pre>
<pre class="link-defaults">
spec: infra; type: dfn; text: list
spec: url; type: interface; text: URL
spec: dom; type: interface; text: Document
spec: ecma-262; type: dfn; for: /; text: internal method
spec: ecma-262; type: dfn; for: /; text: internal slot
spec: ecma-262; type: dfn; for: /; text:realm
</pre>
<pre class="anchors">
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/; spec: WEBGL_compressed_texture_astc
type: interface; text: WEBGL_compressed_texture_astc
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/; spec: WEBGL_compressed_texture_s3tc_srgb
type: interface; text: WEBGL_compressed_texture_s3tc_srgb
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/; spec: WEBGL_draw_buffers
type: interface; text: WEBGL_draw_buffers
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_lose_context/; spec: WEBGL_lose_context
type: interface; text: WEBGL_lose_context
urlPrefix: https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/; spec: ANGLE_instanced_arrays
type: interface; text: ANGLE_instanced_arrays
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_blend_minmax/; spec: EXT_blend_minmax
type: interface; text: EXT_blend_minmax
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_color_buffer_float/; spec: EXT_color_buffer_float
type: interface; text: EXT_color_buffer_float
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query/; spec: EXT_disjoint_timer_query
type: interface; text: EXT_disjoint_timer_query
urlPrefix: https://www.khronos.org/registry/webgl/extensions/OES_standard_derivatives/; spec: OES_standard_derivatives
type: interface; text: OES_standard_derivatives
urlPrefix: https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/; spec: OES_vertex_array_object
type: interface; text: OES_vertex_array_object
urlPrefix: https://www.w3.org/TR/geolocation-API/; spec: GEOLOCATION-API
type: interface
text: Geolocation; url: geolocation;
text: Coordinates; url: coordinates;
text: Position; url: position;
text: PositionError; url: position-error;
urlPrefix: https://w3c.github.io/deviceorientation/spec-source-orientation.html; spec: ORIENTATION-EVENT
type: interface
text: DeviceRotationRate; url: device_rotation_rate;
text: DeviceAcceleration; url: device_acceleration;
urlPrefix: https://w3c.github.io/mediacapture-main/; spec: MEDIACAPTURE-STREAMS
type: interface
text: ConstrainablePattern; url: dom-constrainablepattern;
urlPrefix: http://www.unicode.org/glossary/; spec: UNICODE
type: dfn
text: Unicode scalar value; url: unicode_scalar_value
urlPrefix: https://tc39.es/ecma262/; spec: ECMA-262
type: interface; for: ECMAScript
text: Array; url: sec-array-objects
text: ArrayBuffer; url: sec-arraybuffer-objects
text: DataView; url: sec-dataview-objects
text: Map; url: sec-map-objects
text: Promise; url: sec-promise-objects
text: Set; url: sec-set-objects
text: SharedArrayBuffer; url: sec-sharedarraybuffer-objects
text: %AsyncIteratorPrototype%; url: sec-asynciteratorprototype
text: %ArrayBuffer%; url: sec-arraybuffer-constructor
text: %Array.prototype%; url: sec-properties-of-the-array-prototype-object
text: %Error.prototype%; url: sec-properties-of-the-error-prototype-object
text: %Function.prototype%; url: sec-properties-of-the-function-prototype-object
text: %IteratorPrototype%; url: sec-%25iteratorprototype%25-object
text: %Map.prototype%; url: sec-properties-of-the-map-prototype-object
text: %Object.prototype%; url: sec-properties-of-the-object-prototype-object
text: %Promise%; url: sec-promise-constructor
text: %Set.prototype%; url: sec-properties-of-the-set-prototype-object
type: exception; for: ECMAScript
text: Error; url: sec-error-objects
text: SyntaxError; url: sec-native-error-types-used-in-this-standard-syntaxerror
text: TypeError; url: sec-native-error-types-used-in-this-standard-typeerror
type: method; for: ECMAScript
text: JSON.stringify(); url: sec-json.stringify
text: %Array.prototype.entries%; url: sec-array.prototype.entries
text: %Array.prototype.forEach%; url: sec-array.prototype.foreach
text: %Array.prototype.keys%; url: sec-array.prototype.keys
text: %Array.prototype.values%; url: sec-array.prototype.values
text: %Promise.reject%; url: sec-promise.reject
text: %Promise.prototype.then%; url: sec-promise.prototype.then
text: all(); for: Promise; url: #sec-promise.all
type: const; for: ECMAScript
url: sec-well-known-symbols
text: @@asyncIterator
text: @@iterator
text: @@toStringTag
text: @@unscopables
type: argument
text: NewTarget; url: sec-built-in-function-objects
type: abstract-op
text: AllocateArrayBuffer; url: sec-allocatearraybuffer
text: ArrayCreate; url: sec-arraycreate
text: Call; url: sec-call
text: CanonicalNumericIndexString; url: sec-canonicalnumericindexstring
text: Completion; url: sec-completion-record-specification-type
text: Construct; url: sec-construct
text: CreateArrayFromList; url: sec-createarrayfromlist
text: CreateArrayIterator; url: sec-createarrayiterator
text: CreateBuiltinFunction; url: sec-createbuiltinfunction
text: CreateDataProperty; url: sec-createdataproperty
text: CreateIterResultObject; url: sec-createiterresultobject
text: CreateMapIterator; url: sec-createmapiterator
text: CreateMethodProperty; url: sec-createmethodproperty
text: CreateSetIterator; url: sec-createsetiterator
text: DefinePropertyOrThrow; url: sec-definepropertyorthrow
text: DetachArrayBuffer; url: sec-detacharraybuffer
for: Environment Record; url: table-abstract-methods-of-environment-records
text: SetMutableBinding
text: CreateMutableBinding
text: InitializeBinding
text: FromPropertyDescriptor; url: sec-frompropertydescriptor
text: Get; url: sec-get-o-p
text: GetFunctionRealm; url: sec-getfunctionrealm
text: GetIterator; url: sec-getiterator
text: GetMethod; url: sec-getmethod
text: GetValueFromBuffer; url: sec-getvaluefrombuffer
text: IfAbruptRejectPromise; url: sec-ifabruptrejectpromise
text: IsArray; url: sec-isarray
text: IsAccessorDescriptor; url: sec-isaccessordescriptor
text: IsCallable; url: sec-iscallable
text: IsConstructor; url: sec-isconstructor
text: IsDataDescriptor; url: sec-isdatadescriptor
text: IsDetachedBuffer; url: sec-isdetachedbuffer
text: IsInteger; url: sec-isinteger
text: IsSharedArrayBuffer; url: sec-issharedarraybuffer
text: IteratorStep; url: sec-iteratorstep
text: IteratorValue; url: sec-iteratorvalue
text: MakeBasicObject; url: sec-makebasicobject
text: NewModuleEnvironment; url: sec-newmoduleenvironment
text: NewPromiseCapability; url: sec-newpromisecapability
text: NormalCompletion; url: sec-normalcompletion
text: OrdinaryDefineOwnProperty; url: sec-ordinarydefineownproperty
text: OrdinaryGetOwnProperty; url: sec-ordinarygetownproperty
text: OrdinaryObjectCreate; url: sec-ordinaryobjectcreate
text: OrdinaryPreventExtensions; url: sec-ordinarypreventextensions
text: OrdinarySetWithOwnDescriptor; url: sec-ordinarysetwithowndescriptor
text: PerformPromiseThen; url: sec-performpromisethen
text: ProxyCreate; url: sec-proxycreate
text: Set; url: sec-set-o-p-v-throw
text: SetFunctionLength; url: sec-setfunctionlength
text: SetFunctionName; url: sec-setfunctionname
text: SetImmutablePrototype; url: sec-set-immutable-prototype
text: SetIntegrityLevel; url: sec-setintegritylevel
text: SetValueInBuffer; url: sec-setvalueinbuffer
text: ToBigInt; url: #sec-tobigint
text: ToBoolean; url: sec-toboolean
text: ToInt32; url: sec-toint32
text: ToNumber; url: sec-tonumber
text: ToNumeric; url: sec-tonumeric
text: ToObject; url: sec-toobject
text: ToPropertyDescriptor; url: sec-topropertydescriptor
text: ToPropertyKey; url: sec-topropertykey
text: ToString; url: sec-tostring
text: ToUint16; url: sec-touint16
text: ToUint32; url: sec-touint32
text: Type; url: sec-ecmascript-data-types-and-values
text: abs; url: eqn-abs
text: floor; url: eqn-floor
text: max; url: eqn-max
text: min; url: eqn-min
type: dfn
text: NumericLiteral; url: sec-literals-numeric-literals
text: modulo; url: eqn-modulo
url: sec-returnifabrupt-shorthands
text: !
text: ?
text: ECMA-262 Algorithm Conventions; url: sec-algorithm-conventions
text: ECMA-262 Ordinary Object Internal Methods and Internal Slots; url: sec-ordinary-object-internal-methods-and-internal-slots
text: ECMA-262 Built-in Function Objects; url: sec-built-in-function-objects
text: ECMA-262 Immutable Prototype Exotic Objects; url: sec-immutable-prototype-exotic-objects
text: abrupt completion; url: sec-completion-record-specification-type
text: array index; url: array-index
text: array iterator object; url: sec-array-iterator-objects
text: built-in function object; url: sec-built-in-function-objects
text: BigInt; url: #sec-ecmascript-language-types-bigint-type
text: callable; for: ECMAScript; url: sec-iscallable
text: Completion Record; url: sec-completion-record-specification-type
text: constructor; url: constructor
text: conventions; for: ECMAScript; url: sec-algorithm-conventions
text: current Realm; url: current-realm
text: ECMAScript code execution context; url: sec-execution-contexts
for: ECMAScript code execution context; url: table-additional-state-components-for-ecmascript-code-execution-contexts
text: LexicalEnvironment
text: VariableEnvironment
text: element; for: ECMAScript String; url: sec-ecmascript-language-types-string-type
text: enumerable; url: sec-property-attributes
text: EnvironmentRecord; for: Lexical Environment; url: sec-environment-records
text: equally close values; url: sec-ecmascript-language-types-number-type
text: error objects; for: ECMAScript; url: sec-error-objects
for: Execution context; url: table-state-components-for-all-execution-contexts
text: Function
text: Realm
text: ScriptOrModule
text: execution context stack; url: execution-context-stack
text: function object; url: function-object
text: immutable prototype exotic object; url: sec-immutable-prototype-exotic-objects
url: sec-object-internal-methods-and-internal-slots
text: internal method
text: internal slot
text: Module Record; url: sec-abstract-module-records
text: Module Record Fields; url: table-module-record-fields
text: Number type; url: sec-ecmascript-language-types-number-type
text: Object; for: ECMAScript; url: sec-object-type
for: ordinary object; url: sec-ordinary-object-internal-methods-and-internal-slots
text: internal method
text: internal slot
text: own property; url: sec-own-property
text: PromiseCapability; url: sec-promisecapability-records
text: Property Descriptor; url: sec-property-descriptor-specification-type
text: Proxy exotic object; url: sec-proxy-object-internal-methods-and-internal-slots
text: Source Text Module Record; url: sec-source-text-module-records
text: realm; url: realm
text: ResolvedBinding Record; url: resolvedbinding-record
text: running execution context; url: running-execution-context
text: element size; url: table-the-typedarray-constructors
urlPrefix: https://tc39.es/proposal-resizablearraybuffer/; spec: RESIZABLE-BUFFERS-PROPOSAL
type: abstract-op
text: IsResizableArrayBuffer; url: sec-isresizablearraybuffer
</pre>
<style>
pre.set {
font-size: 80%;
}
.syntax .n,
.syntax .nv {
font-style: italic;
}
.mute,
.deprecated,
.deprecated a,
.deprecated code {
color: #9D937D;
}
.deprecated a:visited,
.deprecated a {
border-bottom-color: #9D937D;
}
emu-const {
font-family: sans-serif;
}
emu-val {
font-weight: bold;
}
emu-nt {
font-family: sans-serif;
font-style: italic;
white-space: nowrap;
}
emu-t {
font-family: Menlo, Consolas, "DejaVu Sans Mono", Monaco, monospace;
font-weight: bold;
white-space: nowrap;
}
emu-t.regex {
font-family: sans-serif;
font-weight: bold;
}
emu-t a[href],
emu-nt a[href] {
color: inherit;
border-bottom: 1px solid transparent;
}
emu-t a[href]:focus,
emu-nt a[href]:focus,
emu-t a[href]:hover,
emu-nt a[href]:hover {
background: #f8f8f8;
background: rgba(75%, 75%, 75%, .25);
border-bottom: 3px solid #707070;
margin-bottom: -2px;
}
/* start bug fix, see: https://github.com/tobie/webidl/issues/24 */
pre.grammar {
padding-bottom: 1px
}
/* end bug fix */
dt p {
display: inline;
}
.char {
font-size: 85%
}
#distinguishable-table {
font-size: 80%;
border-collapse: collapse;
width: auto;
}
#distinguishable-table th {
text-align: right;
}
#distinguishable-table thead th {
white-space: nowrap;
text-align: center;
}
#distinguishable-table .belowdiagonal {
background: #ddd;
}
#distinguishable-table td {
text-align: center;
padding: 5px 10px;
}
.csstransforms #distinguishable-table thead th {
text-align: left;
border: none;
height: 100px;
padding: 0;
}
.csstransforms #distinguishable-table td {
text-align: center;
width: 30px;
min-width: 30px;
padding: 10px 5px;
height: 19px
}
/* Firefox needs the extra DIV for some reason, otherwise the text disappears if you rotate */
.csstransforms #distinguishable-table tr:first-child th div {
-webkit-transform: translate(26px, 31px) rotate(315deg);
transform: translate(26px, 31px) rotate(315deg);
width: 30px;
}
.csstransforms #distinguishable-table thead th div span {
border-bottom: 1px solid #ccc;
padding: 5px 10px;
display: block;
min-width: 120px;
text-align: left
}
.csstransforms #distinguishable-table thead th:last-child div span {
border-bottom: none;
}
</style>
<h2 id="introduction">Introduction</h2>
<i>This section is informative.</i>
This standard defines an interface definition language, Web IDL, that can be used to describe
interfaces that are intended to be implemented in web browsers. Web IDL is an IDL variant with a
number of features that allow the behavior of common script objects in the web platform to be
specified more readily. How interfaces described with Web IDL correspond to constructs within
ECMAScript execution environments is also detailed here.
Concretely, Web IDL provides a syntax for specifying the surface APIs of web platform objects, as
well as ECMAScript bindings that detail how those APIs manifest as ECMAScript constructs. This
ensures common tasks, such as installing global properties, processing numeric inputs, or exposing
iteration behavior, remain uniform across web platform specifications: such specifications describe
their interfaces using Web IDL, and then use prose to specify API-specific details.
<h2 id="idl">Interface definition language</h2>
This section describes a language, <em>Web IDL</em>, which can be used to define
interfaces for APIs in the Web platform. A specification that defines Web APIs
can include one or more <dfn id="dfn-idl-fragment" export lt="IDL fragment">IDL fragments</dfn> that
describe the interfaces (the state and behavior that objects can exhibit)
for the APIs defined by that specification.
An [=IDL fragment=] is
a sequence of definitions that matches the <emu-nt><a href="#prod-Definitions">Definitions</a></emu-nt> grammar symbol.
The set of [=IDL fragments=] that
an implementation supports is not ordered.
See [[#idl-grammar]] for the complete grammar and an explanation of the notation used.
The different kinds of <dfn id="dfn-definition">definitions</dfn> that can appear in an
[=IDL fragment=] are:
[=interfaces=],
[=partial interface|partial interface definitions=],
[=interface mixins=],
[=partial interface mixin|partial mixin definitions=],
[=callback functions=],
[=callback interfaces=],
[=namespaces=],
[=partial namespace|partial namespace definitions=],
[=dictionary|dictionaries=],
[=partial dictionary|partial dictionary definitions=],
[=typedefs=] and
[=includes statements=].
These are all defined in the following sections.
Each [=definition=]
(matching <emu-nt><a href="#prod-Definition">Definition</a></emu-nt>)
can be preceded by a list of [=extended attributes=] (matching
<emu-nt><a href="#prod-ExtendedAttributeList">ExtendedAttributeList</a></emu-nt>),
which can control how the definition will be handled in language bindings.
The extended attributes defined by this specification that are language binding
agnostic are discussed in [[#idl-extended-attributes]],
while those specific to the ECMAScript language binding are discussed
in [[#es-extended-attributes]].
<pre highlight="webidl" class="syntax">
[<mark>extended_attributes</mark>]
interface identifier {
/* interface_members... */
};
</pre>
<pre class="grammar" id="prod-Definitions">
Definitions :
ExtendedAttributeList Definition Definitions
ε
</pre>
<pre class="grammar" id="prod-Definition">
Definition :
CallbackOrInterfaceOrMixin
Namespace
Partial
Dictionary
Enum
Typedef
IncludesStatement
</pre>
<div class="example" id="example-25f60a7c">
The following is an example of an [=IDL fragment=].
<pre highlight="webidl">
[Exposed=Window]
interface Paint { };
[Exposed=Window]
interface SolidColor : Paint {
attribute double red;
attribute double green;
attribute double blue;
};
[Exposed=Window]
interface Pattern : Paint {
attribute DOMString imageURL;
};
[Exposed=Window]
interface GraphicalWindow {
constructor();
readonly attribute unsigned long width;
readonly attribute unsigned long height;
attribute Paint currentPaint;
undefined drawRectangle(double x, double y, double width, double height);
undefined drawText(double x, double y, DOMString text);
};
</pre>
Here, four [=interfaces=]
are being defined.
The <code class="idl">GraphicalWindow</code> interface has two
[=read only=] [=attributes=],
one writable attribute, and two [=operations=]
defined on it. Objects that implement the <code class="idl">GraphicalWindow</code> interface
will expose these attributes and operations in a manner appropriate to the
particular language being used.
In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor
properties and the operations as data properties whose value is a [=built-in function object=] on a
prototype object for all <code class="idl">GraphicalWindow</code>
objects; each ECMAScript object that implements <code class="idl">GraphicalWindow</code>
will have that prototype object in its prototype chain.
The [=constructor operation=] that appears on <code class="idl">GraphicalWindow</code>
causes a [=constructor=] to exist in ECMAScript implementations,
so that calling <code>new GraphicalWindow()</code> would return a new object
that implemented the interface.
All [=interfaces=] have the [{{Exposed}}] [=extended attribute=], which ensures the interfaces
are only available in [=Realms=] whose [=Realm/global object=] is a {{Window}} object.
</div>
<h3 id="idl-names">Names</h3>
Every [=interface=],
[=partial interface|partial interface definition=],
[=namespace=],
[=partial namespace|partial namespace definition=],
[=dictionary=],
[=partial dictionary|partial dictionary definition=],
[=enumeration=],
[=callback function=],
[=callback interface=] and
[=typedef=] (together called <dfn id="dfn-named-definition" export lt="named definition">named definitions</dfn>)
and every [=constant=],
[=attribute=],
and [=dictionary member=] has an
<dfn id="dfn-identifier" export>identifier</dfn>, as do some
[=operations=].
The identifier is determined by an
<emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token somewhere
in the declaration:
* For [=named definitions=],
the <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token that appears
directly after the <emu-t>interface</emu-t>, <emu-t>namespace</emu-t>,
<emu-t>dictionary</emu-t>, <emu-t>enum</emu-t>
or <emu-t>callback</emu-t> keyword
determines the identifier of that definition.
<pre highlight="webidl" class="syntax">
interface <mark>interface_identifier</mark> { /* interface_members... */ };
partial interface <mark>interface_identifier</mark> { /* interface_members... */ };
namespace <mark>namespace_identifier</mark> { /* namespace_members... */ };
partial namespace <mark>namespace_identifier</mark> { /* namespace_members... */ };
dictionary <mark>dictionary_identifier</mark> { /* dictionary_members... */ };
partial dictionary <mark>dictionary_identifier</mark> { /* dictionary_members... */ };
enum <mark>enumeration_identifier</mark> { "enum", "values" /* , ... */ };
callback <mark>callback_identifier</mark> = return_type (/* arguments... */);
callback interface <mark>callback_interface_identifier</mark> { /* interface_members... */ };
</pre>
* For [=attributes=],
[=typedefs=]
and [=dictionary members=],
the final <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token before the
semicolon at the end of the declaration determines the identifier.
<pre highlight="webidl" class="syntax">
[extended_attributes]
interface identifier {
attribute type <mark>attribute_identifier</mark>;
};
typedef type <mark>typedef_identifier</mark>;
dictionary identifier {
type <mark>dictionary_member_identifier</mark>;
};
</pre>
* For [=constants=],
the <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token before the
equals sign determines the identifier.
<pre highlight="webidl" class="syntax">const type <mark>constant_identifier</mark> = 42;</pre>
* For [=operations=], the
<emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token that appears
after the return type but before the opening parenthesis (that is,
one that is matched as part of the <emu-nt><a href="#prod-OptionalOperationName">OptionalOperationName</a></emu-nt>
grammar symbol in an <emu-nt><a href="#prod-OperationRest">OperationRest</a></emu-nt>) determines the identifier of the operation. If
there is no such <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token,
then the operation does not have an identifier.
<pre highlight="webidl" class="syntax">
interface interface_identifier {
return_type <mark>operation_identifier</mark>(/* arguments... */);
};
</pre>
Note: Operations can have no identifier when they are being used to declare a
[=special operation|special kind of operation=], such as a getter or setter.
For all of these constructs, the [=identifier=]
is the value of the <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token with any leading
<span class="char">U+005F LOW LINE ("_")</span> character (underscore) removed.
Note: A leading <span class="char">"_"</span> is used to escape an identifier from looking
like a reserved word so that, for example, an interface named "<code>interface</code>" can be
defined. The leading <span class="char">"_"</span> is dropped to unescape the
identifier.
Operation arguments can take a slightly wider set of identifiers. In an operation
declaration, the identifier of an argument is specified immediately after its
type and is given by either an <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t>
token or by one of the keywords that match the <emu-nt><a href="#prod-ArgumentNameKeyword">ArgumentNameKeyword</a></emu-nt>
symbol. If one of these keywords is used, it need not be escaped with a leading
underscore.
<pre highlight="webidl" class="syntax">
interface interface_identifier {
return_type operation_identifier(argument_type <mark>argument_identifier</mark> /* , ... */);
};
</pre>
<pre class="grammar" id="prod-ArgumentNameKeyword">
ArgumentNameKeyword :
"async"
"attribute"
"callback"
"const"
"constructor"
"deleter"
"dictionary"
"enum"
"getter"
"includes"
"inherit"
"interface"
"iterable"
"maplike"
"mixin"
"namespace"
"partial"
"readonly"
"required"
"setlike"
"setter"
"static"
"stringifier"
"typedef"
"unrestricted"
</pre>
If an <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> token is used, then the
[=identifier=] of the operation argument
is the value of that token with any leading
<span class="char">U+005F LOW LINE ("_")</span> character (underscore) removed.
If instead one of the <emu-nt><a href="#prod-ArgumentNameKeyword">ArgumentNameKeyword</a></emu-nt>
keyword token is used, then the [=identifier=] of the operation argument
is simply that token.
The [=identifier=] of any of the abovementioned
IDL constructs (except operation arguments) must not be "<code>constructor</code>",
"<code>toString</code>",
or begin with a <span class="char">U+005F LOW LINE ("_")</span> character. These
are known as <dfn id="dfn-reserved-identifier" export>reserved identifiers</dfn>.
Although the "<code>toJSON</code>" [=identifier=] is not a [=reserved identifier=],
it must only be used for [=regular operations=]
that convert objects to [=JSON types=],
as described in [[#idl-tojson-operation]].
Note: Further restrictions on identifier names for particular constructs can be made
in later sections.
Within the set of [=IDL fragments=]
that a given implementation supports,
the [=identifier=] of every
[=interface=],
[=namespace=],
[=dictionary=],
[=enumeration=],
[=callback function=],
[=callback interface=] and
[=typedef=]
must not
be the same as the identifier of any other
[=interface=],
[=namespace=],
[=dictionary=],
[=enumeration=],
[=callback function=],
[=callback interface=] or
[=typedef=].
Within an [=IDL fragment=], a reference
to a [=definition=] need not appear after
the declaration of the referenced definition. References can also be made
across [=IDL fragments=].
<div class="example" id="example-679e8e2c">
Therefore, the following [=IDL fragment=] is valid:
<pre highlight="webidl">
[Exposed=Window]
interface B : A {
undefined f(SequenceOfLongs x);
};
[Exposed=Window]
interface A {
};
typedef sequence<long> SequenceOfLongs;
</pre>
</div>
<div class="example" id="example-1192ff1f">
The following [=IDL fragment=]
demonstrates how [=identifiers=]
are given to definitions and [=interface members=].
<pre highlight="webidl">
// Typedef identifier: "number"
typedef double number;
// Interface identifier: "System"
[Exposed=Window]
interface System {
// Operation identifier: "createObject"
// Operation argument identifier: "interface"
object createObject(DOMString _interface);
// Operation argument identifier: "interface"
sequence<object> getObjects(DOMString interface);
// Operation has no identifier; it declares a getter.
getter DOMString (DOMString keyName);
};
// Interface identifier: "TextField"
[Exposed=Window]
interface TextField {
// Attribute identifier: "const"
attribute boolean _const;
// Attribute identifier: "value"
attribute DOMString? _value;
};
</pre>
Note that while the second [=attribute=]
on the <code class="idl">TextField</code> [=interface=]
need not have been escaped with an underscore (because "<code>value</code>" is
not a keyword in the IDL grammar), it is still unescaped
to obtain the attribute’s [=identifier=].
</div>
<h3 id="idl-interfaces">Interfaces</h3>
[=IDL fragments=] are used to
describe object oriented systems. In such systems, objects are entities
that have identity and which are encapsulations of state and behavior.
An <dfn id="dfn-interface" export>interface</dfn> is a definition (matching
<emu-t>interface</emu-t> <emu-nt><a href="#prod-InterfaceRest">InterfaceRest</a></emu-nt>) that declares some
state and behavior that an object implementing that interface will expose.
<pre highlight="webidl" class="syntax">
[extended_attributes]
interface identifier {
/* interface_members... */
};
</pre>
An interface is a specification of a set of
<dfn id="dfn-interface-member" export lt="interface member">interface members</dfn>
(matching <emu-nt><a href="#prod-InterfaceMembers">InterfaceMembers</a></emu-nt>).
These are the [=members=] that appear between the braces in the interface declaration.
Interfaces in Web IDL describe how objects that implement the
interface behave. In bindings for object oriented languages, it is
expected that an object that implements a particular IDL interface
provides ways to inspect and modify the object's state and to
invoke the behavior described by the interface.
An interface can be defined to <dfn id="dfn-inherit" for="interface" export>inherit</dfn> from another interface.
If the identifier of the interface is followed by a
<span class="char">U+003A COLON (":")</span> character
and an [=identifier=],
then that identifier identifies the inherited interface.
An object that implements an interface that inherits from another
also implements that inherited interface. The object therefore will also
have members that correspond to the interface members from the inherited interface.
<pre highlight="webidl" class="syntax">
interface identifier : <mark>identifier_of_inherited_interface</mark> {
/* interface_members... */
};
</pre>
The order that members appear in has significance for property enumeration in the <a href="#es-interfaces">ECMAScript binding</a>.
Interfaces may specify an interface member that has the same name as
one from an inherited interface. Objects that implement the derived
interface will expose the member on the derived interface. It is
language binding specific whether the overridden member can be
accessed on the object.
<div class="example" id="example-367b9481">
Consider the following two interfaces.
<pre highlight="webidl">
[Exposed=Window]
interface A {
undefined f();
undefined g();
};
[Exposed=Window]
interface B : A {
undefined f();
undefined g(DOMString x);
};
</pre>
In the ECMAScript language binding, an instance of <code class="idl">B</code>
will have a prototype chain that looks like the following:
<pre>
[Object.prototype: the Object prototype object]
↑
[A.prototype: interface prototype object for A]
↑
[B.prototype: interface prototype object for B]
↑
[instanceOfB]
</pre>
Calling <code>instanceOfB.f()</code> in ECMAScript will invoke the f defined
on <code class="idl">B</code>. However, the f from <code class="idl">A</code>
can still be invoked on an object that implements <code class="idl">B</code> by
calling <code>A.prototype.f.call(instanceOfB)</code>.
</div>
The <dfn id="dfn-inherited-interfaces" export>inherited interfaces</dfn> of
a given interface |A| is the set of all interfaces that |A|
inherits from, directly or indirectly. If |A| does not [=interface/inherit=]
from another interface, then the set is empty. Otherwise, the set
includes the interface |B| that |A| [=interface/inherits=]
from and all of |B|’s [=inherited interfaces=].
An interface must not be declared such that
its inheritance hierarchy has a cycle. That is, an interface
|A| cannot inherit from itself, nor can it inherit from another
interface |B| that inherits from |A|, and so on.
<div algorithm>
The [=list=] of <dfn for=interface>inclusive inherited interfaces</dfn> of an [=interface=] |I|
is defined as follows:
1. Let |result| be « ».
1. Let |interface| be |I|.
1. While |interface| is not null:
1. [=list/Append=] |interface| to |result|.
1. Set |interface| to the [=interface=] that |I| [=interface/inherits=] from, if any, and
null otherwise.
1. Return |result|.
</div>
Note that general multiple inheritance of interfaces is not supported, and
objects also cannot implement arbitrary sets of interfaces.
Objects can be defined to implement a single given interface |A|,
which means that it also implements all of |A|’s [=inherited interfaces=].
In addition, an [=includes statement=] can be used
to define that objects implementing an [=interface=] |A|
will always also include the [=interface mixin member|members=]
of the [=interface mixins=] |A| [=includes=].
Each interface member can be preceded by a list of [=extended attributes=] (matching
<emu-nt><a href="#prod-ExtendedAttributeList">ExtendedAttributeList</a></emu-nt>),
which can control how the interface member will be handled in language bindings.
<pre highlight="webidl" class="syntax">
[extended_attributes]
interface identifier {
[<mark>extended_attributes</mark>]
const type constant_identifier = 42;
[<mark>extended_attributes</mark>]
attribute type identifier;
[<mark>extended_attributes</mark>]
return_type identifier(/* arguments... */);
};
</pre>
The IDL for interfaces can be split into multiple parts by using
<dfn id="dfn-partial-interface" export>partial interface</dfn> definitions
(matching <emu-t>partial</emu-t> <emu-t>interface</emu-t>
<emu-nt><a href="#prod-PartialInterfaceRest">PartialInterfaceRest</a></emu-nt>).
The [=identifier=] of a partial
interface definition must be the same
as the identifier of an interface definition. All of
the members that appear on each of the partial interfaces are considered to be
members of the interface itself.
<pre highlight="webidl" class="syntax">
interface <mark>SomeInterface</mark> {
/* interface_members... */
};
partial interface <mark>SomeInterface</mark> {
/* interface_members... */
};
</pre>
Note: Partial interface definitions are intended for use as a specification
editorial aide, allowing the definition of an interface to be separated
over more than one section of the document, and sometimes multiple documents.
The order of appearance of an [=interface=]
definition and any of its [=partial interface=]
definitions does not matter.
Note: A partial interface definition cannot specify that the interface
[=interface/inherits=] from another interface.
Inheritance is to be specified on the original [=interface=]
definition.
The relevant language binding determines how interfaces correspond to constructs
in the language.
The following extended attributes are applicable to interfaces:
[{{CrossOriginIsolated}}],
[{{Exposed}}],
[{{Global}}],
[{{LegacyFactoryFunction}}],
[{{LegacyNoInterfaceObject}}],
[{{LegacyOverrideBuiltIns}}],
[{{LegacyWindowAlias}}], and
[{{SecureContext}}].
The following extended attributes are applicable to [=partial interfaces=]:
[{{CrossOriginIsolated}}],
[{{Exposed}}],
[{{LegacyOverrideBuiltIns}}], and
[{{SecureContext}}].
[=Interfaces=] must be annotated with an [{{Exposed}}] [=extended attribute=].
<div algorithm>
The <dfn>qualified name</dfn> of an [=interface=] |interface| is defined as follows:
1. Let |identifier| be the [=identifier=] of |interface|.
1. If |interface| has a [{{LegacyNamespace}}] [=extended attribute=], then:
1. Let |namespace| be the identifier argument of the [{{LegacyNamespace}}]
[=extended attribute=].
1. Return the [=concatenation=] of « |namespace|, |identifier| » with
separator <span class="char">U+002E FULL STOP (".")</span>.
1. Return |identifier|.
</div>
<pre class="grammar" id="prod-CallbackOrInterfaceOrMixin">
CallbackOrInterfaceOrMixin :
"callback" CallbackRestOrInterface
"interface" InterfaceOrMixin
</pre>
<pre class="grammar" id="prod-InterfaceOrMixin">
InterfaceOrMixin :
InterfaceRest
MixinRest
</pre>
<pre class="grammar" id="prod-InterfaceRest">
InterfaceRest :
identifier Inheritance "{" InterfaceMembers "}" ";"
</pre>
<pre class="grammar" id="prod-Partial">
Partial :
"partial" PartialDefinition
</pre>
<pre class="grammar" id="prod-PartialDefinition">
PartialDefinition :
"interface" PartialInterfaceOrPartialMixin
PartialDictionary
Namespace
</pre>
<pre class="grammar" id="prod-PartialInterfaceOrPartialMixin">
PartialInterfaceOrPartialMixin :
PartialInterfaceRest
MixinRest
</pre>
<pre class="grammar" id="prod-PartialInterfaceRest">
PartialInterfaceRest :
identifier "{" PartialInterfaceMembers "}" ";"
</pre>
<pre class="grammar" id="prod-InterfaceMembers">
InterfaceMembers :
ExtendedAttributeList InterfaceMember InterfaceMembers
ε
</pre>
<pre class="grammar" id="prod-InterfaceMember">
InterfaceMember :
PartialInterfaceMember
Constructor