OLD | NEW |
1 # Blink IDL Extended Attributes | 1 # Blink IDL Extended Attributes |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Introduction | 5 ## Introduction |
6 | 6 |
7 The main interest in extended attributes are their _semantics_: Blink implements
many more extended attributes than the Web IDL standard, to specify various beh
avior. | 7 The main interest in extended attributes are their _semantics_: Blink implements
many more extended attributes than the Web IDL standard, to specify various beh
avior. |
8 | 8 |
9 The authoritative list of allowed extended attributes and values is [bindings/ID
LExtendedAttributes.txt](https://code.google.com/p/chromium/codesearch#chromium/
src/third_party/WebKit/Source/bindings/IDLExtendedAttributes.txt). This is compl
ete but not necessarily precise (there may be unused extended attributes or valu
es), since validation is run on build, but coverage isn't checked. | 9 The authoritative list of allowed extended attributes and values is [bindings/ID
LExtendedAttributes.txt](https://code.google.com/p/chromium/codesearch#chromium/
src/third_party/WebKit/Source/bindings/IDLExtendedAttributes.txt). This is compl
ete but not necessarily precise (there may be unused extended attributes or valu
es), since validation is run on build, but coverage isn't checked. |
10 | 10 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 interface GraphicsContext { | 241 interface GraphicsContext { |
242 void setColor(octet red, octet green, octet blue); | 242 void setColor(octet red, octet green, octet blue); |
243 void setColorEnforced([EnforceRange] octet red, [EnforceRange] octet green,
[EnforceRange] octet blue); | 243 void setColorEnforced([EnforceRange] octet red, [EnforceRange] octet green,
[EnforceRange] octet blue); |
244 }; | 244 }; |
245 ``` | 245 ``` |
246 | 246 |
247 Calling the non-`[EnforceRange]` version of `setColor()` uses **ToUint8()** to c
oerce the Numbers to octets. Hence calling `context.setColor(-1, 255, 257)` is e
quivalent to calling `setColor(255, 255, 1)`. | 247 Calling the non-`[EnforceRange]` version of `setColor()` uses **ToUint8()** to c
oerce the Numbers to octets. Hence calling `context.setColor(-1, 255, 257)` is e
quivalent to calling `setColor(255, 255, 1)`. |
248 | 248 |
249 Calling the `[EnforceRange]` version of `setColorEnforced()` with an out of rang
e value, such as -1, 256, or Infinity will result in a `TypeError` exception. | 249 Calling the `[EnforceRange]` version of `setColorEnforced()` with an out of rang
e value, such as -1, 256, or Infinity will result in a `TypeError` exception. |
250 | 250 |
| 251 ### [Exposed] _(i, m, a, c)_ |
| 252 |
| 253 Standard: [Exposed](http://heycam.github.io/webidl/#Exposed) |
| 254 |
| 255 Summary: Indicates on which global object or objects (e.g., Window, WorkerGlobal
Scope) the interface property is generated, i.e., in which global scope or scope
s an interface exists. This is primarily of interest for the constructor, i.e.,
the [interface object Call method](https://heycam.github.io/webidl/#es-interface
-call). Global context defaults to Window (the primary global scope) if not pres
ent, overridden by standard extended attribute `[NoInterfaceObject]` (the value
of the property on the global object corresponding to the interface is called th
e **interface object**), which results in no interface property being generated. |
| 256 |
| 257 As with `[NoInterfaceObject]` does not affect generated code for the interface i
tself, only the code for the corresponding global object. A partial interface is
generated at build time, containing an attribute for each interface property on
that global object. |
| 258 |
| 259 All non-callback interfaces without `[NoInterfaceObject]` have a corresponding i
nterface property on the global object. Note that in the Web IDL spec, callback
interfaces with constants also have interface properties, but in Blink callback
interfaces only have methods (no constants or attributes), so this is not applic
able. `[Exposed]` can be used with different values to indicate on which global
object or objects the property should be generated. Valid values are: |
| 260 |
| 261 * `Window` |
| 262 * [Worker](http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.h
tml#the-workerglobalscope-common-interface) |
| 263 * [SharedWorker](http://www.whatwg.org/specs/web-apps/current-work/multipage/wor
kers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface) |
| 264 * [DedicatedWorker](http://www.whatwg.org/specs/web-apps/current-work/multipage/
workers.html#shared-workers-and-the-sharedworkerglobalscope-interface) |
| 265 * [ServiceWorker](https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/se
rvice_worker/index.html#service-worker-global-scope) |
| 266 |
| 267 For reference, see [ECMAScript 5.1: 15.1 The Global Object](http://www.ecma-inte
rnational.org/ecma-262/5.1/#sec-15.1) ([annotated](http://es5.github.io/#x15.1))
, [HTML: 10 Web workers](http://www.whatwg.org/specs/web-apps/current-work/multi
page/workers.html), [Web Workers](http://dev.w3.org/html5/workers/), and [Servic
e Workers](https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_w
orker/index.html) specs. |
| 268 |
| 269 It is possible to have the global constructor generated on several interfaces by
listing them, e.g. `[Exposed=(Window,WorkerGlobalScope)]`. |
| 270 |
| 271 Usage: `[Exposed]` can be specified on interfaces that do not have the `[NoInter
faceObject]` extended attribute. |
| 272 |
| 273 ```webidl |
| 274 [ |
| 275 Exposed=DedicatedWorker, |
| 276 ] interface XXX { |
| 277 ... |
| 278 }; |
| 279 |
| 280 [ |
| 281 Exposed=(Window,Worker), |
| 282 ] interface YYY { |
| 283 ... |
| 284 }; |
| 285 ``` |
| 286 |
| 287 Exposed can also be specified with a method, attribute and constant. |
| 288 |
| 289 As a Blink-specific extension, we allow `Exposed(Arguments)` form, such as `[Exp
osed(Window Feature1, DedicatedWorker Feature2)]`. You can use this form to vary
the exposing global scope based on runtime enabled features. For example, `[Exp
osed(Window Feature1, Worker Feature2)]` exposes the qualified element to Window
if "Feature1" is enabled and to Worker if "Feature2" is enabled. |
| 290 |
| 291 ### [Global] and [PrimaryGlobal] _(i)_ |
| 292 |
| 293 Standard: [Global](http://heycam.github.io/webidl/#Global) |
| 294 |
| 295 Summary: The `[Global]` and `[PrimaryGlobal]` extended attributes can be used to
give a name to one or more global interfaces, which can then be referenced by t
he `[Exposed]` extended attribute. |
| 296 |
| 297 These extended attributes must either take no arguments or take an identifier li
st. |
| 298 |
| 299 If the `[Global]` or `[PrimaryGlobal]` extended attribute is declared with an id
entifier list argument, then those identifiers are the interface’s global names;
otherwise, the interface has a single global name, which is the interface's ide
ntifier. |
| 300 |
| 301 ### [HTMLConstructor] |
| 302 |
| 303 Standard: [HTMLConstructor](https://html.spec.whatwg.org/multipage/dom.html#html
-element-constructors) |
| 304 |
| 305 Summary: HTML Elements have special constructor behavior. Interface object of gi
ven interface with the `[HTMLConstructor]` attribute will have specific behavior
when called. |
| 306 |
| 307 Usage: Must take no arguments, and must not appear on anything other than an int
erface. It much appear once on an interface, and the interface cannot be annotat
ed with `[Constructor]` or `[NoInterfaceObject]` extended attributes. It must no
t be used on a callback interface. |
251 | 308 |
252 ### [NamedConstructor] _(i)_ | 309 ### [NamedConstructor] _(i)_ |
253 | 310 |
254 Standard: [NamedConstructor](https://heycam.github.io/webidl/#NamedConstructor) | 311 Standard: [NamedConstructor](https://heycam.github.io/webidl/#NamedConstructor) |
255 | 312 |
256 Summary: If you want to allow JavaScript to create a DOM object of XXX using a d
ifferent name constructor (i.e. allow JavaScript to create an XXX object using "
new YYY()", where YYY != XXX), you can use `[NamedConstructor]`. | 313 Summary: If you want to allow JavaScript to create a DOM object of XXX using a d
ifferent name constructor (i.e. allow JavaScript to create an XXX object using "
new YYY()", where YYY != XXX), you can use `[NamedConstructor]`. |
257 | 314 |
258 Usage: The possible usage is `[NamedConstructor=YYY(...)]`. Just as with constru
ctors, an empty argument list can be omitted, as: `[NamedConstructor=YYY]`. `[Na
medConstructor]` can be specified on interfaces. The spec allows multiple named
constructors, but the Blink IDL compiler currently only supports at most one. | 315 Usage: The possible usage is `[NamedConstructor=YYY(...)]`. Just as with constru
ctors, an empty argument list can be omitted, as: `[NamedConstructor=YYY]`. `[Na
medConstructor]` can be specified on interfaces. The spec allows multiple named
constructors, but the Blink IDL compiler currently only supports at most one. |
259 | 316 |
260 ```webidl | 317 ```webidl |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 Note that `[NoInterfaceObject]` **MUST** be specified on testing interfaces, as
follows: | 358 Note that `[NoInterfaceObject]` **MUST** be specified on testing interfaces, as
follows: |
302 | 359 |
303 ```webidl | 360 ```webidl |
304 [ | 361 [ |
305 NoInterfaceObject, // testing interfaces do not appear on global objects | 362 NoInterfaceObject, // testing interfaces do not appear on global objects |
306 ] interface TestingInterfaceX { | 363 ] interface TestingInterfaceX { |
307 ... | 364 ... |
308 }; | 365 }; |
309 ``` | 366 ``` |
310 | 367 |
311 ### [Global] and [PrimaryGlobal] _(i)_ | |
312 | |
313 Standard: [Global](http://heycam.github.io/webidl/#Global) | |
314 | |
315 Summary: The `[Global]` and `[PrimaryGlobal]` extended attributes can be used to
give a name to one or more global interfaces, which can then be referenced by t
he `[Exposed]` extended attribute. | |
316 | |
317 These extended attributes must either take no arguments or take an identifier li
st. | |
318 | |
319 If the `[Global]` or `[PrimaryGlobal]` extended attribute is declared with an id
entifier list argument, then those identifiers are the interface’s global names;
otherwise, the interface has a single global name, which is the interface's ide
ntifier. | |
320 | |
321 ### [Exposed] _(i, m, a, c)_ | |
322 | |
323 Standard: [Exposed](http://heycam.github.io/webidl/#Exposed) | |
324 | |
325 Summary: Indicates on which global object or objects (e.g., Window, WorkerGlobal
Scope) the interface property is generated, i.e., in which global scope or scope
s an interface exists. This is primarily of interest for the constructor, i.e.,
the [interface object Call method](https://heycam.github.io/webidl/#es-interface
-call). Global context defaults to Window (the primary global scope) if not pres
ent, overridden by standard extended attribute `[NoInterfaceObject]` (the value
of the property on the global object corresponding to the interface is called th
e **interface object**), which results in no interface property being generated. | |
326 | |
327 As with `[NoInterfaceObject]` does not affect generated code for the interface i
tself, only the code for the corresponding global object. A partial interface is
generated at build time, containing an attribute for each interface property on
that global object. | |
328 | |
329 All non-callback interfaces without `[NoInterfaceObject]` have a corresponding i
nterface property on the global object. Note that in the Web IDL spec, callback
interfaces with constants also have interface properties, but in Blink callback
interfaces only have methods (no constants or attributes), so this is not applic
able. `[Exposed]` can be used with different values to indicate on which global
object or objects the property should be generated. Valid values are: | |
330 | |
331 * `Window` | |
332 * [Worker](http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.h
tml#the-workerglobalscope-common-interface) | |
333 * [SharedWorker](http://www.whatwg.org/specs/web-apps/current-work/multipage/wor
kers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface) | |
334 * [DedicatedWorker](http://www.whatwg.org/specs/web-apps/current-work/multipage/
workers.html#shared-workers-and-the-sharedworkerglobalscope-interface) | |
335 * [ServiceWorker](https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/se
rvice_worker/index.html#service-worker-global-scope) | |
336 | |
337 For reference, see [ECMAScript 5.1: 15.1 The Global Object](http://www.ecma-inte
rnational.org/ecma-262/5.1/#sec-15.1) ([annotated](http://es5.github.io/#x15.1))
, [HTML: 10 Web workers](http://www.whatwg.org/specs/web-apps/current-work/multi
page/workers.html), [Web Workers](http://dev.w3.org/html5/workers/), and [Servic
e Workers](https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_w
orker/index.html) specs. | |
338 | |
339 It is possible to have the global constructor generated on several interfaces by
listing them, e.g. `[Exposed=(Window,WorkerGlobalScope)]`. | |
340 | |
341 Usage: `[Exposed]` can be specified on interfaces that do not have the `[NoInter
faceObject]` extended attribute. | |
342 | |
343 ```webidl | |
344 [ | |
345 Exposed=DedicatedWorker, | |
346 ] interface XXX { | |
347 ... | |
348 }; | |
349 | |
350 [ | |
351 Exposed=(Window,Worker), | |
352 ] interface YYY { | |
353 ... | |
354 }; | |
355 ``` | |
356 | |
357 Exposed can also be specified with a method, attribute and constant. | |
358 | |
359 As a Blink-specific extension, we allow `Exposed(Arguments)` form, such as `[Exp
osed(Window Feature1, DedicatedWorker Feature2)]`. You can use this form to vary
the exposing global scope based on runtime enabled features. For example, `[Exp
osed(Window Feature1, Worker Feature2)]` exposes the qualified element to Window
if "Feature1" is enabled and to Worker if "Feature2" is enabled. | |
360 | |
361 ### [OverrideBuiltins] _(i)_ | 368 ### [OverrideBuiltins] _(i)_ |
362 | 369 |
363 Standard: [OverrideBuiltins](http://heycam.github.io/webidl/#OverrideBuiltins) | 370 Standard: [OverrideBuiltins](http://heycam.github.io/webidl/#OverrideBuiltins) |
364 | 371 |
365 Summary: Affects named property operations, making named properties shadow built
-in properties of the object. | 372 Summary: Affects named property operations, making named properties shadow built
-in properties of the object. |
366 | 373 |
367 ### [PutForwards] _(a)_ | 374 ### [PutForwards] _(a)_ |
368 | 375 |
369 Standard: [PutForwards](http://heycam.github.io/webidl/#PutForwards) | 376 Standard: [PutForwards](http://heycam.github.io/webidl/#PutForwards) |
370 | 377 |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 Copyright (C) 2009 Apple Inc. All rights reserved. | 1596 Copyright (C) 2009 Apple Inc. All rights reserved. |
1590 | 1597 |
1591 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: | 1598 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: |
1592 | 1599 |
1593 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. | 1600 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. |
1594 | 1601 |
1595 2. Redistributions in binary form must reproduce the above copyright notice, thi
s list of conditions and the following disclaimer in the documentation and/or ot
her materials provided with the distribution. | 1602 2. Redistributions in binary form must reproduce the above copyright notice, thi
s list of conditions and the following disclaimer in the documentation and/or ot
her materials provided with the distribution. |
1596 | 1603 |
1597 THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS “AS IS” AND ANY EXP
RESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIE
S OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, I
NCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMI
TED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFI
TS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHE
THER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
BILITY OF SUCH DAMAGE. | 1604 THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS “AS IS” AND ANY EXP
RESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIE
S OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, I
NCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMI
TED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFI
TS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHE
THER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
BILITY OF SUCH DAMAGE. |
1598 *** | 1605 *** |
OLD | NEW |