262 | | Without [TreatNullAs=NullString], a JavaScript null is converted to a WebKit string "null". |
263 | | |
264 | | [TreatNullAs=NullString] in WebKit corresponds to [TreatNullAs=EmptyString] in the Web IDL spec. |
265 | | Unless the spec specifies [TreatNullAs=EmptyString], you should not specify [TreatNullAs=NullString] in WebKit. |
266 | | |
267 | | [TreatUndefinedAs=NullString] indicates that if a JavaScript undefined is passed to the attribute or parameter, |
| 262 | Without `[TreatNullAs=NullString]`, a JavaScript null is converted to a WebKit string "null". |
| 263 | |
| 264 | `[TreatNullAs=NullString]` in WebKit corresponds to `[TreatNullAs=EmptyString]` in the Web IDL spec. |
| 265 | Unless the spec specifies `[TreatNullAs=EmptyString]`, you should not specify `[TreatNullAs=NullString]` in WebKit. |
| 266 | |
| 267 | `[TreatUndefinedAs=NullString]` indicates that if a JavaScript undefined is passed to the attribute or parameter, |
269 | | Without [TreatUndefinedAs=NullString], a JavaScript undefined is converted to a WebKit string "undefined". |
270 | | |
271 | | [TreatUndefinedAs=NullString] in WebKit corresponds to [TreatUndefinedAs=EmptyString] in the Web IDL spec. |
272 | | Unless the spec specifies [TreatUndefinedAs=EmptyString], you should not specify [TreatUndefinedAs=NullString] in WebKit. |
273 | | |
274 | | Note: For now the sole usage of [TreatUndefinedAs=NullString] is not allowed. |
275 | | [TreatUndefinedAs=NullString] must be used with [TreatNullAs=NullString], i.e. [TreatNullAs=NullString, TreatUndefinedAs=NullString]. |
276 | | |
277 | | == [TreatReturnedNullStringAs](m,a) == #TreatReturnedNullStringAs |
278 | | |
279 | | Summary: [TreatReturnedNullStringAs] controls the behavior when a WebKit null string is returned from the WebCore implementation. |
280 | | |
281 | | Usage: The possible usage is [TreatReturnedNullStringAs=Null], [TreatReturnedNullStringAs=Undefined] or [TreatReturnedNullStringAs=False]. |
| 269 | Without `[TreatUndefinedAs=NullString]`, a JavaScript undefined is converted to a WebKit string "undefined". |
| 270 | |
| 271 | `[TreatUndefinedAs=NullString]` in WebKit corresponds to `[TreatUndefinedAs=EmptyString]` in the Web IDL spec. |
| 272 | Unless the spec specifies `[TreatUndefinedAs=EmptyString]`, you should not specify `[TreatUndefinedAs=NullString]` in WebKit. |
| 273 | |
| 274 | Note: For now the sole usage of `[TreatUndefinedAs=NullString]` is not allowed. |
| 275 | `[TreatUndefinedAs=NullString]` must be used with `[TreatNullAs=NullString]`, i.e. `[TreatNullAs=NullString, TreatUndefinedAs=NullString]`. |
| 276 | |
| 277 | == `[TreatReturnedNullStringAs]`(m,a) == #TreatReturnedNullStringAs |
| 278 | |
| 279 | Summary: `[TreatReturnedNullStringAs]` controls the behavior when a WebKit null string is returned from the WebCore implementation. |
| 280 | |
| 281 | Usage: The possible usage is `[TreatReturnedNullStringAs=Null]`, `[TreatReturnedNullStringAs=Undefined]` or `[TreatReturnedNullStringAs=False]`. |
288 | | * [TreatReturnedNullStringAs=Null] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript null. |
289 | | * [TreatReturnedNullStringAs=Undefined] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript undefined. |
290 | | * [TreatReturnedNullStringAs=False] indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript false. |
291 | | |
292 | | Without [TreatReturnedNullStringAs=...], if the returned DOMString is a WebKit null string, then the returned value is treated as a JavaScript empty string ''. |
293 | | |
294 | | Note that what should be specified on [TreatReturnedNullStringAs=...] depends on the spec of each attribute or method. |
295 | | |
296 | | == [Default](p) == #Default |
297 | | |
298 | | Summary: [Default] allows specifying the default values for optional parameters to simplify WebCore implementations which otherwise require overloads. |
299 | | |
300 | | Standard: In Web IDL, [Default=NullString] is written as "type identifier = default", e.g. optional DOMString? str = null |
301 | | |
302 | | 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: |
| 288 | * `[TreatReturnedNullStringAs=Null]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript null. |
| 289 | * `[TreatReturnedNullStringAs=Undefined]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript undefined. |
| 290 | * `[TreatReturnedNullStringAs=False]` indicates that if the returned DOMString is a WebKit null string, the returned value is treated as a JavaScript false. |
| 291 | |
| 292 | Without `[TreatReturnedNullStringAs=...]`, if the returned DOMString is a WebKit null string, then the returned value is treated as a JavaScript empty string ''. |
| 293 | |
| 294 | Note that what should be specified on `[TreatReturnedNullStringAs=...]` depends on the spec of each attribute or method. |
| 295 | |
| 296 | == `[Default]`(p) == #Default |
| 297 | |
| 298 | Summary: `[Default]` allows specifying the default values for optional parameters to simplify WebCore implementations which otherwise require overloads. |
| 299 | |
| 300 | Standard: In Web IDL, `[Default=NullString]` is written as `"type identifier = default"`, e.g. `optional DOMString? str = null` |
| 301 | |
| 302 | 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: |
314 | | The difference between optional and [Default=Undefined] optional is whether the WebCore implementation has overloaded methods or not, as explained below. |
315 | | |
316 | | 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. |
317 | | |
318 | | 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). |
319 | | |
320 | | 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. |
321 | | |
322 | | == [Clamp](a,p) == #Clamp |
| 314 | The difference between optional and `[Default=Undefined]` optional is whether the WebCore implementation has overloaded methods or not, as explained below. |
| 315 | |
| 316 | 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. |
| 317 | |
| 318 | 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)`. |
| 319 | |
| 320 | 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. |
| 321 | |
| 322 | == `[Clamp]`(a,p) == #Clamp |