Changes between Version 85 and Version 116 of WebKitIDL
- Timestamp:
- (multiple changes)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WebKitIDL
v85 v116 10 10 - [#TreatNullAs TreatNullAs(a,p), TreatUndefinedAs(a,p)][[br]] 11 11 - [#TreatReturnedNullStringAs TreatReturnedNullStringAs(m,a)][[br]] 12 - [# Optional Optional(p)][[br]]12 - [#Default Default(p)][[br]] 13 13 - [#Clamp Clamp(a,p)][[br]] 14 - [#Callback Callback(i,p)][[br]] 15 - [#Custom Custom(m,a), JSCustom(m,a), V8Custom(m,a), CustomGetter(a), JSCustomGetter(a), V8CustomGetter(a), CustomSetter(a), JSCustomSetter(a), V8CustomSetter(a)][[br]] 14 - [#Custom Custom(m,a), CustomGetter(a), CustomSetter(a)][[br]] 16 15 - [#CallWith CallWith(i,m,a)][[br]] 17 16 - [#StrictTypeChecking StrictTypeChecking(m,a,p)][[br]] … … 20 19 - [#Reflect Reflect(a)][[br]] 21 20 - [#Replaceable Replaceable(a)][[br]] 22 - [#Deletable Deletable(a), NotEnumerable(a) , V8ReadOnly(a)][[br]]21 - [#Deletable Deletable(a), NotEnumerable(a)][[br]] 23 22 - [#CachedAttribute CachedAttribute(a)][[br]] 24 - [#V8Unforgeable V8Unforgeable(m,a), V8OnProto(m,a)][[br]]25 - [#URL URL(a)][[br]]26 23 - [#JSWindowEventListener JSWindowEventListener(a)][[br]] 27 - [#Supplemental Supplemental(i)][[br]]28 24 - [#Constructor Constructor(i), CallWith(i,m,a), ConstructorRaisesException(i)][[br]] 29 25 - [#ConstructorTemplate ConstructorTemplate(i), InitializedByEventConstructor(a)][[br]] 30 26 - [#NamedConstructor NamedConstructor(i)][[br]] 31 - [#CustomConstructor CustomConstructor(i), JSCustomConstructor(i), V8CustomConstructor(i),ConstructorParameters(i)][[br]]27 - [#CustomConstructor CustomConstructor(i), ConstructorParameters(i)][[br]] 32 28 - [#Conditional Conditional(i,m,a)][[br]] 33 - [#V8EnabledAtRuntime V8EnabledAtRuntime(i,m,a)][[br]]34 - [#V8EnabledPerContext V8EnabledPerContext(i,m,a)][[br]]35 - [#CustomToJSObject CustomToJSObject(i), JSCustomToJSObject(i), V8CustomToJSObject(i), SuppressToJSObject(i)][[br]]36 29 - [#CheckSecurity CheckSecurity(i), DoNotCheckSecurity(m,a), DoNotCheckSecurityOnGetter(a), DoNotCheckSecurityOnSetter(a)][[br]] 37 30 - [#CheckSecurityForNode CheckSecurityForNode(m,a)][[br]] 38 31 - [#IndexedGetter IndexedGetter(i)][[br]] 39 - [#V8CustomIndexedGetter V8CustomIndexedGetter(i)][[br]]40 32 - [#CustomIndexedSetter CustomIndexedSetter(i)][[br]] 41 33 - [#NamedGetter NamedGetter(i)][[br]] … … 45 37 - [#DoNotCheckConstants DoNotCheckConstants(i)][[br]] 46 38 - [#ActiveDOMObject ActiveDOMObject(i)][[br]] 47 - [#V8DependentLifeTime V8DependentLifeTime(i)][[br]]48 39 - [#CustomEnumerateProperty CustomEnumerateProperty(i), CustomDeleteProperty(i)][[br]] 49 40 - [#IsWorkerContext IsWorkerContext(i)][[br]] 50 - [#TransferList TransferList(p)][[br]]51 41 - [#TypedArray TypedArray(i), [ConstructorTemplate=TypedArray](i)][[br]] 52 42 - [#CustomCall CustomCall(i)][[br]] 53 - [#JSCustomToNativeObject JSCustomToNativeObject(i), JSCustomFinalize(i), JSCustomIsReachable(i), JSCustomMarkFunction(i), JSCustomNamedGetterOnPrototype(i), JSCustomPushEventHandlerScope(i), JSCustomDefineOwnProperty(i), JSCustomDefineOwnPropertyOnPrototype(i), JSCustomGetOwnPropertySlotAndDescriptor(i)][[br]]43 - [#JSCustomToNativeObject JSCustomToNativeObject(i), JSCustomFinalize(i), CustomIsReachable(i), JSCustomMarkFunction(i), JSCustomNamedGetterOnPrototype(i), JSCustomPushEventHandlerScope(i), JSCustomDefineOwnProperty(i), JSCustomDefineOwnPropertyOnPrototype(i), JSCustomGetOwnPropertySlotAndDescriptor(i)][[br]] 54 44 - [#JSGenerateToJSObject JSGenerateToJSObject(i), JSGenerateToNativeObject(i)][[br]] 55 - [#JSGenerateIsReachable JSGenerateIsReachable(i)]56 - [#V8GenerateIsReachable V8GenerateIsReachable(i)]57 - [#V8CustomIsReachable V8CustomIsReachable(i)]58 45 - [#GenerateIsReachable GenerateIsReachable(i)] 59 - [#JSCustomHeader JSCustomHeader(i)][[br]]60 46 - [#JSLegacyParent JSLegacyParent(i)][[br]] 61 47 - [#JSInlineGetOwnPropertySlot JSInlineGetOwnPropertySlot(i)][[br]] … … 65 51 - [#CustomReturn CustomReturn(p)][[br]] 66 52 - [#ArrayClass ArrayClass(i)][[br]] 67 - [#OmitConstructor OmitConstructor, Immutable, MasqueradesAsUndefined, CustomGetOwnPropertySlot, ReplaceableConstructor, ExtendsDOMGlobalObject, IsIndex, V8DoNotCheckSignature,NumericIndexedGetter][[br]]53 - [#OmitConstructor OmitConstructor, Immutable, MasqueradesAsUndefined, CustomGetOwnPropertySlot, ReplaceableConstructor, ExtendsDOMGlobalObject, IsIndex, NumericIndexedGetter][[br]] 68 54 - [#ImplementationNamespace ImplementationNamespace(i)][[br]] 69 - [#V8SkipVTableValidation V8SkipVTableValidation(i), ImplementationLacksVTable(i),][[br]] 55 - [#SkipVTableValidation SkipVTableValidation(i), ImplementationLacksVTable(i),][[br]] 56 - [#NoInterfaceObject NoInterfaceObject(i)][[br]] 70 57 71 58 72 59 = Overview = #Overview 73 60 74 The [http://www.w3.org/TR/WebIDL/ Web IDL] is a language that defines how WebCore interfaces are bound to external languages such as JavaScriptCore, V8, ObjC, GObject and CPP. You need to write IDL files (e.g. XMLHttpRequest.idl, Element.idl, etc) to expose WebCore interfaces to those external languages. When WebKit is built, the IDL files are parsed, and the code to bind WebCore implementations and JavaScriptCore, V8, ObjC, GObject and CPP interfaces is automatically generated.61 The [http://www.w3.org/TR/WebIDL/ Web IDL] is a language that defines how WebCore interfaces are bound to external languages such as JavaScriptCore, ObjC, GObject and CPP. You need to write IDL files (e.g. XMLHttpRequest.idl, Element.idl, etc) to expose WebCore interfaces to those external languages. When WebKit is built, the IDL files are parsed, and the code to bind WebCore implementations and JavaScriptCore, ObjC, GObject and CPP interfaces is automatically generated. 75 62 76 63 This document describes practical information about how the IDL bindings work and how you can write IDL files in WebKit. The syntax of IDL files is fairly well documented in the [http://www.w3.org/TR/WebIDL/ Web IDL spec], but it is too formal to read:-) and there are several differences between the Web IDL spec and the WebKit IDL due to implementation issues. … … 81 68 {{{ 82 69 module core { 83 interface [ 84 JSCustomHeader, 70 [ 85 71 CustomToJSObject 86 ] Node {72 ] interface Node { 87 73 const unsigned short ELEMENT_NODE = 1; 88 74 attribute Node parentNode; 89 attribute [TreatReturnedNullStringAs=Null]DOMString nodeName;90 [Custom] Node appendChild( in[CustomReturn] Node newChild);91 void addEventListener( in DOMString type, in EventListener listener, in [Optional]boolean useCapture);75 [TreatReturnedNullStringAs=Null] attribute DOMString nodeName; 76 [Custom] Node appendChild([CustomReturn] Node newChild); 77 void addEventListener(DOMString type, EventListener listener, optional boolean useCapture); 92 78 }; 93 79 } … … 101 87 * appendChild(...) and addEventListener(...) are '''method'''s of the Node interface. 102 88 * type, listener and useCapture are '''parameter'''s of the Node interface. 103 * [JSCustomHeader], [CustomToJSObject], [TreatReturnedNullStringAs=Null], [Custom], [CustomReturn] and [Optional]are '''IDL attribute'''s.89 * `[CustomToJSObject]`, `[TreatReturnedNullStringAs=Null]`, `[Custom]` and `[CustomReturn]` are '''IDL attribute'''s. 104 90 105 91 Note: These terminologies are not aligned with the Web IDL spec. … … 119 105 {{{ 120 106 module MODULE_NAME { 121 interface[107 [ 122 108 IDL_ATTRIBUTE_ON_INTERFACE1, 123 109 IDL_ATTRIBUTE_ON_INTERFACE2, 124 ... ;125 ] INTERFACE_NAME {110 ... 111 ] interface INTERFACE_NAME { 126 112 const unsigned long value = 12345; 127 attribute [IDL_ATTRIBUTE_ON_ATTRIBUTE1, IDL_ATTRIBUTE_ON_ATTRIBUTE2, ...]Node node;128 [IDL_ATTRIBUTE_ON_METHOD1, IDL_ATTRIBUTE_ON_METHOD2, ...] void func( in[IDL_ATTRIBUTE_ON_PARAMETER1, IDL_ATTRIBUTE_ON_PARAMETER2, ...] int param, ...);113 [IDL_ATTRIBUTE_ON_ATTRIBUTE1, IDL_ATTRIBUTE_ON_ATTRIBUTE2, ...] attribute Node node; 114 [IDL_ATTRIBUTE_ON_METHOD1, IDL_ATTRIBUTE_ON_METHOD2, ...] void func([IDL_ATTRIBUTE_ON_PARAMETER1, IDL_ATTRIBUTE_ON_PARAMETER2, ...] int param, ...); 129 115 }; 130 116 } … … 136 122 interface INTERFACE_NAME { 137 123 const unsigned long value = 12345; 138 attribute [IDL_ATTRIBUTE_ON_ATTRIBUTE1, IDL_ATTRIBUTE_ON_ATTRIBUTE2, ...]Node node;139 [IDL_ATTRIBUTE_ON_METHOD1, IDL_ATTRIBUTE_ON_METHOD2, ...] void func( in[IDL_ATTRIBUTE_ON_PARAMETER1, IDL_ATTRIBUTE_ON_PARAMETER2, ...] int param, ...);124 [IDL_ATTRIBUTE_ON_ATTRIBUTE1, IDL_ATTRIBUTE_ON_ATTRIBUTE2, ...] attribute Node node; 125 [IDL_ATTRIBUTE_ON_METHOD1, IDL_ATTRIBUTE_ON_METHOD2, ...] void func([IDL_ATTRIBUTE_ON_PARAMETER1, IDL_ATTRIBUTE_ON_PARAMETER2, ...] int param, ...); 140 126 }; 141 127 } … … 160 146 Tools/Scripts/run-bindings-tests tests IDL attributes. 161 147 Specifically, run-bindings-tests reads WebCore/bindings/scripts/test/*.idl, 162 and then generates bindings code to WebCore/bindings/scripts/test/{JS, V8,ObjC,GObject,CPP}/*.148 and then generates bindings code to WebCore/bindings/scripts/test/{JS,ObjC,GObject,CPP}/*. 163 149 For example, run-bindings-tests reads WebCore/bindings/scripts/test/TestObj.idl, 164 150 and then generates bindings code to WebCore/bindings/scripts/test/JS/JSTestObj.h, WebCore/bindings/scripts/test/JS/JSTestObj.cpp, etc. … … 203 189 WebKitBuild/Release/DerivedSources/WebCore/JSXXX.cpp 204 190 }}} 205 * V8:206 207 {{{208 out/Release/obj/gen/webkit/bindings/V8XXX.h209 out/Release/obj/gen/webcore/bindings/V8XXX.cpp210 }}}211 191 * ObjC: 212 192 … … 234 214 * A name should be aligned with the Web IDL spec as much as possible. 235 215 * JavaScriptCore-specific IDL attributes are prefixed by "JS". 236 * V8-specific IDL attributes are prefixed by "V8".237 216 * ObjC-specific IDL attributes are prefixed by "ObjC". 238 217 * GObject-specific IDL attributes are prefixed by "GObject". … … 240 219 * IDL attributes for custom bindings are prefixed by "Custom". 241 220 242 For example, [JSNoStaticTables], [CustomGetter], [V8CustomGetter], etc.221 For example, `[JSNoStaticTables]`, `[CustomGetter]`, etc. 243 222 244 223 = IDL attributes = #IDLAttributes … … 246 225 In the following explanations, (i), (m), (a) or (p) means that a given IDL attribute can be specified on interfaces, methods, attributes and parameters, respectively. For example, (a,p) means that the IDL attribute can be specified on attributes and parameters. 247 226 248 == [TreatNullAs](a,p), [TreatUndefinedAs](a,p) == #TreatNullAs227 == `[TreatNullAs]`(a,p), `[TreatUndefinedAs]`(a,p) == #TreatNullAs 249 228 250 229 * [http://dev.w3.org/2006/webapi/WebIDL/#TreatNullAs The spec of TreatNullAs] (Note: The WebKit behavior explained below is different from the spec) … … 253 232 Summary: They control the behavior when a JavaScript null or undefined is passed to a DOMString attribute or parameter. 254 233 255 Usage: The possible usage is [TreatNullAs=NullString] or [TreatUndefinedAs=NullString].234 Usage: The possible usage is `[TreatNullAs=NullString]` or `[TreatUndefinedAs=NullString]`. 256 235 They can be specified on DOMString attributes or DOMString parameters only: 257 236 {{{ 258 attribute [TreatNullAs=NullString]DOMString str;259 void func( in[TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString str);260 }}} 261 262 [TreatNullAs=NullString]indicates that if a JavaScript null is passed to the attribute or parameter,237 [TreatNullAs=NullString] attribute DOMString str; 238 void func([TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString str); 239 }}} 240 241 `[TreatNullAs=NullString]` indicates that if a JavaScript null is passed to the attribute or parameter, 263 242 then it is converted to a WebKit null string, for which both String::IsEmpty() and String::IsNull() will return true. 264 Without [TreatNullAs=NullString], a JavaScript null is converted to a WebKit string "null".265 266 [TreatNullAs=NullString] in WebKit corresponds to [TreatNullAs=EmptyString]in the Web IDL spec.267 Unless the spec specifies [TreatNullAs=EmptyString], you should not specify [TreatNullAs=NullString]in WebKit.268 269 [TreatUndefinedAs=NullString]indicates that if a JavaScript undefined is passed to the attribute or parameter,243 Without `[TreatNullAs=NullString]`, a JavaScript null is converted to a WebKit string "null". 244 245 `[TreatNullAs=NullString]` in WebKit corresponds to `[TreatNullAs=EmptyString]` in the Web IDL spec. 246 Unless the spec specifies `[TreatNullAs=EmptyString]`, you should not specify `[TreatNullAs=NullString]` in WebKit. 247 248 `[TreatUndefinedAs=NullString]` indicates that if a JavaScript undefined is passed to the attribute or parameter, 270 249 then it is converted to a WebKit null string, for which both String::IsEmpty() and String::IsNull() will return true. 271 Without [TreatUndefinedAs=NullString], a JavaScript undefined is converted to a WebKit string "undefined".272 273 [TreatUndefinedAs=NullString] in WebKit corresponds to [TreatUndefinedAs=EmptyString]in the Web IDL spec.274 Unless the spec specifies [TreatUndefinedAs=EmptyString], you should not specify [TreatUndefinedAs=NullString]in WebKit.275 276 Note: For now the sole usage of [TreatUndefinedAs=NullString]is not allowed.277 [TreatUndefinedAs=NullString] must be used with [TreatNullAs=NullString], i.e. [TreatNullAs=NullString, TreatUndefinedAs=NullString].278 279 == [TreatReturnedNullStringAs](m,a) == #TreatReturnedNullStringAs280 281 Summary: [TreatReturnedNullStringAs]controls the behavior when a WebKit null string is returned from the WebCore implementation.282 283 Usage: The possible usage is [TreatReturnedNullStringAs=Null], [TreatReturnedNullStringAs=Undefined] or [TreatReturnedNullStringAs=False].250 Without `[TreatUndefinedAs=NullString]`, a JavaScript undefined is converted to a WebKit string "undefined". 251 252 `[TreatUndefinedAs=NullString]` in WebKit corresponds to `[TreatUndefinedAs=EmptyString]` in the Web IDL spec. 253 Unless the spec specifies `[TreatUndefinedAs=EmptyString]`, you should not specify `[TreatUndefinedAs=NullString]` in WebKit. 254 255 Note: For now the sole usage of `[TreatUndefinedAs=NullString]` is not allowed. 256 `[TreatUndefinedAs=NullString]` must be used with `[TreatNullAs=NullString]`, i.e. `[TreatNullAs=NullString, TreatUndefinedAs=NullString]`. 257 258 == `[TreatReturnedNullStringAs]`(m,a) == #TreatReturnedNullStringAs 259 260 Summary: `[TreatReturnedNullStringAs]` controls the behavior when a WebKit null string is returned from the WebCore implementation. 261 262 Usage: The possible usage is `[TreatReturnedNullStringAs=Null]`, `[TreatReturnedNullStringAs=Undefined]` or `[TreatReturnedNullStringAs=False]`. 284 263 They can be specified on DOMString attributes or methods that return a DOMString value: 285 264 {{{ 286 attribute [TreatReturnedNullStringAs=Null]DOMString str;265 [TreatReturnedNullStringAs=Null] attribute DOMString str; 287 266 [TreatReturnedNullStringAs=Undefined] DOMString func(); 288 267 }}} 289 268 290 * [TreatReturnedNullStringAs=Null] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript null. 291 * [TreatReturnedNullStringAs=Undefined] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript undefined. 292 * [TreatReturnedNullStringAs=False] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript false. 293 294 Without [TreatReturnedNullStringAs=...], if the returned DOMString is a WebKit null string, then the returned value is treated as a JavaScript empty string ''. 295 296 Note that what should be specified on [TreatReturnedNullStringAs=...] depends on the spec of each attribute or method. 297 298 == [Optional](p) == #Optional 299 300 Summary: [Optional] allows method overloading for methods whose argument counts are different with each other. 301 302 Usage: The possible usage is [Optional], [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString]. 303 [Optional] and [Optional=DefaultIsUndefined] can be specified on parameters. 304 [Optional=DefaultIsNullString] can be specified on DOMString parameters only: 269 * `[TreatReturnedNullStringAs=Null]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript null. 270 * `[TreatReturnedNullStringAs=Undefined]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript undefined. 271 * `[TreatReturnedNullStringAs=False]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript false. 272 273 Without `[TreatReturnedNullStringAs=...]`, if the returned DOMString is a WebKit null string, then the returned value is treated as a JavaScript empty string ''. 274 275 Note that what should be specified on `[TreatReturnedNullStringAs=...]` depends on the spec of each attribute or method. 276 277 == `[Default]`(p) == #Default 278 279 Summary: `[Default]` allows specifying the default values for optional parameters to simplify WebCore implementations which otherwise require overloads. 280 281 Standard: In Web IDL, `[Default=NullString]` is written as `"type identifier = default"`, e.g. `optional DOMString? str = null` 282 283 Usage: The possible usages are `[Default=Undefined]` or `[Default=NullString]`. `[Default=Undefined]` can be specified on any optional parameter. `[Default=NullString]` can be specified on DOMString parameters only: 284 305 285 {{{ 306 286 interface HTMLFoo { 307 void func1(in int a, in int b, in [Optional] int c, in [Optional] int d); 308 void func2(in int a, in int b, in [Optional=DefaultIsUndefined] int c); 309 void func3(in int a, in int b, in [Optional=DefaultIsUndefined] DOMString c, in [Optional=DefaultIsNullString] DOMString d); 310 }; 311 }}} 312 313 The parameters marked with [Optional=...] are optional, and JavaScript can omit the parameters. Obviously, if parameter X is marked with [Optional=...], then all subsequent parameters of X should be marked with [Optional=...]. 314 315 The difference between [Optional] and [Optional=DefaultIsUndefined] is whether the WebCore implementation has overloaded methods or not, as explained below. 316 317 In case of func1(...), if JavaScript calls func1(100, 200), then HTMLFoo::func1(int a, int b) is called in WebCore. 318 If JavaScript calls func1(100, 200, 300), then HTMLFoo::func1(int a, int b, int c) is called in WebCore. 319 If JavaScript calls func1(100, 200, 300, 400), then HTMLFoo::func1(int a, int b, int c, int d) is called in WebCore. 320 In other words, if the WebCore implementation has overloaded methods, you can use [Optional]. 321 322 In case of func2(...), if JavaScript calls func2(100, 200), then it behaves as if JavaScript called func2(100, 200, undefined). 323 Consequently, HTMLFoo::func2(int a, int b, int c) is called in WebCore. 324 100 is passed to a, 200 is passed to b, and 0 is passed to c. 325 (A JavaScript undefined is converted to 0, following the value conversion rule in the Web IDL spec.) 326 In this way, WebCore needs to just implement func2(int a, int b, int c) and needs not to implement both func2(int a, int b) and func2(int a, int b, int c). 327 328 The difference between [Optional=DefalutIsUndefined] and [Optional=DefaultIsNullString] appears only when the parameter type is DOMString. 329 In [Optional=DefalutIsUndefined], the "supplemented" JavaScript undefined is converted to a WebKit string "undefined". 330 On the other hand, in [Optional=DefaultIsNullString], the "supplemented" JavaScript undefined is converted to a WebKit null string. 331 For example, if JavaScript calls func3(100, 200), then HTMLFoo::func3(int a, int b, String c, String d) is called in WebCore. 332 At this point, 100 is passed to a, 200 is passed to b, a WebKit string "undefined" is passed to c, and a WebKit null string is passed to d. 333 d.IsEmpty() and d.IsNull() return true. 334 335 == [Clamp](a,p) == #Clamp 287 void func1(int a, int b, optional int c, optional int d); 288 void func2(int a, int b, [Default=Undefined] optional int c); 289 void func3(int a, int b, [Default=Undefined] optional DOMString c, [Default=NullString] optional DOMString d); 290 }; 291 }}} 292 293 The parameters marked with the standard Web IDL optional qualifier are optional, and JavaScript can omit the parameters. Obviously, if parameter X is marked with optional then all subsequent parameters of X should be marked with optional. 294 295 The difference between optional and `[Default=Undefined]` optional is whether the WebCore implementation has overloaded methods or not, as explained below. 296 297 In case of `func1(...)`, if JavaScript calls `func1(100, 200)`, then `HTMLFoo::func1(int a, int b)` is called in WebCore. If JavaScript calls `func1(100, 200, 300)`, then `HTMLFoo::func1(int a, int b, int c)` is called in WebCore. If JavaScript calls `func1(100, 200, 300, 400)`, then `HTMLFoo::func1(int a, int b, int c, int d)` is called in WebCore. In other words, if the WebCore implementation has overloaded methods, you can use optional. 298 299 In case of `func2(...)` which adds `[Default=Undefined]`, if JavaScript calls `func2(100, 200)`, then it behaves as if JavaScript called `func2(100, 200, undefined)`. Consequently, `HTMLFoo::func2(int a, int b, int c)` is called in WebCore. 100 is passed to a, 200 is passed to b, and 0 is passed to c. (A JavaScript undefined is converted to 0, following the value conversion rule in the Web IDL spec.) In this way, WebCore needs to just implement `func2(int a, int b, int c)` and needs not to implement both `func2(int a, int b)` and `func2(int a, int b, int c)`. 300 301 The difference between `[Default=Undefined]` and `[Default=NullString]` appears only when the parameter type is DOMString. In `[Default=Undefined]` the "supplemented" JavaScript undefined is converted to a WebKit string "undefined". On the other hand, in `[Default=NullString]` the "supplemented" JavaScript undefined is converted to a WebKit null string. For example, if JavaScript calls `func3(100, 200)`, then `HTMLFoo::func3(int a, int b, String c, String d)` is called in WebCore. At this point, 100 is passed to a, 200 is passed to b, a WebKit string "undefined" is passed to c, and a WebKit null string is passed to d. d.IsEmpty() and d.IsNull() return true. 302 303 == `[Clamp]`(a,p) == #Clamp 336 304 337 305 * [http://www.w3.org/TR/2012/CR-WebIDL-20120419/#Clamp The spec of Clamp] 338 306 339 Summary: [Clamp]indicates that when an ECMAScript Number is converted to the IDL type, out of range values will be clamped to the range of valid values,307 Summary: `[Clamp]` indicates that when an ECMAScript Number is converted to the IDL type, out of range values will be clamped to the range of valid values, 340 308 rather than using the operators that use a modulo operation (ToInt32, ToUint32, etc.). 341 309 342 Usage: The [Clamp]extended attribute MUST NOT appear on a read only attribute, or an attribute, operation argument or dictionary member310 Usage: The `[Clamp]` extended attribute MUST NOT appear on a read only attribute, or an attribute, operation argument or dictionary member 343 311 that is not of an integer type. 344 312 … … 347 315 {{{ 348 316 interface XXX { 349 attribute [Clamp]unsigned short attributeName;317 [Clamp] attribute unsigned short attributeName; 350 318 }; 351 319 }}} … … 360 328 }}} 361 329 362 Calling the non-[Clamp] version of setColor() uses ToUint8 to coerce the Numbers to octets. 363 Hence calling context.setColor(-1, 255, 257) is equivalent to calling setColor(255, 255, 1). 364 365 Calling the [Clamp] version of setColor() uses clampTo() to coerce the Numbers to octets. 366 Hence calling context.setColor(-1, 255, 257) is equivalent to calling setColorClamped(0, 255, 255). 367 368 == [Callback](i,p) FIXME == #Callback 369 370 Summary: ADD SUMMARY 371 372 Usage: [Callback] can be specified on interfaces and parameters: 373 {{{ 374 interface [ 375 Callback 376 ] HTMLFoo { 377 void func(in int a, in [Callback] int b); 378 }; 379 }}} 380 381 ADD EXPLANATIONS 382 383 == [Custom](m,a), [JSCustom](m,a), [V8Custom](m,a), [CustomGetter](a), [JSCustomGetter](a), [V8CustomGetter](a), [CustomSetter](a), [JSCustomSetter](a), [V8CustomSetter](a) == #Custom 330 Calling the non-`[Clamp]` version of `setColor()` uses ToUint8 to coerce the Numbers to octets. 331 Hence calling `context.setColor(-1, 255, 257)` is equivalent to calling `setColor(255, 255, 1)`. 332 333 Calling the `[Clamp]` version of `setColor()` uses `clampTo()` to coerce the Numbers to octets. 334 Hence calling `context.setColor(-1, 255, 257)` is equivalent to calling `setColorClamped(0, 255, 255)`. 335 336 == `[Custom]`(m,a), `[CustomGetter]`(a), `[CustomSetter]`(a) == #Custom 384 337 385 338 Summary: They allow you to write bindings code manually as you like. 386 339 387 Usage: [Custom], [JSCustom] and [V8Custom] can be specified on methods or attributes. [CustomGetter], [JSCustomGetter], [V8CustomGetter], [CustomSetter], [JSCustomSetter], [V8CustomSetter]can be specified on attributes:340 Usage: `[Custom]` can be specified on methods or attributes. `[CustomGetter]`, `[CustomSetter]` can be specified on attributes: 388 341 {{{ 389 342 [Custom] void func(); 390 attribute [CustomGetter, JSCustomSetter]DOMString str;343 [CustomGetter, JSCustomSetter] attribute DOMString str; 391 344 }}} 392 345 393 346 We should minimize the number of custom bindings as much as possible, since they are likely to be buggy. 394 Before using [Custom], you should doubly consider if you really need custom bindings.395 You are recommended to modify code generators to avoid using [Custom].347 Before using `[Custom]`, you should doubly consider if you really need custom bindings. 348 You are recommended to modify code generators to avoid using `[Custom]`. 396 349 397 350 Before explaining the details, let us clarify the relationship of these IDL attributes. 398 351 399 * [JSCustom] on a method indicates that you can write JavaScriptCore custom bindings for the method. 400 * [V8Custom] on a method indicates that you can write V8 custom bindings for the method. 401 * [Custom] on a method is equivalent to [JSCustom, V8Custom]. 402 * [JSCustomGetter] or [JSCustomSetter] on an attribute indicates that you can write JavaScriptCore custom bindings for the attribute getter or setter. 403 * [V8CustomGetter] or [V8CustomSetter] on an attribute indicates that you can write V8 custom bindings for the attribute getter or setter. 404 * [JSCustom] on an attribute is equivalent to [JSCustomGetter, JSCustomSetter]. 405 * [V8Custom] on an attribute is equivalent to [V8CustomGetter, V8CustomSetter]. 406 * [Custom] on an attribute is equivalent to [JSCustom, V8Custom], i.e. [JSCustomGetter, JSCustomSetter, V8CustomGetter, V8CustomSetter]. 407 408 For example, if you want to write custom bindings only for an attribute getter of JavaScriptCore and V8 and an attribute setter of JavaScriptCore, you can specify [CustomGetter, JSCustomSetter]. 409 410 How to write custom bindings is different between JavaScriptCore and V8 or between a method and an attribute getter/setter, as follows: 411 412 * Method in JavaScriptCore: Consider the following example: 352 * `[Custom]` on a method indicates that you can write JavaScriptCore custom bindings for the method. 353 * `[CustomGetter]` or `[CustomSetter]` on an attribute indicates that you can write JavaScriptCore custom bindings for the attribute getter or setter. 354 355 You can write custom bindings with JavaScriptCore for a method or an attribute getter/setter, as follows: 356 357 * Method: Consider the following example: 413 358 414 359 {{{ 415 360 interface XXX { 416 [ JSCustom] void func(in int a, inint b);361 [Custom] void func(int a, int b); 417 362 }; 418 363 }}} … … 426 371 Refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. 427 372 428 * Attribute getter in JavaScriptCore: Consider the following example:373 * Attribute getter: Consider the following example: 429 374 430 375 {{{ 431 376 interface XXX { 432 attribute [JSCustomGetter]DOMString str;377 [CustomGetter] attribute DOMString str; 433 378 }; 434 379 }}} … … 442 387 Refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. 443 388 444 * Attribute setter in JavaScriptCore: Consider the following example:389 * Attribute setter: Consider the following example: 445 390 446 391 {{{ 447 392 interface XXX { 448 attribute [JSCustomSetter]DOMString str;393 [CustomSetter] attribute DOMString str; 449 394 }; 450 395 }}} … … 456 401 } 457 402 }}} 458 Refer to WebCore/bindings/js/JSXXXCustom.cpp for more details.459 460 * Method in V8: Consider the following example:461 462 {{{463 interface XXX {464 [V8Custom] void func(in int a, in int b);465 };466 }}}467 You can write custom bindings in WebCore/bindings/v8/custom/V8XXXCustom.cpp:468 {{{469 v8::Handle<v8::Value> V8XXX::funcCallback(const v8::Arguments& args)470 {471 ...;472 }473 }}}474 Refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details.475 476 * Attribute getter in V8: Consider the following example:477 478 {{{479 interface XXX {480 attribute [V8CustomGetter] DOMString str;481 };482 }}}483 You can write custom bindings in WebCore/bindings/v8/custom/V8XXXCustom.cpp:484 {{{485 v8::Handle<v8::Value> V8XXX::strAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)486 {487 ...;488 }489 }}}490 Refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details.491 492 * Attribute setter in V8: Consider the following example:493 494 {{{495 interface XXX {496 attribute [V8CustomSetter] DOMString str;497 };498 }}}499 You can write custom bindings in WebCore/bindings/v8/custom/V8XXXCustom.cpp:500 {{{501 void V8XXX::strAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)502 {503 ...;504 }505 }}}506 Refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details.507 403 508 404 Note: ObjC, GObject and CPP bindings do not support custom bindings. 509 405 510 == [CallWith](i,m,a) == #CallWith511 512 Summary: [CallWith]indicates that the bindings code calls a WebCore method with additional information.513 514 Usage: The possible usage is [CallWith=X1|X2|X3|...], where X1, X2, X3, ... is "ScriptExecutionContext", "ScriptState", "ScriptArguments" or "CallStack".406 == `[CallWith]`(i,m,a) == #CallWith 407 408 Summary: `[CallWith]` indicates that the bindings code calls a WebCore method with additional information. 409 410 Usage: The possible usage is `[CallWith=X1|X2|X3|...]`, where X1, X2, X3, ... is "ScriptExecutionContext", "ScriptState", "ScriptArguments" or "CallStack". 515 411 "ScriptExecutionContext", "ScriptState" and "CallStack" can be specified on methods or attributes, 516 412 but "ScriptArguments" can be specified on methods only: 517 413 {{{ 518 414 interface HTMLFoo { 519 attribute [CallWith=ScriptExecutionContext]DOMString str;520 [CallWith=ScriptExecutionContext] void func1(in int a, inint b);521 [CallWith=ScriptState] void func2(in int a, inint b);522 [CallWith=ScriptArguments|CallStack] void func3(in int a, inint b);523 [CallWith=CallStack|ScriptArguments] void func4(in int a, inint b);524 }; 525 }}} 526 527 Note: [CallWith]can be also specified on interfaces but it has a different meaning.528 Refer to [#Constructor the [Constructor] section] for [CallWith]on interfaces.415 [CallWith=ScriptExecutionContext] attribute DOMString str; 416 [CallWith=ScriptExecutionContext] void func1(int a, int b); 417 [CallWith=ScriptState] void func2(int a, int b); 418 [CallWith=ScriptArguments|CallStack] void func3(int a, int b); 419 [CallWith=CallStack|ScriptArguments] void func4(int a, int b); 420 }; 421 }}} 422 423 Note: `[CallWith]` can be also specified on interfaces but it has a different meaning. 424 Refer to [#Constructor the `[Constructor]` section] for `[CallWith]` on interfaces. 529 425 530 426 In case of func1(...), HTMLFoo::func1(ScriptExecutionContext* context, int a, int b) is called in WebCore. … … 537 433 In this way, the additional information is added at the head of normal arguments. 538 434 The order of additional information is "ScriptExecutionContext", "ScriptState", "ScriptArguments", and then "CallStack", 539 despite the order specified in [CallWith=X1|X2|X3|...].540 For example, in case of func4(...), HTMLFoo::func3(ScriptArguments* arguments, ScriptCallStack* callstack, int a, int b)is called in WebCore.541 542 == [StrictTypeChecking](m,a,p) FIXME == #StrictTypeChecking435 despite the order specified in `[CallWith=X1|X2|X3|...]`. 436 For example, in case of `func4(...)`, `HTMLFoo::func3(ScriptArguments* arguments, ScriptCallStack* callstack, int a, int b)` is called in WebCore. 437 438 == `[StrictTypeChecking]`(m,a,p) FIXME == #StrictTypeChecking 543 439 544 440 Summary: ADD SUMMARY 545 441 546 Usage: [StrictTypeChecking]can be specified on methods and attributes:547 {{{ 548 attribute [StringTypeChecking]float x;442 Usage: `[StrictTypeChecking]` can be specified on methods and attributes: 443 {{{ 444 [StringTypeChecking] attribute float x; 549 445 [StrictTypeChecking] DOMString func(); 550 446 }}} … … 552 448 ADD EXPLANATIONS 553 449 554 V8 and JSC: [StrictTypeChecking]can also be applied to a DOMString parameter in an overloaded method to make the450 JSC: `[StrictTypeChecking]` can also be applied to a DOMString parameter in an overloaded method to make the 555 451 overload resolution only match for ECMAScript types null, undefined, string or object - and not number or boolean. 556 452 This is to permit overloads which are not "distinguishable" in WebIDL, for example: … … 558 454 {{{ 559 455 interface CanvasFoo { 560 void setColor( in[StrictTypeChecking] DOMString color);561 void setColor( infloat grayLevel);562 }; 563 }}} 564 565 == [ReturnNewObject](m,a) == #ReturnNewObject566 567 Summary: [ReturnNewObject]controls whether WebCore can return a cached wrapped object or WebCore needs to return a newly created wrapped object every time.568 569 Usage: [ReturnNewObject]can be specified on methods or attributes:570 {{{ 571 attribute [ReturnNewObject]Node node;456 void setColor([StrictTypeChecking] DOMString color); 457 void setColor(float grayLevel); 458 }; 459 }}} 460 461 == `[ReturnNewObject]`(m,a) == #ReturnNewObject 462 463 Summary: `[ReturnNewObject]` controls whether WebCore can return a cached wrapped object or WebCore needs to return a newly created wrapped object every time. 464 465 Usage: `[ReturnNewObject]` can be specified on methods or attributes: 466 {{{ 467 [ReturnNewObject] attribute Node node; 572 468 [ReturnNewObject] Node createTextNode(); 573 469 }}} 574 470 575 Without [ReturnNewObject], JavaScriptCore and V8cache a wrapped object for performance.576 For example, consider the case where node.firstChildis accessed:577 578 1. Node::firstChild()is called in WebCore.579 1. The result of Node::firstChild() is passed to toJS() or toV8().580 1. toJS() or toV8()checks if a wrapped object of the result is already cached on the node.471 Without `[ReturnNewObject]`, JavaScriptCore cache a wrapped object for performance. 472 For example, consider the case where `node.firstChild` is accessed: 473 474 1. `Node::firstChild()` is called in WebCore. 475 1. The result of `Node::firstChild()` is passed to `toJS()`. 476 1. `toJS()` checks if a wrapped object of the result is already cached on the node. 581 477 1. If cached, the cached wrapped object is returned. That's it. 582 1. Otherwise, toJS() or toV8()creates the wrapped object of the result.478 1. Otherwise, `toJS()` creates the wrapped object of the result. 583 479 1. The created wrapped object is cached on the node. 584 480 1. The wrapped object is returned. 585 481 586 482 On the other hand, if you do not want to cache the wrapped object and want to create the wrapped object every time, 587 you can specify [ReturnNewObject].588 589 == [ImplementedAs](m,a) == #ImplementedAs590 591 Summary: [ImplementedAs]specifies a method name in WebCore, if the method name in an IDL file and the method name in WebCore are different.592 593 Usage: The possible usage is [ImplementedAs=XXX], where XXXis a method name in WebCore.594 [ImplementedAs]can be specified on methods:483 you can specify `[ReturnNewObject]`. 484 485 == `[ImplementedAs]`(m,a) == #ImplementedAs 486 487 Summary: `[ImplementedAs]` specifies a method name in WebCore, if the method name in an IDL file and the method name in WebCore are different. 488 489 Usage: The possible usage is `[ImplementedAs=XXX]`, where `XXX` is a method name in WebCore. 490 `[ImplementedAs]` can be specified on methods: 595 491 {{{ 596 492 [ImplementedAs=deleteFunction] void delete(); 597 attribute [ImplementedAs=classAttribute]int class;493 [ImplementedAs=classAttribute] attribute int class; 598 494 }}} 599 495 600 496 Basically a method name in WebCore should be the same as the method name in an IDL file. 601 497 That being said, sometimes you cannot use the same method name; e.g. "delete" is reserved for a C++ keyword. 602 In such cases, you can explicitly specify the method name in WebCore by [ImplementedAs].603 You should avoid using [ImplementedAs]as much as possible though.604 605 == [Reflect](a) == #Reflect498 In such cases, you can explicitly specify the method name in WebCore by `[ImplementedAs]`. 499 You should avoid using `[ImplementedAs]` as much as possible though. 500 501 == `[Reflect]`(a) == #Reflect 606 502 607 503 * [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#reflect The spec of Reflect] 608 504 609 Summary: [Reflect]indicates that a given attribute should reflect the values of a corresponding content attribute.610 611 Usage: The possible usage is [Reflect] or [Reflect=X], where Xis the name of a corresponding content attribute.612 [Reflect]can be specified on attributes:505 Summary: `[Reflect]` indicates that a given attribute should reflect the values of a corresponding content attribute. 506 507 Usage: The possible usage is `[Reflect]` or `[Reflect=X]`, where `X` is the name of a corresponding content attribute. 508 `[Reflect]` can be specified on attributes: 613 509 {{{ 614 510 interface Element { 615 attribute [Reflect]DOMString id;616 attribute [Reflect=class]DOMString className;511 [Reflect] attribute DOMString id; 512 [Reflect=class] attribute DOMString className; 617 513 }; 618 514 }}} … … 624 520 Here 'id' and 'class' are content attributes. 625 521 626 If a given attribute in an IDL file is marked as [Reflect],522 If a given attribute in an IDL file is marked as `[Reflect]`, 627 523 it indicates that the attribute getter returns the value of the corresponding content attribute 628 524 and that the attribute setter sets the value of the corresponding content attribute. … … 630 526 631 527 If the name of the corresponding content attribute is different from the attribute name in an IDL file, 632 you can specify the content attribute name by [Reflect=X].633 For example, in case of [Reflect=class], if 'div.className="barClass"'is evaluated, then "barClass" is set to the 'class' content attribute.634 635 Whether [Reflect]should be specified or not depends on the spec of each attribute.636 637 == [Replaceable](a) == #Replaceable528 you can specify the content attribute name by `[Reflect=X]`. 529 For example, in case of `[Reflect=class]`, if `'div.className="barClass"'` is evaluated, then "barClass" is set to the 'class' content attribute. 530 531 Whether `[Reflect]` should be specified or not depends on the spec of each attribute. 532 533 == `[Replaceable]`(a) == #Replaceable 638 534 639 535 * [http://dev.w3.org/2006/webapi/WebIDL/#Replaceable The spec of Replaceable] 640 536 641 Summary: [Replaceable]controls if a given attribute is "replaceable" or not.642 643 Usage: [Replaceable]can be specified on attributes:537 Summary: `[Replaceable]` controls if a given attribute is "replaceable" or not. 538 539 Usage: `[Replaceable]` can be specified on attributes: 644 540 {{{ 645 541 interface DOMWindow { 646 attribute [Replaceable]screenX;542 [Replaceable] attribute screenX; 647 543 }; 648 544 }}} … … 651 547 If you delete the new value, then the original value still remains. 652 548 653 Specifically, without [Replaceable], the attribute behaves as follows:549 Specifically, without `[Replaceable]`, the attribute behaves as follows: 654 550 {{{ 655 551 window.screenX; // Evaluates to 0 … … 660 556 }}} 661 557 662 With [Replaceable], the attribute behaves as follows:558 With `[Replaceable]`, the attribute behaves as follows: 663 559 {{{ 664 560 window.screenX; // Evaluates to 0 … … 669 565 }}} 670 566 671 Whether [Replaceable]should be specified or not depends on the spec of each attribute.672 673 == [Deletable](a), [NotEnumerable](a), [V8ReadOnly](a) == #Deletable567 Whether `[Replaceable]` should be specified or not depends on the spec of each attribute. 568 569 == `[Deletable]`(a), `[NotEnumerable]`(a)`(a) == #Deletable 674 570 675 571 * [http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf The spec of Writable, Enumerable and Configurable (Section 8.6.1)] 676 572 677 Summary: They control Writability, Enumerability and Configurability of attributes.573 Summary: They control `Writability`, `Enumerability` attributes (`readonly` keyword controls the `Configurability` attributes). 678 574 679 575 Usage: They can be specified on attributes: 680 576 {{{ 681 attribute [NotEnumerable, Deletable]DOMString str;577 [NotEnumerable, Deletable] attribute DOMString str; 682 578 readonly attribute DOMString readonlyStr; 683 attribute [V8ReadOnly] DOMString readonlyStrOnV8; 684 }}} 685 686 By default, non-"readonly" attributes are enumerable, writable and not deletable. "readonly" attributes are enumerable, not writable and not deletable. You can change the default behavior using [Deletable], [NotEnumerable] or [V8ReadOnly]. 687 688 * [Deletable] indicates that the attribute is deletable. 689 * [NotEnumerable] indicates that the attribute is not enumerable. 690 * [V8ReadOnly] indicates that the attribute is readonly in V8 even if the attribute is not prefixed by "readonly". 691 692 == [CachedAttribute](a) == #CachedAttribute 693 694 Summary: For performance optimization, [CachedAttribute] indicates that a wrapped object should be cached on a DOM object. 695 696 Usage: [CachedAttribute] can be specified on attributes: 579 }}} 580 581 By default, non-"readonly" attributes are enumerable, writable and not deletable. "readonly" attributes are enumerable, not writable and not deletable. You can change the default behavior using `[Deletable]`, `[NotEnumerable]` or `readonly`. 582 583 * `[Deletable]` indicates that the attribute is deletable. 584 * `[NotEnumerable]` indicates that the attribute is not enumerable. 585 * `readonly` indicates that the attribute is read only. 586 587 == `[CachedAttribute]`(a) == #CachedAttribute 588 589 Summary: For performance optimization, `[CachedAttribute]` indicates that a wrapped object should be cached on a DOM object. 590 591 Usage: `[CachedAttribute]` can be specified on attributes: 697 592 {{{ 698 593 interface HTMLFoo { 699 attribute [CachedAttribute]DOMString normalValue;700 attribute [CachedAttribute]SerializedScriptValue serializedValue;701 }; 702 }}} 703 704 Without [CachedAttribute], the normalValue getter works in the following way:705 706 1. HTMLFoo::normalValue()is called in WebCore.707 1. The result of HTMLFoo::normalValue() is passed to toJS() or toV8(), and is converted to a wrapped object.594 [CachedAttribute] attribute DOMString normalValue; 595 [CachedAttribute] attribute SerializedScriptValue serializedValue; 596 }; 597 }}} 598 599 Without `[CachedAttribute]`, the normalValue getter works in the following way: 600 601 1. `HTMLFoo::normalValue()` is called in WebCore. 602 1. The result of `HTMLFoo::normalValue()` is passed to `toJS()`, and is converted to a wrapped object. 708 603 1. The wrapped object is returned. 709 604 710 In case where HTMLFoo::normalValue()or the operation to wrap the result is weight,605 In case where `HTMLFoo::normalValue()` or the operation to wrap the result is weight, 711 606 you can cache the wrapped object onto the DOM object. 712 With [CachedAttribute], the normalValue getter works in the following way:607 With `[CachedAttribute]`, the normalValue getter works in the following way: 713 608 714 609 1. If the wrapped object is cached, the cached wrapped object is returned. That's it. 715 1. Otherwise, HTMLFoo::normalValue()is called in WebCore.716 1. The result of HTMLFoo::normalValue() is passed to toJS() or toV8(), and is converted to a wrapped object.610 1. Otherwise, `HTMLFoo::normalValue()` is called in WebCore. 611 1. The result of `HTMLFoo::normalValue()` is passed to `toJS()`, and is converted to a wrapped object. 717 612 1. The wrapped object is cached. 718 613 1. The wrapped object is returned. 719 614 720 In particular, [CachedAttribute]will be useful for serialized values, since deserialization can be weight.721 Without [CachedAttribute], the serializedValue getter works in the following way:722 723 1. HTMLFoo::serializedValue()is called in WebCore.724 1. The result of HTMLFoo::serializedValue()is deserialized.725 1. The deserialized result is passed to toJS() or toV8(), and is converted to a wrapped object.615 In particular, `[CachedAttribute]` will be useful for serialized values, since deserialization can be weight. 616 Without `[CachedAttribute]`, the serializedValue getter works in the following way: 617 618 1. `HTMLFoo::serializedValue()` is called in WebCore. 619 1. The result of `HTMLFoo::serializedValue()` is deserialized. 620 1. The deserialized result is passed to `toJS()`, and is converted to a wrapped object. 726 621 1. The wrapped object is returned. 727 622 728 In case where HTMLFoo::serializedValue(), the deserialization or the operation to wrap the result is weight,623 In case where `HTMLFoo::serializedValue()`, the deserialization or the operation to wrap the result is weight, 729 624 you can cache the wrapped object onto the DOM object. 730 With [CachedAttribute], the serializedValue getter works in the following way:625 With `[CachedAttribute]`, the serializedValue getter works in the following way: 731 626 732 627 1. If the wrapped object is cached, the cached wrapped object is returned. That's it. 733 1. Otherwise, HTMLFoo::serializedValue()is called in WebCore.734 1. The result of HTMLFoo::serializedValue()is deserialized.735 1. The deserialized result is passed to toJS() or toV8(), and is converted to a wrapped object.628 1. Otherwise, `HTMLFoo::serializedValue()` is called in WebCore. 629 1. The result of `HTMLFoo::serializedValue()` is deserialized. 630 1. The deserialized result is passed to `toJS()`, and is converted to a wrapped object. 736 631 1. The wrapped object is cached. 737 632 1. The wrapped object is returned. … … 742 637 In addition, setters always need to invalidate the cache. 743 638 744 == [V8Unforgeable](m,a), [V8OnProto](m,a) == #V8Unforgeable 745 746 * [http://dev.w3.org/2006/webapi/WebIDL/#Unforgeable The spec of Unforgeable] 747 748 Summary: They control where a getter/setter of a given attribute is defined. 749 750 Usage: They can be specified on methods or attributes: 751 {{{ 752 [V8Unforgeable] void func(); 753 attribute [V8OnProto] DOMString str; 754 }}} 755 756 By default in JSC and V8, attribute getters/setters are defined on a DOM object, and methods are defined on a prototype chain 757 (although the Web IDL spec requires that both attribute getters/setters and methods should be defined on a prototype chain). 758 759 If you want to explicitly control where an attribute getter/setter or a method is defined in V8, 760 you can use [V8Unforgeable] or [V8OnProto]. 761 762 * [V8Unforgeable] indicates that an attribute getter/setter or a method should be defined on a DOM object. 763 * [V8OnProto] indicates that an attribute getter/setter or a method should be defined on a prototype chain. 764 765 Note: As explained above, the current implementation of JSC and V8 is wrong with the Web IDL spec, 766 and [V8Unforgeable] and [V8OnProto] are used for hack. 767 You should not use them unless you have a strong reason to use them. 768 769 == [URL](a) == #URL 770 771 Summary: [URL] indicates that a given DOMString represents a URL. 772 773 Usage: [URL] can be specified on DOMString attributes only: 774 {{{ 775 attribute [Reflect, URL] DOMString url; 776 }}} 777 778 You need to specify [URL] if a given DOMString represents a URL, 779 since getters of URL attributes need to be realized in a special routine in WebKit, i.e. Element::getURLAttribute(...). 780 If you forgot to specify [URL], then the attribute getter might cause a bug. 781 782 == [JSWindowEventListener](a) FIXME == #JSWindowEventListener 639 == `[JSWindowEventListener]`(a) FIXME == #JSWindowEventListener 783 640 784 641 Summary: ADD SUMMARY 785 642 786 Usage: [JSWindowEventListener] can be specified on EventListenerattributes only:787 {{{ 788 attribute [JSWindowEventListener]EventListener onload;643 Usage: `[JSWindowEventListener]` can be specified on `EventListener` attributes only: 644 {{{ 645 [JSWindowEventListener] attribute EventListener onload; 789 646 }}} 790 647 791 648 ADD EXPLANATIONS 792 649 793 == [Supplemental](i) == #Supplemental 794 795 * [http://dev.w3.org/2006/webapi/WebIDL/#dfn-supplemental-interface The spec of Supplemental] 796 797 * [http://old.nabble.com/Things-missing-from-Web-IDL-for-HTML5-td24873773.html Easy explanation of Supplemental] 798 799 Summary: [Supplemental] helps WebKit modularization. 800 [Supplemental] makes it possible to add XXX's APIs (e.g. XXX=WebAudio, WebSocket, Blob, GamePad, ...etc) without modifying code outside of WebCore/Modules/XXX/. 801 This helps make XXX a "self-contained module". 802 803 Usage: The possible usage is 804 {{{ 805 interface [ 806 Supplemental=YYY 807 ] XXX { 808 }; 809 }}} 810 where XXX implements YYY. 811 [Supplemental] can be specified on interfaces. 812 813 Without [Supplemental], if you want to add XXX's attributes or methods to DOMWindow, 814 815 * you need to modify WebCore/page/DOMWindow.idl to add the XXX's attributes or methods 816 817 * you need to modify WebCore/page/DOMWindow.{h,cpp} to add the WebCore implementation of the attribute getters and setters or the method callbacks. 818 819 On the other hand, in the modularized world with [Supplemental], you just need to modify the code under WebCore/Modules/XXX/: 820 821 * WebCore/Modules/XXX/DOMWindowXXX.idl 822 823 {{{ 824 interface [ 825 Conditional=XXX, 826 Supplemental=DOMWindow // The attributes and methods of this interface are exposed as those of DOMWindow. 827 ] DOMWindowXXX { 828 attribute int foo; 829 void bar(); 830 }; 831 }}} 832 833 * WebCore/Modules/XXX/DOMWindowXXX.h 834 835 {{{ 836 DOMWindowXXX::foo(...) { ... } // The WebCore implementation of the foo attribute getter. 837 DOMWindowXXX::setFoo(...) { ... } // The WebCore implementation of the foo attribute setter. 838 DOMWindowXXX::bar(...) { ... } // The WebCore implementation of the bar() method callback. 839 }}} 840 841 As shown above, [Supplemental=DOMWindow] indicates that all the attributes and methods of DOMWindowXXX should be exposed on DOMWindow, 842 but should be implemented in DOMWindowXXX. 843 In this way, you can implement the attributes and methods without modifying code of DOMWindow.{h,cpp,idl}. 844 845 If you want to add APIs whose implementations are likely to be independent from WebCore, 846 it is strongly recommended to put the APIs and .h/.cpp files into WebCore/Modules/XXX/ using [Supplemental]. 847 On the other hand, if the implementations need to touch WebCore much, 848 the APIs might not be good candidates for [Supplemental]. 849 850 == [Constructor](i), [CallWith](i,m,a), [ConstructorRaisesException](i) == #Constructor 650 == `[Constructor]`(i), `[CallWith]`(i,m,a), `[ConstructorRaisesException]`(i) == #Constructor 851 651 852 652 * [http://dev.w3.org/2006/webapi/WebIDL/#Constructor The spec of Constructor] 853 653 854 Summary: [Constructor]indicates that the interface should have constructor, i.e. "new XXX()".855 [CallWith] and [ConstructorRaisesException]adds information when the constructor callback is called in WebCore.856 857 Usage: [Constructor], [CallWith] and [ConstructorRaisesException]can be specified on interfaces:858 {{{ 859 interface[860 Constructor( in float x, in float y, inDOMString str),654 Summary: `[Constructor]` indicates that the interface should have constructor, i.e. "new XXX()". 655 `[CallWith]` and `[ConstructorRaisesException]` adds information when the constructor callback is called in WebCore. 656 657 Usage: `[Constructor]`, `[CallWith]` and `[ConstructorRaisesException]` can be specified on interfaces: 658 {{{ 659 [ 660 Constructor(float x, float y, DOMString str), 861 661 ConstructorRaisesException, 862 662 CallWith=ScriptExecutionContext|ScriptState 863 ] XXX {864 }; 865 }}} 866 867 [Constructor(in float x, in float y, in DOMString str)]means that the interface has a constructor868 and the constructor signature is (in float x, in float y, in DOMString str).663 ] interface XXX { 664 }; 665 }}} 666 667 `[Constructor(float x, float y, DOMString str)]` means that the interface has a constructor 668 and the constructor signature is `(float x, float y, DOMString str)`. 869 669 Specifically, JavaScript can create a DOM object of XXX by the following code: 870 670 {{{ 871 671 var x = new XXX(1.0, 2.0, "hello"); 872 672 }}} 873 Then XXX::create(float x, float y, String str)is called in WebCore.673 Then `XXX::create(float x, float y, String str)` is called in WebCore. 874 674 That way WebCore needs to implement the following method as a constructor callback: 875 675 {{{ … … 880 680 }}} 881 681 882 [Constructor()] is equivalent to [Constructor].883 884 If XXX::create(...) can throw Exception, you can use [ConstructorRaisesException].885 With [ConstructorRaisesException], a placeholder for ExceptionCode is added to the tail argument of XXX::create(...).682 `[Constructor()]` is equivalent to `[Constructor]`. 683 684 If `XXX::create(...)` can throw Exception, you can use `[ConstructorRaisesException]`. 685 With `[ConstructorRaisesException]`, a placeholder for ExceptionCode is added to the tail argument of `XXX::create(...)`. 886 686 {{{ 887 687 PassRefPtr<XXX> XXX::create(float x, float y, String str, ExceptionCode& ec) … … 895 695 }}} 896 696 897 If XXX::create(...)needs additional information like ScriptExecutionContext and ScriptState,898 you can specify [CallWith=ScriptExecutionContext|ScriptState].899 Then XXX::create(...)can have the following signature:697 If `XXX::create(...)` needs additional information like ScriptExecutionContext and ScriptState, 698 you can specify `[CallWith=ScriptExecutionContext|ScriptState]`. 699 Then `XXX::create(...)` can have the following signature: 900 700 {{{ 901 701 PassRefPtr<XXX> XXX::create(ScriptExecutionContext* context, ScriptState* state, float x, float y, String str) … … 907 707 Please see [#CallWith another [CallWith] section] for more details. 908 708 909 Note that [CallWith=...] arguments are added at the head of XXX::create(...)'s arguments,910 and the ExceptionCode argument is added at the tail of XXX::create(...)'s arguments.709 Note that `[CallWith=...]` arguments are added at the head of `XXX::create(...)`'s arguments, 710 and the ExceptionCode argument is added at the tail of `XXX::create(...)`'s arguments. 911 711 912 712 Whether you should allow an interface to have constructor depends on the spec of the interface. 913 713 914 Note: Currently [Constructor(...)] does not yet support [Optional] arguments. It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString].915 916 == [ConstructorTemplate](i), [InitializedByEventConstructor](a) == #ConstructorTemplate714 Note: Currently `[Constructor(...)]` does not yet support optional arguments w/o defaults. It just supports `[Default=Undefined] optional` or `[Default=NullString] optional`. 715 716 == `[ConstructorTemplate]`(i), `[InitializedByEventConstructor]`(a) == #ConstructorTemplate 917 717 918 718 Summary: They are used for Event constructors. 919 719 920 Usage: The possible usage is [ConstructorTemplate=Event].921 [ConstructorTemplate=Event]can be specified on Event interfaces only.922 [InitializedByEventConstructor]can be specified on attributes in the Event interfaces:923 {{{ 924 interface[720 Usage: The possible usage is `[ConstructorTemplate=Event]`. 721 `[ConstructorTemplate=Event]` can be specified on Event interfaces only. 722 `[InitializedByEventConstructor]` can be specified on attributes in the Event interfaces: 723 {{{ 724 [ 925 725 ConstructorTemplate=Event 926 ] FooEvent {726 ] interface FooEvent { 927 727 attribute DOMString str1; 928 attribute [InitializedByEventConstructor]DOMString str2;728 [InitializedByEventConstructor] attribute DOMString str2; 929 729 }; 930 730 }}} 931 731 932 732 Since constructors for Event interfaces require special bindings, 933 you need to use [ConstructorTemplate=Event] instead of normal [Constructor].934 935 If you specify [ConstructorTemplate=Event]on FooEvent,733 you need to use `[ConstructorTemplate=Event]` instead of normal `[Constructor]`. 734 735 If you specify `[ConstructorTemplate=Event]` on FooEvent, 936 736 JavaScript can create a DOM object of FooEvent in the following code: 937 737 {{{ … … 947 747 }}} 948 748 949 [InitializedByEventConstructor]should be specified on all the attributes749 `[InitializedByEventConstructor]` should be specified on all the attributes 950 750 that needs to be initialized by the constructor. 951 751 Which attributes need initialization is defined in the spec of each Event interface. … … 953 753 The EventInit dictionary has bubbles and cancelable, and thus bubbles and cancelable are the only attributes 954 754 that need to be initialized by the Event constructor. 955 In other words, in case of Event, you should specify [InitializedByEventConstructor]on bubbles and cancelable.956 957 == [NamedConstructor](i) == #NamedConstructor755 In other words, in case of Event, you should specify `[InitializedByEventConstructor]` on bubbles and cancelable. 756 757 == `[NamedConstructor]`(i) == #NamedConstructor 958 758 959 759 * [http://dev.w3.org/2006/webapi/WebIDL/#NamedConstructor The spec of NamedConstructor] 960 760 961 761 Summary: If you want to allow JavaScript to create a DOM object of XXX using a different name constructor 962 (i.e. allow JavaScript to create an XXX object using "new YYY()", where YYY != XXX), you can use [NamedConstructor].963 964 Usage: The possible usage is [NamedConstructor=YYY].965 [NamedConstructor]can be specified on interfaces:966 {{{ 967 interface[762 (i.e. allow JavaScript to create an XXX object using "new YYY()", where YYY != XXX), you can use `[NamedConstructor]`. 763 764 Usage: The possible usage is `[NamedConstructor=YYY]`. 765 `[NamedConstructor]` can be specified on interfaces: 766 {{{ 767 [ 968 768 NamedConstructor=Audio() 969 ] HTMLAudioElement {970 }; 971 }}} 972 973 The semantics is the same as [Constructor], except that JavaScript can make a DOM object not by "new HTMLAudioElement()" but by "Audio()".769 ] interface HTMLAudioElement { 770 }; 771 }}} 772 773 The semantics is the same as `[Constructor]`, except that JavaScript can make a DOM object not by "new HTMLAudioElement()" but by "Audio()". 974 774 975 775 Whether you should allow an interface to have a named constructor or not depends on the spec of each interface. 976 776 977 == [CustomConstructor](i), [JSCustomConstructor](i), [V8CustomConstructor](i), [ConstructorParameters](i) == #CustomConstructor777 == `[CustomConstructor]`(i), `[ConstructorParameters]`(i) == #CustomConstructor 978 778 979 779 Summary: They allow you to write custom bindings for constructors. 980 780 981 781 Usage: They can be specified on interfaces. 982 Regarding [ConstructorParameters], the possible usage is [ConstructorParameters=X], where X is the maximum number ofarguments of the constructor:983 {{{ 984 interface[782 Regarding `[ConstructorParameters]`, the possible usage is `[ConstructorParameters=X]`, where `X` is the number of mandatory arguments of the constructor: 783 {{{ 784 [ 985 785 CustomConstructor, 986 786 ConstructorParameters=4 987 ] XXX {787 ] interface XXX { 988 788 }; 989 789 }}} 990 790 991 791 We should minimize the number of custom bindings as less as possible. 992 Before using [CustomConstructor], you should doubly consider if you really need custom bindings.993 You are recommended to modify code generators to avoid using [Custom].792 Before using `[CustomConstructor]`, you should doubly consider if you really need custom bindings. 793 You are recommended to modify code generators to avoid using `[Custom]`. 994 794 995 795 Before explaining the details, let us clarify the relationship of these IDL attributes. 996 796 997 * [JSCustomConstructor] on an interface indicates that you can write JavaScriptCore custom bindings for the constructor. 998 * [V8CustomConstructor] on an interface indicates that you can write V8 custom bindings for the constructor. 999 * [CustomConstructor] is equivalent to [JSCustomConstructor, V8CustomConstructor]. 1000 1001 For example, if you specify [Constructor, JSCustomConstructor], 1002 then the constructor is generated only for V8 and you need to write JavaScriptCore custom bindings for the constructor. 1003 1004 How to write custom bindings is different between JavaScriptCore and V8. 1005 1006 * JavaScriptCore: Consider the following example: 1007 1008 {{{ 1009 interface [ 797 * `[CustomConstructor]` on an interface indicates that you can write JavaScriptCore custom bindings for the constructor. 798 799 You can write custom bindings for JavaScriptCore as follows. 800 801 * Consider the following example: 802 803 {{{ 804 [ 1010 805 CustomConstructor, 1011 806 ConstructorParameters=2 1012 ] XXX {807 ] interface XXX { 1013 808 }; 1014 809 }}} … … 1022 817 Refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. 1023 818 1024 * V8: Consider the following example: 1025 1026 {{{ 1027 interface [ 1028 CustomConstructor, 1029 ConstructorParameters=2 1030 ] XXX { 1031 }; 1032 }}} 1033 Then you can write custom bindings in WebCore/bindings/v8/custom/V8XXXConstructorCustom.cpp: 1034 {{{ 1035 v8::Handle<v8::Value> V8XXX::constructorCallback(const v8::Arguments& args) 1036 { 1037 ...; 1038 } 1039 }}} 1040 Refer to WebCore/bindings/v8/custom/V8XXXConstructorCustom.cpp for more details. 1041 1042 X of [ConstructorParameters=X] is the maximum number of arguments, including optional arguments. 1043 For example, if a constructor signature is [Constructor(in int a, in int b, in [Optional=DefaultIsUndefined] int c, in [Optional=DefaultIsUndefined] int d)], then X is 4. 1044 1045 You do not need to specify [ConstructorParameters] if the interface does not have any of [JSCustomConstructor], [V8CustomConstructor] or [CustomConstructor]. 1046 1047 == [Conditional](i,m,a) == #Conditional 1048 1049 Summary: [Conditional] inserts "#if ENABLE(SOME_FLAG) ... #endif" into the generated code. 1050 1051 Usage: [Conditional] can be specified on interfaces, methods and attributes: 1052 {{{ 1053 interface [ 819 `X` of `[ConstructorParameters=X]` is the number of mandatory arguments. 820 For example, if a constructor signature is `[Constructor(int a, int b, [Default=Undefined] optional int c, [Default=DefaultIsUndefined] optional int d)]`, then `X` is 2. 821 822 You do not need to specify `[ConstructorParameters]` if the interface does not have `[CustomConstructor]` extended attribute. 823 824 == `[Conditional]`(i,m,a) == #Conditional 825 826 Summary: `[Conditional]` inserts "#if ENABLE(SOME_FLAG) ... #endif" into the generated code. 827 828 Usage: `[Conditional]` can be specified on interfaces, methods and attributes: 829 {{{ 830 [ 1054 831 Conditional=INDEXED_DATABASE 1055 ] XXX {832 ] interface XXX { 1056 833 }; 1057 834 }}} 1058 835 {{{ 1059 836 interface XXX { 1060 attribute [Conditional=INDEXED_DATABASE]DOMString str;837 [Conditional=INDEXED_DATABASE] attribute DOMString str; 1061 838 [Conditional=INDEXED_DATABASE] void open(); 1062 839 }; 1063 840 }}} 1064 841 1065 [Conditional]is used to enable or disable the generated code based on a "flag".842 `[Conditional]` is used to enable or disable the generated code based on a "flag". 1066 843 If a given flag is enabled, the generated code is compiled. Otherwise, the generated code is not compiled. 1067 844 Whether a flag is enabled or disabled is controlled (mostly) by Tools/Scripts/build-webkit. 1068 845 1069 If [Conditional] is specified on an interface, it means that [Conditional]is specified on all attributes and methods of the interface.1070 1071 == [CheckSecurity](i), [DoNotCheckSecurity](m,a), [DoNotCheckSecurityOnGetter](a), [DoNotCheckSecurityOnSetter](a) == #CheckSecurity846 If `[Conditional]` is specified on an interface, it means that `[Conditional]` is specified on all attributes and methods of the interface. 847 848 == `[CheckSecurity]`(i), `[DoNotCheckSecurity]`(m,a), `[DoNotCheckSecurityOnGetter]`(a), `[DoNotCheckSecurityOnSetter]`(a) == #CheckSecurity 1072 849 1073 850 Summary: They check whether a given access is allowed or not, in terms of the same-origin security policy. 1074 851 1075 Usage: [CheckSecurity]can be specified on interfaces.1076 [DoNotCheckSecurity] can be specified on methods or attributes that belong to interfaces that have [CheckSecurity].1077 [DoNotCheckSecurityOnGetter] and [DoNotCheckSecurityOnSetter]can be specified on attributes1078 that belong to interfaces that have [CheckSecurity]:1079 {{{ 1080 interface[852 Usage: `[CheckSecurity]` can be specified on interfaces. 853 `[DoNotCheckSecurity]` can be specified on methods or attributes that belong to interfaces that have `[CheckSecurity]`. 854 `[DoNotCheckSecurityOnGetter]` and `[DoNotCheckSecurityOnSetter]` can be specified on attributes 855 that belong to interfaces that have `[CheckSecurity]`: 856 {{{ 857 [ 1081 858 CheckSecurity 1082 ] DOMWindow {859 ] interface DOMWindow { 1083 860 attribute DOMString str1; 1084 attribute [DoNotCheckSecurity]DOMString str2:1085 attribute [DoNotCheckSecurityOnGetter]DOMString str3:1086 attribute [DoNotCheckSecurityOnSetter]DOMString str4:861 [DoNotCheckSecurity] attribute DOMString str2: 862 [DoNotCheckSecurityOnGetter] attribute DOMString str3: 863 [DoNotCheckSecurityOnSetter] attribute DOMString str4: 1087 864 void func1(); 1088 865 [DoNotCheckSecurity] void func2(); … … 1092 869 Consider the case where you access window.parent from inside an iframe that comes from a different origin. 1093 870 While it is allowed to access window.parent, it is not allowed to access window.parent.document. 1094 In such cases, you need to specify [CheckSecurity]in order to check871 In such cases, you need to specify `[CheckSecurity]` in order to check 1095 872 whether a given DOM object is allowed to access the attribute or method, in terms of the same-origin security policy. 1096 873 This is really important for security. 1097 874 1098 If you specify [CheckSecurity]on an interface, the security check is enabled on all the attributes and methods of the interface.875 If you specify `[CheckSecurity]` on an interface, the security check is enabled on all the attributes and methods of the interface. 1099 876 To disable the security check for particular attributes or methods, 1100 you can use [DoNotCheckSecurity], [DoNotCheckSecurityOnGetter] or [DoNotCheckSecurityOnSetter].1101 1102 * [DoNotCheckSecurity]on a method disables the security check for the method.1103 * [DoNotCheckSecurity]on an attribute disables the security check for a getter and setter of the attribute.1104 * [DoNotCheckSecurityOnGetter]on an attribute disables the security check for a getter of the attribute.1105 * [DoNotCheckSecurityOnSetter]on an attribute disables the security check for a setter of the attribute.1106 * [DoNotCheckSecurity] on an attribute is equivalent to [DoNotCheckSecurityOnGetter, DoNotCheckSecurityOnSetter].1107 1108 == [CheckSecurityForNode](m,a) == #CheckSecurityForNode1109 1110 Summary: [CheckSecurityForNode]checks whether a given access to Node is allowed or not, in terms of the same-origin security policy.1111 1112 Usage: [CheckSecurityForNode]can be specified on methods or attributes:1113 {{{ 1114 attribute [CheckSecurityForNode]Node contentDocument;877 you can use `[DoNotCheckSecurity]`, `[DoNotCheckSecurityOnGetter]` or `[DoNotCheckSecurityOnSetter]`. 878 879 * `[DoNotCheckSecurity]` on a method disables the security check for the method. 880 * `[DoNotCheckSecurity]` on an attribute disables the security check for a getter and setter of the attribute. 881 * `[DoNotCheckSecurityOnGetter]` on an attribute disables the security check for a getter of the attribute. 882 * `[DoNotCheckSecurityOnSetter]` on an attribute disables the security check for a setter of the attribute. 883 * `[DoNotCheckSecurity]` on an attribute is equivalent to `[DoNotCheckSecurityOnGetter, DoNotCheckSecurityOnSetter]`. 884 885 == `[CheckSecurityForNode]`(m,a) == #CheckSecurityForNode 886 887 Summary: `[CheckSecurityForNode]` checks whether a given access to Node is allowed or not, in terms of the same-origin security policy. 888 889 Usage: `[CheckSecurityForNode]` can be specified on methods or attributes: 890 {{{ 891 [CheckSecurityForNode] attribute Node contentDocument; 1115 892 [CheckSecurityForNode] SVGDocument getSVGDocument(); 1116 893 }}} 1117 894 1118 In terms of the same-origin security policy, node.contentDocumentshould return undefined if the parent frame and the child frame are from different origins.1119 If the security check is necessary, you should specify [CheckSecurityForNode].895 In terms of the same-origin security policy, `node.contentDocument` should return undefined if the parent frame and the child frame are from different origins. 896 If the security check is necessary, you should specify `[CheckSecurityForNode]`. 1120 897 This is really important for security. 1121 898 1122 == [IndexedGetter](i) == #IndexedGetter899 == `[IndexedGetter]`(i) == #IndexedGetter 1123 900 1124 901 * [http://dev.w3.org/2006/webapi/WebIDL/#idl-indexed-properties The spec of indexed properties] (Note: The WebKit behavior explained below is different from the spec) 1125 902 1126 Summary: [IndexedGetter]means that a given interface should have a getter of indexed properties.1127 1128 Usage: [IndexedGetter]can be specified on interfaces:1129 {{{ 1130 interface[903 Summary: `[IndexedGetter]` means that a given interface should have a getter of indexed properties. 904 905 Usage: `[IndexedGetter]` can be specified on interfaces: 906 {{{ 907 [ 1131 908 IndexedGetter 1132 ] XXX { 1133 }; 1134 }}} 1135 1136 Indexed getters define the behavior when XXX[i] is evaluated. 1137 For example, if XXX is an array-type interface, it should have indexed getters (and setters). 1138 The bindings code for indexed getters is generated automatically so that XXX[i] behaves equivalent to XXX.item(i). 1139 1140 == [V8CustomIndexedGetter](i) == #V8CustomIndexedGetter 1141 1142 Summary: [V8CustomIndexedGetter] allows you to write custom bindings for a getter of indexed properties. 1143 1144 Usage: [V8CustomIndexedGetter] can be specified on interfaces: 1145 {{{ 1146 interface [ 1147 V8CustomIndexedGetter 1148 ] XXX { 1149 }; 1150 }}} 1151 1152 Interface that have V8CustomIndexedGetter attribute must have also IndexedGetter attribute. 1153 1154 == [CustomIndexedSetter](i) == #CustomIndexedSetter 909 ] interface XXX { 910 }; 911 }}} 912 913 Indexed getters define the behavior when `XXX[i]` is evaluated. 914 For example, if `XXX` is an array-type interface, it should have indexed getters (and setters). 915 The bindings code for indexed getters is generated automatically so that `XXX[i]` behaves equivalent to `XXX.item(i)`. 916 917 == `[CustomIndexedSetter]`(i) == #CustomIndexedSetter 1155 918 1156 919 * [http://dev.w3.org/2006/webapi/WebIDL/#idl-indexed-properties The spec of indexed properties] (Note: The WebKit behavior explained below is different from the spec) 1157 920 1158 Summary: [CustomIndexedSetter]allows you to write custom bindings for a setter of indexed properties.921 Summary: `[CustomIndexedSetter]` allows you to write custom bindings for a setter of indexed properties. 1159 922 1160 923 Usage: [CustomIndexedSetter] can be specified on interfaces: 1161 924 {{{ 1162 interface[925 [ 1163 926 CustomIndexedSetter 1164 ] XXX {927 ] interface XXX { 1165 928 }; 1166 929 }}} … … 1168 931 Indexed setters define the behavior when "XXX[i] = ..." is evaluated. 1169 932 For example, if XXX is an array-type interface, it should have indexed (getters and) setters. 1170 [CustomIndexedSetter]allows you to write the custom bindings, as follows.1171 1172 * JavaScriptCore: You can write custom JSXXX::indexSetter(...)in WebCore/bindings/js/JSXXXCustom.cpp:933 `[CustomIndexedSetter]` allows you to write the custom bindings, as follows. 934 935 * JavaScriptCore: You can write custom `JSXXX::indexSetter(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1173 936 1174 937 {{{ … … 1178 941 } 1179 942 }}} 1180 * In V8: You can write custom V8XXX::indexedPropertySetter(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1181 1182 {{{ 1183 v8::Handle<v8::Value> V8XXX::indexedPropertySetter(uint32_t index, const v8::AccessorInfo& info) 1184 { 1185 ...; 1186 } 1187 }}} 1188 1189 == [NamedGetter](i) == #NamedGetter 943 944 == `[NamedGetter]`(i) == #NamedGetter 1190 945 1191 946 * [http://dev.w3.org/2006/webapi/WebIDL/#idl-named-properties The spec of named properties] (Note: The WebKit behavior explained below is different from the spec) 1192 947 1193 Summary: [NamedGetter]means that a given interface should have a getter of named properties.1194 1195 Usage: [NamedGetter]can be specified on interfaces:1196 {{{ 1197 interface[948 Summary: `[NamedGetter]` means that a given interface should have a getter of named properties. 949 950 Usage: `[NamedGetter]` can be specified on interfaces: 951 {{{ 952 [ 1198 953 NamedGetter 1199 ] XXX {954 ] interface XXX { 1200 955 }; 1201 956 }}} … … 1204 959 The bindings code for named getters is generated automatically so that XXX.foooooooo behaves equivalent to XXX.namedItem(i). 1205 960 1206 == [CustomNamedGetter](i), [CustomNamedSetter](i) == #CustomNamedGetter961 == `[CustomNamedGetter]`(i), `[CustomNamedSetter]`(i) == #CustomNamedGetter 1207 962 1208 963 * [http://dev.w3.org/2006/webapi/WebIDL/#idl-named-properties The spec of named properties] (Note: The WebKit behavior explained below is different from the spec) 1209 964 1210 Summary: [CustomNamedGetter] or [CustomNamedSetter]allows you to write custom bindings for a getter or setter of named properties.965 Summary: `[CustomNamedGetter]` or `[CustomNamedSetter]` allows you to write custom bindings for a getter or setter of named properties. 1211 966 1212 967 Usage: They can be specified on interfaces: 1213 968 {{{ 1214 interface[969 [ 1215 970 CustomNamedGetter, 1216 971 CustomNamedSetter 1217 ] XXX {972 ] interface XXX { 1218 973 }; 1219 974 }}} … … 1221 976 Named getters define the behavior when XXX.foooooooo is evaluated, where foooooooo is not an attribute of XXX. 1222 977 Named setters define the behavior when "XXX.foooooooo = ..." is evaluated. 1223 [CustomNamedGetter] or [CustomNamedSetter]allow you to write the custom bindings, as follows:1224 1225 * [CustomNamedGetter] in JavaScriptCore: You can write custom JSXXX::canGetItemsForName(...) and JSXXX::nameGetter(...)in WebCore/bindings/js/JSXXXCustom.cpp:978 `[CustomNamedGetter]` or `[CustomNamedSetter]` allow you to write the custom bindings, as follows: 979 980 * `[CustomNamedGetter]` in JavaScriptCore: You can write custom `JSXXX::canGetItemsForName(...)` and `JSXXX::nameGetter(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1226 981 1227 982 {{{ … … 1236 991 } 1237 992 }}} 1238 * [CustomNamedGetter] in V8: You can write custom V8XXX::namedPropertyGetter(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1239 1240 {{{ 1241 v8::Handle<v8::Value> V8XXX::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 1242 { 1243 ...; 1244 } 1245 }}} 1246 * [CustomNamedSetter] in JavaScriptCore: You can write custom JSXXX::putDelegate(...) in WebCore/bindings/js/JSXXXCustom.cpp: 993 * `[CustomNamedSetter]` in JavaScriptCore: You can write custom `JSXXX::putDelegate(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1247 994 1248 995 {{{ … … 1252 999 } 1253 1000 }}} 1254 * [CustomNamedSetter] in V8: You can write custom V8XXX::namedPropertySetter(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1255 1256 {{{ 1257 v8::Handle<v8::Value> V8XXX::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 1258 { 1259 ...; 1260 } 1261 }}} 1262 1263 == [InterfaceName](i) == #InterfaceName 1264 1265 Summary: If you want to expose a different interface name to JavaScript, you can specify the name by [InterfaceName]. 1266 1267 Usage: The possible usage is [InterfaceName=X], where X is the interface name exposed to JavaScript. 1268 [InterfaceName] can be specified on interfaces: 1001 1002 == `[InterfaceName]`(i) == #InterfaceName 1003 1004 Summary: If you want to expose a different interface name to JavaScript, you can specify the name by `[InterfaceName]`. 1005 1006 Usage: The possible usage is `[InterfaceName=X]`, where `X` is the interface name exposed to JavaScript. 1007 `[InterfaceName]` can be specified on interfaces: 1269 1008 {{{ 1270 1009 interface [ … … 1274 1013 }}} 1275 1014 1276 Without [InterfaceName=...], the interface name exposed to JavaScript becomes the same as the interface name in an IDL file.1277 If you want change it based on the spec, you can use [InterfaceName=...].1015 Without `[InterfaceName=...]`, the interface name exposed to JavaScript becomes the same as the interface name in an IDL file. 1016 If you want change it based on the spec, you can use `[InterfaceName=...]`. 1278 1017 In the above example, `window.toString()` will return `"[object Window]"` in JavaScript. 1279 1018 1280 == [EventTarget](i) FIXME == #EventTarget1019 == `[EventTarget]`(i) FIXME == #EventTarget 1281 1020 1282 1021 Summary: ADD SUMMARY 1283 1022 1284 Usage: [EventTarget]can be specified on interfaces:1285 {{{ 1286 interface[1023 Usage: `[EventTarget]` can be specified on interfaces: 1024 {{{ 1025 [ 1287 1026 EventTarget 1288 ] XXX {1027 ] interface XXX { 1289 1028 }; 1290 1029 }}} … … 1292 1031 ADD EXPLANATIONS 1293 1032 1294 == [DoNotCheckConstants](i) == #DoNotCheckConstants1295 1296 Summary: [DoNotCheckConstants]indicates that constant values in an IDL file can be different from constant values in WebCore implementation.1297 1298 Usage: [DoNotCheckConstants]can be specified on interfaces:1299 {{{ 1300 interface[1033 == `[DoNotCheckConstants]`(i) == #DoNotCheckConstants 1034 1035 Summary: `[DoNotCheckConstants]` indicates that constant values in an IDL file can be different from constant values in WebCore implementation. 1036 1037 Usage: `[DoNotCheckConstants]` can be specified on interfaces: 1038 {{{ 1039 [ 1301 1040 DoNotCheckConstants 1302 ] XXX {1041 ] interface XXX { 1303 1042 const unsigned short NOT_FOUND_ERR = 12345; 1304 1043 const unsigned short SYNTAX_ERR = 12346; … … 1306 1045 }}} 1307 1046 1308 By default (i.e. without [DoNotCheckConstants]), compile-time assertions are inserted to check if the constant values defined in IDL files1047 By default (i.e. without `[DoNotCheckConstants]`), compile-time assertions are inserted to check if the constant values defined in IDL files 1309 1048 are equal to the constant values in WebCore implementation. 1310 1049 In the above example, if NOT_FOUND_ERR were implemented as 100 in WebCore, the build will fail. … … 1313 1052 and thus the values in WebCore implementation should be equal to the values defined in the spec. 1314 1053 If you really want to introduce non-speced constant values and allow different values between IDL files and WebCore implementation, 1315 you can specify [DoNotCheckConstants]to skip the compile-time assertions.1316 1317 == [ActiveDOMObject](i) == #ActiveDOMObject1318 1319 Summary: [ActiveDOMObject]indicates that a given DOM object should be kept alive as long as the DOM object has pending activities.1320 1321 Usage: [ActiveDOMObject]can be specified on interfaces:1322 {{{ 1323 interface[1054 you can specify `[DoNotCheckConstants]` to skip the compile-time assertions. 1055 1056 == `[ActiveDOMObject]`(i) == #ActiveDOMObject 1057 1058 Summary: `[ActiveDOMObject]` indicates that a given DOM object should be kept alive as long as the DOM object has pending activities. 1059 1060 Usage: `[ActiveDOMObject]` can be specified on interfaces: 1061 {{{ 1062 [ 1324 1063 ActiveDOMObject 1325 ] XMLHttpRequest {1326 }; 1327 }}} 1328 1329 If a given DOM object needs to be kept alive as long as the DOM object has pending activities, you need to specify [ActiveDOMObject].1330 For example, [ActiveDOMObject]can be used when the DOM object is expecting events to be raised in the future.1331 1332 If you use [ActiveDOMObject], the corresponding WebCore class needs to inherit ActiveDOMObject.1064 ] interface XMLHttpRequest { 1065 }; 1066 }}} 1067 1068 If a given DOM object needs to be kept alive as long as the DOM object has pending activities, you need to specify `[ActiveDOMObject]`. 1069 For example, `[ActiveDOMObject]` can be used when the DOM object is expecting events to be raised in the future. 1070 1071 If you use `[ActiveDOMObject]`, the corresponding WebCore class needs to inherit ActiveDOMObject. 1333 1072 For example, in case of XMLHttpRequest, WebCore/xml/XMLHttpRequest.h would look like this: 1334 1073 {{{ … … 1339 1078 Then you need to implement the virtual methods of the ActiveDOMObject class, e.g. contextDestroyed(), canSuspend(), suspend(), resume() and stop(). 1340 1079 1341 If an interface X has [ActiveDOMObject] and an interface Y inherits the interface X, 1342 then the interface Y should also have [ActiveDOMObject]. 1343 1344 == [V8DependentLifeTime](i) FIXME == #V8DependentLifeTime 1345 1346 Summary: ADD SUMMARY 1347 1348 Usage: [V8DependentLifeTime] can be specified on interfaces: 1349 {{{ 1350 interface [ 1351 V8DependentLifeTime 1352 ] XXX { 1353 }; 1354 }}} 1355 1356 ADD EXPLANATIONS 1357 1358 == [CustomEnumerateProperty](i), [CustomDeleteProperty](i) == #CustomEnumerateProperty 1359 1360 Summary: [CustomEnumerateProperty] allows you to write custom bindings for the case where properties of a given interface are enumerated. 1361 [CustomDeleteProperty] allows you to write custom bindings for the case where a property of a given interface is deleted. 1080 If an interface X has `[ActiveDOMObject]` and an interface Y inherits the interface X, 1081 then the interface Y should also have `[ActiveDOMObject]`. 1082 1083 == `[CustomEnumerateProperty]`(i), `[CustomDeleteProperty]`(i) == #CustomEnumerateProperty 1084 1085 Summary: `[CustomEnumerateProperty]` allows you to write custom bindings for the case where properties of a given interface are enumerated. 1086 `[CustomDeleteProperty]` allows you to write custom bindings for the case where a property of a given interface is deleted. 1362 1087 1363 1088 Usage: They can be specified on interfaces: 1364 1089 {{{ 1365 interface[1090 [ 1366 1091 CustomEnumerateProperty, 1367 1092 CustomDeleteProperty 1368 ] XXX {1369 }; 1370 }}} 1371 1372 * [CustomEnumerateProperty]in JavaScriptCore: You can write custom bindings when properties of XXX are enumerated.1373 Specifically, you can write custom JSXXX::getOwnPropertyNames(...)in WebCore/bindings/js/JSXXXCustom.cpp:1093 ] interface XXX { 1094 }; 1095 }}} 1096 1097 * `[CustomEnumerateProperty]` in JavaScriptCore: You can write custom bindings when properties of XXX are enumerated. 1098 Specifically, you can write custom `JSXXX::getOwnPropertyNames(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1374 1099 1375 1100 {{{ … … 1380 1105 }}} 1381 1106 1382 * [CustomEnumerateProperty] in V8: You can write custom bindings as V8XXX::namedPropertyQuery(...) and V8XXX::namedPropertyEnumerator(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1383 1384 {{{ 1385 v8::Handle<v8::Integer> V8XXX::namedPropertyQuery(v8::Local<v8::String> name, const v8::AccessorInfo& info) 1386 { 1387 ...; 1388 } 1389 1390 v8::Handle<v8::Array> V8XXX::namedPropertyEnumerator(const v8::AccessorInfo& info) 1391 { 1392 ...; 1393 } 1394 }}} 1395 1396 * [CustomDeleteProperty] in JavaScriptCore: You can write custom bindings for the case where a property of XXX is deleted. 1397 Specifically, you can write custom JSXXX::deleteProperty(...) in WebCore/bindings/js/JSXXXCustom.cpp: 1107 * `[CustomDeleteProperty]` in JavaScriptCore: You can write custom bindings for the case where a property of XXX is deleted. 1108 Specifically, you can write custom `JSXXX::deleteProperty(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1398 1109 1399 1110 {{{ … … 1404 1115 }}} 1405 1116 1406 * [CustomDeleteProperty] in V8: You can write custom bindings as V8XXX::namedPropertyDeleter(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1407 1408 {{{ 1409 v8::Handle<v8::Boolean> V8XXX::namedPropertyDeleter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 1410 { 1411 ...; 1412 } 1413 }}} 1414 1415 == [IsWorkerContext](i) == #IsWorkerContext 1416 1417 Summary: [IsWorkerContext] indicates that a given interface is a WorkerContext-related interface. 1418 1419 Usage: [IsWorkerContext] can be specified on WorkerContext-related interfaces only: 1420 {{{ 1421 interface [ 1117 == `[IsWorkerContext]`(i) == #IsWorkerContext 1118 1119 Summary: `[IsWorkerContext]` indicates that a given interface is a WorkerContext-related interface. 1120 1121 Usage: `[IsWorkerContext]` can be specified on WorkerContext-related interfaces only: 1122 {{{ 1123 [ 1422 1124 IsWorkerContext 1423 ] SharedWorkerContext { 1424 }; 1425 }}} 1426 1427 == [TransferList](p) == #TransferList 1428 1429 Summary: [TransferList] allows a SerializedScriptValue parameter used 1430 with the structured clone algorithm to specify another parameter used 1431 to pass the transfer list. 1432 1433 Usage: The possible usage is [TransferList=XXX] where XXX is another 1434 parameter in the same method signature as the SerializedScriptValue 1435 parameter on which the modifier is placed. The referenced parameter 1436 should be of type "Array" to be compatible with the Web Messaging 1437 standard. 1438 1439 When this modifier is used, the code generation automatically creates 1440 a MessagePortArray and completes the structured clone algorithm using 1441 the input data from the JavaScript caller. The resulting 1442 MessagePortArray is then passed to the implementation's method 1443 signature in place of the Array parameter referenced. 1444 1445 Example: 1446 {{{ 1447 interface Worker { 1448 void postMessage(in [TransferList=transfer] SerializedScriptValue data, in [Optional=DefaultIsUndefined] Array transfer); 1449 } 1450 }}} 1451 And in the implementation: 1452 {{{ 1453 class Worker { 1454 virtual void postMessage(PassRefPtr<SerializedScriptValue> data, const MessagePortArray& ports); 1455 } 1456 }}} 1457 1458 == [TypedArray](i), [ConstructorTemplate=TypedArray](i) == #TypedArray 1125 ] interface SharedWorkerContext { 1126 }; 1127 }}} 1128 1129 == `[TypedArray]`(i), [ConstructorTemplate=TypedArray](i) == #TypedArray 1459 1130 1460 1131 * [http://www.khronos.org/registry/typedarray/specs/latest/#7 The spec of TypedArray] … … 1463 1134 TypedArray implements ArrayBufferView. Each of the typed array types has the following constructors, properties, constants and methods. 1464 1135 1465 Usage: [TypedArray] must be specified on interfaces in conjunction with [ConstructorTemplate=TypedArray]:1136 Usage: `[TypedArray]` must be specified on interfaces in conjunction with `[ConstructorTemplate=TypedArray]`: 1466 1137 Example: 1467 1138 1468 1139 {{{ 1469 interface[1470 ConstructorTemplate=TypedArray,1471 TypedArray=int1472 ]XXX : ArrayBufferView {1473 void set(TypedArray array, optional unsigned long offset);1474 }1475 }}} 1476 1477 TypedArray=*Allows us to specify any valid typed array view type.1478 TypedArray interfaces require special bindings code, you need to use [ConstructorTemplate=TypedArray] instead of normal [Constructor].1479 1480 == [CustomCall](i) == #CustomCall1481 1482 Summary: [CustomCall] allows you to write custom bindings for call(...)of a given interface.1483 1484 Usage: [CustomCall]can be specified on interfaces:1485 {{{ 1486 interface[1140 [ 1141 ConstructorTemplate=TypedArray, 1142 TypedArray=int 1143 ] interface XXX : ArrayBufferView { 1144 void set(TypedArray array, optional unsigned long offset); 1145 } 1146 }}} 1147 1148 `TypedArray=*` Allows us to specify any valid typed array view type. 1149 TypedArray interfaces require special bindings code, you need to use `[ConstructorTemplate=TypedArray]` instead of normal `[Constructor]`. 1150 1151 == `[CustomCall]`(i) == #CustomCall 1152 1153 Summary: `[CustomCall]` allows you to write custom bindings for `call(...)` of a given interface. 1154 1155 Usage: `[CustomCall]` can be specified on interfaces: 1156 {{{ 1157 [ 1487 1158 CustomCall 1488 ] XXX {1489 }; 1490 }}} 1491 1492 If you want to write custom bindings for XXX.call(...), you can use [CustomCall].1493 1494 * JavaScriptCore: You can write custom JSXXX::getCallData(...)in WebCore/bindings/js/JSXXXCustom.cpp:1159 ] interface XXX { 1160 }; 1161 }}} 1162 1163 If you want to write custom bindings for XXX.call(...), you can use `[CustomCall]`. 1164 1165 * JavaScriptCore: You can write custom `JSXXX::getCallData(...)` in WebCore/bindings/js/JSXXXCustom.cpp: 1495 1166 1496 1167 {{{ … … 1500 1171 } 1501 1172 }}} 1502 * V8: You can write custom V8XXX::callAsFunctionCallback(...) in WebCore/bindings/v8/custom/V8XXXCustom.cpp: 1503 1504 {{{ 1505 v8::Handle<v8::Value> V8XXX::callAsFunctionCallback(const v8::Arguments& args) 1506 { 1507 ...; 1508 } 1509 }}} 1510 1511 == [JSCustomToNativeObject](i), [JSCustomFinalize](i), [JSCustomIsReachable](i), [JSCustomMarkFunction](i), [JSCustomNamedGetterOnPrototype](i), [JSCustomPushEventHandlerScope](i), [JSCustomDefineOwnProperty](i), [JSCustomDefineOwnPropertyOnPrototype](i), [JSCustomGetOwnPropertySlotAndDescriptor](i) == #JSCustomToNativeObject 1173 1174 == `[JSCustomToNativeObject]`(i), `[JSCustomFinalize]`(i), `[CustomIsReachable]`(i), `[JSCustomMarkFunction]`(i), `[JSCustomNamedGetterOnPrototype]`(i), `[JSCustomPushEventHandlerScope]`(i), `[JSCustomDefineOwnProperty]`(i), `[JSCustomDefineOwnPropertyOnPrototype]`(i), `[JSCustomGetOwnPropertySlotAndDescriptor]`(i) == #JSCustomToNativeObject 1512 1175 1513 1176 Summary: They allow you to write custom bindings for the JavaScriptCore-specific code that would be generated automatically by default. … … 1515 1178 Usage: They can be specified on interfaces: 1516 1179 {{{ 1517 interface[1180 [ 1518 1181 JSCustomToNativeObject, 1519 1182 JSCustomFinalize, 1520 JSCustomIsReachable,1183 CustomIsReachable, 1521 1184 JSCustomMarkFunction, 1522 1185 JSCustomNamedGetterOnPrototype, … … 1525 1188 JSCustomDefineOwnPropertyOnPrototype, 1526 1189 JSCustomGetOwnPropertySlotAndDescriptor 1527 ] XXX {1190 ] interface XXX { 1528 1191 }; 1529 1192 }}} … … 1532 1195 Refer to use cases in WebCore/bindings/js/JSXXXCustom.cpp for more details. 1533 1196 1534 * [JSCustomToNativeObject]: You can write custom toXXX(...):1197 * `[JSCustomToNativeObject]`: You can write custom `toXXX(...)`: 1535 1198 1536 1199 {{{ … … 1540 1203 } 1541 1204 }}} 1542 * [JSCustomFinalize]: You can write custom JSXXXOwner::finalize(...):1205 * `[JSCustomFinalize]`: You can write custom `JSXXXOwner::finalize(...)`: 1543 1206 1544 1207 {{{ … … 1548 1211 } 1549 1212 }}} 1550 * [JSCustomIsReachable]: You can write custom JSXXXOwner::isReachableFromOpaqueRoots(...):1213 * `[CustomIsReachable]`: You can write custom `JSXXXOwner::isReachableFromOpaqueRoots(...)`: 1551 1214 1552 1215 {{{ … … 1556 1219 } 1557 1220 }}} 1558 * [JSCustomMarkFunction]: You can write custom JSXXX::visitChildren(...):1221 * `[JSCustomMarkFunction]`: You can write custom `JSXXX::visitChildren(...)`: 1559 1222 1560 1223 {{{ … … 1564 1227 } 1565 1228 }}} 1566 * [JSCustomNamedGetterOnPrototype]: You can write custom JSXXXPrototype::putDelegate(...):1229 * `[JSCustomNamedGetterOnPrototype]`: You can write custom `JSXXXPrototype::putDelegate(...)`: 1567 1230 1568 1231 {{{ … … 1572 1235 } 1573 1236 }}} 1574 * [JSCustomPushEventHandlerScope]: You can write custom JSXXX::pushEventHandlerScope(...):1237 * `[JSCustomPushEventHandlerScope]`: You can write custom `JSXXX::pushEventHandlerScope(...)`: 1575 1238 1576 1239 {{{ … … 1580 1243 } 1581 1244 }}} 1582 * [JSCustomDefineOwnProperty]: You can write custom JSXXX::defineOwnProperty(...):1245 * `[JSCustomDefineOwnProperty]`: You can write custom `JSXXX::defineOwnProperty(...)`: 1583 1246 1584 1247 {{{ … … 1588 1251 } 1589 1252 }}} 1590 * [JSCustomDefineOwnPropertyOnPrototype]: You can write custom JSXXXPrototype::defineOwnProperty(...):1253 * `[JSCustomDefineOwnPropertyOnPrototype]`: You can write custom `JSXXXPrototype::defineOwnProperty(...)`: 1591 1254 1592 1255 {{{ … … 1596 1259 } 1597 1260 }}} 1598 * [JSCustomGetOwnPropertySlotAndDescriptor]: You can write custom JSXXX::getOwnPropertySlotDelegate(...) and JSXXX::getOwnPropertyDescriptorDelegate(...):1261 * `[JSCustomGetOwnPropertySlotAndDescriptor]`: You can write custom `JSXXX::getOwnPropertySlotDelegate(...)` and `JSXXX::getOwnPropertyDescriptorDelegate(...)`: 1599 1262 1600 1263 {{{ … … 1610 1273 }}} 1611 1274 1612 == [JSGenerateToJSObject](i), [JSGenerateToNativeObject](i) == #JSGenerateToJSObject1275 == `[JSGenerateToJSObject]`(i), `[JSGenerateToNativeObject]`(i) == #JSGenerateToJSObject 1613 1276 1614 1277 Summary: They force JavaScriptCore bindings to generate JavaScriptCore-specific methods, even if a given interface has a parent interface. … … 1616 1279 Usage: They can be specified on interfaces that do not have a parent interface: 1617 1280 {{{ 1618 interface[1281 [ 1619 1282 JSGenerateToJSObject, 1620 1283 JSGenerateToNativeObject 1621 ] XXX {1622 }; 1623 }}} 1624 1625 toJS(...), isReachableFromOpaqueRoots(...) or toXXX()is not generated if XXX has a parent interface.1284 ] interface XXX { 1285 }; 1286 }}} 1287 1288 `toJS(...)`, `isReachableFromOpaqueRoots(...)` or `toXXX()` is not generated if XXX has a parent interface. 1626 1289 If you want to generate it even if XXX does not have a parent interface, you can specify 1627 [JSGenerateToJSObject] or [JSGenerateToNativeObject], respectively.1628 1629 == [JSGenerateIsReachable](i) == #JSGenerateIsReachable1290 `[JSGenerateToJSObject]` or `[JSGenerateToNativeObject]`, respectively. 1291 1292 == `[GenerateIsReachable]`(i) == #GenerateIsReachable 1630 1293 1631 1294 Summary: This generates code that determines if a wrapper is reachable. 1632 1295 1633 Usage: The JSGenerateIsReachable can be specified on the interface. This attribute is ignored if CustomIsReachableis present.1634 1635 {{{ 1636 interface[1637 JSGenerateIsReachable=ImplBaseRoot1638 ] XXX {1639 }; 1640 }}} 1641 1642 The code generates a function called XXX::isReachableFromOpaqueRootswhich returns a boolean if the wrapper is reachable.1296 Usage: The `GenerateIsReachable` can be specified on the interface. This attribute is ignored if `CustomIsReachable` is present. 1297 1298 {{{ 1299 [ 1300 GenerateIsReachable=ImplBaseRoot 1301 ] interface XXX { 1302 }; 1303 }}} 1304 1305 The code generates a function called `XXX::isReachableFromOpaqueRoots` which returns a boolean if the wrapper is reachable. 1643 1306 1644 1307 The currently valid values are: … … 1654 1317 The value of these represents the functions to call to get the object that determines whether the object is reachable or not. See CodeGeneratorJS.pm for more details. The values that end with Root calls WebCore::root to get the root. If the value is left out then WebCore::root is called on impl(). 1655 1318 1656 == [V8GenerateIsReachable](i), V8CustomIsReachable(i) == #V8GenerateIsReachable 1657 1658 Summary: This generates code that allows you to set up implicit references between wrappers which can be used to keep wrappers alive during GC. 1659 1660 Usage: The V8GenerateIsReachable can be specified on the interface. This attribute is ignored if CustomIsReachable is present. 1661 1662 {{{ 1663 interface [ 1664 V8GenerateIsReachable=ImplBaseRoot 1665 ] XXX { 1666 }; 1667 }}} 1668 1669 The code generates a function called XXX::visitDOMWrapper which is called by V8GCController before GC. The function adds implicit references to the wrapper which keeps it alive. 1670 1671 The currently valid values are: 1672 1673 |ImplElementRoot|ImplOwnerRoot|ImplOwnerNodeRoot|ImplBaseRoot 1674 1675 - ImplOwnerRoot 1676 - ImplOwnerNodeRoot 1677 - ImplElementRoot 1678 - ImplBaseRoot 1679 1680 The value of these represents the functions to call to get the object that determines whether the object is reachable or not. See CodeGeneratorV8.pm for more details. 1681 1682 == [V8CustomIsReachable(i) == #V8CustomIsReachable 1683 1684 Summary: Allows you to write custom code for visitDOMWrapper. 1685 1686 Usage: 1687 1688 {{{ 1689 interface [ 1690 V8CustomIsReachable 1691 ] XXX { 1692 }; 1693 }}} 1694 1695 And then in V8XXXCustom.cpp: 1696 1697 {{{ 1698 void V8XXX::visitDOMWrapper(DOMDataStore* store, void* object, v8::Persistent<v8::Object> wrapper) 1699 { 1700 ... 1701 } 1702 }}} 1703 == [GenerateIsReachable](i) == #GenerateIsReachable 1704 1705 Summary: This is the shared version of [JSGenerateIsReachable] and V8GenerateIsReachable. The accepted values are the intersection of those two. 1706 1707 - ImplElementRoot 1708 - ImplBaseRoot 1709 1710 == [JSCustomHeader](i) == #JSCustomHeader 1711 1712 Summary: [JSCustomHeader] allows you to write a custom header for a given interface. 1713 1714 Usage: [JSCustomHeader] can be specified on interfaces: 1715 {{{ 1716 interface [ 1717 JSCustomHeader 1718 ] XXX { 1719 }; 1720 }}} 1721 1722 By default, JSXXX.h and JSXXX.cpp are generated automatically. 1723 By specifying [Custom*], you can write custom bindings in WebCore/bindings/js/JSXXXCustom.cpp. 1724 In addition, by specifying [JSCustomHeader], you can write custom header in WebCore/bindings/js/JSXXXCustom.h, which will be included by JSXXX.h. 1725 1726 == [JSLegacyParent](i) == #JSLegacyParent 1727 1728 Summary: [JSLegacyParent] explicitly controls the parent interface of a given interface. 1729 1730 Usage: [JSLegacyParent] can be specified on interfaces that do not have a parent interface: 1731 {{{ 1732 interface [ 1319 == `[JSLegacyParent]`(i) == #JSLegacyParent 1320 1321 Summary: `[JSLegacyParent]` explicitly controls the parent interface of a given interface. 1322 1323 Usage: `[JSLegacyParent]` can be specified on interfaces that do not have a parent interface: 1324 {{{ 1325 [ 1733 1326 JSLegacyParent=JSDOMWindowBase 1734 ] DOMWindow {1735 }; 1736 }}} 1737 1738 Even if a given interface does not have a parent interface, you can specify a parent interface using [JSLegacyParent].1739 1740 == [JSInlineGetOwnPropertySlot](i) == #JSInlineGetOwnPropertySlot1741 1742 Summary: For performance, [JSInlineGetOwnPropertySlot] makes getOwnPropertySlot(...) and getOwnPropertyDescriptor(...)an inline method.1743 1744 Usage: [JSInlineGetOwnPropertySlot]can be specified on interfaces:1745 {{{ 1746 interface[1327 ] interface DOMWindow { 1328 }; 1329 }}} 1330 1331 Even if a given interface does not have a parent interface, you can specify a parent interface using `[JSLegacyParent]`. 1332 1333 == `[JSInlineGetOwnPropertySlot]`(i) == #JSInlineGetOwnPropertySlot 1334 1335 Summary: For performance, `[JSInlineGetOwnPropertySlot]` makes `getOwnPropertySlot(...)` and `getOwnPropertyDescriptor(...)` an inline method. 1336 1337 Usage: `[JSInlineGetOwnPropertySlot]` can be specified on interfaces: 1338 {{{ 1339 [ 1747 1340 JSInlineGetOwnPropertySlot 1748 ] XXX {1749 }; 1750 }}} 1751 1752 == [JSNoStaticTables](i) == #JSNoStaticTables1341 ] interface XXX { 1342 }; 1343 }}} 1344 1345 == `[JSNoStaticTables]`(i) == #JSNoStaticTables 1753 1346 1754 1347 Summary: By default, there is only a single static prototype table for the interface. This flag turns off creation of the static table, and each user gets its own table. … … 1756 1349 Sharing a single static prototype table only works when a class is guaranteed to be accessed from a single heap, because the lookup code expects the key (attribute name) to have the same address across all instances of the object. For interfaces that are exposed to Workers, a single static table won't work because a given string used to look up a property on the object will lie at a different address in each heap. 1757 1350 1758 Usage: [JSNoStaticTables]can be specified on interfaces:1759 {{{ 1760 interface[1351 Usage: `[JSNoStaticTables]` can be specified on interfaces: 1352 {{{ 1353 [ 1761 1354 JSNoStaticTables 1762 ] XXX {1355 ] interface XXX { 1763 1356 }; 1764 1357 }}} … … 1766 1359 ADD EXPLANATIONS 1767 1360 1768 == [ObjCProtocol](i), [ObjCPolymorphic](i), [ObjCLegacyUnnamedParameters](m), [ObjCUseDefaultView](m), [ObjCImplementedAsUnsignedLongLong](a) == #ObjCProtocol1361 == `[ObjCProtocol]`(i), `[ObjCPolymorphic]`(i), `[ObjCLegacyUnnamedParameters]`(m), `[ObjCUseDefaultView]`(m), `[ObjCImplementedAsUnsignedLongLong]`(a) == #ObjCProtocol 1769 1362 1770 1363 Used by ObjC bindings only. 1771 1364 1772 == [CPPPureInterface](i) == #CPPPureInterface1365 == `[CPPPureInterface]`(i) == #CPPPureInterface 1773 1366 1774 1367 Used by CPP bindings only. 1775 1368 1776 == [CustomReturn](p) == #CustomReturn1369 == `[CustomReturn]`(p) == #CustomReturn 1777 1370 1778 1371 Used by ObjC, GObject and CPP bindings only. 1779 1372 1780 == [ArrayClass](i) == #ArrayClass1373 == `[ArrayClass]`(i) == #ArrayClass 1781 1374 1782 1375 * [http://dev.w3.org/2006/webapi/WebIDL/#ArrayClass The spec of ArrayClass] … … 1784 1377 Summary: Allows an interface to extend JavaScript arrays. 1785 1378 1786 Usage: [ArrayClass] can be specified on interfaces. An interface may not both have [ArrayClass]and extend another interface.1379 Usage: `[ArrayClass]` can be specified on interfaces. An interface may not both have `[ArrayClass]` and extend another interface. 1787 1380 1788 1381 The bindings for the interface will have the `[[Prototype]]` of the constructor prototype set to `Array.prototype` which means that the methods defined on JavaScript arrays work on the instances of this interface. 1789 1382 1790 1383 {{{ 1791 // IDL1792 interface[1793 ArrayClass,1794 IndexedGetter1795 ]NodeList {1796 Node item(inunsigned long index);1797 readonly attribute unsigned long length;1798 } 1799 1800 // JS1801 myNodeList instanceof Array // true1802 myNodeList.forEach(function(node) { console.log(node_; });1803 }}} 1804 1805 == [OmitConstructor], [Immutable], [MasqueradesAsUndefined], [CustomGetOwnPropertySlot], [ReplaceableConstructor], [ExtendsDOMGlobalObject], [IsIndex], [V8DoNotCheckSignature], [NumericIndexedGetter]== #OmitConstructor1384 // IDL 1385 [ 1386 ArrayClass, 1387 IndexedGetter 1388 ] interface NodeList { 1389 Node item(unsigned long index); 1390 readonly attribute unsigned long length; 1391 }; 1392 1393 // JS 1394 myNodeList instanceof Array // true 1395 myNodeList.forEach(function(node) { console.log(node_; }); 1396 }}} 1397 1398 == `[OmitConstructor]`, `[Immutable]`, `[MasqueradesAsUndefined]`, `[CustomGetOwnPropertySlot]`, `[ReplaceableConstructor]`, `[ExtendsDOMGlobalObject]`, `[IsIndex]`, `[NumericIndexedGetter]` == #OmitConstructor 1806 1399 1807 1400 Might be deprecated. Discussion is on-going. 1808 1401 1809 == [ImplementationNameSpace]== #ImplementationNamespace1402 == `[ImplementationNameSpace]` == #ImplementationNamespace 1810 1403 1811 1404 Summary: Specifies the namespace for the corresponding native type. … … 1813 1406 By default, the namespace is WebCore. This is presently used to mark WTF types. 1814 1407 1815 Usage: [ImplementationNamespace]can be specified on interfaces:1816 {{{ 1817 interface[1408 Usage: `[ImplementationNamespace]` can be specified on interfaces: 1409 {{{ 1410 [ 1818 1411 ImplementationNamespace=WTF 1819 ] ArrayBuffer {1820 }; 1821 }}} 1822 1823 == [V8SkipVTableValidation], [ImplementationLacksVTable] == #V8SkipVTableValidation1824 1825 Summary: Specifies that a type can not be checked as part of the V8Bindings Integrity option.1826 1827 V8 Bindings Integrity tries to ensure that free/corrupted objects are not wrapped by V8, thereby reducing their exploitability. In order for that to be the case, the implementation must have a distinct VTable pointer in its first word.1828 1829 Usage: [V8SkipVTableValidation] and [ImplementationLacksVTable]can be specified on interfaces.1830 1831 {{{ 1832 interface[1833 V8SkipVTableValidation1834 ] XXX {1835 }; 1836 }}} 1837 1838 {{{ 1839 interface[1412 ] interface ArrayBuffer { 1413 }; 1414 }}} 1415 1416 == `[SkipVTableValidation]`, `[ImplementationLacksVTable]` == #SkipVTableValidation 1417 1418 Summary: Specifies that a type can not be checked as part of the Bindings Integrity option. 1419 1420 Bindings Integrity tries to ensure that free/corrupted objects are not wrapped by JSC, thereby reducing their exploitability. In order for that to be the case, the implementation must have a distinct VTable pointer in its first word. 1421 1422 Usage: `[SkipVTableValidation]` and `[ImplementationLacksVTable]` can be specified on interfaces. 1423 1424 {{{ 1425 [ 1426 SkipVTableValidation 1427 ] interface XXX { 1428 }; 1429 }}} 1430 1431 {{{ 1432 [ 1840 1433 ImplementationLacksVTable 1841 ] XXX { 1842 }; 1843 }}} 1434 ] interface XXX { 1435 }; 1436 }}} 1437 1438 == `[NoInterfaceObject]`(i) == #NoInterfaceObject 1439 1440 Standard: [http://dev.w3.org/2006/webapi/WebIDL/#NoInterfaceObject The spec of NoInterfaceObject] 1441 1442 Summary: If the `[NoInterfaceObject]` extended attribute appears on an interface, it indicates that an interface object will not exist for the interface in the ECMAScript binding. 1443 1444 Note that for every interface that: 1445 * is a callback interface that has constants declared on it, or 1446 * is a non-callback interface that is not declared with the `[NoInterfaceObject]` extended attribute, 1447 a corresponding property is added on the global Window object by the bindings generator. 1448 1449 Usage: `[NoInterfaceObject]` can be specified on interfaces. 1450 1451 {{{ 1452 [ 1453 NoInterfaceObject 1454 ] interface XXX { 1455 ... 1456 }; 1457 }}}