2 * Copyright (C) 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "UIScriptController.h"
29 #include "JSUIScriptController.h"
30 #include "UIScriptContext.h"
31 #include <JavaScriptCore/JSValueRef.h>
35 UIScriptController::UIScriptController(UIScriptContext& context)
40 void UIScriptController::contextDestroyed()
45 void UIScriptController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
47 setProperty(context, windowObject, "uiController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
50 JSClassRef UIScriptController::wrapperClass()
52 return JSUIScriptController::uIScriptControllerClass();
56 void UIScriptController::doAsyncTask(JSValueRef)
60 void simulateAccessibilitySettingsChangeNotification(JSValueRef)
65 void UIScriptController::setDidStartFormControlInteractionCallback(JSValueRef callback)
67 m_context->registerCallback(callback, CallbackTypeDidStartFormControlInteraction);
68 platformSetDidStartFormControlInteractionCallback();
71 JSValueRef UIScriptController::didStartFormControlInteractionCallback() const
73 return m_context->callbackWithID(CallbackTypeDidStartFormControlInteraction);
76 void UIScriptController::setDidEndFormControlInteractionCallback(JSValueRef callback)
78 m_context->registerCallback(callback, CallbackTypeDidEndFormControlInteraction);
79 platformSetDidEndFormControlInteractionCallback();
82 JSValueRef UIScriptController::didEndFormControlInteractionCallback() const
84 return m_context->callbackWithID(CallbackTypeDidEndFormControlInteraction);
87 void UIScriptController::setDidShowForcePressPreviewCallback(JSValueRef callback)
89 m_context->registerCallback(callback, CallbackTypeDidShowForcePressPreview);
90 platformSetDidShowForcePressPreviewCallback();
93 JSValueRef UIScriptController::didShowForcePressPreviewCallback() const
95 return m_context->callbackWithID(CallbackTypeDidShowForcePressPreview);
98 void UIScriptController::setDidDismissForcePressPreviewCallback(JSValueRef callback)
100 m_context->registerCallback(callback, CallbackTypeDidDismissForcePressPreview);
101 platformSetDidDismissForcePressPreviewCallback();
104 JSValueRef UIScriptController::didDismissForcePressPreviewCallback() const
106 return m_context->callbackWithID(CallbackTypeDidDismissForcePressPreview);
109 void UIScriptController::setWillBeginZoomingCallback(JSValueRef callback)
111 m_context->registerCallback(callback, CallbackTypeWillBeginZooming);
112 platformSetWillBeginZoomingCallback();
115 JSValueRef UIScriptController::willBeginZoomingCallback() const
117 return m_context->callbackWithID(CallbackTypeWillBeginZooming);
120 void UIScriptController::setDidEndZoomingCallback(JSValueRef callback)
122 m_context->registerCallback(callback, CallbackTypeDidEndZooming);
123 platformSetDidEndZoomingCallback();
126 JSValueRef UIScriptController::didEndZoomingCallback() const
128 return m_context->callbackWithID(CallbackTypeDidEndZooming);
131 void UIScriptController::setDidEndScrollingCallback(JSValueRef callback)
133 m_context->registerCallback(callback, CallbackTypeDidEndScrolling);
134 platformSetDidEndScrollingCallback();
137 JSValueRef UIScriptController::didEndScrollingCallback() const
139 return m_context->callbackWithID(CallbackTypeDidEndScrolling);
142 void UIScriptController::setDidShowKeyboardCallback(JSValueRef callback)
144 m_context->registerCallback(callback, CallbackTypeDidShowKeyboard);
145 platformSetDidShowKeyboardCallback();
148 JSValueRef UIScriptController::didShowKeyboardCallback() const
150 return m_context->callbackWithID(CallbackTypeDidShowKeyboard);
153 void UIScriptController::setDidHideKeyboardCallback(JSValueRef callback)
155 m_context->registerCallback(callback, CallbackTypeDidHideKeyboard);
156 platformSetDidHideKeyboardCallback();
159 JSValueRef UIScriptController::didHideKeyboardCallback() const
161 return m_context->callbackWithID(CallbackTypeDidHideKeyboard);
165 void UIScriptController::zoomToScale(double, JSValueRef)
169 void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
173 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
180 void UIScriptController::touchDownAtPoint(long x, long y, long touchCount, JSValueRef)
184 void UIScriptController::liftUpAtPoint(long x, long y, long touchCount, JSValueRef)
188 void UIScriptController::singleTapAtPoint(long x, long y, JSValueRef)
192 void UIScriptController::doubleTapAtPoint(long x, long y, JSValueRef)
196 void UIScriptController::dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback)
200 void UIScriptController::longPressAtPoint(long x, long y, JSValueRef)
204 void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
208 void UIScriptController::stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
212 void UIScriptController::stylusUpAtPoint(long x, long y, JSValueRef callback)
216 void UIScriptController::stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
220 void UIScriptController::sendEventStream(JSStringRef eventsJSON, JSValueRef callback)
224 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef, JSValueRef)
228 void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef, JSValueRef)
232 void UIScriptController::selectTextCandidateAtIndex(long, JSValueRef)
236 void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(long, unsigned, float)
240 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef, JSValueRef)
244 void UIScriptController::dismissFormAccessoryView()
248 void UIScriptController::selectFormAccessoryPickerRow(long)
252 void UIScriptController::scrollToOffset(long x, long y)
256 void UIScriptController::keyboardAccessoryBarNext()
260 void UIScriptController::keyboardAccessoryBarPrevious()
264 double UIScriptController::zoomScale() const
269 double UIScriptController::minimumZoomScale() const
274 double UIScriptController::maximumZoomScale() const
279 JSObjectRef UIScriptController::contentVisibleRect() const
284 JSObjectRef UIScriptController::selectionRangeViewRects() const
289 void UIScriptController::removeAllDynamicDictionaries()
293 JSRetainPtr<JSStringRef> UIScriptController::scrollingTreeAsText() const
298 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
302 void UIScriptController::platformSetDidEndFormControlInteractionCallback()
306 void UIScriptController::platformSetDidShowForcePressPreviewCallback()
310 void UIScriptController::platformSetDidDismissForcePressPreviewCallback()
314 void UIScriptController::platformSetWillBeginZoomingCallback()
318 void UIScriptController::platformSetDidEndZoomingCallback()
322 void UIScriptController::platformSetDidEndScrollingCallback()
326 void UIScriptController::platformSetDidShowKeyboardCallback()
330 void UIScriptController::platformSetDidHideKeyboardCallback()
334 void UIScriptController::platformClearAllCallbacks()
341 void UIScriptController::insertText(JSStringRef, int, int)
347 void UIScriptController::uiScriptComplete(JSStringRef result)
349 m_context->requestUIScriptCompletion(result);
350 platformClearAllCallbacks();