e9ab1fefe74d9734eac28416b09ef2310fcfc71b
[WebKit-https.git] / Source / WebKitLegacy / mac / DOM / DOMKeyboardEvent.mm
1 /*
2  * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "DOMKeyboardEvent.h"
27
28 #import "DOMAbstractViewInternal.h"
29 #import "DOMEventInternal.h"
30 #import "DOMNodeInternal.h"
31 #import <WebCore/DOMWindow.h>
32 #import "ExceptionHandlers.h"
33 #import <WebCore/JSMainThreadExecState.h>
34 #import <WebCore/KeyboardEvent.h>
35 #import <WebCore/ThreadCheck.h>
36 #import <WebCore/URL.h>
37 #import <WebCore/WebScriptObjectPrivate.h>
38 #import <wtf/GetPtr.h>
39
40 #define IMPL static_cast<WebCore::KeyboardEvent*>(reinterpret_cast<WebCore::Event*>(_internal))
41
42 @implementation DOMKeyboardEvent
43
44 - (NSString *)keyIdentifier
45 {
46     WebCore::JSMainThreadNullState state;
47     return IMPL->keyIdentifier();
48 }
49
50 - (unsigned)location
51 {
52     WebCore::JSMainThreadNullState state;
53     return IMPL->location();
54 }
55
56 - (unsigned)keyLocation
57 {
58     WebCore::JSMainThreadNullState state;
59     return IMPL->location();
60 }
61
62 - (BOOL)ctrlKey
63 {
64     WebCore::JSMainThreadNullState state;
65     return IMPL->ctrlKey();
66 }
67
68 - (BOOL)shiftKey
69 {
70     WebCore::JSMainThreadNullState state;
71     return IMPL->shiftKey();
72 }
73
74 - (BOOL)altKey
75 {
76     WebCore::JSMainThreadNullState state;
77     return IMPL->altKey();
78 }
79
80 - (BOOL)metaKey
81 {
82     WebCore::JSMainThreadNullState state;
83     return IMPL->metaKey();
84 }
85
86 - (BOOL)altGraphKey
87 {
88     WebCore::JSMainThreadNullState state;
89     return IMPL->altGraphKey();
90 }
91
92 - (int)keyCode
93 {
94     WebCore::JSMainThreadNullState state;
95     return IMPL->keyCode();
96 }
97
98 - (int)charCode
99 {
100     WebCore::JSMainThreadNullState state;
101     return IMPL->charCode();
102 }
103
104 - (BOOL)getModifierState:(NSString *)keyIdentifierArg
105 {
106     WebCore::JSMainThreadNullState state;
107     return IMPL->getModifierState(keyIdentifierArg);
108 }
109
110 - (void)initKeyboardEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view keyIdentifier:(NSString *)inKeyIdentifier location:(unsigned)inLocation ctrlKey:(BOOL)inCtrlKey altKey:(BOOL)inAltKey shiftKey:(BOOL)inShiftKey metaKey:(BOOL)inMetaKey altGraphKey:(BOOL)inAltGraphKey
111 {
112     WebCore::JSMainThreadNullState state;
113     IMPL->initKeyboardEvent(type, canBubble, cancelable, core(view), inKeyIdentifier, inLocation, inCtrlKey, inAltKey, inShiftKey, inMetaKey, inAltGraphKey);
114 }
115
116 - (void)initKeyboardEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view keyIdentifier:(NSString *)inKeyIdentifier location:(unsigned)inLocation ctrlKey:(BOOL)inCtrlKey altKey:(BOOL)inAltKey shiftKey:(BOOL)inShiftKey metaKey:(BOOL)inMetaKey
117 {
118     WebCore::JSMainThreadNullState state;
119     IMPL->initKeyboardEvent(type, canBubble, cancelable, core(view), inKeyIdentifier, inLocation, inCtrlKey, inAltKey, inShiftKey, inMetaKey);
120 }
121
122 - (void)initKeyboardEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view keyIdentifier:(NSString *)inKeyIdentifier keyLocation:(unsigned)inKeyLocation ctrlKey:(BOOL)inCtrlKey altKey:(BOOL)inAltKey shiftKey:(BOOL)inShiftKey metaKey:(BOOL)inMetaKey altGraphKey:(BOOL)inAltGraphKey
123 {
124     WebCore::JSMainThreadNullState state;
125     IMPL->initKeyboardEvent(type, canBubble, cancelable, core(view), inKeyIdentifier, inKeyLocation, inCtrlKey, inAltKey, inShiftKey, inMetaKey, inAltGraphKey);
126 }
127
128 - (void)initKeyboardEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view keyIdentifier:(NSString *)inKeyIdentifier keyLocation:(unsigned)inKeyLocation ctrlKey:(BOOL)inCtrlKey altKey:(BOOL)inAltKey shiftKey:(BOOL)inShiftKey metaKey:(BOOL)inMetaKey
129 {
130     WebCore::JSMainThreadNullState state;
131     IMPL->initKeyboardEvent(type, canBubble, cancelable, core(view), inKeyIdentifier, inKeyLocation, inCtrlKey, inAltKey, inShiftKey, inMetaKey);
132 }
133
134 @end