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.
32 #include "WebDOMEvent.h"
35 #include "EventNames.h"
37 #include <wtf/PassRefPtr.h>
39 using WebCore::eventNames;
43 class WebDOMEventPrivate : public WebCore::Event {
46 void WebDOMEvent::reset()
51 void WebDOMEvent::assign(const WebDOMEvent& other)
53 WebDOMEventPrivate* p = const_cast<WebDOMEventPrivate*>(other.m_private);
59 void WebDOMEvent::assign(WebDOMEventPrivate* p)
61 // p is already ref'd for us by the caller
67 WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event)
68 : m_private(static_cast<WebDOMEventPrivate*>(event.leakRef()))
72 WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const
74 return static_cast<WebCore::Event*>(m_private);
77 WebString WebDOMEvent::type() const
80 return m_private->type();
83 WebNode WebDOMEvent::target() const
86 return WebNode(m_private->target()->toNode());
89 WebNode WebDOMEvent::currentTarget() const
92 return WebNode(m_private->currentTarget()->toNode());
95 WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
98 return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
101 bool WebDOMEvent::bubbles() const
104 return m_private->bubbles();
107 bool WebDOMEvent::cancelable() const
110 return m_private->cancelable();
113 bool WebDOMEvent::isUIEvent() const
116 return m_private->isUIEvent();
119 bool WebDOMEvent::isMouseEvent() const
122 return m_private->isMouseEvent();
125 bool WebDOMEvent::isKeyboardEvent() const
128 return m_private->isKeyboardEvent();
131 bool WebDOMEvent::isMutationEvent() const
134 return m_private->hasInterface(WebCore::eventNames().interfaceForMutationEvent);
137 bool WebDOMEvent::isTextEvent() const
140 return m_private->hasInterface(eventNames().interfaceForTextEvent);
143 bool WebDOMEvent::isCompositionEvent() const
146 return m_private->hasInterface(eventNames().interfaceForCompositionEvent);
149 bool WebDOMEvent::isDragEvent() const
152 return m_private->isDragEvent();
155 bool WebDOMEvent::isClipboardEvent() const
158 return m_private->isClipboardEvent();
161 bool WebDOMEvent::isMessageEvent() const
164 return m_private->hasInterface(eventNames().interfaceForMessageEvent);
167 bool WebDOMEvent::isWheelEvent() const
170 return m_private->hasInterface(eventNames().interfaceForWheelEvent);
173 bool WebDOMEvent::isBeforeTextInsertedEvent() const
176 return m_private->isBeforeTextInsertedEvent();
179 bool WebDOMEvent::isOverflowEvent() const
182 return m_private->hasInterface(eventNames().interfaceForOverflowEvent);
185 bool WebDOMEvent::isPageTransitionEvent() const
188 return m_private->hasInterface(eventNames().interfaceForPageTransitionEvent);
191 bool WebDOMEvent::isPopStateEvent() const
194 return m_private->hasInterface(eventNames().interfaceForPopStateEvent);
197 bool WebDOMEvent::isProgressEvent() const
200 return m_private->hasInterface(eventNames().interfaceForProgressEvent);
203 bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
206 return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent);
209 bool WebDOMEvent::isWebKitAnimationEvent() const
212 return m_private->hasInterface(eventNames().interfaceForWebKitAnimationEvent);
215 bool WebDOMEvent::isWebKitTransitionEvent() const
218 return m_private->hasInterface(eventNames().interfaceForWebKitTransitionEvent);
221 bool WebDOMEvent::isBeforeLoadEvent() const
224 return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent);
227 } // namespace WebKit