OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/views/event.h" | 5 #include "chrome/views/event.h" |
6 | 6 |
7 #include "chrome/views/view.h" | 7 #include "chrome/views/view.h" |
8 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | |
9 | |
10 using WebKit::WebInputEvent; | |
11 | 8 |
12 namespace views { | 9 namespace views { |
13 | 10 |
14 Event::Event(EventType type, int flags) | 11 Event::Event(EventType type, int flags) |
15 : type_(type), | 12 : type_(type), |
16 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
17 time_stamp_(GetTickCount()), | 14 time_stamp_(GetTickCount()), |
18 #else | 15 #else |
19 time_stamp_(0), | 16 time_stamp_(0), |
20 #endif | 17 #endif |
21 flags_(flags) { | 18 flags_(flags) { |
22 } | 19 } |
23 | 20 |
24 // static | |
25 int Event::ConvertWebInputEventFlags(int web_input_event_flags) { | |
26 int r = 0; | |
27 if (web_input_event_flags & WebInputEvent::ShiftKey) | |
28 r |= EF_SHIFT_DOWN; | |
29 if (web_input_event_flags & WebInputEvent::ControlKey) | |
30 r |= EF_CONTROL_DOWN; | |
31 if (web_input_event_flags & WebInputEvent::AltKey) | |
32 r |= EF_ALT_DOWN; | |
33 return r; | |
34 } | |
35 | |
36 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) | 21 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) |
37 : Event(model), | 22 : Event(model), |
38 location_(model.location_) { | 23 location_(model.location_) { |
39 if (to) | 24 if (to) |
40 View::ConvertPointToView(from, to, &location_); | 25 View::ConvertPointToView(from, to, &location_); |
41 } | 26 } |
42 | 27 |
43 MouseEvent::MouseEvent(EventType type, | 28 MouseEvent::MouseEvent(EventType type, |
44 View* from, | 29 View* from, |
45 View* to, | 30 View* to, |
46 const gfx::Point &l, | 31 const gfx::Point &l, |
47 int flags) | 32 int flags) |
48 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), | 33 : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags), |
49 from, | 34 from, |
50 to) { | 35 to) { |
51 }; | 36 }; |
52 | 37 |
53 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) | 38 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) |
54 : LocatedEvent(model, from, to) { | 39 : LocatedEvent(model, from, to) { |
55 } | 40 } |
56 | 41 |
57 } // namespace views | 42 } // namespace views |
OLD | NEW |