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

Side by Side Diff: chrome/common/native_web_keyboard_event_linux.cc

Issue 40065: RenderWidgetHost now stores both the WebKeyboardEvent and the native (Closed)
Patch Set: Redesign Created 11 years, 9 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 // 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 namespace {
8
9 void CopyEventTo(const GdkEventKey* in, GdkEventKey** out) {
10 if (in) {
11 *out = reinterpret_cast<GdkEventKey*>(
12 gdk_event_copy(
13 reinterpret_cast<GdkEvent*>(const_cast<GdkEventKey*>(in))));
14 } else {
15 *out = NULL;
16 }
17 }
18
19 void FreeEvent(GdkEventKey* event) {
20 if (event) {
21 gdk_event_free(reinterpret_cast<GdkEvent*>(event));
22 }
23 }
24
25 } // namespace
26
27
28 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
29 : event(NULL) {
30 }
31
32 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const GdkEventKey* native_event)
33 : WebKeyboardEvent(native_event) {
34 CopyEventTo(native_event, &event);
35 }
36
37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
38 const NativeWebKeyboardEvent& other) : WebKeyboardEvent(other) {
39 CopyEventTo(other.event, &event);
40 }
41
42 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
43 const NativeWebKeyboardEvent& other) {
44 WebKeyboardEvent::operator=(other);
45
46 FreeEvent(event);
47 CopyEventTo(other.event, &event);
48 return *this;
49 }
50
51 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
52 FreeEvent(event);
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698