2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "Clipboard.h"
35 #include "ClipboardEvent.h"
36 #include "CustomEvent.h"
38 #include "V8BeforeLoadEvent.h"
39 #include "V8Binding.h"
40 #include "V8Clipboard.h"
41 #include "V8CloseEvent.h"
42 #include "V8CompositionEvent.h"
43 #include "V8CustomEvent.h"
44 #include "V8DeviceMotionEvent.h"
45 #include "V8DeviceOrientationEvent.h"
46 #include "V8ErrorEvent.h"
47 #include "V8HashChangeEvent.h"
48 #include "V8IDBVersionChangeEvent.h"
49 #include "V8KeyboardEvent.h"
50 #include "V8MessageEvent.h"
51 #include "V8MouseEvent.h"
52 #include "V8MutationEvent.h"
53 #include "V8OverflowEvent.h"
54 #include "V8PageTransitionEvent.h"
55 #include "V8PopStateEvent.h"
56 #include "V8ProgressEvent.h"
58 #include "V8SpeechInputEvent.h"
59 #include "V8StorageEvent.h"
60 #include "V8TextEvent.h"
61 #include "V8TouchEvent.h"
62 #include "V8UIEvent.h"
63 #include "V8WebKitAnimationEvent.h"
64 #include "V8WebKitTransitionEvent.h"
65 #include "V8WheelEvent.h"
66 #include "V8XMLHttpRequestProgressEvent.h"
69 #include "V8SVGZoomEvent.h"
73 #include "V8AudioProcessingEvent.h"
74 #include "V8OfflineAudioCompletionEvent.h"
77 #if ENABLE(MEDIA_STREAM)
78 #include "V8MediaStreamEvent.h"
83 void V8Event::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
85 Event* event = V8Event::toNative(info.Holder());
86 event->setDefaultPrevented(!value->BooleanValue());
89 v8::Handle<v8::Value> V8Event::dataTransferAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
91 Event* event = V8Event::toNative(info.Holder());
93 if (event->isDragEvent())
94 return toV8(static_cast<MouseEvent*>(event)->clipboard());
96 return v8::Undefined();
99 v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
101 Event* event = V8Event::toNative(info.Holder());
103 if (event->isClipboardEvent())
104 return toV8(static_cast<ClipboardEvent*>(event)->clipboard());
106 return v8::Undefined();
109 v8::Handle<v8::Value> toV8(Event* impl)
113 if (impl->isUIEvent()) {
114 if (impl->isKeyboardEvent())
115 return toV8(static_cast<KeyboardEvent*>(impl));
116 if (impl->isTextEvent())
117 return toV8(static_cast<TextEvent*>(impl));
118 if (impl->isMouseEvent())
119 return toV8(static_cast<MouseEvent*>(impl));
120 if (impl->isWheelEvent())
121 return toV8(static_cast<WheelEvent*>(impl));
123 if (impl->isSVGZoomEvent())
124 return toV8(static_cast<SVGZoomEvent*>(impl));
126 if (impl->isCompositionEvent())
127 return toV8(static_cast<CompositionEvent*>(impl));
128 #if ENABLE(TOUCH_EVENTS)
129 if (impl->isTouchEvent())
130 return toV8(static_cast<TouchEvent*>(impl));
132 return toV8(static_cast<UIEvent*>(impl));
134 if (impl->isHashChangeEvent())
135 return toV8(static_cast<HashChangeEvent*>(impl));
136 if (impl->isMutationEvent())
137 return toV8(static_cast<MutationEvent*>(impl));
138 if (impl->isOverflowEvent())
139 return toV8(static_cast<OverflowEvent*>(impl));
140 if (impl->isMessageEvent())
141 return toV8(static_cast<MessageEvent*>(impl));
142 if (impl->isPageTransitionEvent())
143 return toV8(static_cast<PageTransitionEvent*>(impl));
144 if (impl->isPopStateEvent())
145 return toV8(static_cast<PopStateEvent*>(impl));
146 if (impl->isProgressEvent()) {
147 if (impl->isXMLHttpRequestProgressEvent())
148 return toV8(static_cast<XMLHttpRequestProgressEvent*>(impl));
149 return toV8(static_cast<ProgressEvent*>(impl));
151 if (impl->isWebKitAnimationEvent())
152 return toV8(static_cast<WebKitAnimationEvent*>(impl));
153 if (impl->isWebKitTransitionEvent())
154 return toV8(static_cast<WebKitTransitionEvent*>(impl));
156 if (impl->isErrorEvent())
157 return toV8(static_cast<ErrorEvent*>(impl));
159 #if ENABLE(DOM_STORAGE)
160 if (impl->isStorageEvent())
161 return toV8(static_cast<StorageEvent*>(impl));
163 #if ENABLE(INDEXED_DATABASE)
164 if (impl->isIDBVersionChangeEvent())
165 return toV8(static_cast<IDBVersionChangeEvent*>(impl));
167 if (impl->isBeforeLoadEvent())
168 return toV8(static_cast<BeforeLoadEvent*>(impl));
169 #if ENABLE(DEVICE_ORIENTATION)
170 if (impl->isDeviceMotionEvent())
171 return toV8(static_cast<DeviceMotionEvent*>(impl));
172 if (impl->isDeviceOrientationEvent())
173 return toV8(static_cast<DeviceOrientationEvent*>(impl));
175 #if ENABLE(WEB_AUDIO)
176 if (impl->isAudioProcessingEvent())
177 return toV8(static_cast<AudioProcessingEvent*>(impl));
178 if (impl->isOfflineAudioCompletionEvent())
179 return toV8(static_cast<OfflineAudioCompletionEvent*>(impl));
181 #if ENABLE(INPUT_SPEECH)
182 if (impl->isSpeechInputEvent())
183 return toV8(static_cast<SpeechInputEvent*>(impl));
185 if (impl->isCustomEvent())
186 return toV8(static_cast<CustomEvent*>(impl));
187 #if ENABLE(WEB_SOCKETS)
188 if (impl->isCloseEvent())
189 return toV8(static_cast<CloseEvent*>(impl));
191 #if ENABLE(MEDIA_STREAM)
192 if (impl->isMediaStreamEvent())
193 return toV8(static_cast<MediaStreamEvent*>(impl));
195 return V8Event::wrap(impl);
197 } // namespace WebCore