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 "public/web/WebDOMEvent.h"
33
34 #include "core/EventNames.h"
35 #include "core/dom/Node.h"
36 #include "core/events/Event.h"
37 #include "wtf/PassRefPtr.h"
38
39 namespace blink {
40
reset()41 void WebDOMEvent::reset()
42 {
43 assign(nullptr);
44 }
45
assign(const WebDOMEvent & other)46 void WebDOMEvent::assign(const WebDOMEvent& other)
47 {
48 m_private = other.m_private;
49 }
50
assign(const PassRefPtrWillBeRawPtr<Event> & event)51 void WebDOMEvent::assign(const PassRefPtrWillBeRawPtr<Event>& event)
52 {
53 m_private = event;
54 }
55
WebDOMEvent(const PassRefPtrWillBeRawPtr<Event> & event)56 WebDOMEvent::WebDOMEvent(const PassRefPtrWillBeRawPtr<Event>& event)
57 : m_private(event)
58 {
59 }
60
operator PassRefPtrWillBeRawPtr<Event>() const61 WebDOMEvent::operator PassRefPtrWillBeRawPtr<Event>() const
62 {
63 return m_private.get();
64 }
65
type() const66 WebString WebDOMEvent::type() const
67 {
68 ASSERT(m_private.get());
69 return m_private->type();
70 }
71
target() const72 WebNode WebDOMEvent::target() const
73 {
74 ASSERT(m_private.get());
75 return WebNode(m_private->target()->toNode());
76 }
77
currentTarget() const78 WebNode WebDOMEvent::currentTarget() const
79 {
80 ASSERT(m_private.get());
81 return WebNode(m_private->currentTarget()->toNode());
82 }
83
eventPhase() const84 WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
85 {
86 ASSERT(m_private.get());
87 return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
88 }
89
bubbles() const90 bool WebDOMEvent::bubbles() const
91 {
92 ASSERT(m_private.get());
93 return m_private->bubbles();
94 }
95
cancelable() const96 bool WebDOMEvent::cancelable() const
97 {
98 ASSERT(m_private.get());
99 return m_private->cancelable();
100 }
101
isUIEvent() const102 bool WebDOMEvent::isUIEvent() const
103 {
104 ASSERT(m_private.get());
105 return m_private->isUIEvent();
106 }
107
isMouseEvent() const108 bool WebDOMEvent::isMouseEvent() const
109 {
110 ASSERT(m_private.get());
111 return m_private->isMouseEvent();
112 }
113
isKeyboardEvent() const114 bool WebDOMEvent::isKeyboardEvent() const
115 {
116 ASSERT(m_private.get());
117 return m_private->isKeyboardEvent();
118 }
119
isMutationEvent() const120 bool WebDOMEvent::isMutationEvent() const
121 {
122 ASSERT(m_private.get());
123 return m_private->hasInterface(EventNames::MutationEvent);
124 }
125
isTextEvent() const126 bool WebDOMEvent::isTextEvent() const
127 {
128 ASSERT(m_private.get());
129 return m_private->hasInterface(EventNames::TextEvent);
130 }
131
isCompositionEvent() const132 bool WebDOMEvent::isCompositionEvent() const
133 {
134 ASSERT(m_private.get());
135 return m_private->hasInterface(EventNames::CompositionEvent);
136 }
137
isDragEvent() const138 bool WebDOMEvent::isDragEvent() const
139 {
140 ASSERT(m_private.get());
141 return m_private->isDragEvent();
142 }
143
isClipboardEvent() const144 bool WebDOMEvent::isClipboardEvent() const
145 {
146 ASSERT(m_private.get());
147 return m_private->isClipboardEvent();
148 }
149
isMessageEvent() const150 bool WebDOMEvent::isMessageEvent() const
151 {
152 ASSERT(m_private.get());
153 return m_private->hasInterface(EventNames::MessageEvent);
154 }
155
isWheelEvent() const156 bool WebDOMEvent::isWheelEvent() const
157 {
158 ASSERT(m_private.get());
159 return m_private->hasInterface(EventNames::WheelEvent);
160 }
161
isBeforeTextInsertedEvent() const162 bool WebDOMEvent::isBeforeTextInsertedEvent() const
163 {
164 ASSERT(m_private.get());
165 return m_private->isBeforeTextInsertedEvent();
166 }
167
isOverflowEvent() const168 bool WebDOMEvent::isOverflowEvent() const
169 {
170 ASSERT(m_private.get());
171 return m_private->hasInterface(EventNames::OverflowEvent);
172 }
173
isPageTransitionEvent() const174 bool WebDOMEvent::isPageTransitionEvent() const
175 {
176 ASSERT(m_private.get());
177 return m_private->hasInterface(EventNames::PageTransitionEvent);
178 }
179
isPopStateEvent() const180 bool WebDOMEvent::isPopStateEvent() const
181 {
182 ASSERT(m_private.get());
183 return m_private->hasInterface(EventNames::PopStateEvent);
184 }
185
isProgressEvent() const186 bool WebDOMEvent::isProgressEvent() const
187 {
188 ASSERT(m_private.get());
189 return m_private->hasInterface(EventNames::ProgressEvent);
190 }
191
isXMLHttpRequestProgressEvent() const192 bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
193 {
194 ASSERT(m_private.get());
195 return m_private->hasInterface(EventNames::XMLHttpRequestProgressEvent);
196 }
197
198 } // namespace blink
199