1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
4 * Copyright (C) 2011, 2012 Igalia S.L
5 * Copyright (C) 2018 Sony Interactive Entertainment Inc.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef NativeWebKeyboardEvent_h
30#define NativeWebKeyboardEvent_h
31
32#include "WebEvent.h"
33
34#if USE(APPKIT)
35#include <wtf/RetainPtr.h>
36OBJC_CLASS NSView;
37
38namespace WebCore {
39struct KeypressCommand;
40}
41#endif
42
43#if PLATFORM(GTK)
44#include "InputMethodFilter.h"
45#include <WebCore/CompositionResults.h>
46#include <WebCore/GUniquePtrGtk.h>
47typedef union _GdkEvent GdkEvent;
48#endif
49
50#if PLATFORM(IOS_FAMILY)
51#include <wtf/RetainPtr.h>
52OBJC_CLASS WebEvent;
53#endif
54
55#if USE(LIBWPE)
56struct wpe_input_keyboard_event;
57#endif
58
59#if PLATFORM(WIN)
60#include <windows.h>
61#endif
62
63namespace WebKit {
64
65class NativeWebKeyboardEvent : public WebKeyboardEvent {
66public:
67#if USE(APPKIT)
68 // FIXME: Share iOS's HandledByInputMethod enum here instead of passing a boolean.
69 NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&);
70#elif PLATFORM(GTK)
71 NativeWebKeyboardEvent(const NativeWebKeyboardEvent&);
72 NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands);
73#elif PLATFORM(IOS_FAMILY)
74 enum class HandledByInputMethod : bool { No, Yes };
75 NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod);
76#elif USE(LIBWPE)
77 NativeWebKeyboardEvent(struct wpe_input_keyboard_event*);
78#elif PLATFORM(WIN)
79 NativeWebKeyboardEvent(HWND, UINT message, WPARAM, LPARAM);
80#endif
81
82#if USE(APPKIT)
83 NSEvent *nativeEvent() const { return m_nativeEvent.get(); }
84#elif PLATFORM(GTK)
85 GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
86 const WebCore::CompositionResults& compositionResults() const { return m_compositionResults; }
87 bool isFakeEventForComposition() const { return m_fakeEventForComposition; }
88#elif PLATFORM(IOS_FAMILY)
89 ::WebEvent* nativeEvent() const { return m_nativeEvent.get(); }
90#elif PLATFORM(WIN)
91 const MSG* nativeEvent() const { return &m_nativeEvent; }
92#else
93 const void* nativeEvent() const { return nullptr; }
94#endif
95
96private:
97#if USE(APPKIT)
98 RetainPtr<NSEvent> m_nativeEvent;
99#elif PLATFORM(GTK)
100 GUniquePtr<GdkEvent> m_nativeEvent;
101 WebCore::CompositionResults m_compositionResults;
102 bool m_fakeEventForComposition;
103#elif PLATFORM(IOS_FAMILY)
104 RetainPtr<::WebEvent> m_nativeEvent;
105#elif PLATFORM(WIN)
106 MSG m_nativeEvent;
107#endif
108};
109
110} // namespace WebKit
111
112#endif // NativeWebKeyboardEvent_h
113