| 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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 ] interface Foo { ... }; | 899 ] interface Foo { ... }; |
| 900 | 900 |
| 901 interface Bar : Foo { ... }; // inherits [DependentLifetime] | 901 interface Bar : Foo { ... }; // inherits [DependentLifetime] |
| 902 ``` | 902 ``` |
| 903 | 903 |
| 904 If a DOM object does not have `[DependentLifetime]`, V8's GC collects the wrappe
r of the DOM object | 904 If a DOM object does not have `[DependentLifetime]`, V8's GC collects the wrappe
r of the DOM object |
| 905 if the wrapper is unreachable on the JS side (i.e., V8's GC assumes that the wra
pper should not be | 905 if the wrapper is unreachable on the JS side (i.e., V8's GC assumes that the wra
pper should not be |
| 906 reachable in the DOM side). Use `[DependentLifetime]` to relax the assumption. | 906 reachable in the DOM side). Use `[DependentLifetime]` to relax the assumption. |
| 907 For example, if the DOM object has `[ActiveScriptWrappable]` and implements hasP
endingActivity(), it must be annotated with | 907 For example, if the DOM object has `[ActiveScriptWrappable]` and implements hasP
endingActivity(), it must be annotated with |
| 908 `[DependentLifetime]`. Otherwise, the wrapper will be collected regardless of th
e returned value | 908 `[DependentLifetime]`. Otherwise, the wrapper will be collected regardless of th
e returned value |
| 909 of the hasPendingActivity(). DOM objects that are pointed to by `[SetWrapperRefe
renceFrom]` and | 909 of the hasPendingActivity(). |
| 910 `[SetWrapperReferenceTo]` must be annotated with `[DependentLifetime]`. | |
| 911 | 910 |
| 912 ### [DeprecateAs] _(m, a, c)_ | 911 ### [DeprecateAs] _(m, a, c)_ |
| 913 | 912 |
| 914 Summary: Measures usage of a deprecated feature via UseCounter, and notifies dev
elopers about deprecation via a console warning. | 913 Summary: Measures usage of a deprecated feature via UseCounter, and notifies dev
elopers about deprecation via a console warning. |
| 915 | 914 |
| 916 `[DeprecateAs]` can be considered an extended form of `[MeasureAs]`: it both mea
sures the feature's usage via the same UseCounter mechanism, and also sends out
a warning to the console (optionally with a message) in order to inform develope
rs that the code they've written will stop working at some point in the relative
ly near future. | 915 `[DeprecateAs]` can be considered an extended form of `[MeasureAs]`: it both mea
sures the feature's usage via the same UseCounter mechanism, and also sends out
a warning to the console (optionally with a message) in order to inform develope
rs that the code they've written will stop working at some point in the relative
ly near future. |
| 917 | 916 |
| 918 Usage: `[DeprecateAs]` can be specified on methods, attributes, and constants. | 917 Usage: `[DeprecateAs]` can be specified on methods, attributes, and constants. |
| 919 | 918 |
| 920 ```webidl | 919 ```webidl |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 ``` | 1255 ``` |
| 1257 | 1256 |
| 1258 For more information, see [RuntimeEnabledFeatures](https://code.google.com/p/chr
omium/codesearch#chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledF
eatures.in). | 1257 For more information, see [RuntimeEnabledFeatures](https://code.google.com/p/chr
omium/codesearch#chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledF
eatures.in). |
| 1259 | 1258 |
| 1260 ### [SaveSameObject] _(a)_ | 1259 ### [SaveSameObject] _(a)_ |
| 1261 | 1260 |
| 1262 Summary: Caches the resulting object and always returns the same object. | 1261 Summary: Caches the resulting object and always returns the same object. |
| 1263 | 1262 |
| 1264 When specified, caches the resulting object and returns it in later calls so tha
t the attribute always returns the same object. Must be accompanied with `[SameO
bject]`. | 1263 When specified, caches the resulting object and returns it in later calls so tha
t the attribute always returns the same object. Must be accompanied with `[SameO
bject]`. |
| 1265 | 1264 |
| 1266 ### [SetWrapperReferenceFrom=xxx] _(i)_ | |
| 1267 | |
| 1268 ### [SetWrapperReferenceTo=xxx] _(i)_ | |
| 1269 | |
| 1270 Summary: This generates code that allows you to set up implicit references betwe
en wrappers which can be used to keep wrappers alive during GC. | |
| 1271 | |
| 1272 Usage: `[SetWrapperReferenceFrom]` and `[SetWrapperReferenceTo]` can be specifie
d on an interface. Use `[Custom=VisitDOMWrapper]` if want to write a custom func
tion. | |
| 1273 | |
| 1274 ```webidl | |
| 1275 [ | |
| 1276 SetWrapperReferenceFrom=element | |
| 1277 ] interface XXX { ... }; | |
| 1278 ``` | |
| 1279 | |
| 1280 The code generates a function called `XXX::visitDOMWrapper` which is called by `
V8GCController` before GC. The function adds implicit references from the specif
ied object to this object's wrapper to keep it alive. | |
| 1281 | |
| 1282 The `[SetWrapperReferenceFrom]` extended attribute takes a value, which is the f
unction to call to get the object that determines whether the object is reachabl
e or not. The currently valid values are: `document`, `element`, `owner`, `owner
Node` | |
| 1283 | |
| 1284 ```webidl | |
| 1285 [ | |
| 1286 SetWrapperReferenceTo=targetMethod | |
| 1287 ] interface YYY { ... }; | |
| 1288 ``` | |
| 1289 | |
| 1290 The code generates a function called `YYY::visitDOMWrapper` which is called by `
V8GCController` before GC. The function adds implicit references from this objec
t's wrapper to a target object's wrapper to keeps it alive. | |
| 1291 | |
| 1292 The `[SetWrapperReferenceTo]` extended attribute takes a value, which is the met
hod name to call to get the target object. For example, with the above declarati
on a call will be made to `YYY::targetMethod()` to get the target of the referen
ce. | |
| 1293 | |
| 1294 ## Rare Blink-specific IDL Extended Attributes | 1265 ## Rare Blink-specific IDL Extended Attributes |
| 1295 | 1266 |
| 1296 These extended attributes are rarely used, generally only in one or two places.
These are often replacements for `[Custom]` bindings, and may be candidates for
deprecation and removal. | 1267 These extended attributes are rarely used, generally only in one or two places.
These are often replacements for `[Custom]` bindings, and may be candidates for
deprecation and removal. |
| 1297 | 1268 |
| 1298 ### [CachedAttribute] _(a)_ | 1269 ### [CachedAttribute] _(a)_ |
| 1299 | 1270 |
| 1300 Summary: For performance optimization, `[CachedAttribute]` indicates that a wrap
ped object should be cached on a DOM object. Rarely used (only by IndexDB). | 1271 Summary: For performance optimization, `[CachedAttribute]` indicates that a wrap
ped object should be cached on a DOM object. Rarely used (only by IndexDB). |
| 1301 | 1272 |
| 1302 Usage: `[CachedAttribute]` can be specified on attributes, and takes a required
value, generally called is*Dirty (esp. isValueDirty): | 1273 Usage: `[CachedAttribute]` can be specified on attributes, and takes a required
value, generally called is*Dirty (esp. isValueDirty): |
| 1303 | 1274 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: | 1605 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: |
| 1635 | 1606 |
| 1636 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. | 1607 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. |
| 1637 | 1608 |
| 1638 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. | 1609 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. |
| 1639 | 1610 |
| 1640 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. | 1611 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. |
| 1641 *** | 1612 *** |
| 1642 | 1613 |
| 1643 [CrossOriginProperties]: https://html.spec.whatwg.org/multipage/browsers.html#cr
ossoriginproperties-(-o-) | 1614 [CrossOriginProperties]: https://html.spec.whatwg.org/multipage/browsers.html#cr
ossoriginproperties-(-o-) |
| OLD | NEW |