Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebDOMEvent.cpp
blob4d980df0ba19707945cf6cfabebea5c125f503be
1 /*
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
6 * met:
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.
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.
31 #include "config.h"
32 #include "public/web/WebDOMEvent.h"
34 #include "core/EventNames.h"
35 #include "core/dom/Node.h"
36 #include "core/events/Event.h"
37 #include "wtf/PassRefPtr.h"
39 namespace blink {
41 void WebDOMEvent::reset()
43 assign(nullptr);
46 void WebDOMEvent::assign(const WebDOMEvent& other)
48 m_private = other.m_private;
51 void WebDOMEvent::assign(const PassRefPtrWillBeRawPtr<Event>& event)
53 m_private = event;
56 WebDOMEvent::WebDOMEvent(const PassRefPtrWillBeRawPtr<Event>& event)
57 : m_private(event)
61 WebDOMEvent::operator PassRefPtrWillBeRawPtr<Event>() const
63 return m_private.get();
66 WebString WebDOMEvent::type() const
68 ASSERT(m_private.get());
69 return m_private->type();
72 WebNode WebDOMEvent::target() const
74 ASSERT(m_private.get());
75 return WebNode(m_private->target()->toNode());
78 WebNode WebDOMEvent::currentTarget() const
80 ASSERT(m_private.get());
81 return WebNode(m_private->currentTarget()->toNode());
84 WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
86 ASSERT(m_private.get());
87 return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
90 bool WebDOMEvent::bubbles() const
92 ASSERT(m_private.get());
93 return m_private->bubbles();
96 bool WebDOMEvent::cancelable() const
98 ASSERT(m_private.get());
99 return m_private->cancelable();
102 bool WebDOMEvent::isUIEvent() const
104 ASSERT(m_private.get());
105 return m_private->isUIEvent();
108 bool WebDOMEvent::isMouseEvent() const
110 ASSERT(m_private.get());
111 return m_private->isMouseEvent();
114 bool WebDOMEvent::isKeyboardEvent() const
116 ASSERT(m_private.get());
117 return m_private->isKeyboardEvent();
120 bool WebDOMEvent::isMutationEvent() const
122 ASSERT(m_private.get());
123 return m_private->hasInterface(EventNames::MutationEvent);
126 bool WebDOMEvent::isTextEvent() const
128 ASSERT(m_private.get());
129 return m_private->hasInterface(EventNames::TextEvent);
132 bool WebDOMEvent::isCompositionEvent() const
134 ASSERT(m_private.get());
135 return m_private->hasInterface(EventNames::CompositionEvent);
138 bool WebDOMEvent::isDragEvent() const
140 ASSERT(m_private.get());
141 return m_private->isDragEvent();
144 bool WebDOMEvent::isClipboardEvent() const
146 ASSERT(m_private.get());
147 return m_private->isClipboardEvent();
150 bool WebDOMEvent::isMessageEvent() const
152 ASSERT(m_private.get());
153 return m_private->hasInterface(EventNames::MessageEvent);
156 bool WebDOMEvent::isWheelEvent() const
158 ASSERT(m_private.get());
159 return m_private->hasInterface(EventNames::WheelEvent);
162 bool WebDOMEvent::isBeforeTextInsertedEvent() const
164 ASSERT(m_private.get());
165 return m_private->isBeforeTextInsertedEvent();
168 bool WebDOMEvent::isPageTransitionEvent() const
170 ASSERT(m_private.get());
171 return m_private->hasInterface(EventNames::PageTransitionEvent);
174 bool WebDOMEvent::isPopStateEvent() const
176 ASSERT(m_private.get());
177 return m_private->hasInterface(EventNames::PopStateEvent);
180 bool WebDOMEvent::isProgressEvent() const
182 ASSERT(m_private.get());
183 return m_private->hasInterface(EventNames::ProgressEvent);
186 bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
188 ASSERT(m_private.get());
189 return m_private->hasInterface(EventNames::XMLHttpRequestProgressEvent);
192 } // namespace blink