Skip to content

Commit 3647a8e

Browse files
committed
[OIPF] Add window.KeyEvent interface with VK keys mapping
1 parent e735e26 commit 3647a8e

10 files changed

Lines changed: 153 additions & 0 deletions

File tree

Source/WebCore/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,15 @@ if (USE_LIBWEBRTC)
22582258
)
22592259
endif ()
22602260

2261+
if (ENABLE_OIPF_VK)
2262+
list(APPEND WebCore_IDL_FILES
2263+
page/VkConsts.idl
2264+
)
2265+
list(APPEND WebCore_SOURCES
2266+
page/VkConsts.cpp
2267+
)
2268+
endif ()
2269+
22612270
# FIXME: This needs a more scalable solution. See webkit.org/b/267080 for some related discussion.
22622271
if (HAVE_OS_DARK_MODE_SUPPORT)
22632272
set(FEATURE_DEFINES_WITH_SPACE_SEPARATOR "${FEATURE_DEFINES_WITH_SPACE_SEPARATOR} HAVE_OS_DARK_MODE_SUPPORT")

Source/WebCore/page/DOMWindow.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#include <wtf/IsoMallocInlines.h>
4949
#include <wtf/NeverDestroyed.h>
5050

51+
#if ENABLE(OIPF_VK)
52+
#include "VkConsts.h"
53+
#endif
54+
5155
namespace WebCore {
5256

5357
WTF_MAKE_ISO_ALLOCATED_IMPL(DOMWindow);
@@ -527,6 +531,16 @@ void DOMWindow::blur()
527531
RELEASE_ASSERT_NOT_REACHED();
528532
}
529533

534+
#if ENABLE(OIPF_VK)
535+
ExceptionOr<RefPtr<VkConsts>> DOMWindow::keyEvent()
536+
{
537+
auto* localThis = dynamicDowncast<LocalDOMWindow>(*this);
538+
if (!localThis)
539+
return Exception { ExceptionCode::SecurityError };
540+
return localThis->keyEvent();
541+
}
542+
#endif
543+
530544
ExceptionOr<void> DOMWindow::print()
531545
{
532546
auto* localThis = dynamicDowncast<LocalDOMWindow>(*this);

Source/WebCore/page/DOMWindow.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ class WebKitNamespace;
7676
class WebKitPoint;
7777
class WindowProxy;
7878

79+
#if ENABLE(OIPF_VK)
80+
class VkConsts;
81+
#endif
82+
7983
#if ENABLE(DEVICE_ORIENTATION)
8084
class DeviceMotionController;
8185
class DeviceOrientationController;
@@ -130,6 +134,10 @@ class DOMWindow : public RefCounted<DOMWindow>, public EventTarget {
130134
void focus(LocalDOMWindow& incumbentWindow);
131135
void blur();
132136

137+
#if ENABLE(OIPF_VK)
138+
ExceptionOr<RefPtr<VkConsts>> keyEvent();
139+
#endif
140+
133141
ExceptionOr<AtomString> name() const;
134142
ExceptionOr<void> setName(const AtomString&);
135143
ExceptionOr<String> status() const;

Source/WebCore/page/DOMWindow.idl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
// Internal operations, not exposed to the Web.
121121
[EnabledForWorld=shadowRootIsAlwaysOpen] NodeList collectMatchingElementsInFlatTree(Node scope, DOMString selectors);
122122
[EnabledForWorld=shadowRootIsAlwaysOpen] Element? matchingElementInFlatTree(Node scope, DOMString selectors);
123+
124+
#if defined(ENABLE_OIPF_VK) && ENABLE_OIPF_VK
125+
readonly attribute VkConsts KeyEvent;
126+
#endif
123127
};
124128

125129
DOMWindow includes AnimationFrameProvider;

Source/WebCore/page/LocalDOMWindow.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
#include "PointerLockController.h"
161161
#endif
162162

163+
#if ENABLE(OIPF_VK)
164+
#include "VkConsts.h"
165+
#endif
166+
163167
namespace WebCore {
164168
using namespace Inspector;
165169

@@ -2782,4 +2786,16 @@ CookieStore& LocalDOMWindow::cookieStore()
27822786
return *m_cookieStore;
27832787
}
27842788

2789+
#if ENABLE(OIPF_VK)
2790+
RefPtr<VkConsts> LocalDOMWindow::keyEvent()
2791+
{
2792+
if (!isCurrentlyDisplayedInFrame())
2793+
return nullptr;
2794+
if (!m_keyEvent)
2795+
m_keyEvent = VkConsts::create(*this);
2796+
2797+
return m_keyEvent;
2798+
}
2799+
#endif
2800+
27852801
} // namespace WebCore

Source/WebCore/page/LocalDOMWindow.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class JSValue;
6161

6262
namespace WebCore {
6363

64+
#if ENABLE(OIPF_VK)
65+
class VkConsts;
66+
#endif
67+
6468
enum class IncludeTargetOrigin : bool { No, Yes };
6569

6670
class LocalDOMWindowObserver : public CanMakeWeakPtr<LocalDOMWindowObserver> {
@@ -363,6 +367,10 @@ class LocalDOMWindow final
363367

364368
CookieStore& cookieStore();
365369

370+
#if ENABLE(OIPF_VK)
371+
RefPtr<VkConsts> keyEvent();
372+
#endif
373+
366374
private:
367375
explicit LocalDOMWindow(Document&);
368376

@@ -412,6 +420,9 @@ class LocalDOMWindow final
412420
mutable RefPtr<BarProp> m_toolbar;
413421
mutable RefPtr<VisualViewport> m_visualViewport;
414422
mutable RefPtr<Navigation> m_navigation;
423+
#if ENABLE(OIPF_VK)
424+
mutable RefPtr<VkConsts> m_keyEvent;
425+
#endif
415426

416427
String m_status;
417428

Source/WebCore/page/VkConsts.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "VkConsts.h"
2+
3+
namespace WebCore {
4+
5+
VkConsts::VkConsts(LocalDOMWindow& window)
6+
: LocalDOMWindowProperty(&window)
7+
{
8+
}
9+
10+
} // namespace WebCore

Source/WebCore/page/VkConsts.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef VKCONSTS_H
2+
#define VKCONSTS_H
3+
4+
#include "config.h"
5+
#include "LocalDOMWindowProperty.h"
6+
#include <wtf/RefCounted.h>
7+
8+
namespace WebCore {
9+
10+
class VkConsts final : public RefCounted<VkConsts>, public LocalDOMWindowProperty {
11+
public:
12+
static Ref<VkConsts> create(LocalDOMWindow& window) { return adoptRef(*new VkConsts(window)); }
13+
14+
private:
15+
explicit VkConsts(LocalDOMWindow&);
16+
};
17+
} // namespace WebCore
18+
19+
#endif // VKCONSTS_H

Source/WebCore/page/VkConsts.idl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[
2+
Exposed=Window,
3+
DoNotCheckConstants
4+
] interface VkConsts {
5+
const long VK_ENTER = 13;
6+
const long VK_LEFT = 37;
7+
const long VK_UP = 38;
8+
const long VK_RIGHT = 39;
9+
const long VK_DOWN = 40;
10+
const long VK_SPACE = 32;
11+
const long VK_BACK_SPACE = 8;
12+
const long VK_0 = 48;
13+
const long VK_1 = 49;
14+
const long VK_2 = 50;
15+
const long VK_3 = 51;
16+
const long VK_4 = 52;
17+
const long VK_5 = 53;
18+
const long VK_6 = 54;
19+
const long VK_7 = 55;
20+
const long VK_8 = 56;
21+
const long VK_9 = 57;
22+
const long VK_A = 65;
23+
const long VK_B = 66;
24+
const long VK_C = 67;
25+
const long VK_D = 68;
26+
const long VK_E = 69;
27+
const long VK_F = 70;
28+
const long VK_G = 71;
29+
const long VK_H = 72;
30+
const long VK_I = 73;
31+
const long VK_J = 74;
32+
const long VK_K = 75;
33+
const long VK_L = 76;
34+
const long VK_M = 77;
35+
const long VK_N = 78;
36+
const long VK_O = 79;
37+
const long VK_P = 80;
38+
const long VK_Q = 81;
39+
const long VK_R = 82;
40+
const long VK_S = 83;
41+
const long VK_T = 84;
42+
const long VK_U = 85;
43+
const long VK_V = 86;
44+
const long VK_W = 87;
45+
const long VK_X = 88;
46+
const long VK_Y = 89;
47+
const long VK_Z = 90;
48+
const long VK_RED = 403;
49+
const long VK_GREEN = 404;
50+
const long VK_YELLOW = 405;
51+
const long VK_BLUE = 406;
52+
const long VK_HELP = 47;
53+
const long VK_PLAY = 250;
54+
const long VK_PAUSE = 19;
55+
const long VK_PLAY_PAUSE = 179;
56+
const long VK_STOP = 178;
57+
const long VK_FAST_FWD = 228;
58+
const long VK_REWIND = 227;
59+
const long VK_BACK = 27;
60+
const long VK_CONTEXT_MENU = 93;
61+
};

Source/cmake/OptionsWPE.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Sou
112112
# Private options specific to the WPE port.
113113
WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
114114
WEBKIT_OPTION_DEFINE(USE_ANGLE_GBM "Whether to enable ANGLE implementation with GBM" PRIVATE OFF)
115+
WEBKIT_OPTION_DEFINE(ENABLE_OIPF_VK "Whether to enable OIPF keys for DAE applications" PRIVATE OFF)
115116

116117
WEBKIT_OPTION_DEPEND(ENABLE_DOCUMENTATION ENABLE_INTROSPECTION)
117118

0 commit comments

Comments
 (0)