IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / renderer_host / native_web_keyboard_event_gtk.cc
blob74ce6a36cbb1fc87ce3f829df54da4a1592fd8e1
1 // Copyright (c) 2011 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.
5 #include "content/public/browser/native_web_keyboard_event.h"
7 #include <gdk/gdk.h>
9 #include "content/browser/renderer_host/input/web_input_event_builders_gtk.h"
11 namespace {
13 void CopyEventTo(gfx::NativeEvent in, gfx::NativeEvent* out) {
14 *out = in ? gdk_event_copy(in) : NULL;
17 void FreeEvent(gfx::NativeEvent event) {
18 if (event)
19 gdk_event_free(event);
22 } // namespace
24 namespace content {
26 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
27 : os_event(NULL),
28 skip_in_browser(false),
29 match_edit_command(false) {
32 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
33 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(&native_event->key)),
34 skip_in_browser(false),
35 match_edit_command(false) {
36 CopyEventTo(native_event, &os_event);
39 NativeWebKeyboardEvent::NativeWebKeyboardEvent(wchar_t character,
40 int state,
41 double time_stamp_seconds)
42 : WebKeyboardEvent(WebKeyboardEventBuilder::Build(character,
43 state,
44 time_stamp_seconds)),
45 os_event(NULL),
46 skip_in_browser(false),
47 match_edit_command(false) {
50 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
51 const NativeWebKeyboardEvent& other)
52 : WebKeyboardEvent(other),
53 skip_in_browser(other.skip_in_browser),
54 match_edit_command(other.match_edit_command) {
55 CopyEventTo(other.os_event, &os_event);
58 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
59 const NativeWebKeyboardEvent& other) {
60 WebKeyboardEvent::operator=(other);
62 FreeEvent(os_event);
63 CopyEventTo(other.os_event, &os_event);
65 skip_in_browser = other.skip_in_browser;
66 match_edit_command = other.match_edit_command;
68 return *this;
71 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
72 FreeEvent(os_event);
75 } // namespace content