Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: sky/engine/core/events/MouseEvent.h

Issue 870073003: Remove mouse events from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
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
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #ifndef SKY_ENGINE_CORE_EVENTS_MOUSEEVENT_H_
25 #define SKY_ENGINE_CORE_EVENTS_MOUSEEVENT_H_
26
27 #include "sky/engine/core/events/EventDispatchMediator.h"
28 #include "sky/engine/core/events/MouseRelatedEvent.h"
29 #include "sky/engine/platform/PlatformMouseEvent.h"
30
31 namespace blink {
32
33 class EventDispatcher;
34
35 struct MouseEventInit : public UIEventInit {
36 MouseEventInit();
37
38 int screenX;
39 int screenY;
40 int clientX;
41 int clientY;
42 bool ctrlKey;
43 bool altKey;
44 bool shiftKey;
45 bool metaKey;
46 unsigned short button;
47 RefPtr<EventTarget> relatedTarget;
48 };
49
50 class MouseEvent : public MouseRelatedEvent {
51 DEFINE_WRAPPERTYPEINFO();
52 public:
53 static PassRefPtr<MouseEvent> create()
54 {
55 return adoptRef(new MouseEvent);
56 }
57
58 static PassRefPtr<MouseEvent> create(const AtomicString& type, bool canBubbl e, bool cancelable, PassRefPtr<AbstractView>,
59 int detail, int screenX, int screenY, int pageX, int pageY,
60 int movementX, int movementY,
61 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton,
62 PassRefPtr<EventTarget> relatedTarget,
63 bool isSimulated = false, PlatformMouseEvent::SyntheticEventType = Platf ormMouseEvent::RealOrIndistinguishable);
64
65 static PassRefPtr<MouseEvent> create(const AtomicString& eventType, PassRefP tr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtr<Node> relate dTarget);
66
67 static PassRefPtr<MouseEvent> create(const AtomicString& eventType, const Mo useEventInit&);
68
69 virtual ~MouseEvent();
70
71 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelabl e, PassRefPtr<AbstractView>,
72 int detail, int screenX, int screenY, int clientX, int clientY,
73 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
74 unsigned short button, PassRefPtr<EventTarget> relatedTarget);
75
76 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused own/up, maybe others),
77 // but we will match the standard DOM.
78 unsigned short button() const { return m_button; }
79 bool buttonDown() const { return m_buttonDown; }
80 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
81 void setRelatedTarget(PassRefPtr<EventTarget> relatedTarget) { m_relatedTarg et = relatedTarget; }
82
83 Node* toElement() const;
84 Node* fromElement() const;
85
86 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent:: FromTouch; }
87
88 virtual const AtomicString& interfaceName() const override;
89
90 virtual bool isMouseEvent() const override;
91 virtual bool isDragEvent() const override final;
92 virtual int which() const override final;
93
94 protected:
95 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe fPtr<AbstractView>,
96 int detail, int screenX, int screenY, int pageX, int pageY,
97 int movementX, int movementY,
98 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton,
99 PassRefPtr<EventTarget> relatedTarget,
100 bool isSimulated, PlatformMouseEvent::SyntheticEventType);
101
102 MouseEvent(const AtomicString& type, const MouseEventInit&);
103
104 MouseEvent();
105
106 private:
107 unsigned short m_button;
108 bool m_buttonDown;
109 RefPtr<EventTarget> m_relatedTarget;
110 PlatformMouseEvent::SyntheticEventType m_syntheticEventType;
111 };
112
113 class SimulatedMouseEvent final : public MouseEvent {
114 public:
115 static PassRefPtr<SimulatedMouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
116 virtual ~SimulatedMouseEvent();
117
118 private:
119 SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
120 };
121
122 class MouseEventDispatchMediator final : public EventDispatchMediator {
123 public:
124 enum MouseEventType { SyntheticMouseEvent, NonSyntheticMouseEvent};
125 static PassRefPtr<MouseEventDispatchMediator> create(PassRefPtr<MouseEvent>, MouseEventType = NonSyntheticMouseEvent);
126
127 private:
128 explicit MouseEventDispatchMediator(PassRefPtr<MouseEvent>, MouseEventType);
129 MouseEvent* event() const;
130
131 virtual bool dispatchEvent(EventDispatcher*) const override;
132 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou seEvent; }
133 MouseEventType m_mouseEventType;
134 };
135
136 DEFINE_EVENT_TYPE_CASTS(MouseEvent);
137
138 } // namespace blink
139
140 #endif // SKY_ENGINE_CORE_EVENTS_MOUSEEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698