Home | History | Annotate | Download | only in web
      1 /*
      2  * Copyright (C) 2009 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 WebInputEventConversion_h
     32 #define WebInputEventConversion_h
     33 
     34 #include "WebInputEvent.h"
     35 #include "platform/PlatformGestureEvent.h"
     36 #include "platform/PlatformKeyboardEvent.h"
     37 #include "platform/PlatformMouseEvent.h"
     38 #include "platform/PlatformTouchEvent.h"
     39 #include "platform/PlatformWheelEvent.h"
     40 
     41 namespace WebCore {
     42 class GestureEvent;
     43 class KeyboardEvent;
     44 class MouseEvent;
     45 class RenderObject;
     46 class ScrollView;
     47 class TouchEvent;
     48 class WheelEvent;
     49 class Widget;
     50 }
     51 
     52 namespace blink {
     53 
     54 class WebMouseEvent;
     55 class WebMouseWheelEvent;
     56 class WebKeyboardEvent;
     57 class WebTouchEvent;
     58 class WebGestureEvent;
     59 
     60 // These classes are used to convert from WebInputEvent subclasses to
     61 // corresponding WebCore events.
     62 
     63 class PlatformMouseEventBuilder : public WebCore::PlatformMouseEvent {
     64 public:
     65     PlatformMouseEventBuilder(WebCore::Widget*, const WebMouseEvent&);
     66 };
     67 
     68 class PlatformWheelEventBuilder : public WebCore::PlatformWheelEvent {
     69 public:
     70     PlatformWheelEventBuilder(WebCore::Widget*, const WebMouseWheelEvent&);
     71 };
     72 
     73 class PlatformGestureEventBuilder : public WebCore::PlatformGestureEvent {
     74 public:
     75     PlatformGestureEventBuilder(WebCore::Widget*, const WebGestureEvent&);
     76 };
     77 
     78 class PlatformKeyboardEventBuilder : public WebCore::PlatformKeyboardEvent {
     79 public:
     80     PlatformKeyboardEventBuilder(const WebKeyboardEvent&);
     81     void setKeyType(Type);
     82     bool isCharacterKey() const;
     83 };
     84 
     85 // Converts a WebTouchPoint to a WebCore::PlatformTouchPoint.
     86 class PlatformTouchPointBuilder : public WebCore::PlatformTouchPoint {
     87 public:
     88     PlatformTouchPointBuilder(WebCore::Widget*, const WebTouchPoint&);
     89 };
     90 
     91 // Converts a WebTouchEvent to a WebCore::PlatformTouchEvent.
     92 class PlatformTouchEventBuilder : public WebCore::PlatformTouchEvent {
     93 public:
     94     PlatformTouchEventBuilder(WebCore::Widget*, const WebTouchEvent&);
     95 };
     96 
     97 class WebMouseEventBuilder : public WebMouseEvent {
     98 public:
     99     // Converts a WebCore::MouseEvent to a corresponding WebMouseEvent.
    100     // NOTE: This is only implemented for mousemove, mouseover, mouseout,
    101     // mousedown and mouseup. If the event mapping fails, the event type will
    102     // be set to Undefined.
    103     WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::MouseEvent&);
    104     WebMouseEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
    105 
    106     // Converts a WebCore::PlatformMouseEvent to a corresponding WebMouseEvent.
    107     // NOTE: This is only implemented for mousepressed, mousereleased, and
    108     // mousemoved. If the event mapping fails, the event type will be set to
    109     // Undefined.
    110     WebMouseEventBuilder(const WebCore::Widget*, const WebCore::PlatformMouseEvent&);
    111 };
    112 
    113 // Converts a WebCore::WheelEvent to a corresponding WebMouseWheelEvent.
    114 // If the event mapping fails, the event type will be set to Undefined.
    115 class WebMouseWheelEventBuilder : public WebMouseWheelEvent {
    116 public:
    117     WebMouseWheelEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::WheelEvent&);
    118 };
    119 
    120 // Converts a WebCore::KeyboardEvent or WebCore::PlatformKeyboardEvent to a
    121 // corresponding WebKeyboardEvent.
    122 // NOTE: For WebCore::KeyboardEvent, this is only implemented for keydown,
    123 // keyup, and keypress. If the event mapping fails, the event type will be set
    124 // to Undefined.
    125 class WebKeyboardEventBuilder : public WebKeyboardEvent {
    126 public:
    127     WebKeyboardEventBuilder(const WebCore::KeyboardEvent&);
    128     WebKeyboardEventBuilder(const WebCore::PlatformKeyboardEvent&);
    129 };
    130 
    131 // Converts a WebCore::TouchEvent to a corresponding WebTouchEvent.
    132 // NOTE: WebTouchEvents have a cap on the number of WebTouchPoints. Any points
    133 // exceeding that cap will be dropped.
    134 class WebTouchEventBuilder : public WebTouchEvent {
    135 public:
    136     WebTouchEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::TouchEvent&);
    137 };
    138 
    139 // Converts WebCore::GestureEvent to a corresponding WebGestureEvent.
    140 // NOTE: If event mapping fails, the type will be set to Undefined.
    141 class WebGestureEventBuilder : public WebGestureEvent {
    142 public:
    143     WebGestureEventBuilder(const WebCore::Widget*, const WebCore::RenderObject*, const WebCore::GestureEvent&);
    144 };
    145 
    146 } // namespace blink
    147 
    148 #endif
    149