| 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 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 ```webidl | 1328 ```webidl |
| 1329 interface HTMLFoo { | 1329 interface HTMLFoo { |
| 1330 [CachedAttribute=isKeyDirty] attribute DOMString key; | 1330 [CachedAttribute=isKeyDirty] attribute DOMString key; |
| 1331 [CachedAttribute=isValueDirty] attribute SerializedScriptValue serializedVal
ue; | 1331 [CachedAttribute=isValueDirty] attribute SerializedScriptValue serializedVal
ue; |
| 1332 }; | 1332 }; |
| 1333 ``` | 1333 ``` |
| 1334 | 1334 |
| 1335 Without `[CachedAttribute]`, the key getter works in the following way: | 1335 Without `[CachedAttribute]`, the key getter works in the following way: |
| 1336 | 1336 |
| 1337 1. HTMLFoo::key() is called in Blink. | 1337 1. HTMLFoo::key() is called in Blink. |
| 1338 2. The result of HTMLFoo::key() is passed to toV8(), and is converted to a wrapp
ed object. | 1338 2. The result of HTMLFoo::key() is passed to ToV8(), and is converted to a wrapp
ed object. |
| 1339 3. The wrapped object is returned. | 1339 3. The wrapped object is returned. |
| 1340 | 1340 |
| 1341 In case where HTMLFoo::key() or the operation to wrap the result is costly, you
can cache the wrapped object onto the DOM object. With CachedAttribute, the key
getter works in the following way: | 1341 In case where HTMLFoo::key() or the operation to wrap the result is costly, you
can cache the wrapped object onto the DOM object. With CachedAttribute, the key
getter works in the following way: |
| 1342 | 1342 |
| 1343 1. If the wrapped object is cached, the cached wrapped object is returned. That'
s it. | 1343 1. If the wrapped object is cached, the cached wrapped object is returned. That'
s it. |
| 1344 2. Otherwise, `HTMLFoo::key()` is called in Blink. | 1344 2. Otherwise, `HTMLFoo::key()` is called in Blink. |
| 1345 3. The result of `HTMLFoo::key()` is passed to `toV8()`, and is converted to a w
rapped object. | 1345 3. The result of `HTMLFoo::key()` is passed to `ToV8()`, and is converted to a w
rapped object. |
| 1346 4. The wrapped object is cached. | 1346 4. The wrapped object is cached. |
| 1347 5. The wrapped object is returned. | 1347 5. The wrapped object is returned. |
| 1348 | 1348 |
| 1349 `[CachedAttribute]` is particularly useful for serialized values, since deserial
ization can be costly. Without `[CachedAttribute]`, the serializedValue getter w
orks in the following way: | 1349 `[CachedAttribute]` is particularly useful for serialized values, since deserial
ization can be costly. Without `[CachedAttribute]`, the serializedValue getter w
orks in the following way: |
| 1350 | 1350 |
| 1351 1. `HTMLFoo::serializedValue()` is called in Blink. | 1351 1. `HTMLFoo::serializedValue()` is called in Blink. |
| 1352 2. The result of `HTMLFoo::serializedValue()` is deserialized. | 1352 2. The result of `HTMLFoo::serializedValue()` is deserialized. |
| 1353 3. The deserialized result is passed to `toV8()`, and is converted to a wrapped
object. | 1353 3. The deserialized result is passed to `ToV8()`, and is converted to a wrapped
object. |
| 1354 4. The wrapped object is returned. | 1354 4. The wrapped object is returned. |
| 1355 | 1355 |
| 1356 In case where `HTMLFoo::serializedValue()`, the deserialization or the operation
to wrap the result is costly, you can cache the wrapped object onto the DOM obj
ect. With `[CachedAttribute]`, the serializedValue getter works in the following
way: | 1356 In case where `HTMLFoo::serializedValue()`, the deserialization or the operation
to wrap the result is costly, you can cache the wrapped object onto the DOM obj
ect. With `[CachedAttribute]`, the serializedValue getter works in the following
way: |
| 1357 | 1357 |
| 1358 1. If the wrapped object is cached, the cached wrapped object is returned. That'
s it. | 1358 1. If the wrapped object is cached, the cached wrapped object is returned. That'
s it. |
| 1359 2. Otherwise, `HTMLFoo::serializedValue()` is called in Blink. | 1359 2. Otherwise, `HTMLFoo::serializedValue()` is called in Blink. |
| 1360 3. The result of `HTMLFoo::serializedValue()` is deserialized. | 1360 3. The result of `HTMLFoo::serializedValue()` is deserialized. |
| 1361 4. The deserialized result is passed to `toJS()` or `toV8()`, and is converted t
o a wrapped object. | 1361 4. The deserialized result is passed to `toJS()` or `ToV8()`, and is converted t
o a wrapped object. |
| 1362 5. The wrapped object is cached. | 1362 5. The wrapped object is cached. |
| 1363 6. The wrapped object is returned. | 1363 6. The wrapped object is returned. |
| 1364 | 1364 |
| 1365 *** note | 1365 *** note |
| 1366 You should cache attributes if and only if it is really important for performanc
e. Not only does caching increase the DOM object size, but also it increases the
overhead of "cache-miss"ed getters. In addition, setters always need to invalid
ate the cache. | 1366 You should cache attributes if and only if it is really important for performanc
e. Not only does caching increase the DOM object size, but also it increases the
overhead of "cache-miss"ed getters. In addition, setters always need to invalid
ate the cache. |
| 1367 *** | 1367 *** |
| 1368 | 1368 |
| 1369 `[CachedAttribute]` takes a required parameter which the name of a method to cal
l on the implementation object. The method should take void and return bool. Bef
ore the cached attribute is used, the method will be called. If the method retur
ns true the cached value is not used, which will result in the accessor being ca
lled again. This allows the implementation to both gain the performance benefit
of caching (when the conversion to a script value can be done lazily) while allo
wing the value to be updated. The typical use pattern is: | 1369 `[CachedAttribute]` takes a required parameter which the name of a method to cal
l on the implementation object. The method should take void and return bool. Bef
ore the cached attribute is used, the method will be called. If the method retur
ns true the cached value is not used, which will result in the accessor being ca
lled again. This allows the implementation to both gain the performance benefit
of caching (when the conversion to a script value can be done lazily) while allo
wing the value to be updated. The typical use pattern is: |
| 1370 | 1370 |
| 1371 ```c++ | 1371 ```c++ |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: | 1658 Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: |
| 1659 | 1659 |
| 1660 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. | 1660 1. Redistributions of source code must retain the above copyright notice, this l
ist of conditions and the following disclaimer. |
| 1661 | 1661 |
| 1662 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. | 1662 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. |
| 1663 | 1663 |
| 1664 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. | 1664 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. |
| 1665 *** | 1665 *** |
| 1666 | 1666 |
| 1667 [CrossOriginProperties]: https://html.spec.whatwg.org/multipage/browsers.html#cr
ossoriginproperties-(-o-) | 1667 [CrossOriginProperties]: https://html.spec.whatwg.org/multipage/browsers.html#cr
ossoriginproperties-(-o-) |
| OLD | NEW |