OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/common/native_web_keyboard_event.h" | |
6 | |
7 #include <gdk/gdk.h> | |
8 | |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" | |
10 | |
11 using WebKit::WebInputEventFactory; | |
12 | |
13 namespace { | |
14 | |
15 void CopyEventTo(const GdkEventKey* in, GdkEventKey** out) { | |
16 if (in) { | |
17 *out = reinterpret_cast<GdkEventKey*>( | |
18 gdk_event_copy( | |
19 reinterpret_cast<GdkEvent*>(const_cast<GdkEventKey*>(in)))); | |
20 } else { | |
21 *out = NULL; | |
22 } | |
23 } | |
24 | |
25 void FreeEvent(GdkEventKey* event) { | |
26 if (event) { | |
27 gdk_event_free(reinterpret_cast<GdkEvent*>(event)); | |
28 } | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 | |
34 NativeWebKeyboardEvent::NativeWebKeyboardEvent() | |
35 : os_event(NULL), | |
36 skip_in_browser(false), | |
37 match_edit_command(false) { | |
38 } | |
39 | |
40 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const GdkEventKey* native_event) | |
41 : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(native_event)), | |
42 skip_in_browser(false), | |
43 match_edit_command(false) { | |
44 CopyEventTo(native_event, &os_event); | |
45 } | |
46 | |
47 NativeWebKeyboardEvent::NativeWebKeyboardEvent(wchar_t character, | |
48 int state, | |
49 double time_stamp_seconds) | |
50 : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(character, | |
51 state, | |
52 time_stamp_seconds)), | |
53 os_event(NULL), | |
54 skip_in_browser(false), | |
55 match_edit_command(false) { | |
56 } | |
57 | |
58 NativeWebKeyboardEvent::NativeWebKeyboardEvent( | |
59 const NativeWebKeyboardEvent& other) | |
60 : WebKeyboardEvent(other), | |
61 skip_in_browser(other.skip_in_browser), | |
62 match_edit_command(other.match_edit_command) { | |
63 CopyEventTo(other.os_event, &os_event); | |
64 } | |
65 | |
66 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( | |
67 const NativeWebKeyboardEvent& other) { | |
68 WebKeyboardEvent::operator=(other); | |
69 | |
70 FreeEvent(os_event); | |
71 CopyEventTo(other.os_event, &os_event); | |
72 | |
73 skip_in_browser = other.skip_in_browser; | |
74 match_edit_command = other.match_edit_command; | |
75 | |
76 return *this; | |
77 } | |
78 | |
79 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { | |
80 FreeEvent(os_event); | |
81 } | |
OLD | NEW |