671 | | == `[ConstructorTemplate]`(i), `[InitializedByEventConstructor]`(a) == #ConstructorTemplate |
672 | | |
673 | | Summary: They are used for Event constructors. |
674 | | |
675 | | Usage: The possible usage is `[ConstructorTemplate=Event]`. |
676 | | `[ConstructorTemplate=Event]` can be specified on Event interfaces only. |
677 | | `[InitializedByEventConstructor]` can be specified on attributes in the Event interfaces: |
678 | | {{{ |
679 | | [ |
680 | | ConstructorTemplate=Event |
681 | | ] interface FooEvent { |
682 | | attribute DOMString str1; |
683 | | [InitializedByEventConstructor] attribute DOMString str2; |
684 | | }; |
685 | | }}} |
686 | | |
687 | | Since constructors for Event interfaces require special bindings, |
688 | | you need to use `[ConstructorTemplate=Event]` instead of normal `[Constructor]`. |
689 | | |
690 | | If you specify `[ConstructorTemplate=Event]` on FooEvent, |
691 | | JavaScript can create a DOM object of FooEvent in the following code: |
692 | | {{{ |
693 | | var e = new FooEvent("type", { bubbles: true, cancelable: true }); |
694 | | }}} |
695 | | Then FooEvent::create(...) is called in WebCore. |
696 | | Specifically, WebCore needs to implement the following method as a constructor callback: |
697 | | {{{ |
698 | | PassRefPtr<FooEvent> FooEvent::create(const AtomicString& type, const FooEventInit& initializer) |
699 | | { |
700 | | ...; |
701 | | } |
702 | | }}} |
703 | | |
704 | | `[InitializedByEventConstructor]` should be specified on all the attributes |
705 | | that needs to be initialized by the constructor. |
706 | | Which attributes need initialization is defined in the spec of each Event interface. |
707 | | For example, look at [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event the spec of Event]. |
708 | | The EventInit dictionary has bubbles and cancelable, and thus bubbles and cancelable are the only attributes |
709 | | that need to be initialized by the Event constructor. |
710 | | In other words, in case of Event, you should specify `[InitializedByEventConstructor]` on bubbles and cancelable. |
711 | | |
1021 | | |
1022 | | == `[TypedArray]`(i), [ConstructorTemplate=TypedArray](i) == #TypedArray |
1023 | | |
1024 | | * [http://www.khronos.org/registry/typedarray/specs/latest/#7 The spec of TypedArray] |
1025 | | |
1026 | | Summary: The typed array view types represent a view of an ArrayBuffer that allows for indexing and manipulation. |
1027 | | TypedArray implements ArrayBufferView. Each of the typed array types has the following constructors, properties, constants and methods. |
1028 | | |
1029 | | Usage: `[TypedArray]` must be specified on interfaces in conjunction with `[ConstructorTemplate=TypedArray]`: |
1030 | | Example: |
1031 | | |
1032 | | {{{ |
1033 | | [ |
1034 | | ConstructorTemplate=TypedArray, |
1035 | | TypedArray=int |
1036 | | ] interface XXX : ArrayBufferView { |
1037 | | void set(TypedArray array, optional unsigned long offset); |
1038 | | } |
1039 | | }}} |
1040 | | |
1041 | | `TypedArray=*` Allows us to specify any valid typed array view type. |
1042 | | TypedArray interfaces require special bindings code, you need to use `[ConstructorTemplate=TypedArray]` instead of normal `[Constructor]`. |