1 | /* |
2 | * Copyright (C) 2015-2018 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. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | #include "config.h" |
26 | #include "JSUIScriptController.h" |
27 | #include "UIScriptController.h" |
28 | #include <JavaScriptCore/JSRetainPtr.h> |
29 | #include <wtf/GetPtr.h> |
30 | |
31 | namespace WTR { |
32 | |
33 | UIScriptController* toUIScriptController(JSContextRef context, JSValueRef value) |
34 | { |
35 | if (!context || !value || !JSUIScriptController::uIScriptControllerClass() || !JSValueIsObjectOfClass(context, value, JSUIScriptController::uIScriptControllerClass())) |
36 | return 0; |
37 | return static_cast<UIScriptController*>(JSWrapper::unwrap(context, value)); |
38 | } |
39 | |
40 | JSClassRef JSUIScriptController::uIScriptControllerClass() |
41 | { |
42 | static JSClassRef jsClass; |
43 | if (!jsClass) { |
44 | JSClassDefinition definition = kJSClassDefinitionEmpty; |
45 | definition.className = "UIScriptController" ; |
46 | definition.parentClass = 0; |
47 | definition.staticValues = staticValues(); |
48 | definition.staticFunctions = staticFunctions(); |
49 | definition.initialize = initialize; |
50 | definition.finalize = finalize; |
51 | jsClass = JSClassCreate(&definition); |
52 | } |
53 | return jsClass; |
54 | } |
55 | |
56 | const JSStaticFunction* JSUIScriptController::staticFunctions() |
57 | { |
58 | static const JSStaticFunction functions[] = { |
59 | { "doAsyncTask" , doAsyncTask, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
60 | { "uiScriptComplete" , uiScriptComplete, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
61 | { "doAfterPresentationUpdate" , doAfterPresentationUpdate, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
62 | { "doAfterNextStablePresentationUpdate" , doAfterNextStablePresentationUpdate, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
63 | { "doAfterVisibleContentRectUpdate" , doAfterVisibleContentRectUpdate, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
64 | { "simulateAccessibilitySettingsChangeNotification" , simulateAccessibilitySettingsChangeNotification, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
65 | { "touchDownAtPoint" , touchDownAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
66 | { "liftUpAtPoint" , liftUpAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
67 | { "singleTapAtPoint" , singleTapAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
68 | { "singleTapAtPointWithModifiers" , singleTapAtPointWithModifiers, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
69 | { "doubleTapAtPoint" , doubleTapAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
70 | { "dragFromPointToPoint" , dragFromPointToPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
71 | { "longPressAtPoint" , longPressAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
72 | { "stylusDownAtPoint" , stylusDownAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
73 | { "stylusMoveToPoint" , stylusMoveToPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
74 | { "stylusUpAtPoint" , stylusUpAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
75 | { "stylusTapAtPoint" , stylusTapAtPoint, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
76 | { "stylusTapAtPointWithModifiers" , stylusTapAtPointWithModifiers, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
77 | { "enterText" , enterText, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
78 | { "typeCharacterUsingHardwareKeyboard" , typeCharacterUsingHardwareKeyboard, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
79 | { "keyDown" , keyDown, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
80 | { "toggleCapsLock" , toggleCapsLock, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
81 | { "sendEventStream" , sendEventStream, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
82 | { "beginBackSwipe" , beginBackSwipe, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
83 | { "completeBackSwipe" , completeBackSwipe, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
84 | { "playBackEventStream" , playBackEventStream, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
85 | { "dismissFormAccessoryView" , dismissFormAccessoryView, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
86 | { "dismissFilePicker" , dismissFilePicker, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
87 | { "selectFormAccessoryPickerRow" , selectFormAccessoryPickerRow, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
88 | { "setTimePickerValue" , setTimePickerValue, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
89 | { "setShareSheetCompletesImmediatelyWithResolution" , setShareSheetCompletesImmediatelyWithResolution, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
90 | { "keyboardAccessoryBarNext" , keyboardAccessoryBarNext, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
91 | { "keyboardAccessoryBarPrevious" , keyboardAccessoryBarPrevious, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
92 | { "applyAutocorrection" , applyAutocorrection, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
93 | { "contentsOfUserInterfaceItem" , contentsOfUserInterfaceItem, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
94 | { "rectForMenuAction" , rectForMenuAction, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
95 | { "zoomToScale" , zoomToScale, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
96 | { "setViewScale" , setViewScale, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
97 | { "setMinimumEffectiveWidth" , setMinimumEffectiveWidth, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
98 | { "setAllowsViewportShrinkToFit" , setAllowsViewportShrinkToFit, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
99 | { "resignFirstResponder" , resignFirstResponder, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
100 | { "scrollToOffset" , scrollToOffset, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
101 | { "immediateScrollToOffset" , immediateScrollToOffset, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
102 | { "immediateZoomToScale" , immediateZoomToScale, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
103 | { "immediateScrollElementAtContentPointToOffset" , immediateScrollElementAtContentPointToOffset, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
104 | { "setDefaultCalendarType" , setDefaultCalendarType, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
105 | { "setKeyboardInputModeIdentifier" , setKeyboardInputModeIdentifier, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
106 | { "replaceTextAtRange" , replaceTextAtRange, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
107 | { "removeAllDynamicDictionaries" , removeAllDynamicDictionaries, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
108 | { "propertiesOfLayerWithID" , propertiesOfLayerWithID, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
109 | { "retrieveSpeakSelectionContent" , retrieveSpeakSelectionContent, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
110 | { "simulateRotation" , simulateRotation, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
111 | { "simulateRotationLikeSafari" , simulateRotationLikeSafari, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
112 | { "findString" , findString, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
113 | { "removeViewFromWindow" , removeViewFromWindow, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
114 | { "addViewToWindow" , addViewToWindow, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
115 | { "overridePreference" , overridePreference, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
116 | { "setSafeAreaInsets" , setSafeAreaInsets, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
117 | { "firstResponderSuppressionForWebView" , firstResponderSuppressionForWebView, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
118 | { "makeWindowContentViewFirstResponder" , makeWindowContentViewFirstResponder, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
119 | { "setHardwareKeyboardAttached" , setHardwareKeyboardAttached, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
120 | { "attachmentInfo" , attachmentInfo, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
121 | { "drawSquareInEditableImage" , drawSquareInEditableImage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
122 | { 0, 0, 0 } |
123 | }; |
124 | return functions; |
125 | } |
126 | |
127 | const JSStaticValue* JSUIScriptController::staticValues() |
128 | { |
129 | static const JSStaticValue values[] = { |
130 | { "textContentType" , textContentType, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
131 | { "didStartFormControlInteractionCallback" , didStartFormControlInteractionCallback, setDidStartFormControlInteractionCallback, kJSPropertyAttributeDontDelete }, |
132 | { "didEndFormControlInteractionCallback" , didEndFormControlInteractionCallback, setDidEndFormControlInteractionCallback, kJSPropertyAttributeDontDelete }, |
133 | { "didShowForcePressPreviewCallback" , didShowForcePressPreviewCallback, setDidShowForcePressPreviewCallback, kJSPropertyAttributeDontDelete }, |
134 | { "didDismissForcePressPreviewCallback" , didDismissForcePressPreviewCallback, setDidDismissForcePressPreviewCallback, kJSPropertyAttributeDontDelete }, |
135 | { "selectFormPopoverTitle" , selectFormPopoverTitle, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
136 | { "formInputLabel" , formInputLabel, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
137 | { "isShowingDataListSuggestions" , isShowingDataListSuggestions, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
138 | { "didShowKeyboardCallback" , didShowKeyboardCallback, setDidShowKeyboardCallback, kJSPropertyAttributeDontDelete }, |
139 | { "didHideKeyboardCallback" , didHideKeyboardCallback, setDidHideKeyboardCallback, kJSPropertyAttributeDontDelete }, |
140 | { "isShowingKeyboard" , isShowingKeyboard, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
141 | { "didShowMenuCallback" , didShowMenuCallback, setDidShowMenuCallback, kJSPropertyAttributeDontDelete }, |
142 | { "didHideMenuCallback" , didHideMenuCallback, setDidHideMenuCallback, kJSPropertyAttributeDontDelete }, |
143 | { "isDismissingMenu" , isDismissingMenu, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
144 | { "isShowingMenu" , isShowingMenu, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
145 | { "menuRect" , menuRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
146 | { "isShowingPopover" , isShowingPopover, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
147 | { "willPresentPopoverCallback" , willPresentPopoverCallback, setWillPresentPopoverCallback, kJSPropertyAttributeDontDelete }, |
148 | { "didDismissPopoverCallback" , didDismissPopoverCallback, setDidDismissPopoverCallback, kJSPropertyAttributeDontDelete }, |
149 | { "willBeginZoomingCallback" , willBeginZoomingCallback, setWillBeginZoomingCallback, kJSPropertyAttributeDontDelete }, |
150 | { "didEndZoomingCallback" , didEndZoomingCallback, setDidEndZoomingCallback, kJSPropertyAttributeDontDelete }, |
151 | { "isPresentingModally" , isPresentingModally, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
152 | { "contentOffsetX" , contentOffsetX, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
153 | { "contentOffsetY" , contentOffsetY, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
154 | { "scrollUpdatesDisabled" , scrollUpdatesDisabled, setScrollUpdatesDisabled, kJSPropertyAttributeDontDelete }, |
155 | { "didEndScrollingCallback" , didEndScrollingCallback, setDidEndScrollingCallback, kJSPropertyAttributeDontDelete }, |
156 | { "zoomScale" , zoomScale, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
157 | { "minimumZoomScale" , minimumZoomScale, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
158 | { "maximumZoomScale" , maximumZoomScale, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
159 | { "stableStateOverride" , stableStateOverride, setStableStateOverride, kJSPropertyAttributeDontDelete }, |
160 | { "contentVisibleRect" , contentVisibleRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
161 | { "textSelectionRangeRects" , textSelectionRangeRects, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
162 | { "textSelectionCaretRect" , textSelectionCaretRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
163 | { "selectionStartGrabberViewRect" , selectionStartGrabberViewRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
164 | { "selectionEndGrabberViewRect" , selectionEndGrabberViewRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
165 | { "selectionCaretViewRect" , selectionCaretViewRect, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
166 | { "selectionRangeViewRects" , selectionRangeViewRects, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
167 | { "calendarType" , calendarType, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
168 | { "inputViewBounds" , inputViewBounds, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
169 | { "scrollingTreeAsText" , scrollingTreeAsText, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
170 | { "accessibilitySpeakSelectionContent" , accessibilitySpeakSelectionContent, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
171 | { "isWindowContentViewFirstResponder" , isWindowContentViewFirstResponder, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
172 | { "numberOfStrokesInEditableImage" , numberOfStrokesInEditableImage, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
173 | { "lastUndoLabel" , lastUndoLabel, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
174 | { "firstRedoLabel" , firstRedoLabel, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, |
175 | { 0, 0, 0, 0 } |
176 | }; |
177 | return values; |
178 | } |
179 | |
180 | // Functions |
181 | |
182 | JSValueRef JSUIScriptController::doAsyncTask(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
183 | { |
184 | UIScriptController* impl = toUIScriptController(context, thisObject); |
185 | if (!impl) |
186 | return JSValueMakeUndefined(context); |
187 | |
188 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
189 | impl->doAsyncTask(callback); |
190 | |
191 | return JSValueMakeUndefined(context); |
192 | } |
193 | |
194 | JSValueRef JSUIScriptController::uiScriptComplete(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
195 | { |
196 | UIScriptController* impl = toUIScriptController(context, thisObject); |
197 | if (!impl) |
198 | return JSValueMakeUndefined(context); |
199 | |
200 | JSRetainPtr<JSStringRef> result = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
201 | impl->uiScriptComplete(result.get()); |
202 | |
203 | return JSValueMakeUndefined(context); |
204 | } |
205 | |
206 | JSValueRef JSUIScriptController::doAfterPresentationUpdate(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
207 | { |
208 | UIScriptController* impl = toUIScriptController(context, thisObject); |
209 | if (!impl) |
210 | return JSValueMakeUndefined(context); |
211 | |
212 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
213 | impl->doAfterPresentationUpdate(callback); |
214 | |
215 | return JSValueMakeUndefined(context); |
216 | } |
217 | |
218 | JSValueRef JSUIScriptController::doAfterNextStablePresentationUpdate(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
219 | { |
220 | UIScriptController* impl = toUIScriptController(context, thisObject); |
221 | if (!impl) |
222 | return JSValueMakeUndefined(context); |
223 | |
224 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
225 | impl->doAfterNextStablePresentationUpdate(callback); |
226 | |
227 | return JSValueMakeUndefined(context); |
228 | } |
229 | |
230 | JSValueRef JSUIScriptController::doAfterVisibleContentRectUpdate(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
231 | { |
232 | UIScriptController* impl = toUIScriptController(context, thisObject); |
233 | if (!impl) |
234 | return JSValueMakeUndefined(context); |
235 | |
236 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
237 | impl->doAfterVisibleContentRectUpdate(callback); |
238 | |
239 | return JSValueMakeUndefined(context); |
240 | } |
241 | |
242 | JSValueRef JSUIScriptController::simulateAccessibilitySettingsChangeNotification(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
243 | { |
244 | UIScriptController* impl = toUIScriptController(context, thisObject); |
245 | if (!impl) |
246 | return JSValueMakeUndefined(context); |
247 | |
248 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
249 | impl->simulateAccessibilitySettingsChangeNotification(callback); |
250 | |
251 | return JSValueMakeUndefined(context); |
252 | } |
253 | |
254 | JSValueRef JSUIScriptController::touchDownAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
255 | { |
256 | UIScriptController* impl = toUIScriptController(context, thisObject); |
257 | if (!impl) |
258 | return JSValueMakeUndefined(context); |
259 | |
260 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
261 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
262 | double touchCount = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
263 | JSValueRef callback = argumentCount > 3 ? arguments[3] : JSValueMakeUndefined(context); |
264 | impl->touchDownAtPoint(x, y, touchCount, callback); |
265 | |
266 | return JSValueMakeUndefined(context); |
267 | } |
268 | |
269 | JSValueRef JSUIScriptController::liftUpAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
270 | { |
271 | UIScriptController* impl = toUIScriptController(context, thisObject); |
272 | if (!impl) |
273 | return JSValueMakeUndefined(context); |
274 | |
275 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
276 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
277 | double touchCount = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
278 | JSValueRef callback = argumentCount > 3 ? arguments[3] : JSValueMakeUndefined(context); |
279 | impl->liftUpAtPoint(x, y, touchCount, callback); |
280 | |
281 | return JSValueMakeUndefined(context); |
282 | } |
283 | |
284 | JSValueRef JSUIScriptController::singleTapAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
285 | { |
286 | UIScriptController* impl = toUIScriptController(context, thisObject); |
287 | if (!impl) |
288 | return JSValueMakeUndefined(context); |
289 | |
290 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
291 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
292 | JSValueRef callback = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
293 | impl->singleTapAtPoint(x, y, callback); |
294 | |
295 | return JSValueMakeUndefined(context); |
296 | } |
297 | |
298 | JSValueRef JSUIScriptController::singleTapAtPointWithModifiers(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
299 | { |
300 | UIScriptController* impl = toUIScriptController(context, thisObject); |
301 | if (!impl) |
302 | return JSValueMakeUndefined(context); |
303 | |
304 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
305 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
306 | JSValueRef modifierArray = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
307 | JSValueRef callback = argumentCount > 3 ? arguments[3] : JSValueMakeUndefined(context); |
308 | impl->singleTapAtPointWithModifiers(x, y, modifierArray, callback); |
309 | |
310 | return JSValueMakeUndefined(context); |
311 | } |
312 | |
313 | JSValueRef JSUIScriptController::doubleTapAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
314 | { |
315 | UIScriptController* impl = toUIScriptController(context, thisObject); |
316 | if (!impl) |
317 | return JSValueMakeUndefined(context); |
318 | |
319 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
320 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
321 | JSValueRef callback = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
322 | impl->doubleTapAtPoint(x, y, callback); |
323 | |
324 | return JSValueMakeUndefined(context); |
325 | } |
326 | |
327 | JSValueRef JSUIScriptController::dragFromPointToPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
328 | { |
329 | UIScriptController* impl = toUIScriptController(context, thisObject); |
330 | if (!impl) |
331 | return JSValueMakeUndefined(context); |
332 | |
333 | double startX = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
334 | double startY = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
335 | double endX = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
336 | double endY = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
337 | double durationSeconds = argumentCount > 4 ? JSValueToNumber(context, arguments[4], nullptr) : 0; |
338 | JSValueRef callback = argumentCount > 5 ? arguments[5] : JSValueMakeUndefined(context); |
339 | impl->dragFromPointToPoint(startX, startY, endX, endY, durationSeconds, callback); |
340 | |
341 | return JSValueMakeUndefined(context); |
342 | } |
343 | |
344 | JSValueRef JSUIScriptController::longPressAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
345 | { |
346 | UIScriptController* impl = toUIScriptController(context, thisObject); |
347 | if (!impl) |
348 | return JSValueMakeUndefined(context); |
349 | |
350 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
351 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
352 | JSValueRef callback = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
353 | impl->longPressAtPoint(x, y, callback); |
354 | |
355 | return JSValueMakeUndefined(context); |
356 | } |
357 | |
358 | JSValueRef JSUIScriptController::stylusDownAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
359 | { |
360 | UIScriptController* impl = toUIScriptController(context, thisObject); |
361 | if (!impl) |
362 | return JSValueMakeUndefined(context); |
363 | |
364 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
365 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
366 | double azimuthAngle = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
367 | double altitudeAngle = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
368 | double pressure = argumentCount > 4 ? JSValueToNumber(context, arguments[4], nullptr) : 0; |
369 | JSValueRef callback = argumentCount > 5 ? arguments[5] : JSValueMakeUndefined(context); |
370 | impl->stylusDownAtPoint(x, y, azimuthAngle, altitudeAngle, pressure, callback); |
371 | |
372 | return JSValueMakeUndefined(context); |
373 | } |
374 | |
375 | JSValueRef JSUIScriptController::stylusMoveToPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
376 | { |
377 | UIScriptController* impl = toUIScriptController(context, thisObject); |
378 | if (!impl) |
379 | return JSValueMakeUndefined(context); |
380 | |
381 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
382 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
383 | double azimuthAngle = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
384 | double altitudeAngle = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
385 | double pressure = argumentCount > 4 ? JSValueToNumber(context, arguments[4], nullptr) : 0; |
386 | JSValueRef callback = argumentCount > 5 ? arguments[5] : JSValueMakeUndefined(context); |
387 | impl->stylusMoveToPoint(x, y, azimuthAngle, altitudeAngle, pressure, callback); |
388 | |
389 | return JSValueMakeUndefined(context); |
390 | } |
391 | |
392 | JSValueRef JSUIScriptController::stylusUpAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
393 | { |
394 | UIScriptController* impl = toUIScriptController(context, thisObject); |
395 | if (!impl) |
396 | return JSValueMakeUndefined(context); |
397 | |
398 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
399 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
400 | JSValueRef callback = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
401 | impl->stylusUpAtPoint(x, y, callback); |
402 | |
403 | return JSValueMakeUndefined(context); |
404 | } |
405 | |
406 | JSValueRef JSUIScriptController::stylusTapAtPoint(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
407 | { |
408 | UIScriptController* impl = toUIScriptController(context, thisObject); |
409 | if (!impl) |
410 | return JSValueMakeUndefined(context); |
411 | |
412 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
413 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
414 | double azimuthAngle = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
415 | double altitudeAngle = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
416 | double pressure = argumentCount > 4 ? JSValueToNumber(context, arguments[4], nullptr) : 0; |
417 | JSValueRef callback = argumentCount > 5 ? arguments[5] : JSValueMakeUndefined(context); |
418 | impl->stylusTapAtPoint(x, y, azimuthAngle, altitudeAngle, pressure, callback); |
419 | |
420 | return JSValueMakeUndefined(context); |
421 | } |
422 | |
423 | JSValueRef JSUIScriptController::stylusTapAtPointWithModifiers(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
424 | { |
425 | UIScriptController* impl = toUIScriptController(context, thisObject); |
426 | if (!impl) |
427 | return JSValueMakeUndefined(context); |
428 | |
429 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
430 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
431 | double azimuthAngle = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
432 | double altitudeAngle = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
433 | double pressure = argumentCount > 4 ? JSValueToNumber(context, arguments[4], nullptr) : 0; |
434 | JSValueRef modifierArray = argumentCount > 5 ? arguments[5] : JSValueMakeUndefined(context); |
435 | JSValueRef callback = argumentCount > 6 ? arguments[6] : JSValueMakeUndefined(context); |
436 | impl->stylusTapAtPointWithModifiers(x, y, azimuthAngle, altitudeAngle, pressure, modifierArray, callback); |
437 | |
438 | return JSValueMakeUndefined(context); |
439 | } |
440 | |
441 | JSValueRef JSUIScriptController::enterText(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
442 | { |
443 | UIScriptController* impl = toUIScriptController(context, thisObject); |
444 | if (!impl) |
445 | return JSValueMakeUndefined(context); |
446 | |
447 | JSRetainPtr<JSStringRef> text = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
448 | impl->enterText(text.get()); |
449 | |
450 | return JSValueMakeUndefined(context); |
451 | } |
452 | |
453 | JSValueRef JSUIScriptController::typeCharacterUsingHardwareKeyboard(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
454 | { |
455 | UIScriptController* impl = toUIScriptController(context, thisObject); |
456 | if (!impl) |
457 | return JSValueMakeUndefined(context); |
458 | |
459 | JSRetainPtr<JSStringRef> character = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
460 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
461 | impl->typeCharacterUsingHardwareKeyboard(character.get(), callback); |
462 | |
463 | return JSValueMakeUndefined(context); |
464 | } |
465 | |
466 | JSValueRef JSUIScriptController::keyDown(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
467 | { |
468 | UIScriptController* impl = toUIScriptController(context, thisObject); |
469 | if (!impl) |
470 | return JSValueMakeUndefined(context); |
471 | |
472 | JSRetainPtr<JSStringRef> character = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
473 | JSValueRef modifierArray = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
474 | impl->keyDown(character.get(), modifierArray); |
475 | |
476 | return JSValueMakeUndefined(context); |
477 | } |
478 | |
479 | JSValueRef JSUIScriptController::toggleCapsLock(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
480 | { |
481 | UIScriptController* impl = toUIScriptController(context, thisObject); |
482 | if (!impl) |
483 | return JSValueMakeUndefined(context); |
484 | |
485 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
486 | impl->toggleCapsLock(callback); |
487 | |
488 | return JSValueMakeUndefined(context); |
489 | } |
490 | |
491 | JSValueRef JSUIScriptController::sendEventStream(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
492 | { |
493 | UIScriptController* impl = toUIScriptController(context, thisObject); |
494 | if (!impl) |
495 | return JSValueMakeUndefined(context); |
496 | |
497 | JSRetainPtr<JSStringRef> eventsJSON = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
498 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
499 | impl->sendEventStream(eventsJSON.get(), callback); |
500 | |
501 | return JSValueMakeUndefined(context); |
502 | } |
503 | |
504 | JSValueRef JSUIScriptController::beginBackSwipe(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
505 | { |
506 | UIScriptController* impl = toUIScriptController(context, thisObject); |
507 | if (!impl) |
508 | return JSValueMakeUndefined(context); |
509 | |
510 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
511 | impl->beginBackSwipe(callback); |
512 | |
513 | return JSValueMakeUndefined(context); |
514 | } |
515 | |
516 | JSValueRef JSUIScriptController::completeBackSwipe(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
517 | { |
518 | UIScriptController* impl = toUIScriptController(context, thisObject); |
519 | if (!impl) |
520 | return JSValueMakeUndefined(context); |
521 | |
522 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
523 | impl->completeBackSwipe(callback); |
524 | |
525 | return JSValueMakeUndefined(context); |
526 | } |
527 | |
528 | JSValueRef JSUIScriptController::playBackEventStream(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
529 | { |
530 | UIScriptController* impl = toUIScriptController(context, thisObject); |
531 | if (!impl) |
532 | return JSValueMakeUndefined(context); |
533 | |
534 | JSRetainPtr<JSStringRef> eventStream = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
535 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
536 | impl->playBackEventStream(eventStream.get(), callback); |
537 | |
538 | return JSValueMakeUndefined(context); |
539 | } |
540 | |
541 | JSValueRef JSUIScriptController::dismissFormAccessoryView(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
542 | { |
543 | UIScriptController* impl = toUIScriptController(context, thisObject); |
544 | if (!impl) |
545 | return JSValueMakeUndefined(context); |
546 | |
547 | impl->dismissFormAccessoryView(); |
548 | |
549 | return JSValueMakeUndefined(context); |
550 | } |
551 | |
552 | JSValueRef JSUIScriptController::dismissFilePicker(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
553 | { |
554 | UIScriptController* impl = toUIScriptController(context, thisObject); |
555 | if (!impl) |
556 | return JSValueMakeUndefined(context); |
557 | |
558 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
559 | impl->dismissFilePicker(callback); |
560 | |
561 | return JSValueMakeUndefined(context); |
562 | } |
563 | |
564 | JSValueRef JSUIScriptController::selectFormAccessoryPickerRow(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
565 | { |
566 | UIScriptController* impl = toUIScriptController(context, thisObject); |
567 | if (!impl) |
568 | return JSValueMakeUndefined(context); |
569 | |
570 | double rowIndex = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
571 | impl->selectFormAccessoryPickerRow(rowIndex); |
572 | |
573 | return JSValueMakeUndefined(context); |
574 | } |
575 | |
576 | JSValueRef JSUIScriptController::setTimePickerValue(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
577 | { |
578 | UIScriptController* impl = toUIScriptController(context, thisObject); |
579 | if (!impl) |
580 | return JSValueMakeUndefined(context); |
581 | |
582 | double hour = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
583 | double minute = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
584 | impl->setTimePickerValue(hour, minute); |
585 | |
586 | return JSValueMakeUndefined(context); |
587 | } |
588 | |
589 | JSValueRef JSUIScriptController::setShareSheetCompletesImmediatelyWithResolution(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
590 | { |
591 | UIScriptController* impl = toUIScriptController(context, thisObject); |
592 | if (!impl) |
593 | return JSValueMakeUndefined(context); |
594 | |
595 | bool resolved = argumentCount > 0 && JSValueToBoolean(context, arguments[0]); |
596 | impl->setShareSheetCompletesImmediatelyWithResolution(resolved); |
597 | |
598 | return JSValueMakeUndefined(context); |
599 | } |
600 | |
601 | JSValueRef JSUIScriptController::keyboardAccessoryBarNext(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
602 | { |
603 | UIScriptController* impl = toUIScriptController(context, thisObject); |
604 | if (!impl) |
605 | return JSValueMakeUndefined(context); |
606 | |
607 | impl->keyboardAccessoryBarNext(); |
608 | |
609 | return JSValueMakeUndefined(context); |
610 | } |
611 | |
612 | JSValueRef JSUIScriptController::keyboardAccessoryBarPrevious(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
613 | { |
614 | UIScriptController* impl = toUIScriptController(context, thisObject); |
615 | if (!impl) |
616 | return JSValueMakeUndefined(context); |
617 | |
618 | impl->keyboardAccessoryBarPrevious(); |
619 | |
620 | return JSValueMakeUndefined(context); |
621 | } |
622 | |
623 | JSValueRef JSUIScriptController::applyAutocorrection(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
624 | { |
625 | UIScriptController* impl = toUIScriptController(context, thisObject); |
626 | if (!impl) |
627 | return JSValueMakeUndefined(context); |
628 | |
629 | JSRetainPtr<JSStringRef> newString = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
630 | JSRetainPtr<JSStringRef> oldString = argumentCount > 1 ? adopt(JSValueToStringCopy(context, arguments[1], nullptr)) : JSRetainPtr<JSStringRef>(); |
631 | JSValueRef callback = argumentCount > 2 ? arguments[2] : JSValueMakeUndefined(context); |
632 | impl->applyAutocorrection(newString.get(), oldString.get(), callback); |
633 | |
634 | return JSValueMakeUndefined(context); |
635 | } |
636 | |
637 | JSValueRef JSUIScriptController::contentsOfUserInterfaceItem(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
638 | { |
639 | UIScriptController* impl = toUIScriptController(context, thisObject); |
640 | if (!impl) |
641 | return JSValueMakeUndefined(context); |
642 | |
643 | JSRetainPtr<JSStringRef> interfaceItem = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
644 | return impl->contentsOfUserInterfaceItem(interfaceItem.get()); |
645 | } |
646 | |
647 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
648 | { |
649 | UIScriptController* impl = toUIScriptController(context, thisObject); |
650 | if (!impl) |
651 | return JSValueMakeUndefined(context); |
652 | |
653 | JSRetainPtr<JSStringRef> action = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
654 | return impl->rectForMenuAction(action.get()); |
655 | } |
656 | |
657 | JSValueRef JSUIScriptController::zoomToScale(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
658 | { |
659 | UIScriptController* impl = toUIScriptController(context, thisObject); |
660 | if (!impl) |
661 | return JSValueMakeUndefined(context); |
662 | |
663 | double scale = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
664 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
665 | impl->zoomToScale(scale, callback); |
666 | |
667 | return JSValueMakeUndefined(context); |
668 | } |
669 | |
670 | JSValueRef JSUIScriptController::setViewScale(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
671 | { |
672 | UIScriptController* impl = toUIScriptController(context, thisObject); |
673 | if (!impl) |
674 | return JSValueMakeUndefined(context); |
675 | |
676 | double scale = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
677 | impl->setViewScale(scale); |
678 | |
679 | return JSValueMakeUndefined(context); |
680 | } |
681 | |
682 | JSValueRef JSUIScriptController::setMinimumEffectiveWidth(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
683 | { |
684 | UIScriptController* impl = toUIScriptController(context, thisObject); |
685 | if (!impl) |
686 | return JSValueMakeUndefined(context); |
687 | |
688 | double effectiveWidth = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
689 | impl->setMinimumEffectiveWidth(effectiveWidth); |
690 | |
691 | return JSValueMakeUndefined(context); |
692 | } |
693 | |
694 | JSValueRef JSUIScriptController::setAllowsViewportShrinkToFit(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
695 | { |
696 | UIScriptController* impl = toUIScriptController(context, thisObject); |
697 | if (!impl) |
698 | return JSValueMakeUndefined(context); |
699 | |
700 | bool allows = argumentCount > 0 && JSValueToBoolean(context, arguments[0]); |
701 | impl->setAllowsViewportShrinkToFit(allows); |
702 | |
703 | return JSValueMakeUndefined(context); |
704 | } |
705 | |
706 | JSValueRef JSUIScriptController::resignFirstResponder(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
707 | { |
708 | UIScriptController* impl = toUIScriptController(context, thisObject); |
709 | if (!impl) |
710 | return JSValueMakeUndefined(context); |
711 | |
712 | impl->resignFirstResponder(); |
713 | |
714 | return JSValueMakeUndefined(context); |
715 | } |
716 | |
717 | JSValueRef JSUIScriptController::scrollToOffset(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
718 | { |
719 | UIScriptController* impl = toUIScriptController(context, thisObject); |
720 | if (!impl) |
721 | return JSValueMakeUndefined(context); |
722 | |
723 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
724 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
725 | impl->scrollToOffset(x, y); |
726 | |
727 | return JSValueMakeUndefined(context); |
728 | } |
729 | |
730 | JSValueRef JSUIScriptController::immediateScrollToOffset(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
731 | { |
732 | UIScriptController* impl = toUIScriptController(context, thisObject); |
733 | if (!impl) |
734 | return JSValueMakeUndefined(context); |
735 | |
736 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
737 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
738 | impl->immediateScrollToOffset(x, y); |
739 | |
740 | return JSValueMakeUndefined(context); |
741 | } |
742 | |
743 | JSValueRef JSUIScriptController::immediateZoomToScale(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
744 | { |
745 | UIScriptController* impl = toUIScriptController(context, thisObject); |
746 | if (!impl) |
747 | return JSValueMakeUndefined(context); |
748 | |
749 | double scale = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
750 | impl->immediateZoomToScale(scale); |
751 | |
752 | return JSValueMakeUndefined(context); |
753 | } |
754 | |
755 | JSValueRef JSUIScriptController::immediateScrollElementAtContentPointToOffset(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
756 | { |
757 | UIScriptController* impl = toUIScriptController(context, thisObject); |
758 | if (!impl) |
759 | return JSValueMakeUndefined(context); |
760 | |
761 | double x = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
762 | double y = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
763 | double xOffset = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
764 | double yOffset = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
765 | impl->immediateScrollElementAtContentPointToOffset(x, y, xOffset, yOffset); |
766 | |
767 | return JSValueMakeUndefined(context); |
768 | } |
769 | |
770 | JSValueRef JSUIScriptController::setDefaultCalendarType(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
771 | { |
772 | UIScriptController* impl = toUIScriptController(context, thisObject); |
773 | if (!impl) |
774 | return JSValueMakeUndefined(context); |
775 | |
776 | JSRetainPtr<JSStringRef> calendarIdentifier = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
777 | impl->setDefaultCalendarType(calendarIdentifier.get()); |
778 | |
779 | return JSValueMakeUndefined(context); |
780 | } |
781 | |
782 | JSValueRef JSUIScriptController::setKeyboardInputModeIdentifier(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
783 | { |
784 | UIScriptController* impl = toUIScriptController(context, thisObject); |
785 | if (!impl) |
786 | return JSValueMakeUndefined(context); |
787 | |
788 | JSRetainPtr<JSStringRef> identifier = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
789 | impl->setKeyboardInputModeIdentifier(identifier.get()); |
790 | |
791 | return JSValueMakeUndefined(context); |
792 | } |
793 | |
794 | JSValueRef JSUIScriptController::replaceTextAtRange(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
795 | { |
796 | UIScriptController* impl = toUIScriptController(context, thisObject); |
797 | if (!impl) |
798 | return JSValueMakeUndefined(context); |
799 | |
800 | JSRetainPtr<JSStringRef> text = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
801 | double location = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
802 | double length = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
803 | impl->replaceTextAtRange(text.get(), location, length); |
804 | |
805 | return JSValueMakeUndefined(context); |
806 | } |
807 | |
808 | JSValueRef JSUIScriptController::removeAllDynamicDictionaries(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
809 | { |
810 | UIScriptController* impl = toUIScriptController(context, thisObject); |
811 | if (!impl) |
812 | return JSValueMakeUndefined(context); |
813 | |
814 | impl->removeAllDynamicDictionaries(); |
815 | |
816 | return JSValueMakeUndefined(context); |
817 | } |
818 | |
819 | JSValueRef JSUIScriptController::propertiesOfLayerWithID(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
820 | { |
821 | UIScriptController* impl = toUIScriptController(context, thisObject); |
822 | if (!impl) |
823 | return JSValueMakeUndefined(context); |
824 | |
825 | double layerID = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
826 | return impl->propertiesOfLayerWithID(layerID); |
827 | } |
828 | |
829 | JSValueRef JSUIScriptController::retrieveSpeakSelectionContent(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
830 | { |
831 | UIScriptController* impl = toUIScriptController(context, thisObject); |
832 | if (!impl) |
833 | return JSValueMakeUndefined(context); |
834 | |
835 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
836 | impl->retrieveSpeakSelectionContent(callback); |
837 | |
838 | return JSValueMakeUndefined(context); |
839 | } |
840 | |
841 | JSValueRef JSUIScriptController::simulateRotation(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
842 | { |
843 | UIScriptController* impl = toUIScriptController(context, thisObject); |
844 | if (!impl) |
845 | return JSValueMakeUndefined(context); |
846 | |
847 | DeviceOrientation* orientation = argumentCount > 0 ? toDeviceOrientation(context, arguments[0]) : 0; |
848 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
849 | impl->simulateRotation(orientation, callback); |
850 | |
851 | return JSValueMakeUndefined(context); |
852 | } |
853 | |
854 | JSValueRef JSUIScriptController::simulateRotationLikeSafari(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
855 | { |
856 | UIScriptController* impl = toUIScriptController(context, thisObject); |
857 | if (!impl) |
858 | return JSValueMakeUndefined(context); |
859 | |
860 | DeviceOrientation* orientation = argumentCount > 0 ? toDeviceOrientation(context, arguments[0]) : 0; |
861 | JSValueRef callback = argumentCount > 1 ? arguments[1] : JSValueMakeUndefined(context); |
862 | impl->simulateRotationLikeSafari(orientation, callback); |
863 | |
864 | return JSValueMakeUndefined(context); |
865 | } |
866 | |
867 | JSValueRef JSUIScriptController::findString(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
868 | { |
869 | UIScriptController* impl = toUIScriptController(context, thisObject); |
870 | if (!impl) |
871 | return JSValueMakeUndefined(context); |
872 | |
873 | JSRetainPtr<JSStringRef> string = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
874 | double options = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
875 | double maxCount = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
876 | impl->findString(string.get(), options, maxCount); |
877 | |
878 | return JSValueMakeUndefined(context); |
879 | } |
880 | |
881 | JSValueRef JSUIScriptController::removeViewFromWindow(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
882 | { |
883 | UIScriptController* impl = toUIScriptController(context, thisObject); |
884 | if (!impl) |
885 | return JSValueMakeUndefined(context); |
886 | |
887 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
888 | impl->removeViewFromWindow(callback); |
889 | |
890 | return JSValueMakeUndefined(context); |
891 | } |
892 | |
893 | JSValueRef JSUIScriptController::addViewToWindow(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
894 | { |
895 | UIScriptController* impl = toUIScriptController(context, thisObject); |
896 | if (!impl) |
897 | return JSValueMakeUndefined(context); |
898 | |
899 | JSValueRef callback = argumentCount > 0 ? arguments[0] : JSValueMakeUndefined(context); |
900 | impl->addViewToWindow(callback); |
901 | |
902 | return JSValueMakeUndefined(context); |
903 | } |
904 | |
905 | JSValueRef JSUIScriptController::overridePreference(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
906 | { |
907 | UIScriptController* impl = toUIScriptController(context, thisObject); |
908 | if (!impl) |
909 | return JSValueMakeUndefined(context); |
910 | |
911 | JSRetainPtr<JSStringRef> preference = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
912 | JSRetainPtr<JSStringRef> value = argumentCount > 1 ? adopt(JSValueToStringCopy(context, arguments[1], nullptr)) : JSRetainPtr<JSStringRef>(); |
913 | impl->overridePreference(preference.get(), value.get()); |
914 | |
915 | return JSValueMakeUndefined(context); |
916 | } |
917 | |
918 | JSValueRef JSUIScriptController::setSafeAreaInsets(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
919 | { |
920 | UIScriptController* impl = toUIScriptController(context, thisObject); |
921 | if (!impl) |
922 | return JSValueMakeUndefined(context); |
923 | |
924 | double top = argumentCount > 0 ? JSValueToNumber(context, arguments[0], nullptr) : 0; |
925 | double right = argumentCount > 1 ? JSValueToNumber(context, arguments[1], nullptr) : 0; |
926 | double bottom = argumentCount > 2 ? JSValueToNumber(context, arguments[2], nullptr) : 0; |
927 | double left = argumentCount > 3 ? JSValueToNumber(context, arguments[3], nullptr) : 0; |
928 | impl->setSafeAreaInsets(top, right, bottom, left); |
929 | |
930 | return JSValueMakeUndefined(context); |
931 | } |
932 | |
933 | JSValueRef JSUIScriptController::firstResponderSuppressionForWebView(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
934 | { |
935 | UIScriptController* impl = toUIScriptController(context, thisObject); |
936 | if (!impl) |
937 | return JSValueMakeUndefined(context); |
938 | |
939 | bool shouldSuppress = argumentCount > 0 && JSValueToBoolean(context, arguments[0]); |
940 | impl->firstResponderSuppressionForWebView(shouldSuppress); |
941 | |
942 | return JSValueMakeUndefined(context); |
943 | } |
944 | |
945 | JSValueRef JSUIScriptController::makeWindowContentViewFirstResponder(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
946 | { |
947 | UIScriptController* impl = toUIScriptController(context, thisObject); |
948 | if (!impl) |
949 | return JSValueMakeUndefined(context); |
950 | |
951 | impl->makeWindowContentViewFirstResponder(); |
952 | |
953 | return JSValueMakeUndefined(context); |
954 | } |
955 | |
956 | JSValueRef JSUIScriptController::setHardwareKeyboardAttached(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
957 | { |
958 | UIScriptController* impl = toUIScriptController(context, thisObject); |
959 | if (!impl) |
960 | return JSValueMakeUndefined(context); |
961 | |
962 | bool attached = argumentCount > 0 && JSValueToBoolean(context, arguments[0]); |
963 | impl->setHardwareKeyboardAttached(attached); |
964 | |
965 | return JSValueMakeUndefined(context); |
966 | } |
967 | |
968 | JSValueRef JSUIScriptController::attachmentInfo(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
969 | { |
970 | UIScriptController* impl = toUIScriptController(context, thisObject); |
971 | if (!impl) |
972 | return JSValueMakeUndefined(context); |
973 | |
974 | JSRetainPtr<JSStringRef> attachmentIdentifier = argumentCount > 0 ? adopt(JSValueToStringCopy(context, arguments[0], nullptr)) : JSRetainPtr<JSStringRef>(); |
975 | return impl->attachmentInfo(attachmentIdentifier.get()); |
976 | } |
977 | |
978 | JSValueRef JSUIScriptController::drawSquareInEditableImage(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) |
979 | { |
980 | UIScriptController* impl = toUIScriptController(context, thisObject); |
981 | if (!impl) |
982 | return JSValueMakeUndefined(context); |
983 | |
984 | impl->drawSquareInEditableImage(); |
985 | |
986 | return JSValueMakeUndefined(context); |
987 | } |
988 | |
989 | // Attributes |
990 | |
991 | JSValueRef JSUIScriptController::textContentType(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
992 | { |
993 | UIScriptController* impl = toUIScriptController(context, object); |
994 | if (!impl) |
995 | return JSValueMakeUndefined(context); |
996 | |
997 | return JSValueMakeStringOrNull(context, impl->textContentType().get()); |
998 | } |
999 | |
1000 | JSValueRef JSUIScriptController::didStartFormControlInteractionCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1001 | { |
1002 | UIScriptController* impl = toUIScriptController(context, object); |
1003 | if (!impl) |
1004 | return JSValueMakeUndefined(context); |
1005 | |
1006 | return impl->didStartFormControlInteractionCallback(); |
1007 | } |
1008 | |
1009 | bool JSUIScriptController::setDidStartFormControlInteractionCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1010 | { |
1011 | UIScriptController* impl = toUIScriptController(context, object); |
1012 | if (!impl) |
1013 | return false; |
1014 | |
1015 | impl->setDidStartFormControlInteractionCallback(value); |
1016 | |
1017 | return true; |
1018 | } |
1019 | |
1020 | JSValueRef JSUIScriptController::didEndFormControlInteractionCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1021 | { |
1022 | UIScriptController* impl = toUIScriptController(context, object); |
1023 | if (!impl) |
1024 | return JSValueMakeUndefined(context); |
1025 | |
1026 | return impl->didEndFormControlInteractionCallback(); |
1027 | } |
1028 | |
1029 | bool JSUIScriptController::setDidEndFormControlInteractionCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1030 | { |
1031 | UIScriptController* impl = toUIScriptController(context, object); |
1032 | if (!impl) |
1033 | return false; |
1034 | |
1035 | impl->setDidEndFormControlInteractionCallback(value); |
1036 | |
1037 | return true; |
1038 | } |
1039 | |
1040 | JSValueRef JSUIScriptController::didShowForcePressPreviewCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1041 | { |
1042 | UIScriptController* impl = toUIScriptController(context, object); |
1043 | if (!impl) |
1044 | return JSValueMakeUndefined(context); |
1045 | |
1046 | return impl->didShowForcePressPreviewCallback(); |
1047 | } |
1048 | |
1049 | bool JSUIScriptController::setDidShowForcePressPreviewCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1050 | { |
1051 | UIScriptController* impl = toUIScriptController(context, object); |
1052 | if (!impl) |
1053 | return false; |
1054 | |
1055 | impl->setDidShowForcePressPreviewCallback(value); |
1056 | |
1057 | return true; |
1058 | } |
1059 | |
1060 | JSValueRef JSUIScriptController::didDismissForcePressPreviewCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1061 | { |
1062 | UIScriptController* impl = toUIScriptController(context, object); |
1063 | if (!impl) |
1064 | return JSValueMakeUndefined(context); |
1065 | |
1066 | return impl->didDismissForcePressPreviewCallback(); |
1067 | } |
1068 | |
1069 | bool JSUIScriptController::setDidDismissForcePressPreviewCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1070 | { |
1071 | UIScriptController* impl = toUIScriptController(context, object); |
1072 | if (!impl) |
1073 | return false; |
1074 | |
1075 | impl->setDidDismissForcePressPreviewCallback(value); |
1076 | |
1077 | return true; |
1078 | } |
1079 | |
1080 | JSValueRef JSUIScriptController::selectFormPopoverTitle(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1081 | { |
1082 | UIScriptController* impl = toUIScriptController(context, object); |
1083 | if (!impl) |
1084 | return JSValueMakeUndefined(context); |
1085 | |
1086 | return JSValueMakeStringOrNull(context, impl->selectFormPopoverTitle().get()); |
1087 | } |
1088 | |
1089 | JSValueRef JSUIScriptController::formInputLabel(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1090 | { |
1091 | UIScriptController* impl = toUIScriptController(context, object); |
1092 | if (!impl) |
1093 | return JSValueMakeUndefined(context); |
1094 | |
1095 | return JSValueMakeStringOrNull(context, impl->formInputLabel().get()); |
1096 | } |
1097 | |
1098 | JSValueRef JSUIScriptController::isShowingDataListSuggestions(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1099 | { |
1100 | UIScriptController* impl = toUIScriptController(context, object); |
1101 | if (!impl) |
1102 | return JSValueMakeUndefined(context); |
1103 | |
1104 | return JSValueMakeBoolean(context, impl->isShowingDataListSuggestions()); |
1105 | } |
1106 | |
1107 | JSValueRef JSUIScriptController::didShowKeyboardCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1108 | { |
1109 | UIScriptController* impl = toUIScriptController(context, object); |
1110 | if (!impl) |
1111 | return JSValueMakeUndefined(context); |
1112 | |
1113 | return impl->didShowKeyboardCallback(); |
1114 | } |
1115 | |
1116 | bool JSUIScriptController::setDidShowKeyboardCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1117 | { |
1118 | UIScriptController* impl = toUIScriptController(context, object); |
1119 | if (!impl) |
1120 | return false; |
1121 | |
1122 | impl->setDidShowKeyboardCallback(value); |
1123 | |
1124 | return true; |
1125 | } |
1126 | |
1127 | JSValueRef JSUIScriptController::didHideKeyboardCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1128 | { |
1129 | UIScriptController* impl = toUIScriptController(context, object); |
1130 | if (!impl) |
1131 | return JSValueMakeUndefined(context); |
1132 | |
1133 | return impl->didHideKeyboardCallback(); |
1134 | } |
1135 | |
1136 | bool JSUIScriptController::setDidHideKeyboardCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1137 | { |
1138 | UIScriptController* impl = toUIScriptController(context, object); |
1139 | if (!impl) |
1140 | return false; |
1141 | |
1142 | impl->setDidHideKeyboardCallback(value); |
1143 | |
1144 | return true; |
1145 | } |
1146 | |
1147 | JSValueRef JSUIScriptController::isShowingKeyboard(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1148 | { |
1149 | UIScriptController* impl = toUIScriptController(context, object); |
1150 | if (!impl) |
1151 | return JSValueMakeUndefined(context); |
1152 | |
1153 | return JSValueMakeBoolean(context, impl->isShowingKeyboard()); |
1154 | } |
1155 | |
1156 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1157 | { |
1158 | UIScriptController* impl = toUIScriptController(context, object); |
1159 | if (!impl) |
1160 | return JSValueMakeUndefined(context); |
1161 | |
1162 | return impl->didShowMenuCallback(); |
1163 | } |
1164 | |
1165 | bool JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1166 | { |
1167 | UIScriptController* impl = toUIScriptController(context, object); |
1168 | if (!impl) |
1169 | return false; |
1170 | |
1171 | impl->setDidShowMenuCallback(value); |
1172 | |
1173 | return true; |
1174 | } |
1175 | |
1176 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1177 | { |
1178 | UIScriptController* impl = toUIScriptController(context, object); |
1179 | if (!impl) |
1180 | return JSValueMakeUndefined(context); |
1181 | |
1182 | return impl->didHideMenuCallback(); |
1183 | } |
1184 | |
1185 | bool JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1186 | { |
1187 | UIScriptController* impl = toUIScriptController(context, object); |
1188 | if (!impl) |
1189 | return false; |
1190 | |
1191 | impl->setDidHideMenuCallback(value); |
1192 | |
1193 | return true; |
1194 | } |
1195 | |
1196 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1197 | { |
1198 | UIScriptController* impl = toUIScriptController(context, object); |
1199 | if (!impl) |
1200 | return JSValueMakeUndefined(context); |
1201 | |
1202 | return JSValueMakeBoolean(context, impl->isDismissingMenu()); |
1203 | } |
1204 | |
1205 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1206 | { |
1207 | UIScriptController* impl = toUIScriptController(context, object); |
1208 | if (!impl) |
1209 | return JSValueMakeUndefined(context); |
1210 | |
1211 | return JSValueMakeBoolean(context, impl->isShowingMenu()); |
1212 | } |
1213 | |
1214 | JSValueRef JSUIScriptController::(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1215 | { |
1216 | UIScriptController* impl = toUIScriptController(context, object); |
1217 | if (!impl) |
1218 | return JSValueMakeUndefined(context); |
1219 | |
1220 | return impl->menuRect(); |
1221 | } |
1222 | |
1223 | JSValueRef JSUIScriptController::isShowingPopover(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1224 | { |
1225 | UIScriptController* impl = toUIScriptController(context, object); |
1226 | if (!impl) |
1227 | return JSValueMakeUndefined(context); |
1228 | |
1229 | return JSValueMakeBoolean(context, impl->isShowingPopover()); |
1230 | } |
1231 | |
1232 | JSValueRef JSUIScriptController::willPresentPopoverCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1233 | { |
1234 | UIScriptController* impl = toUIScriptController(context, object); |
1235 | if (!impl) |
1236 | return JSValueMakeUndefined(context); |
1237 | |
1238 | return impl->willPresentPopoverCallback(); |
1239 | } |
1240 | |
1241 | bool JSUIScriptController::setWillPresentPopoverCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1242 | { |
1243 | UIScriptController* impl = toUIScriptController(context, object); |
1244 | if (!impl) |
1245 | return false; |
1246 | |
1247 | impl->setWillPresentPopoverCallback(value); |
1248 | |
1249 | return true; |
1250 | } |
1251 | |
1252 | JSValueRef JSUIScriptController::didDismissPopoverCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1253 | { |
1254 | UIScriptController* impl = toUIScriptController(context, object); |
1255 | if (!impl) |
1256 | return JSValueMakeUndefined(context); |
1257 | |
1258 | return impl->didDismissPopoverCallback(); |
1259 | } |
1260 | |
1261 | bool JSUIScriptController::setDidDismissPopoverCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1262 | { |
1263 | UIScriptController* impl = toUIScriptController(context, object); |
1264 | if (!impl) |
1265 | return false; |
1266 | |
1267 | impl->setDidDismissPopoverCallback(value); |
1268 | |
1269 | return true; |
1270 | } |
1271 | |
1272 | JSValueRef JSUIScriptController::willBeginZoomingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1273 | { |
1274 | UIScriptController* impl = toUIScriptController(context, object); |
1275 | if (!impl) |
1276 | return JSValueMakeUndefined(context); |
1277 | |
1278 | return impl->willBeginZoomingCallback(); |
1279 | } |
1280 | |
1281 | bool JSUIScriptController::setWillBeginZoomingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1282 | { |
1283 | UIScriptController* impl = toUIScriptController(context, object); |
1284 | if (!impl) |
1285 | return false; |
1286 | |
1287 | impl->setWillBeginZoomingCallback(value); |
1288 | |
1289 | return true; |
1290 | } |
1291 | |
1292 | JSValueRef JSUIScriptController::didEndZoomingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1293 | { |
1294 | UIScriptController* impl = toUIScriptController(context, object); |
1295 | if (!impl) |
1296 | return JSValueMakeUndefined(context); |
1297 | |
1298 | return impl->didEndZoomingCallback(); |
1299 | } |
1300 | |
1301 | bool JSUIScriptController::setDidEndZoomingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1302 | { |
1303 | UIScriptController* impl = toUIScriptController(context, object); |
1304 | if (!impl) |
1305 | return false; |
1306 | |
1307 | impl->setDidEndZoomingCallback(value); |
1308 | |
1309 | return true; |
1310 | } |
1311 | |
1312 | JSValueRef JSUIScriptController::isPresentingModally(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1313 | { |
1314 | UIScriptController* impl = toUIScriptController(context, object); |
1315 | if (!impl) |
1316 | return JSValueMakeUndefined(context); |
1317 | |
1318 | return JSValueMakeBoolean(context, impl->isPresentingModally()); |
1319 | } |
1320 | |
1321 | JSValueRef JSUIScriptController::contentOffsetX(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1322 | { |
1323 | UIScriptController* impl = toUIScriptController(context, object); |
1324 | if (!impl) |
1325 | return JSValueMakeUndefined(context); |
1326 | |
1327 | return JSValueMakeNumber(context, impl->contentOffsetX()); |
1328 | } |
1329 | |
1330 | JSValueRef JSUIScriptController::contentOffsetY(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1331 | { |
1332 | UIScriptController* impl = toUIScriptController(context, object); |
1333 | if (!impl) |
1334 | return JSValueMakeUndefined(context); |
1335 | |
1336 | return JSValueMakeNumber(context, impl->contentOffsetY()); |
1337 | } |
1338 | |
1339 | JSValueRef JSUIScriptController::scrollUpdatesDisabled(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1340 | { |
1341 | UIScriptController* impl = toUIScriptController(context, object); |
1342 | if (!impl) |
1343 | return JSValueMakeUndefined(context); |
1344 | |
1345 | return JSValueMakeBoolean(context, impl->scrollUpdatesDisabled()); |
1346 | } |
1347 | |
1348 | bool JSUIScriptController::setScrollUpdatesDisabled(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1349 | { |
1350 | UIScriptController* impl = toUIScriptController(context, object); |
1351 | if (!impl) |
1352 | return false; |
1353 | |
1354 | impl->setScrollUpdatesDisabled(JSValueToBoolean(context, value)); |
1355 | |
1356 | return true; |
1357 | } |
1358 | |
1359 | JSValueRef JSUIScriptController::didEndScrollingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1360 | { |
1361 | UIScriptController* impl = toUIScriptController(context, object); |
1362 | if (!impl) |
1363 | return JSValueMakeUndefined(context); |
1364 | |
1365 | return impl->didEndScrollingCallback(); |
1366 | } |
1367 | |
1368 | bool JSUIScriptController::setDidEndScrollingCallback(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1369 | { |
1370 | UIScriptController* impl = toUIScriptController(context, object); |
1371 | if (!impl) |
1372 | return false; |
1373 | |
1374 | impl->setDidEndScrollingCallback(value); |
1375 | |
1376 | return true; |
1377 | } |
1378 | |
1379 | JSValueRef JSUIScriptController::zoomScale(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1380 | { |
1381 | UIScriptController* impl = toUIScriptController(context, object); |
1382 | if (!impl) |
1383 | return JSValueMakeUndefined(context); |
1384 | |
1385 | return JSValueMakeNumber(context, impl->zoomScale()); |
1386 | } |
1387 | |
1388 | JSValueRef JSUIScriptController::minimumZoomScale(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1389 | { |
1390 | UIScriptController* impl = toUIScriptController(context, object); |
1391 | if (!impl) |
1392 | return JSValueMakeUndefined(context); |
1393 | |
1394 | return JSValueMakeNumber(context, impl->minimumZoomScale()); |
1395 | } |
1396 | |
1397 | JSValueRef JSUIScriptController::maximumZoomScale(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1398 | { |
1399 | UIScriptController* impl = toUIScriptController(context, object); |
1400 | if (!impl) |
1401 | return JSValueMakeUndefined(context); |
1402 | |
1403 | return JSValueMakeNumber(context, impl->maximumZoomScale()); |
1404 | } |
1405 | |
1406 | JSValueRef JSUIScriptController::stableStateOverride(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1407 | { |
1408 | UIScriptController* impl = toUIScriptController(context, object); |
1409 | if (!impl) |
1410 | return JSValueMakeUndefined(context); |
1411 | |
1412 | return JSValueMakeBooleanOrNull(context, impl->stableStateOverride()); |
1413 | } |
1414 | |
1415 | bool JSUIScriptController::setStableStateOverride(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) |
1416 | { |
1417 | UIScriptController* impl = toUIScriptController(context, object); |
1418 | if (!impl) |
1419 | return false; |
1420 | |
1421 | impl->setStableStateOverride(JSValueToNullableBoolean(context, value)); |
1422 | |
1423 | return true; |
1424 | } |
1425 | |
1426 | JSValueRef JSUIScriptController::contentVisibleRect(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1427 | { |
1428 | UIScriptController* impl = toUIScriptController(context, object); |
1429 | if (!impl) |
1430 | return JSValueMakeUndefined(context); |
1431 | |
1432 | return impl->contentVisibleRect(); |
1433 | } |
1434 | |
1435 | JSValueRef JSUIScriptController::textSelectionRangeRects(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1436 | { |
1437 | UIScriptController* impl = toUIScriptController(context, object); |
1438 | if (!impl) |
1439 | return JSValueMakeUndefined(context); |
1440 | |
1441 | return impl->textSelectionRangeRects(); |
1442 | } |
1443 | |
1444 | JSValueRef JSUIScriptController::textSelectionCaretRect(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1445 | { |
1446 | UIScriptController* impl = toUIScriptController(context, object); |
1447 | if (!impl) |
1448 | return JSValueMakeUndefined(context); |
1449 | |
1450 | return impl->textSelectionCaretRect(); |
1451 | } |
1452 | |
1453 | JSValueRef JSUIScriptController::selectionStartGrabberViewRect(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1454 | { |
1455 | UIScriptController* impl = toUIScriptController(context, object); |
1456 | if (!impl) |
1457 | return JSValueMakeUndefined(context); |
1458 | |
1459 | return impl->selectionStartGrabberViewRect(); |
1460 | } |
1461 | |
1462 | JSValueRef JSUIScriptController::selectionEndGrabberViewRect(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1463 | { |
1464 | UIScriptController* impl = toUIScriptController(context, object); |
1465 | if (!impl) |
1466 | return JSValueMakeUndefined(context); |
1467 | |
1468 | return impl->selectionEndGrabberViewRect(); |
1469 | } |
1470 | |
1471 | JSValueRef JSUIScriptController::selectionCaretViewRect(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1472 | { |
1473 | UIScriptController* impl = toUIScriptController(context, object); |
1474 | if (!impl) |
1475 | return JSValueMakeUndefined(context); |
1476 | |
1477 | return impl->selectionCaretViewRect(); |
1478 | } |
1479 | |
1480 | JSValueRef JSUIScriptController::selectionRangeViewRects(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1481 | { |
1482 | UIScriptController* impl = toUIScriptController(context, object); |
1483 | if (!impl) |
1484 | return JSValueMakeUndefined(context); |
1485 | |
1486 | return impl->selectionRangeViewRects(); |
1487 | } |
1488 | |
1489 | JSValueRef JSUIScriptController::calendarType(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1490 | { |
1491 | UIScriptController* impl = toUIScriptController(context, object); |
1492 | if (!impl) |
1493 | return JSValueMakeUndefined(context); |
1494 | |
1495 | return impl->calendarType(); |
1496 | } |
1497 | |
1498 | JSValueRef JSUIScriptController::inputViewBounds(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1499 | { |
1500 | UIScriptController* impl = toUIScriptController(context, object); |
1501 | if (!impl) |
1502 | return JSValueMakeUndefined(context); |
1503 | |
1504 | return impl->inputViewBounds(); |
1505 | } |
1506 | |
1507 | JSValueRef JSUIScriptController::scrollingTreeAsText(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1508 | { |
1509 | UIScriptController* impl = toUIScriptController(context, object); |
1510 | if (!impl) |
1511 | return JSValueMakeUndefined(context); |
1512 | |
1513 | return JSValueMakeStringOrNull(context, impl->scrollingTreeAsText().get()); |
1514 | } |
1515 | |
1516 | JSValueRef JSUIScriptController::accessibilitySpeakSelectionContent(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1517 | { |
1518 | UIScriptController* impl = toUIScriptController(context, object); |
1519 | if (!impl) |
1520 | return JSValueMakeUndefined(context); |
1521 | |
1522 | return JSValueMakeStringOrNull(context, impl->accessibilitySpeakSelectionContent().get()); |
1523 | } |
1524 | |
1525 | JSValueRef JSUIScriptController::isWindowContentViewFirstResponder(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1526 | { |
1527 | UIScriptController* impl = toUIScriptController(context, object); |
1528 | if (!impl) |
1529 | return JSValueMakeUndefined(context); |
1530 | |
1531 | return JSValueMakeBoolean(context, impl->isWindowContentViewFirstResponder()); |
1532 | } |
1533 | |
1534 | JSValueRef JSUIScriptController::numberOfStrokesInEditableImage(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1535 | { |
1536 | UIScriptController* impl = toUIScriptController(context, object); |
1537 | if (!impl) |
1538 | return JSValueMakeUndefined(context); |
1539 | |
1540 | return JSValueMakeNumber(context, impl->numberOfStrokesInEditableImage()); |
1541 | } |
1542 | |
1543 | JSValueRef JSUIScriptController::lastUndoLabel(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1544 | { |
1545 | UIScriptController* impl = toUIScriptController(context, object); |
1546 | if (!impl) |
1547 | return JSValueMakeUndefined(context); |
1548 | |
1549 | return JSValueMakeStringOrNull(context, impl->lastUndoLabel().get()); |
1550 | } |
1551 | |
1552 | JSValueRef JSUIScriptController::firstRedoLabel(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) |
1553 | { |
1554 | UIScriptController* impl = toUIScriptController(context, object); |
1555 | if (!impl) |
1556 | return JSValueMakeUndefined(context); |
1557 | |
1558 | return JSValueMakeStringOrNull(context, impl->firstRedoLabel().get()); |
1559 | } |
1560 | |
1561 | } // namespace WTR |
1562 | |
1563 | |