| 30 | |
| 31 | * [http://dev.w3.org/2006/webapi/WebIDL/#TreatNullAs The spec of [TreatNullAs]] (Note: The WebKit IDL explained below behaves differently from the spec) |
| 32 | * [http://dev.w3.org/2006/webapi/WebIDL/#TreatUndefinedAs The spec of [TreatUndefinedAs]] (Note: The WebKit IDL explained below behaves differently from the spec) |
| 33 | |
| 34 | The possible usage is [TreatNullAs=NullString] or [TreatUndefinedAs=NullString]. |
| 35 | They can be specified on attributes or parameters of type DOMString only, like this: |
| 36 | |
| 37 | {{{ |
| 38 | attribute [TreatNullAs=NullString] DOMString str; |
| 39 | void operation(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString str); |
| 40 | }}} |
| 41 | |
| 42 | [TreatNullAs=NullString] indicates that if JavaScript null is passed to the attribute/parameter, |
| 43 | then it is converted to the null string in WebKit, for which String::IsEmpty() and String::IsNull() will return true. |
| 44 | Without [TreatNullAs=NullString], JavaScript null is converted to a string "null" in WebKit. |
| 45 | |
| 46 | [TreatNullAs=NullString] corresponds to [TreatNullAs=EmptyString] in the Web IDL spec. |
| 47 | Unless the spec does not specify [TreatNullAs=EmptyString], you should not specify [TreatNullAs=NullString] in WebKit. |
| 48 | |
| 49 | [TreatUndefinedAs=NullString] indicates that if JavaScript undefined is passed to the attribute/parameter, |
| 50 | then it is converted to the null string in WebKit, for which IsEmpty() and IsNull() will return true. |
| 51 | Without [TreatUndefinedAs=NullString], JavaScript undefined is converted to a string "undefined" in WebKit. |
| 52 | |
| 53 | [TreatUndefinedAs=NullString] corresponds to [TreatUndefinedAs=EmptyString] in the Web IDL spec. |
| 54 | Unless the spec does not specify [TreatUndefinedAs=EmptyString], you should not specify [TreatUndefinedAs=NullString] in WebKit. |
| 55 | |
| 56 | Note: For now the sole usage of [TreatUndefinedAs=NullString] is not allowed in WebKit. |
| 57 | [TreatUndefinedAs=NullString] must be used with [TreatNullAs=NullString], i.e. [TreatNullAs=NullString, TreatUndefinedAs=NullString]. |
| 58 | |