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

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

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 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 "ui/events/base_event_utils.h" 8 #include "ui/events/base_event_utils.h"
9 #include "ui/events/blink/web_input_event.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(blink::WebInputEvent::Type type,
29 : os_event(NULL), 29 int modifiers,
30 skip_in_browser(false) { 30 base::TimeTicks timestamp)
31 } 31 : NativeWebKeyboardEvent(type,
32 modifiers,
33 ui::EventTimeStampToSeconds(timestamp)) {}
34
35 NativeWebKeyboardEvent::NativeWebKeyboardEvent(blink::WebInputEvent::Type type,
36 int modifiers,
37 double timestampSeconds)
38 : WebKeyboardEvent(type, modifiers, timestampSeconds),
39 os_event(nullptr),
40 skip_in_browser(false) {}
32 41
33 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event) 42 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
34 : NativeWebKeyboardEvent(static_cast<ui::KeyEvent&>(*native_event)) { 43 : NativeWebKeyboardEvent(static_cast<ui::KeyEvent&>(*native_event)) {
35 } 44 }
36 45
37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event) 46 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event)
38 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)), 47 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)),
39 os_event(CopyEvent(&key_event)), 48 os_event(CopyEvent(&key_event)),
40 skip_in_browser(false) {} 49 skip_in_browser(false) {}
41 50
42 NativeWebKeyboardEvent::NativeWebKeyboardEvent( 51 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
43 const NativeWebKeyboardEvent& other) 52 const NativeWebKeyboardEvent& other)
44 : WebKeyboardEvent(other), 53 : WebKeyboardEvent(other),
45 os_event(CopyEvent(other.os_event)), 54 os_event(CopyEvent(other.os_event)),
46 skip_in_browser(other.skip_in_browser) { 55 skip_in_browser(other.skip_in_browser) {
47 } 56 }
48 57
49 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event, 58 NativeWebKeyboardEvent::NativeWebKeyboardEvent(const ui::KeyEvent& key_event,
50 base::char16 character) 59 base::char16 character)
51 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)), 60 : WebKeyboardEvent(ui::MakeWebKeyboardEvent(key_event)),
52 os_event(NULL), 61 os_event(nullptr),
53 skip_in_browser(false) { 62 skip_in_browser(false) {
54 type = blink::WebInputEvent::Char; 63 type = blink::WebInputEvent::Char;
55 windowsKeyCode = character; 64 windowsKeyCode = character;
56 text[0] = character; 65 text[0] = character;
57 unmodifiedText[0] = character; 66 unmodifiedText[0] = character;
58 } 67 }
59 68
60 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=( 69 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
61 const NativeWebKeyboardEvent& other) { 70 const NativeWebKeyboardEvent& other) {
62 WebKeyboardEvent::operator=(other); 71 WebKeyboardEvent::operator=(other);
63 delete os_event; 72 delete os_event;
64 os_event = CopyEvent(other.os_event); 73 os_event = CopyEvent(other.os_event);
65 skip_in_browser = other.skip_in_browser; 74 skip_in_browser = other.skip_in_browser;
66 return *this; 75 return *this;
67 } 76 }
68 77
69 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() { 78 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
70 delete os_event; 79 delete os_event;
71 } 80 }
72 81
73 } // namespace content 82 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698