Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / PlatformMouseEvent.h
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2009 Apple 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
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef PlatformMouseEvent_h
27 #define PlatformMouseEvent_h
28
29 #include "platform/PlatformEvent.h"
30 #include "platform/geometry/IntPoint.h"
31
32 namespace blink {
33
34 // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified.
35 enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
36
37 class PlatformMouseEvent : public PlatformEvent {
38 public:
39     enum SyntheticEventType {
40         // Real mouse input events or synthetic events that behave just like real events
41         RealOrIndistinguishable,
42         // Mouse events derived from touch input
43         FromTouch,
44     };
45
46     PlatformMouseEvent()
47         : PlatformEvent(PlatformEvent::MouseMoved)
48         , m_button(NoButton)
49         , m_clickCount(0)
50         , m_synthesized(RealOrIndistinguishable)
51         , m_modifierFlags(0)
52     {
53     }
54
55     PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, double timestamp)
56         : PlatformEvent(type, modifiers, timestamp)
57         , m_position(position)
58         , m_globalPosition(globalPosition)
59         , m_button(button)
60         , m_clickCount(clickCount)
61         , m_synthesized(RealOrIndistinguishable)
62         , m_modifierFlags(0)
63     {
64     }
65
66     PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, Modifiers modifiers, SyntheticEventType synthesized, double timestamp)
67         : PlatformEvent(type, modifiers, timestamp)
68         , m_position(position)
69         , m_globalPosition(globalPosition)
70         , m_button(button)
71         , m_clickCount(clickCount)
72         , m_synthesized(synthesized)
73         , m_modifierFlags(0)
74     {
75     }
76
77     PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type, int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, SyntheticEventType synthesized, double timestamp)
78         : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
79         , m_position(position)
80         , m_globalPosition(globalPosition)
81         , m_button(button)
82         , m_clickCount(clickCount)
83         , m_synthesized(synthesized)
84         , m_modifierFlags(0)
85     {
86     }
87
88     const IntPoint& position() const { return m_position; }
89     const IntPoint& globalPosition() const { return m_globalPosition; }
90     const IntPoint& movementDelta() const { return m_movementDelta; }
91
92     MouseButton button() const { return m_button; }
93     int clickCount() const { return m_clickCount; }
94     unsigned modifierFlags() const { return m_modifierFlags; }
95     bool fromTouch() const { return m_synthesized == FromTouch; }
96     SyntheticEventType syntheticEventType() const { return m_synthesized; }
97
98 protected:
99     IntPoint m_position;
100     IntPoint m_globalPosition;
101     IntPoint m_movementDelta;
102     MouseButton m_button;
103     int m_clickCount;
104     SyntheticEventType m_synthesized;
105     unsigned m_modifierFlags;
106 };
107
108 } // namespace blink
109
110 #endif // PlatformMouseEvent_h