WebKit/chromium/public/WebEvent.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 WebEvent_h
       
    32 #define WebEvent_h
       
    33 
       
    34 #include "WebCommon.h"
       
    35 #include "WebNode.h"
       
    36 #include "WebString.h"
       
    37 
       
    38 namespace WebCore { class Event; }
       
    39 #if WEBKIT_IMPLEMENTATION
       
    40 namespace WTF { template <typename T> class PassRefPtr; }
       
    41 #endif
       
    42 
       
    43 namespace WebKit {
       
    44 
       
    45 class WebEvent {
       
    46 public:
       
    47     enum PhaseType {
       
    48         CapturingPhase     = 1,
       
    49         AtTarget           = 2,
       
    50         BubblingPhase      = 3
       
    51     };
       
    52 
       
    53     WebEvent() : m_private(0) { }
       
    54     WebEvent(const WebEvent& e) : m_private(0) { assign(e); }
       
    55     WebEvent& operator=(const WebEvent& e)
       
    56     {
       
    57         assign(e);
       
    58         return *this;
       
    59     }
       
    60 
       
    61     WEBKIT_API void reset();
       
    62     WEBKIT_API void assign(const WebEvent&);
       
    63 
       
    64     bool isNull() const { return !m_private; }
       
    65 
       
    66     WEBKIT_API WebString type() const;
       
    67     WEBKIT_API WebNode target() const;
       
    68     WEBKIT_API WebNode currentTarget() const;
       
    69 
       
    70     WEBKIT_API PhaseType eventPhase() const;
       
    71     WEBKIT_API bool bubbles() const;
       
    72     WEBKIT_API bool cancelable() const;
       
    73 
       
    74     WEBKIT_API bool isUIEvent() const;
       
    75     WEBKIT_API bool isMouseEvent() const;
       
    76     WEBKIT_API bool isMutationEvent() const;
       
    77     WEBKIT_API bool isKeyboardEvent() const;
       
    78     WEBKIT_API bool isTextEvent() const;
       
    79     WEBKIT_API bool isCompositionEvent() const;
       
    80     WEBKIT_API bool isDragEvent() const;
       
    81     WEBKIT_API bool isClipboardEvent() const;
       
    82     WEBKIT_API bool isMessageEvent() const;
       
    83     WEBKIT_API bool isWheelEvent() const;
       
    84     WEBKIT_API bool isBeforeTextInsertedEvent() const;
       
    85     WEBKIT_API bool isOverflowEvent() const;
       
    86     WEBKIT_API bool isPageTransitionEvent() const;
       
    87     WEBKIT_API bool isPopStateEvent() const;
       
    88     WEBKIT_API bool isProgressEvent() const;
       
    89     WEBKIT_API bool isXMLHttpRequestProgressEvent() const;
       
    90     WEBKIT_API bool isWebKitAnimationEvent() const;
       
    91     WEBKIT_API bool isWebKitTransitionEvent() const;
       
    92     WEBKIT_API bool isBeforeLoadEvent() const;
       
    93 
       
    94 #if WEBKIT_IMPLEMENTATION
       
    95     WebEvent(const WTF::PassRefPtr<WebCore::Event>&);
       
    96 #endif
       
    97 
       
    98 protected:
       
    99     typedef WebCore::Event WebEventPrivate;
       
   100     void assign(WebEventPrivate*);
       
   101     WebEventPrivate* m_private;
       
   102 
       
   103     template<typename T> T* unwrap()
       
   104     {
       
   105         return static_cast<T*>(m_private);
       
   106     }
       
   107 
       
   108     template<typename T> const T* constUnwrap() const
       
   109     {
       
   110         return static_cast<const T*>(m_private);
       
   111     }
       
   112 };
       
   113 
       
   114 } // namespace WebKit
       
   115 
       
   116 #endif