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

Side by Side Diff: content/browser/renderer_host/native_web_keyboard_event_aura.cc

Issue 739993002: MacViews: Fix build errors related to NativeWebKeyboardEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for sadrul Created 6 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "content/public/browser/native_web_keyboard_event.h" 5 #include "content/public/browser/native_web_keyboard_event.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/web_input_event_aura.h" 8 #include "content/browser/renderer_host/web_input_event_aura.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 10
11 namespace { 11 namespace {
12 12
13 // We need to copy |os_event| in NativeWebKeyboardEvent because it is 13 // We need to copy |os_event| in NativeWebKeyboardEvent because it is
14 // queued in RenderWidgetHost and may be passed and used 14 // queued in RenderWidgetHost and may be passed and used
15 // RenderViewHostDelegate::HandledKeybardEvent after the original aura 15 // RenderViewHostDelegate::HandledKeybardEvent after the original aura
16 // event is destroyed. 16 // event is destroyed.
17 ui::Event* CopyEvent(ui::Event* event) { 17 ui::Event* CopyEvent(const ui::Event* event) {
18 return event ? new ui::KeyEvent(*static_cast<ui::KeyEvent*>(event)) : NULL; 18 return event ? new ui::KeyEvent(*static_cast<const ui::KeyEvent*>(event))
19 : NULL;
sadrul 2014/11/24 06:24:33 You can do: return event ? ui::Event::Clone(*eve
Andre 2014/11/25 03:26:57 Done.
19 } 20 }
20 21
21 int EventFlagsToWebInputEventModifiers(int flags) { 22 int EventFlagsToWebInputEventModifiers(int flags) {
22 return 23 return
23 (flags & ui::EF_SHIFT_DOWN ? blink::WebInputEvent::ShiftKey : 0) | 24 (flags & ui::EF_SHIFT_DOWN ? blink::WebInputEvent::ShiftKey : 0) |
24 (flags & ui::EF_CONTROL_DOWN ? blink::WebInputEvent::ControlKey : 0) | 25 (flags & ui::EF_CONTROL_DOWN ? blink::WebInputEvent::ControlKey : 0) |
25 (flags & ui::EF_CAPS_LOCK_DOWN ? blink::WebInputEvent::CapsLockOn : 0) | 26 (flags & ui::EF_CAPS_LOCK_DOWN ? blink::WebInputEvent::CapsLockOn : 0) |
26 (flags & ui::EF_ALT_DOWN ? blink::WebInputEvent::AltKey : 0); 27 (flags & ui::EF_ALT_DOWN ? blink::WebInputEvent::AltKey : 0);
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 using blink::WebKeyboardEvent; 32 using blink::WebKeyboardEvent;
32 33
33 namespace content { 34 namespace content {
34 35
35 NativeWebKeyboardEvent::NativeWebKeyboardEvent() 36 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
36 : os_event(NULL), 37 : os_event(NULL),
37 skip_in_browser(false), 38 skip_in_browser(false),
38 match_edit_command(false) { 39 match_edit_command(false) {
39 } 40 }
40 41
41 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event) 42 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
42 : WebKeyboardEvent(MakeWebKeyboardEvent( 43 : NativeWebKeyboardEvent(static_cast<ui::KeyEvent&>(*native_event)) {
43 static_cast<ui::KeyEvent*>(native_event))), 44 }
44 os_event(CopyEvent(native_event)), 45
46 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event)
47 : WebKeyboardEvent(MakeWebKeyboardEvent(&key_event)),
48 os_event(CopyEvent(&key_event)),
45 skip_in_browser(false), 49 skip_in_browser(false),
46 match_edit_command(false) { 50 match_edit_command(false) {
47 } 51 }
48 52
49 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 53 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
50 const NativeWebKeyboardEvent& other) 54 const NativeWebKeyboardEvent& other)
51 : WebKeyboardEvent(other), 55 : WebKeyboardEvent(other),
52 os_event(CopyEvent(other.os_event)), 56 os_event(CopyEvent(other.os_event)),
53 skip_in_browser(other.skip_in_browser), 57 skip_in_browser(other.skip_in_browser),
54 match_edit_command(false) { 58 match_edit_command(false) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 skip_in_browser = other.skip_in_browser; 98 skip_in_browser = other.skip_in_browser;
95 match_edit_command = other.match_edit_command; 99 match_edit_command = other.match_edit_command;
96 return *this; 100 return *this;
97 } 101 }
98 102
99 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { 103 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
100 delete os_event; 104 delete os_event;
101 } 105 }
102 106
103 } // namespace content 107 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.cc ('k') | content/browser/renderer_host/native_web_keyboard_event_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698