Provide a viewport parameter to disable clipping to the safe area
[WebKit-https.git] / Tools / TestRunnerShared / UIScriptContext / UIScriptController.h
1 /*
2  * Copyright (C) 2015 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
26 #ifndef UIScriptController_h
27 #define UIScriptController_h
28
29 #include "JSWrappable.h"
30 #include <JavaScriptCore/JSRetainPtr.h>
31 #include <wtf/Optional.h>
32 #include <wtf/Ref.h>
33
34 namespace WebCore {
35 class FloatRect;
36 }
37
38 namespace WTR {
39
40 class UIScriptContext;
41
42 class UIScriptController : public JSWrappable {
43 public:
44     static Ref<UIScriptController> create(UIScriptContext& context)
45     {
46         return adoptRef(*new UIScriptController(context));
47     }
48
49     void contextDestroyed();
50     void checkForOutstandingCallbacks();
51
52     void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
53     
54     void doAsyncTask(JSValueRef callback);
55     void doAfterPresentationUpdate(JSValueRef callback);
56     void doAfterNextStablePresentationUpdate(JSValueRef callback);
57     void doAfterVisibleContentRectUpdate(JSValueRef callback);
58
59     void zoomToScale(double scale, JSValueRef callback);
60
61     void simulateAccessibilitySettingsChangeNotification(JSValueRef callback);
62
63     void touchDownAtPoint(long x, long y, long touchCount, JSValueRef callback);
64     void liftUpAtPoint(long x, long y, long touchCount, JSValueRef callback);
65     void singleTapAtPoint(long x, long y, JSValueRef callback);
66     void doubleTapAtPoint(long x, long y, JSValueRef callback);
67     void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback);
68
69     void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
70     void stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
71     void stylusUpAtPoint(long x, long y, JSValueRef callback);
72     void stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
73
74     void longPressAtPoint(long x, long y, JSValueRef callback);
75
76     void sendEventStream(JSStringRef eventsJSON, JSValueRef callback);
77
78     void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
79     void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
80     void keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
81
82     void selectTextCandidateAtIndex(long index, JSValueRef callback);
83
84     void keyboardAccessoryBarNext();
85     void keyboardAccessoryBarPrevious();
86     
87     void dismissFormAccessoryView();
88     void selectFormAccessoryPickerRow(long);
89     
90     JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
91     void overridePreference(JSStringRef preference, JSStringRef value);
92     
93     void scrollToOffset(long x, long y);
94
95     void immediateScrollToOffset(long x, long y);
96     void immediateZoomToScale(double scale);
97
98     void beginBackSwipe(JSValueRef callback);
99     void completeBackSwipe(JSValueRef callback);
100
101     void setDidStartFormControlInteractionCallback(JSValueRef);
102     JSValueRef didStartFormControlInteractionCallback() const;
103
104     void setDidEndFormControlInteractionCallback(JSValueRef);
105     JSValueRef didEndFormControlInteractionCallback() const;
106     
107     void setDidShowForcePressPreviewCallback(JSValueRef);
108     JSValueRef didShowForcePressPreviewCallback() const;
109     
110     void setDidDismissForcePressPreviewCallback(JSValueRef);
111     JSValueRef didDismissForcePressPreviewCallback() const;
112
113     void setWillBeginZoomingCallback(JSValueRef);
114     JSValueRef willBeginZoomingCallback() const;
115
116     void setDidEndZoomingCallback(JSValueRef);
117     JSValueRef didEndZoomingCallback() const;
118
119     void setDidShowKeyboardCallback(JSValueRef);
120     JSValueRef didShowKeyboardCallback() const;
121
122     void setDidHideKeyboardCallback(JSValueRef);
123     JSValueRef didHideKeyboardCallback() const;
124
125     void setDidEndScrollingCallback(JSValueRef);
126     JSValueRef didEndScrollingCallback() const;
127
128     void playBackEventStream(JSStringRef stream, JSValueRef callback);
129
130     double zoomScale() const;
131     double minimumZoomScale() const;
132     double maximumZoomScale() const;
133     
134     std::optional<bool> stableStateOverride() const;
135     void setStableStateOverride(std::optional<bool>);
136
137     JSObjectRef contentVisibleRect() const;
138     
139     JSObjectRef selectionRangeViewRects() const;
140     JSObjectRef textSelectionCaretRect() const;
141     JSObjectRef inputViewBounds() const;
142
143     void insertText(JSStringRef, int location, int length);
144     void removeAllDynamicDictionaries();
145     
146     JSRetainPtr<JSStringRef> scrollingTreeAsText() const;
147
148     JSObjectRef propertiesOfLayerWithID(uint64_t layerID) const;
149
150     void uiScriptComplete(JSStringRef result);
151     
152     void retrieveSpeakSelectionContent(JSValueRef);
153     JSRetainPtr<JSStringRef> accessibilitySpeakSelectionContent() const;
154
155     // These use a callback to allow the client to know when view visibility state updates get to the web process.
156     void removeViewFromWindow(JSValueRef);
157     void addViewToWindow(JSValueRef);
158
159     void setObscuredInsets(double top, double right, double bottom, double left);
160
161 private:
162     UIScriptController(UIScriptContext&);
163     
164     UIScriptContext* context() { return m_context; }
165
166     void platformSetDidStartFormControlInteractionCallback();
167     void platformSetDidEndFormControlInteractionCallback();
168     void platformSetDidShowForcePressPreviewCallback();
169     void platformSetDidDismissForcePressPreviewCallback();
170     void platformSetWillBeginZoomingCallback();
171     void platformSetDidEndZoomingCallback();
172     void platformSetDidShowKeyboardCallback();
173     void platformSetDidHideKeyboardCallback();
174     void platformSetDidEndScrollingCallback();
175     void platformClearAllCallbacks();
176     void platformPlayBackEventStream(JSStringRef, JSValueRef);
177
178     JSClassRef wrapperClass() final;
179
180     JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
181     void waitForTextPredictionsViewAndSelectCandidateAtIndex(long index, unsigned callbackID, float interval);
182
183     UIScriptContext* m_context;
184 };
185
186 }
187
188 #endif // UIScriptController_h