| OLD | NEW |
| (Empty) |
| 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 #ifndef WebDOMEvent_h | |
| 32 #define WebDOMEvent_h | |
| 33 | |
| 34 #include "../platform/WebCommon.h" | |
| 35 #include "../platform/WebPrivatePtr.h" | |
| 36 #include "../platform/WebString.h" | |
| 37 #include "WebNode.h" | |
| 38 | |
| 39 namespace WebCore { class Event; } | |
| 40 #if WEBKIT_IMPLEMENTATION | |
| 41 namespace WTF { template <typename T> class PassRefPtr; } | |
| 42 #endif | |
| 43 | |
| 44 namespace WebKit { | |
| 45 | |
| 46 class WebDOMEvent { | |
| 47 public: | |
| 48 enum PhaseType { | |
| 49 CapturingPhase = 1, | |
| 50 AtTarget = 2, | |
| 51 BubblingPhase = 3 | |
| 52 }; | |
| 53 | |
| 54 ~WebDOMEvent() { reset(); } | |
| 55 | |
| 56 WebDOMEvent() { } | |
| 57 WebDOMEvent(const WebDOMEvent& other) { assign(other); } | |
| 58 WebDOMEvent& operator=(const WebDOMEvent& e) | |
| 59 { | |
| 60 assign(e); | |
| 61 return *this; | |
| 62 } | |
| 63 | |
| 64 WEBKIT_EXPORT void reset(); | |
| 65 WEBKIT_EXPORT void assign(const WebDOMEvent&); | |
| 66 | |
| 67 bool isNull() const { return m_private.isNull(); } | |
| 68 | |
| 69 WEBKIT_EXPORT WebString type() const; | |
| 70 WEBKIT_EXPORT WebNode target() const; | |
| 71 WEBKIT_EXPORT WebNode currentTarget() const; | |
| 72 | |
| 73 WEBKIT_EXPORT PhaseType eventPhase() const; | |
| 74 WEBKIT_EXPORT bool bubbles() const; | |
| 75 WEBKIT_EXPORT bool cancelable() const; | |
| 76 | |
| 77 WEBKIT_EXPORT bool isUIEvent() const; | |
| 78 WEBKIT_EXPORT bool isMouseEvent() const; | |
| 79 WEBKIT_EXPORT bool isMutationEvent() const; | |
| 80 WEBKIT_EXPORT bool isKeyboardEvent() const; | |
| 81 WEBKIT_EXPORT bool isTextEvent() const; | |
| 82 WEBKIT_EXPORT bool isCompositionEvent() const; | |
| 83 WEBKIT_EXPORT bool isDragEvent() const; | |
| 84 WEBKIT_EXPORT bool isClipboardEvent() const; | |
| 85 WEBKIT_EXPORT bool isMessageEvent() const; | |
| 86 WEBKIT_EXPORT bool isWheelEvent() const; | |
| 87 WEBKIT_EXPORT bool isBeforeTextInsertedEvent() const; | |
| 88 WEBKIT_EXPORT bool isOverflowEvent() const; | |
| 89 WEBKIT_EXPORT bool isPageTransitionEvent() const; | |
| 90 WEBKIT_EXPORT bool isPopStateEvent() const; | |
| 91 WEBKIT_EXPORT bool isProgressEvent() const; | |
| 92 WEBKIT_EXPORT bool isXMLHttpRequestProgressEvent() const; | |
| 93 WEBKIT_EXPORT bool isBeforeLoadEvent() const; | |
| 94 | |
| 95 #if WEBKIT_IMPLEMENTATION | |
| 96 WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>&); | |
| 97 operator WTF::PassRefPtr<WebCore::Event>() const; | |
| 98 #endif | |
| 99 | |
| 100 template<typename T> T to() | |
| 101 { | |
| 102 T res; | |
| 103 res.WebDOMEvent::assign(*this); | |
| 104 return res; | |
| 105 } | |
| 106 | |
| 107 template<typename T> const T toConst() const | |
| 108 { | |
| 109 T res; | |
| 110 res.WebDOMEvent::assign(*this); | |
| 111 return res; | |
| 112 } | |
| 113 | |
| 114 protected: | |
| 115 typedef WebCore::Event WebDOMEventPrivate; | |
| 116 #if WEBKIT_IMPLEMENTATION | |
| 117 void assign(const WTF::PassRefPtr<WebDOMEventPrivate>&); | |
| 118 | |
| 119 template<typename T> T* unwrap() | |
| 120 { | |
| 121 return static_cast<T*>(m_private.get()); | |
| 122 } | |
| 123 | |
| 124 template<typename T> const T* constUnwrap() const | |
| 125 { | |
| 126 return static_cast<const T*>(m_private.get()); | |
| 127 } | |
| 128 #endif | |
| 129 | |
| 130 WebPrivatePtr<WebDOMEventPrivate> m_private; | |
| 131 }; | |
| 132 | |
| 133 } // namespace WebKit | |
| 134 | |
| 135 #endif | |
| OLD | NEW |