Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: third_party/WebKit/Source/bindings/IDLExtendedAttributes.md

Issue 2408083003: Drop [ExperimentalCallbackFunction] (Closed)
Patch Set: Update tests and expectations Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/code_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 Syntactically, Blink IDL extended attributes differ from standard Web IDL extend ed attributes in a few ways: 11 Syntactically, Blink IDL extended attributes differ from standard Web IDL extend ed attributes in a few ways:
12 12
13 * trailing commas are allowed (for convenience), 13 * trailing commas are allowed (for convenience),
14 * the value of a key=value pair can be a string literal, not just an identifier: `key="foo"` or `key=("foo","bar")` 14 * the value of a key=value pair can be a string literal, not just an identifier: `key="foo"` or `key=("foo","bar")`
15 15
16 Blink IDL also does not support certain recent features of the Web IDL grammar: 16 Blink IDL also does not support certain recent features of the Web IDL grammar:
17 17
18 * Values that are not identifiers or strings are _not_ supported (the `Other` pr oduction): any non-identifier should simply be quoted (this could be changed to remove the need for quotes, but requires rather lengthy additions to the parser) . 18 * Values that are not identifiers or strings are _not_ supported (the `Other` pr oduction): any non-identifier should simply be quoted (this could be changed to remove the need for quotes, but requires rather lengthy additions to the parser) .
19 19
20 Semantically, only certain extended attributes allow lists. Similarly, only cert ain extended attributes allow string literals. 20 Semantically, only certain extended attributes allow lists. Similarly, only cert ain extended attributes allow string literals.
21 21
22 Extended attributes either take no value, take a required value, or take an opti onal value. 22 Extended attributes either take no value, take a required value, or take an opti onal value.
23 In the following explanations, _(i)_, _(m)_, _(s)_, _(a)_, _(p)_, _(c)_, and _(d )_ mean that a given extended attribute can be specified on interfaces, methods, special operations, attributes, parameters, constants, and dictionaries, respec tively. For example, _(a,p)_ means that the IDL attribute can be specified on at tributes and parameters. 23 In the following explanations, _(i)_, _(m)_, _(s)_, _(a)_, _(p)_, _(c)_, _(d)_, and _(f)_ mean that a given extended attribute can be specified on interfaces, m ethods, special operations, attributes, parameters, constants, dictionaries, and callback functions respectively. For example, _(a,p)_ means that the IDL attrib ute can be specified on attributes and parameters.
24 24
25 *** note 25 *** note
26 These restrictions are not enforced by the parser: extended attributes used in u nsupported contexts will simply be ignored. 26 These restrictions are not enforced by the parser: extended attributes used in u nsupported contexts will simply be ignored.
27 *** 27 ***
28 28
29 As a rule, we do _not_ add extended attributes to the IDL that are not supported by the compiler (and are thus nops). This is because it makes the IDL misleadin g: looking at the IDL, it looks like it should do something, but actually doesn' t, which is opaque (it requires knowledge of compiler internals). Instead, pleas e place a comment on the preceding line, with the desired extended attribute and a FIXME referring to the relevant bug. For example (back when [Bug 358506](http s://crbug.com/358506) was open): 29 As a rule, we do _not_ add extended attributes to the IDL that are not supported by the compiler (and are thus nops). This is because it makes the IDL misleadin g: looking at the IDL, it looks like it should do something, but actually doesn' t, which is opaque (it requires knowledge of compiler internals). Instead, pleas e place a comment on the preceding line, with the desired extended attribute and a FIXME referring to the relevant bug. For example (back when [Bug 358506](http s://crbug.com/358506) was open):
30 30
31 ```webidl 31 ```webidl
32 // FIXME: should be [MeasureAs=Foo] but [MeasureAs] not supported on constants: http://crbug.com/358506 32 // FIXME: should be [MeasureAs=Foo] but [MeasureAs] not supported on constants: http://crbug.com/358506
33 const unsigned short bar; 33 const unsigned short bar;
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 ```c++ 680 ```c++
681 PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, ScriptState* state, float x, float y, String str) 681 PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, ScriptState* state, float x, float y, String str)
682 { 682 {
683 ...; 683 ...;
684 } 684 }
685 ``` 685 ```
686 686
687 You can retrieve document or frame from ScriptExecutionContext. 687 You can retrieve document or frame from ScriptExecutionContext.
688 688
689 ### [Custom] _(i, m, s, a)_ 689 ### [Custom] _(i, m, s, a, f)_
690 690
691 Summary: They allow you to write bindings code manually as you like: full bindin gs for methods and attributes, certain functions for interfaces. 691 Summary: They allow you to write bindings code manually as you like: full bindin gs for methods and attributes, certain functions for interfaces.
692 692
693 Custom bindings are _strongly discouraged_. They are likely to be buggy, a sourc e of security holes, and represent a significant maintenance burden. Before usin g `[Custom]`, you should doubly consider if you really need custom bindings. You are recommended to modify code generators and add specialized extended attribut es or special cases if necessary to avoid using `[Custom]`. 693 Custom bindings are _strongly discouraged_. They are likely to be buggy, a sourc e of security holes, and represent a significant maintenance burden. Before usin g `[Custom]`, you should doubly consider if you really need custom bindings. You are recommended to modify code generators and add specialized extended attribut es or special cases if necessary to avoid using `[Custom]`.
694 694
695 Usage: `[Custom]` can be specified on methods or attributes. `[Custom=CallEpilog ue]` can be specified on methods. `[Custom=Getter]` and `[Custom=Setter]` can be specified on attributes. `[Custom=A|B]` can be specified on interfaces, with va rious values (see below). 695 Usage: `[Custom]` can be specified on methods or attributes. `[Custom=CallEpilog ue]` can be specified on methods. `[Custom=Getter]` and `[Custom=Setter]` can be specified on attributes. `[Custom=A|B]` can be specified on interfaces, with va rious values (see below).
696 696
697 On read only attributes (that are not `[Replaceable]`), `[Custom]` is equivalent to `[Custom=Getter]` (since there is no setter) and `[Custom=Getter]` is prefer red. 697 On read only attributes (that are not `[Replaceable]`), `[Custom]` is equivalent to `[Custom=Getter]` (since there is no setter) and `[Custom=Getter]` is prefer red.
698 698
699 The bindings generator largely _ignores_ the specified type information of `[Cus tom]` members (signature of methods and type of attributes), but they must be va lid types. It is best if the signature exactly matches the spec, but if one of t he types is an interface that is not implemented, you can use object as the type instead, to indicate "unspecified object type". 699 The bindings generator largely _ignores_ the specified type information of `[Cus tom]` members (signature of methods and type of attributes), but they must be va lid types. It is best if the signature exactly matches the spec, but if one of t he types is an interface that is not implemented, you can use object as the type instead, to indicate "unspecified object type".
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 [Custom] getter Node (DOMString name); 782 [Custom] getter Node (DOMString name);
783 [Custom] setter Node (DOMString name, Node value); 783 [Custom] setter Node (DOMString name, Node value);
784 [Custom] deleter boolean (DOMString name); 784 [Custom] deleter boolean (DOMString name);
785 } 785 }
786 interface YYY { // special operations with identifiers 786 interface YYY { // special operations with identifiers
787 [Custom] getter Node item(unsigned long index); 787 [Custom] getter Node item(unsigned long index);
788 [Custom] getter Node namedItem(DOMString name); 788 [Custom] getter Node namedItem(DOMString name);
789 } 789 }
790 ``` 790 ```
791 791
792 `[Custom]` may also be specified on callback functions:
793
794 ```webidl
795 [Custom] callback SomeCallback = void ();
796 interface XXX {
797 void func(SomeCallback callback);
798 };
799 ```
800
801 When`[Custom]` is specified on a callback function, the code generator doesn't
802 generate bindings for the callback function. The binding layer uses a
803 `ScriptValue` instead.
804
792 #### [Custom=PropertyQuery|PropertyEnumerator] _(s)_ 805 #### [Custom=PropertyQuery|PropertyEnumerator] _(s)_
793 806
794 Summary: `[Custom=PropertyEnumerator]` allows you to write custom bindings for t he case where properties of a given interface are enumerated; a custom named enu merator. There is currently only one use, and in that case it is used with `[Cus tom=PropertyQuery]`, since the query is also custom. 807 Summary: `[Custom=PropertyEnumerator]` allows you to write custom bindings for t he case where properties of a given interface are enumerated; a custom named enu merator. There is currently only one use, and in that case it is used with `[Cus tom=PropertyQuery]`, since the query is also custom.
795 808
796 Usage: Can be specified on named property getters: 809 Usage: Can be specified on named property getters:
797 810
798 ```webidl 811 ```webidl
799 interface XXX { 812 interface XXX {
800 [Custom=PropertyQuery|PropertyEnumerator] getter Foo (DOMString name); 813 [Custom=PropertyQuery|PropertyEnumerator] getter Foo (DOMString name);
801 }; 814 };
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 ...; 1519 ...;
1507 }; 1520 };
1508 ``` 1521 ```
1509 1522
1510 Without `[NoImplHeader]`, the IDL compiler assumes that there is XXX.h in the im pl side. With `[NoImplHeader]`, you can tell the IDL compiler that there is no X XX.h. You can use `[NoImplHeader]` when all of the DOM attributes and methods of the interface are implemented in Blink-in-JS and thus don't have any C++ header file. 1523 Without `[NoImplHeader]`, the IDL compiler assumes that there is XXX.h in the im pl side. With `[NoImplHeader]`, you can tell the IDL compiler that there is no X XX.h. You can use `[NoImplHeader]` when all of the DOM attributes and methods of the interface are implemented in Blink-in-JS and thus don't have any C++ header file.
1511 1524
1512 ## Temporary Blink-specific IDL Extended Attributes 1525 ## Temporary Blink-specific IDL Extended Attributes
1513 1526
1514 These extended attributes are _temporary_ and are only in use while some change is in progress. Unless you are involved with the change, you can generally ignor e them, and should not use them. 1527 These extended attributes are _temporary_ and are only in use while some change is in progress. Unless you are involved with the change, you can generally ignor e them, and should not use them.
1515 1528
1516 ### [ExperimentalCallbackFunction]
1517
1518 Summary: `[ExperimentalCallbackFunction]` on a callback function is a flag to co llect callback functions. Currently the code generator doesn't generate bindings for IDL callback functions (instead, it just uses `ScriptValue`). While generat ing bindings for callback functions, to change existing code which uses callback functions until the generated bindings are stabilized is undesirable. To implem ent bindings generation for IDL callback functions incrementally, [ExperimentalC allbackFunction] extended attribute is added. The code generator keeps using Scr iptValue for IDL callback functions which don't have this extended attribute.
1519
1520 ### [LegacyTreatAsPartialInterface] _(i)_ 1529 ### [LegacyTreatAsPartialInterface] _(i)_
1521 1530
1522 Summary: `[LegacyTreatAsPartialInterface]` on an interface that is the target of an `implements` statement means that the interface is treated as a partial inte rface, meaning members are accessed via static member functions in a separate cl ass, rather than as instance methods on the instance object `*impl` or class met hods on the C++ class implementing the (main) interface. This is legacy from ori ginal implementation of `implements`, and is being removed ([Bug 360435](https:/ /crbug.com/360435), nbarth@). 1531 Summary: `[LegacyTreatAsPartialInterface]` on an interface that is the target of an `implements` statement means that the interface is treated as a partial inte rface, meaning members are accessed via static member functions in a separate cl ass, rather than as instance methods on the instance object `*impl` or class met hods on the C++ class implementing the (main) interface. This is legacy from ori ginal implementation of `implements`, and is being removed ([Bug 360435](https:/ /crbug.com/360435), nbarth@).
1523 1532
1524 ## Discouraged Blink-specific IDL Extended Attributes 1533 ## Discouraged Blink-specific IDL Extended Attributes
1525 1534
1526 These extended attributes are _discouraged_ - they are not deprecated, but they should be avoided and removed if possible. 1535 These extended attributes are _discouraged_ - they are not deprecated, but they should be avoided and removed if possible.
1527 1536
1528 ### [DoNotCheckConstants] _(i)_ 1537 ### [DoNotCheckConstants] _(i)_
1529 1538
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 Copyright (C) 2009 Apple Inc. All rights reserved. 1605 Copyright (C) 2009 Apple Inc. All rights reserved.
1597 1606
1598 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1607 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1599 1608
1600 1. Redistributions of source code must retain the above copyright notice, this l ist of conditions and the following disclaimer. 1609 1. Redistributions of source code must retain the above copyright notice, this l ist of conditions and the following disclaimer.
1601 1610
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. 1611 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.
1603 1612
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. 1613 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.
1605 *** 1614 ***
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/code_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698