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

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

Issue 2234023002: Refactor WebInputEventAura to ui/events/blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
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"
9 #include "ui/events/base_event_utils.h" 8 #include "ui/events/base_event_utils.h"
9 #include "ui/events/blink/web_input_event.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 11
12 namespace { 12 namespace {
13 13
14 // We need to copy |os_event| in NativeWebKeyboardEvent because it is 14 // We need to copy |os_event| in NativeWebKeyboardEvent because it is
15 // queued in RenderWidgetHost and may be passed and used 15 // queued in RenderWidgetHost and may be passed and used
16 // RenderViewHostDelegate::HandledKeybardEvent after the original aura 16 // RenderViewHostDelegate::HandledKeybardEvent after the original aura
17 // event is destroyed. 17 // event is destroyed.
18 ui::Event* CopyEvent(const ui::Event* event) { 18 ui::Event* CopyEvent(const ui::Event* event) {
19 return event ? ui::Event::Clone(*event).release() : nullptr; 19 return event ? ui::Event::Clone(*event).release() : nullptr;
20 } 20 }
21 21
22 } // namespace 22 } // namespace
23 23
24 using blink::WebKeyboardEvent; 24 using blink::WebKeyboardEvent;
25 25
26 namespace content { 26 namespace content {
27 27
28 NativeWebKeyboardEvent::NativeWebKeyboardEvent() 28 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
29 : os_event(NULL), 29 : os_event(NULL),
30 skip_in_browser(false) { 30 skip_in_browser(false) {
31 } 31 }
32 32
33 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event) 33 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
34 : NativeWebKeyboardEvent(static_cast<ui::KeyEvent&>(*native_event)) { 34 : NativeWebKeyboardEvent(static_cast<ui::KeyEvent&>(*native_event)) {
35 } 35 }
36 36
37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event) 37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event)
38 : WebKeyboardEvent(MakeWebKeyboardEvent(key_event)), 38 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)),
39 os_event(CopyEvent(&key_event)), 39 os_event(CopyEvent(&key_event)),
40 skip_in_browser(false) { 40 skip_in_browser(false) {}
41 }
42 41
43 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 42 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
44 const NativeWebKeyboardEvent& other) 43 const NativeWebKeyboardEvent& other)
45 : WebKeyboardEvent(other), 44 : WebKeyboardEvent(other),
46 os_event(CopyEvent(other.os_event)), 45 os_event(CopyEvent(other.os_event)),
47 skip_in_browser(other.skip_in_browser) { 46 skip_in_browser(other.skip_in_browser) {
48 } 47 }
49 48
50 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event, 49 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event,
51 base::char16 character) 50 base::char16 character)
52 : WebKeyboardEvent(MakeWebKeyboardEvent(key_event)), 51 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)),
53 os_event(NULL), 52 os_event(NULL),
54 skip_in_browser(false) { 53 skip_in_browser(false) {
55 type = blink::WebInputEvent::Char; 54 type = blink::WebInputEvent::Char;
56 windowsKeyCode = character; 55 windowsKeyCode = character;
57 text[0] = character; 56 text[0] = character;
58 unmodifiedText[0] = character; 57 unmodifiedText[0] = character;
59 } 58 }
60 59
61 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( 60 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
62 const NativeWebKeyboardEvent& other) { 61 const NativeWebKeyboardEvent& other) {
63 WebKeyboardEvent::operator=(other); 62 WebKeyboardEvent::operator=(other);
64 delete os_event; 63 delete os_event;
65 os_event = CopyEvent(other.os_event); 64 os_event = CopyEvent(other.os_event);
66 skip_in_browser = other.skip_in_browser; 65 skip_in_browser = other.skip_in_browser;
67 return *this; 66 return *this;
68 } 67 }
69 68
70 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { 69 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
71 delete os_event; 70 delete os_event;
72 } 71 }
73 72
74 } // namespace content 73 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698