OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef MouseEvent_h | 24 #ifndef MouseEvent_h |
25 #define MouseEvent_h | 25 #define MouseEvent_h |
26 | 26 |
27 #include "core/events/EventDispatchMediator.h" | 27 #include "core/events/EventDispatchMediator.h" |
28 #include "core/events/MouseRelatedEvent.h" | 28 #include "core/events/MouseRelatedEvent.h" |
| 29 #include "platform/PlatformMouseEvent.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 class DataTransfer; | 33 class DataTransfer; |
33 class EventDispatcher; | 34 class EventDispatcher; |
34 class PlatformMouseEvent; | |
35 | 35 |
36 struct MouseEventInit : public UIEventInit { | 36 struct MouseEventInit : public UIEventInit { |
37 MouseEventInit(); | 37 MouseEventInit(); |
38 | 38 |
39 int screenX; | 39 int screenX; |
40 int screenY; | 40 int screenY; |
41 int clientX; | 41 int clientX; |
42 int clientY; | 42 int clientY; |
43 bool ctrlKey; | 43 bool ctrlKey; |
44 bool altKey; | 44 bool altKey; |
45 bool shiftKey; | 45 bool shiftKey; |
46 bool metaKey; | 46 bool metaKey; |
47 unsigned short button; | 47 unsigned short button; |
48 RefPtrWillBeMember<EventTarget> relatedTarget; | 48 RefPtrWillBeMember<EventTarget> relatedTarget; |
49 }; | 49 }; |
50 | 50 |
51 class MouseEvent : public MouseRelatedEvent { | 51 class MouseEvent : public MouseRelatedEvent { |
52 public: | 52 public: |
53 static PassRefPtrWillBeRawPtr<MouseEvent> create() | 53 static PassRefPtrWillBeRawPtr<MouseEvent> create() |
54 { | 54 { |
55 return adoptRefWillBeNoop(new MouseEvent); | 55 return adoptRefWillBeNoop(new MouseEvent); |
56 } | 56 } |
57 | 57 |
58 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b
ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, | 58 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b
ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, |
59 int detail, int screenX, int screenY, int pageX, int pageY, | 59 int detail, int screenX, int screenY, int pageX, int pageY, |
60 int movementX, int movementY, | 60 int movementX, int movementY, |
61 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b
utton, | 61 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b
utton, |
62 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt
r<DataTransfer>, bool isSimulated = false); | 62 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt
r<DataTransfer>, |
| 63 bool isSimulated = false, PlatformMouseEvent::SyntheticEventType = Platf
ormMouseEvent::RealOrIndistinguishable); |
63 | 64 |
64 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail,
PassRefPtrWillBeRawPtr<Node> relatedTarget); | 65 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail,
PassRefPtrWillBeRawPtr<Node> relatedTarget); |
65 | 66 |
66 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, const MouseEventInit&); | 67 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy
pe, const MouseEventInit&); |
67 | 68 |
68 virtual ~MouseEvent(); | 69 virtual ~MouseEvent(); |
69 | 70 |
70 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelabl
e, PassRefPtrWillBeRawPtr<AbstractView>, | 71 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelabl
e, PassRefPtrWillBeRawPtr<AbstractView>, |
71 int detail, int screenX, int screenY, int clientX, int clientY, | 72 int detail, int screenX, int screenY, int clientX, int clientY, |
72 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
73 unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget
); | 74 unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget
); |
74 | 75 |
75 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), | 76 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused
own/up, maybe others), |
76 // but we will match the standard DOM. | 77 // but we will match the standard DOM. |
77 unsigned short button() const { return m_button; } | 78 unsigned short button() const { return m_button; } |
78 bool buttonDown() const { return m_buttonDown; } | 79 bool buttonDown() const { return m_buttonDown; } |
79 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 80 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
80 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m
_relatedTarget = relatedTarget; } | 81 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m
_relatedTarget = relatedTarget; } |
81 | 82 |
82 Node* toElement() const; | 83 Node* toElement() const; |
83 Node* fromElement() const; | 84 Node* fromElement() const; |
84 | 85 |
85 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g
et() : 0; } | 86 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g
et() : 0; } |
86 | 87 |
| 88 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent::
FromTouch; } |
| 89 |
87 virtual const AtomicString& interfaceName() const OVERRIDE; | 90 virtual const AtomicString& interfaceName() const OVERRIDE; |
88 | 91 |
89 virtual bool isMouseEvent() const OVERRIDE; | 92 virtual bool isMouseEvent() const OVERRIDE; |
90 virtual bool isDragEvent() const OVERRIDE FINAL; | 93 virtual bool isDragEvent() const OVERRIDE FINAL; |
91 virtual int which() const OVERRIDE FINAL; | 94 virtual int which() const OVERRIDE FINAL; |
92 | 95 |
93 virtual void trace(Visitor*) OVERRIDE; | 96 virtual void trace(Visitor*) OVERRIDE; |
94 | 97 |
95 protected: | 98 protected: |
96 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe
fPtrWillBeRawPtr<AbstractView>, | 99 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe
fPtrWillBeRawPtr<AbstractView>, |
97 int detail, int screenX, int screenY, int pageX, int pageY, | 100 int detail, int screenX, int screenY, int pageX, int pageY, |
98 int movementX, int movementY, | 101 int movementX, int movementY, |
99 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b
utton, | 102 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b
utton, |
100 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt
r<DataTransfer>, bool isSimulated); | 103 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt
r<DataTransfer>, |
| 104 bool isSimulated, PlatformMouseEvent::SyntheticEventType); |
101 | 105 |
102 MouseEvent(const AtomicString& type, const MouseEventInit&); | 106 MouseEvent(const AtomicString& type, const MouseEventInit&); |
103 | 107 |
104 MouseEvent(); | 108 MouseEvent(); |
105 | 109 |
106 private: | 110 private: |
107 unsigned short m_button; | 111 unsigned short m_button; |
108 bool m_buttonDown; | 112 bool m_buttonDown; |
109 RefPtrWillBeMember<EventTarget> m_relatedTarget; | 113 RefPtrWillBeMember<EventTarget> m_relatedTarget; |
110 RefPtrWillBeMember<DataTransfer> m_dataTransfer; | 114 RefPtrWillBeMember<DataTransfer> m_dataTransfer; |
| 115 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; |
111 }; | 116 }; |
112 | 117 |
113 class SimulatedMouseEvent FINAL : public MouseEvent { | 118 class SimulatedMouseEvent FINAL : public MouseEvent { |
114 public: | 119 public: |
115 static PassRefPtrWillBeRawPtr<SimulatedMouseEvent> create(const AtomicString
& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event>
underlyingEvent); | 120 static PassRefPtrWillBeRawPtr<SimulatedMouseEvent> create(const AtomicString
& eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event>
underlyingEvent); |
116 virtual ~SimulatedMouseEvent(); | 121 virtual ~SimulatedMouseEvent(); |
117 | 122 |
118 virtual void trace(Visitor*) OVERRIDE; | 123 virtual void trace(Visitor*) OVERRIDE; |
119 | 124 |
120 private: | 125 private: |
(...skipping 12 matching lines...) Expand all Loading... |
133 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; | 138 virtual bool dispatchEvent(EventDispatcher*) const OVERRIDE; |
134 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou
seEvent; } | 139 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou
seEvent; } |
135 MouseEventType m_mouseEventType; | 140 MouseEventType m_mouseEventType; |
136 }; | 141 }; |
137 | 142 |
138 DEFINE_EVENT_TYPE_CASTS(MouseEvent); | 143 DEFINE_EVENT_TYPE_CASTS(MouseEvent); |
139 | 144 |
140 } // namespace blink | 145 } // namespace blink |
141 | 146 |
142 #endif // MouseEvent_h | 147 #endif // MouseEvent_h |
OLD | NEW |