Home | History | Annotate | Download | only in web
      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 "WebDOMEvent.h"
     33 
     34 #include "core/dom/Event.h"
     35 #include "core/dom/EventNames.h"
     36 #include "core/dom/Node.h"
     37 #include "wtf/PassRefPtr.h"
     38 
     39 using WebCore::eventNames;
     40 
     41 namespace WebKit {
     42 
     43 class WebDOMEventPrivate : public WebCore::Event {
     44 };
     45 
     46 void WebDOMEvent::reset()
     47 {
     48     assign(0);
     49 }
     50 
     51 void WebDOMEvent::assign(const WebDOMEvent& other)
     52 {
     53     m_private = other.m_private;
     54 }
     55 
     56 void WebDOMEvent::assign(const WTF::PassRefPtr<WebDOMEventPrivate>& event)
     57 {
     58     m_private = event;
     59 }
     60 
     61 WebDOMEvent::WebDOMEvent(const WTF::PassRefPtr<WebCore::Event>& event)
     62     : m_private(event)
     63 {
     64 }
     65 
     66 WebDOMEvent::operator WTF::PassRefPtr<WebCore::Event>() const
     67 {
     68     return m_private.get();
     69 }
     70 
     71 WebString WebDOMEvent::type() const
     72 {
     73     ASSERT(m_private.get());
     74     return m_private->type();
     75 }
     76 
     77 WebNode WebDOMEvent::target() const
     78 {
     79     ASSERT(m_private.get());
     80     return WebNode(m_private->target()->toNode());
     81 }
     82 
     83 WebNode WebDOMEvent::currentTarget() const
     84 {
     85     ASSERT(m_private.get());
     86     return WebNode(m_private->currentTarget()->toNode());
     87 }
     88 
     89 WebDOMEvent::PhaseType WebDOMEvent::eventPhase() const
     90 {
     91     ASSERT(m_private.get());
     92     return static_cast<WebDOMEvent::PhaseType>(m_private->eventPhase());
     93 }
     94 
     95 bool WebDOMEvent::bubbles() const
     96 {
     97     ASSERT(m_private.get());
     98     return m_private->bubbles();
     99 }
    100 
    101 bool WebDOMEvent::cancelable() const
    102 {
    103     ASSERT(m_private.get());
    104     return m_private->cancelable();
    105 }
    106 
    107 bool WebDOMEvent::isUIEvent() const
    108 {
    109     ASSERT(m_private.get());
    110     return m_private->isUIEvent();
    111 }
    112 
    113 bool WebDOMEvent::isMouseEvent() const
    114 {
    115     ASSERT(m_private.get());
    116     return m_private->isMouseEvent();
    117 }
    118 
    119 bool WebDOMEvent::isKeyboardEvent() const
    120 {
    121     ASSERT(m_private.get());
    122     return m_private->isKeyboardEvent();
    123 }
    124 
    125 bool WebDOMEvent::isMutationEvent() const
    126 {
    127     ASSERT(m_private.get());
    128     return m_private->hasInterface(WebCore::eventNames().interfaceForMutationEvent);
    129 }
    130 
    131 bool WebDOMEvent::isTextEvent() const
    132 {
    133     ASSERT(m_private.get());
    134     return m_private->hasInterface(eventNames().interfaceForTextEvent);
    135 }
    136 
    137 bool WebDOMEvent::isCompositionEvent() const
    138 {
    139     ASSERT(m_private.get());
    140     return m_private->hasInterface(eventNames().interfaceForCompositionEvent);
    141 }
    142 
    143 bool WebDOMEvent::isDragEvent() const
    144 {
    145     ASSERT(m_private.get());
    146     return m_private->isDragEvent();
    147 }
    148 
    149 bool WebDOMEvent::isClipboardEvent() const
    150 {
    151     ASSERT(m_private.get());
    152     return m_private->isClipboardEvent();
    153 }
    154 
    155 bool WebDOMEvent::isMessageEvent() const
    156 {
    157     ASSERT(m_private.get());
    158     return m_private->hasInterface(eventNames().interfaceForMessageEvent);
    159 }
    160 
    161 bool WebDOMEvent::isWheelEvent() const
    162 {
    163     ASSERT(m_private.get());
    164     return m_private->hasInterface(eventNames().interfaceForWheelEvent);
    165 }
    166 
    167 bool WebDOMEvent::isBeforeTextInsertedEvent() const
    168 {
    169     ASSERT(m_private.get());
    170     return m_private->isBeforeTextInsertedEvent();
    171 }
    172 
    173 bool WebDOMEvent::isOverflowEvent() const
    174 {
    175     ASSERT(m_private.get());
    176     return m_private->hasInterface(eventNames().interfaceForOverflowEvent);
    177 }
    178 
    179 bool WebDOMEvent::isPageTransitionEvent() const
    180 {
    181     ASSERT(m_private.get());
    182     return m_private->hasInterface(eventNames().interfaceForPageTransitionEvent);
    183 }
    184 
    185 bool WebDOMEvent::isPopStateEvent() const
    186 {
    187     ASSERT(m_private.get());
    188     return m_private->hasInterface(eventNames().interfaceForPopStateEvent);
    189 }
    190 
    191 bool WebDOMEvent::isProgressEvent() const
    192 {
    193     ASSERT(m_private.get());
    194     return m_private->hasInterface(eventNames().interfaceForProgressEvent);
    195 }
    196 
    197 bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
    198 {
    199     ASSERT(m_private.get());
    200     return m_private->hasInterface(eventNames().interfaceForXMLHttpRequestProgressEvent);
    201 }
    202 
    203 bool WebDOMEvent::isBeforeLoadEvent() const
    204 {
    205     ASSERT(m_private.get());
    206     return m_private->hasInterface(eventNames().interfaceForBeforeLoadEvent);
    207 }
    208 
    209 } // namespace WebKit
    210