Skip to content

Commit 61b6e2a

Browse files
magomezpgorszkowski-igalia
authored andcommitted
[OIPF] Add window.KeyEvent interface with VK keys mapping
1 parent fbb355f commit 61b6e2a

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
@@ -2256,6 +2256,15 @@ if (USE_LIBWEBRTC)
22562256
)
22572257
endif ()
22582258

2259+
if (ENABLE_OIPF_VK)
2260+
list(APPEND WebCore_IDL_FILES
2261+
page/VkConsts.idl
2262+
)
2263+
list(APPEND WebCore_SOURCES
2264+
page/VkConsts.cpp
2265+
)
2266+
endif ()
2267+
22592268
# FIXME: This needs a more scalable solution. See webkit.org/b/267080 for some related discussion.
22602269
if (HAVE_OS_DARK_MODE_SUPPORT)
22612270
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);
@@ -535,6 +539,16 @@ void DOMWindow::blur()
535539
RELEASE_ASSERT_NOT_REACHED();
536540
}
537541

542+
#if ENABLE(OIPF_VK)
543+
ExceptionOr<RefPtr<VkConsts>> DOMWindow::keyEvent()
544+
{
545+
auto* localThis = dynamicDowncast<LocalDOMWindow>(*this);
546+
if (!localThis)
547+
return Exception { ExceptionCode::SecurityError };
548+
return localThis->keyEvent();
549+
}
550+
#endif
551+
538552
ExceptionOr<void> DOMWindow::print()
539553
{
540554
auto* localThis = dynamicDowncast<LocalDOMWindow>(*this);

Source/WebCore/page/DOMWindow.h

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

80+
#if ENABLE(OIPF_VK)
81+
class VkConsts;
82+
#endif
83+
8084
#if ENABLE(DEVICE_ORIENTATION)
8185
class DeviceMotionController;
8286
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
@@ -122,6 +122,10 @@
122122
// Internal operations, not exposed to the Web.
123123
[EnabledForWorld=shadowRootIsAlwaysOpen] NodeList collectMatchingElementsInFlatTree(Node scope, DOMString selectors);
124124
[EnabledForWorld=shadowRootIsAlwaysOpen] Element? matchingElementInFlatTree(Node scope, DOMString selectors);
125+
126+
#if defined(ENABLE_OIPF_VK) && ENABLE_OIPF_VK
127+
readonly attribute VkConsts KeyEvent;
128+
#endif
125129
};
126130

127131
DOMWindow includes AnimationFrameProvider;

Source/WebCore/page/LocalDOMWindow.cpp

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

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

@@ -2789,4 +2793,16 @@ CookieStore& LocalDOMWindow::cookieStore()
27892793
return *m_cookieStore;
27902794
}
27912795

2796+
#if ENABLE(OIPF_VK)
2797+
RefPtr<VkConsts> LocalDOMWindow::keyEvent()
2798+
{
2799+
if (!isCurrentlyDisplayedInFrame())
2800+
return nullptr;
2801+
if (!m_keyEvent)
2802+
m_keyEvent = VkConsts::create(*this);
2803+
2804+
return m_keyEvent;
2805+
}
2806+
#endif
2807+
27922808
} // 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> {
@@ -366,6 +370,10 @@ class LocalDOMWindow final
366370

367371
CookieStore& cookieStore();
368372

373+
#if ENABLE(OIPF_VK)
374+
RefPtr<VkConsts> keyEvent();
375+
#endif
376+
369377
private:
370378
explicit LocalDOMWindow(Document&);
371379

@@ -415,6 +423,9 @@ class LocalDOMWindow final
415423
mutable RefPtr<BarProp> m_toolbar;
416424
mutable RefPtr<VisualViewport> m_visualViewport;
417425
mutable RefPtr<Navigation> m_navigation;
426+
#if ENABLE(OIPF_VK)
427+
mutable RefPtr<VkConsts> m_keyEvent;
428+
#endif
418429

419430
String m_status;
420431

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
@@ -103,6 +103,7 @@ WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Sou
103103
# Private options specific to the WPE port.
104104
WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
105105
WEBKIT_OPTION_DEFINE(USE_ANGLE_GBM "Whether to enable ANGLE implementation with GBM" PRIVATE OFF)
106+
WEBKIT_OPTION_DEFINE(ENABLE_OIPF_VK "Whether to enable OIPF keys for DAE applications" PRIVATE OFF)
106107

107108
WEBKIT_OPTION_DEPEND(ENABLE_DOCUMENTATION ENABLE_INTROSPECTION)
108109

0 commit comments

Comments
 (0)