|
1 /* |
|
2 * Copyright (C) 2010 Google Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions are |
|
6 * met: |
|
7 * |
|
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 |
|
13 * distribution. |
|
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. |
|
17 * |
|
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. |
|
29 */ |
|
30 |
|
31 #include "config.h" |
|
32 #include "WebEvent.h" |
|
33 |
|
34 #include "Event.h" |
|
35 #include "Node.h" |
|
36 #include <wtf/PassRefPtr.h> |
|
37 |
|
38 namespace WebKit { |
|
39 |
|
40 class WebEventPrivate : public WebCore::Event { |
|
41 }; |
|
42 |
|
43 void WebEvent::reset() |
|
44 { |
|
45 assign(0); |
|
46 } |
|
47 |
|
48 void WebEvent::assign(const WebEvent& other) |
|
49 { |
|
50 WebEventPrivate* p = const_cast<WebEventPrivate*>(other.m_private); |
|
51 if (p) |
|
52 p->ref(); |
|
53 assign(p); |
|
54 } |
|
55 |
|
56 void WebEvent::assign(WebEventPrivate* p) |
|
57 { |
|
58 // p is already ref'd for us by the caller |
|
59 if (m_private) |
|
60 m_private->deref(); |
|
61 m_private = p; |
|
62 } |
|
63 |
|
64 WebEvent::WebEvent(const WTF::PassRefPtr<WebCore::Event>& event) |
|
65 : m_private(static_cast<WebEventPrivate*>(event.releaseRef())) |
|
66 { |
|
67 } |
|
68 |
|
69 WebString WebEvent::type() const |
|
70 { |
|
71 ASSERT(m_private); |
|
72 return m_private->type(); |
|
73 } |
|
74 |
|
75 WebNode WebEvent::target() const |
|
76 { |
|
77 ASSERT(m_private); |
|
78 return WebNode(m_private->target()->toNode()); |
|
79 } |
|
80 |
|
81 WebNode WebEvent::currentTarget() const |
|
82 { |
|
83 ASSERT(m_private); |
|
84 return WebNode(m_private->currentTarget()->toNode()); |
|
85 } |
|
86 |
|
87 WebEvent::PhaseType WebEvent::eventPhase() const |
|
88 { |
|
89 ASSERT(m_private); |
|
90 return static_cast<WebEvent::PhaseType>(m_private->eventPhase()); |
|
91 } |
|
92 |
|
93 bool WebEvent::bubbles() const |
|
94 { |
|
95 ASSERT(m_private); |
|
96 return m_private->bubbles(); |
|
97 } |
|
98 |
|
99 bool WebEvent::cancelable() const |
|
100 { |
|
101 ASSERT(m_private); |
|
102 return m_private->cancelable(); |
|
103 } |
|
104 |
|
105 bool WebEvent::isUIEvent() const |
|
106 { |
|
107 ASSERT(m_private); |
|
108 return m_private->isUIEvent(); |
|
109 } |
|
110 |
|
111 bool WebEvent::isMouseEvent() const |
|
112 { |
|
113 ASSERT(m_private); |
|
114 return m_private->isMouseEvent(); |
|
115 } |
|
116 |
|
117 bool WebEvent::isMutationEvent() const |
|
118 { |
|
119 ASSERT(m_private); |
|
120 return m_private->isMutationEvent(); |
|
121 } |
|
122 |
|
123 bool WebEvent::isKeyboardEvent() const |
|
124 { |
|
125 ASSERT(m_private); |
|
126 return m_private->isKeyboardEvent(); |
|
127 } |
|
128 |
|
129 bool WebEvent::isTextEvent() const |
|
130 { |
|
131 ASSERT(m_private); |
|
132 return m_private->isTextEvent(); |
|
133 } |
|
134 |
|
135 bool WebEvent::isCompositionEvent() const |
|
136 { |
|
137 ASSERT(m_private); |
|
138 return m_private->isCompositionEvent(); |
|
139 } |
|
140 |
|
141 bool WebEvent::isDragEvent() const |
|
142 { |
|
143 ASSERT(m_private); |
|
144 return m_private->isDragEvent(); |
|
145 } |
|
146 |
|
147 bool WebEvent::isClipboardEvent() const |
|
148 { |
|
149 ASSERT(m_private); |
|
150 return m_private->isClipboardEvent(); |
|
151 } |
|
152 |
|
153 bool WebEvent::isMessageEvent() const |
|
154 { |
|
155 ASSERT(m_private); |
|
156 return m_private->isMessageEvent(); |
|
157 } |
|
158 |
|
159 bool WebEvent::isWheelEvent() const |
|
160 { |
|
161 ASSERT(m_private); |
|
162 return m_private->isWheelEvent(); |
|
163 } |
|
164 |
|
165 bool WebEvent::isBeforeTextInsertedEvent() const |
|
166 { |
|
167 ASSERT(m_private); |
|
168 return m_private->isBeforeTextInsertedEvent(); |
|
169 } |
|
170 |
|
171 bool WebEvent::isOverflowEvent() const |
|
172 { |
|
173 ASSERT(m_private); |
|
174 return m_private->isOverflowEvent(); |
|
175 } |
|
176 |
|
177 bool WebEvent::isPageTransitionEvent() const |
|
178 { |
|
179 ASSERT(m_private); |
|
180 return m_private->isPageTransitionEvent(); |
|
181 } |
|
182 |
|
183 bool WebEvent::isPopStateEvent() const |
|
184 { |
|
185 ASSERT(m_private); |
|
186 return m_private->isPopStateEvent(); |
|
187 } |
|
188 |
|
189 bool WebEvent::isProgressEvent() const |
|
190 { |
|
191 ASSERT(m_private); |
|
192 return m_private->isProgressEvent(); |
|
193 } |
|
194 |
|
195 bool WebEvent::isXMLHttpRequestProgressEvent() const |
|
196 { |
|
197 ASSERT(m_private); |
|
198 return m_private->isXMLHttpRequestProgressEvent(); |
|
199 } |
|
200 |
|
201 bool WebEvent::isWebKitAnimationEvent() const |
|
202 { |
|
203 ASSERT(m_private); |
|
204 return m_private->isWebKitAnimationEvent(); |
|
205 } |
|
206 |
|
207 bool WebEvent::isWebKitTransitionEvent() const |
|
208 { |
|
209 ASSERT(m_private); |
|
210 return m_private->isWebKitTransitionEvent(); |
|
211 } |
|
212 |
|
213 bool WebEvent::isBeforeLoadEvent() const |
|
214 { |
|
215 ASSERT(m_private); |
|
216 return m_private->isBeforeLoadEvent(); |
|
217 } |
|
218 |
|
219 } // namespace WebKit |