| 25 | [http://dev.w3.org/2006/webapi/WebIDL/#dfn-supplemental-interface The spec]. |
| 26 | [http://old.nabble.com/Things-missing-from-Web-IDL-for-HTML5-td24873773.html Easy explanation] |
| 27 | |
| 28 | The [Supplemental] IDL helps WebKit modularization. The [Supplemental] IDL makes it possible to add XXX's APIs (e.g. XXX=WebAudio, WebSocket, Blob, GamePad, ...etc) without modifying code outside of WebCore/Modules/XXX/. This helps make XXX a "self-contained module". |
| 29 | |
| 30 | Here is an example. Without the [Supplemental] IDL, if we want to add attributes or methods of XXX to DOMWindow, |
| 31 | |
| 32 | - we need to modify WebCore/page/DOMWindow.idl to add the IDLs of the attributes or methods |
| 33 | - we might need to modify WebCore/page/DOMWindow.{h,cpp} to add the C++ implementation of attribute getters and setters or method callbacks. |
| 34 | |
| 35 | On the other hand, in the modularized world with the [Supplemental] IDL, we just need to modify the code under WebCore/Modules/XXX/, like this: |
| 36 | |
| 37 | WebCore/Modules/XXX/DOMWindowXXX.idl |
| 38 | {{{ |
| 39 | interface [ |
| 40 | Conditional=XXX, |
| 41 | Supplemental=DOMWindow |
| 42 | ] DOMWindowXXX { |
| 43 | attribute foo; |
| 44 | void bar(); |
| 45 | }; |
| 46 | }}} |
| 47 | |
| 48 | WebCore/Modules/XXX/DOMWindowXXX.h |
| 49 | {{{ |
| 50 | DOMWindowXXX::foo(...) { ... } // the C++ implementation of the foo attribute getter |
| 51 | DOMWindowXXX::setFoo(...) { ... } // the C++ implementation of the foo attribute setter |
| 52 | DOMWindowXXX::bar(...) { ... } // the C++ implementation of the bar method callback |
| 53 | }}} |
| 54 | |
| 55 | As shown above, [Supplemental=DOMWindow] indicates that all the attributes and methods in DOMWindowXXX should be exposed on DOMWindow but should be implemented in DOMWindowXXX. In this way, we can implement the attributes and methods without modifying code of DOMWindow.{h,cpp,idl}. If you want to add APIs whose implementations are likely to be independent from WebCore, it is strongly recommended to put the APIs in WebCore/Modules/XXX/ using the [Supplemental] IDL. |
| 56 | |