blob: 4755c60bf5cead6f519dc99daac022d7fcc5c68d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.Chromium file.
#include "content/public/browser/native_web_keyboard_event.h"
#include <QKeyEvent>
namespace {
// We need to copy |os_event| in NativeWebKeyboardEvent because it is
// queued in RenderWidgetHost and may be passed and used
// RenderViewHostDelegate::HandledKeybardEvent after the original aura
// event is destroyed.
gfx::NativeEvent CopyEvent(gfx::NativeEvent event)
{
if (!event)
return nullptr;
QKeyEvent *keyEvent = reinterpret_cast<QKeyEvent *>(event);
return reinterpret_cast<gfx::NativeEvent>(keyEvent->clone());
}
void DestroyEvent(gfx::NativeEvent event)
{
delete reinterpret_cast<QKeyEvent*>(event);
}
} // namespace
using blink::WebKeyboardEvent;
namespace content {
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const blink::WebKeyboardEvent &web_event, gfx::NativeView)
: WebKeyboardEvent(web_event)
, os_event(nullptr)
, skip_in_browser(false)
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(blink::WebInputEvent::Type type, int modifiers,
base::TimeTicks timestamp)
: WebKeyboardEvent(type, modifiers, timestamp)
, os_event(nullptr)
, skip_in_browser(false)
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
: os_event(CopyEvent(native_event))
, skip_in_browser(false)
{
}
NativeWebKeyboardEvent::NativeWebKeyboardEvent(const NativeWebKeyboardEvent& other)
: WebKeyboardEvent(other)
, os_event(CopyEvent(other.os_event))
, skip_in_browser(other.skip_in_browser)
{
}
NativeWebKeyboardEvent &NativeWebKeyboardEvent::operator=(const NativeWebKeyboardEvent &other)
{
if (this == &other)
return *this;
WebKeyboardEvent::operator=(other);
DestroyEvent(os_event);
os_event = CopyEvent(other.os_event);
skip_in_browser = other.skip_in_browser;
return *this;
}
NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
DestroyEvent(os_event);
}
} // namespace content
|