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.
26 #ifndef UIScriptController_h
27 #define UIScriptController_h
29 #include "JSWrappable.h"
30 #include <JavaScriptCore/JSRetainPtr.h>
31 #include <wtf/Optional.h>
40 class UIScriptContext;
42 class UIScriptController : public JSWrappable {
44 static Ref<UIScriptController> create(UIScriptContext& context)
46 return adoptRef(*new UIScriptController(context));
49 void contextDestroyed();
51 void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
53 void doAsyncTask(JSValueRef callback);
54 void doAfterPresentationUpdate(JSValueRef callback);
56 void zoomToScale(double scale, JSValueRef callback);
58 void simulateAccessibilitySettingsChangeNotification(JSValueRef callback);
60 void touchDownAtPoint(long x, long y, long touchCount, JSValueRef callback);
61 void liftUpAtPoint(long x, long y, long touchCount, JSValueRef callback);
62 void singleTapAtPoint(long x, long y, JSValueRef callback);
63 void doubleTapAtPoint(long x, long y, JSValueRef callback);
64 void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback);
66 void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
67 void stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
68 void stylusUpAtPoint(long x, long y, JSValueRef callback);
69 void stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
71 void longPressAtPoint(long x, long y, JSValueRef callback);
73 void sendEventStream(JSStringRef eventsJSON, JSValueRef callback);
75 void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
76 void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
77 void keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
79 void selectTextCandidateAtIndex(long index, JSValueRef callback);
81 void keyboardAccessoryBarNext();
82 void keyboardAccessoryBarPrevious();
84 void dismissFormAccessoryView();
85 void selectFormAccessoryPickerRow(long);
87 JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
89 void scrollToOffset(long x, long y);
91 void immediateScrollToOffset(long x, long y);
92 void immediateZoomToScale(double scale);
94 void setDidStartFormControlInteractionCallback(JSValueRef);
95 JSValueRef didStartFormControlInteractionCallback() const;
97 void setDidEndFormControlInteractionCallback(JSValueRef);
98 JSValueRef didEndFormControlInteractionCallback() const;
100 void setDidShowForcePressPreviewCallback(JSValueRef);
101 JSValueRef didShowForcePressPreviewCallback() const;
103 void setDidDismissForcePressPreviewCallback(JSValueRef);
104 JSValueRef didDismissForcePressPreviewCallback() const;
106 void setWillBeginZoomingCallback(JSValueRef);
107 JSValueRef willBeginZoomingCallback() const;
109 void setDidEndZoomingCallback(JSValueRef);
110 JSValueRef didEndZoomingCallback() const;
112 void setDidShowKeyboardCallback(JSValueRef);
113 JSValueRef didShowKeyboardCallback() const;
115 void setDidHideKeyboardCallback(JSValueRef);
116 JSValueRef didHideKeyboardCallback() const;
118 void setDidEndScrollingCallback(JSValueRef);
119 JSValueRef didEndScrollingCallback() const;
121 double zoomScale() const;
122 double minimumZoomScale() const;
123 double maximumZoomScale() const;
125 Optional<bool> stableStateOverride() const;
126 void setStableStateOverride(Optional<bool>);
128 JSObjectRef contentVisibleRect() const;
130 JSObjectRef selectionRangeViewRects() const;
132 void insertText(JSStringRef, int location, int length);
133 void removeAllDynamicDictionaries();
135 JSRetainPtr<JSStringRef> scrollingTreeAsText() const;
137 void uiScriptComplete(JSStringRef result);
140 UIScriptController(UIScriptContext&);
142 UIScriptContext* context() { return m_context; }
144 void platformSetDidStartFormControlInteractionCallback();
145 void platformSetDidEndFormControlInteractionCallback();
146 void platformSetDidShowForcePressPreviewCallback();
147 void platformSetDidDismissForcePressPreviewCallback();
148 void platformSetWillBeginZoomingCallback();
149 void platformSetDidEndZoomingCallback();
150 void platformSetDidShowKeyboardCallback();
151 void platformSetDidHideKeyboardCallback();
152 void platformSetDidEndScrollingCallback();
153 void platformClearAllCallbacks();
155 JSClassRef wrapperClass() final;
157 JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
158 void waitForTextPredictionsViewAndSelectCandidateAtIndex(long index, unsigned callbackID, float interval);
160 UIScriptContext* m_context;
165 #endif // UIScriptController_h