forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIScriptController.h
400 lines (284 loc) · 16.4 KB
/
UIScriptController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/*
* Copyright (C) 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "JSWrappable.h"
#include <JavaScriptCore/JSRetainPtr.h>
#include <wtf/Ref.h>
OBJC_CLASS NSUndoManager;
OBJC_CLASS NSView;
OBJC_CLASS UIView;
namespace WebCore {
class FloatRect;
}
namespace WTR {
class UIScriptContext;
enum class DeviceOrientation {
Portrait,
PortraitUpsideDown,
LandscapeLeft,
LandscapeRight
};
DeviceOrientation* toDeviceOrientation(JSContextRef, JSValueRef);
struct ScrollToOptions {
bool unconstrained { false };
};
ScrollToOptions* toScrollToOptions(JSContextRef, JSValueRef);
class UIScriptController : public JSWrappable {
public:
static Ref<UIScriptController> create(UIScriptContext&);
void uiScriptComplete(JSStringRef result);
void notImplemented() const { RELEASE_ASSERT_NOT_REACHED(); }
void contextDestroyed();
virtual void waitForOutstandingCallbacks() { /* notImplemented(); */ }
void makeWindowObject(JSContextRef);
// Transaction helpers
virtual void doAsyncTask(JSValueRef) { notImplemented(); }
virtual void doAfterPresentationUpdate(JSValueRef callback) { doAsyncTask(callback); }
virtual void doAfterNextStablePresentationUpdate(JSValueRef callback) { doAsyncTask(callback); }
virtual void ensurePositionInformationIsUpToDateAt(long, long, JSValueRef callback) { doAsyncTask(callback); }
virtual void doAfterVisibleContentRectUpdate(JSValueRef callback) { doAsyncTask(callback); }
virtual void doAfterDoubleTapDelay(JSValueRef callback) { doAsyncTask(callback); }
// Preferences
virtual void overridePreference(JSStringRef, JSStringRef) { notImplemented(); }
// Zooming
virtual void zoomToScale(double, JSValueRef) { notImplemented(); }
virtual void immediateZoomToScale(double) { notImplemented(); }
virtual void setViewScale(double) { notImplemented(); }
virtual double zoomScale() const { notImplemented(); return 1; }
virtual double minimumZoomScale() const { notImplemented(); return 1; }
virtual double maximumZoomScale() const { notImplemented(); return 1; }
// Viewports
virtual void setMinimumEffectiveWidth(double) { notImplemented(); }
virtual void setAllowsViewportShrinkToFit(bool) { notImplemented(); }
virtual void setScrollViewKeyboardAvoidanceEnabled(bool) { notImplemented(); }
virtual std::optional<bool> stableStateOverride() const { notImplemented(); return std::nullopt; }
virtual void setStableStateOverride(std::optional<bool>) { notImplemented(); }
virtual JSObjectRef contentVisibleRect() const { notImplemented(); return nullptr; }
virtual void setSafeAreaInsets(double, double, double, double) { notImplemented(); }
// View Parenting and Visibility
virtual void becomeFirstResponder() { notImplemented(); }
virtual void resignFirstResponder() { notImplemented(); }
virtual void copyText(JSStringRef) { notImplemented(); }
virtual void paste() { notImplemented(); }
virtual void chooseMenuAction(JSStringRef, JSValueRef);
virtual void dismissMenu();
virtual void firstResponderSuppressionForWebView(bool) { notImplemented(); }
virtual void makeWindowContentViewFirstResponder() { notImplemented(); }
virtual bool isWindowContentViewFirstResponder() const { notImplemented(); return false; }
virtual bool isWebContentFirstResponder() const { notImplemented(); return false; }
virtual void removeViewFromWindow(JSValueRef) { notImplemented(); }
virtual void addViewToWindow(JSValueRef) { notImplemented(); }
virtual void installTapGestureOnWindow(JSValueRef) { notImplemented(); }
// Editable region
virtual bool mayContainEditableElementsInRect(unsigned, unsigned, unsigned, unsigned) { notImplemented(); return false; }
// Compositing
virtual JSObjectRef propertiesOfLayerWithID(uint64_t) const { notImplemented(); return nullptr; }
// Scrolling
virtual bool scrollUpdatesDisabled() const { notImplemented(); return false; }
virtual void setScrollUpdatesDisabled(bool) { notImplemented(); }
virtual void scrollToOffset(long, long, ScrollToOptions*) { notImplemented(); }
virtual void immediateScrollToOffset(long, long, ScrollToOptions*) { notImplemented(); }
virtual void immediateScrollElementAtContentPointToOffset(long, long, long, long) { notImplemented(); }
virtual double contentOffsetX() const { notImplemented(); return 0; }
virtual double contentOffsetY() const { notImplemented(); return 0; }
virtual JSRetainPtr<JSStringRef> scrollingTreeAsText() const { notImplemented(); return nullptr; }
virtual JSRetainPtr<JSStringRef> uiViewTreeAsText() const { notImplemented(); return nullptr; }
// Touches
virtual void touchDownAtPoint(long, long, long, JSValueRef) { notImplemented(); }
virtual void liftUpAtPoint(long, long, long, JSValueRef) { notImplemented(); }
virtual void singleTapAtPoint(long, long, JSValueRef) { notImplemented(); }
virtual void singleTapAtPointWithModifiers(long, long, JSValueRef, JSValueRef) { notImplemented(); }
virtual void twoFingerSingleTapAtPoint(long, long, JSValueRef) { notImplemented(); }
virtual void doubleTapAtPoint(long, long, float, JSValueRef) { notImplemented(); }
virtual void dragFromPointToPoint(long, long, long, long, double, JSValueRef) { notImplemented(); }
virtual void longPressAtPoint(long, long, JSValueRef) { notImplemented(); }
virtual void activateAtPoint(long, long, JSValueRef) { notImplemented(); }
// Keyboard
virtual void enterText(JSStringRef) { notImplemented(); }
virtual void typeCharacterUsingHardwareKeyboard(JSStringRef, JSValueRef) { notImplemented(); }
virtual void keyDown(JSStringRef, JSValueRef) { notImplemented(); }
virtual void toggleCapsLock(JSValueRef) { notImplemented(); }
virtual void setContinuousSpellCheckingEnabled(bool) { notImplemented(); }
virtual void setSpellCheckerResults(JSValueRef) { notImplemented(); }
virtual bool keyboardIsAutomaticallyShifted() const
{
notImplemented();
return false;
}
virtual bool isAnimatingDragCancel() const
{
notImplemented();
return false;
}
virtual JSRetainPtr<JSStringRef> selectionCaretBackgroundColor() const
{
notImplemented();
return { };
}
virtual JSObjectRef tapHighlightViewRect() const
{
notImplemented();
return nullptr;
}
virtual void setWebViewEditable(bool) { }
virtual void rawKeyDown(JSStringRef) { notImplemented(); }
virtual void rawKeyUp(JSStringRef) { notImplemented(); }
virtual void keyboardAccessoryBarNext() { notImplemented(); }
virtual void keyboardAccessoryBarPrevious() { notImplemented(); }
virtual void applyAutocorrection(JSStringRef, JSStringRef, JSValueRef) { notImplemented(); }
virtual bool isShowingKeyboard() const { notImplemented(); return false; }
virtual bool hasInputSession() const { notImplemented(); return false; }
virtual void setHardwareKeyboardAttached(bool) { }
virtual void setKeyboardInputModeIdentifier(JSStringRef) { notImplemented(); }
virtual void replaceTextAtRange(JSStringRef, int, int) { notImplemented(); }
virtual bool windowIsKey() const { notImplemented(); return false; }
virtual void setWindowIsKey(bool) { notImplemented(); }
virtual bool suppressSoftwareKeyboard() const { notImplemented(); return false; }
virtual void setSuppressSoftwareKeyboard(bool) { notImplemented(); }
// Stylus
virtual void stylusDownAtPoint(long, long, float, float, float, JSValueRef) { notImplemented(); }
virtual void stylusMoveToPoint(long, long, float, float, float, JSValueRef) { notImplemented(); }
virtual void stylusUpAtPoint(long, long, JSValueRef) { notImplemented(); }
virtual void stylusTapAtPoint(long, long, float, float, float, JSValueRef) { notImplemented(); }
virtual void stylusTapAtPointWithModifiers(long, long, float, float, float, JSValueRef, JSValueRef) { notImplemented(); }
// Event Stream
virtual void sendEventStream(JSStringRef, JSValueRef) { notImplemented(); }
virtual void playBackEventStream(JSStringRef, JSValueRef) { notImplemented(); }
// Form Controls
virtual JSObjectRef filePickerAcceptedTypeIdentifiers() { notImplemented(); return nullptr; }
virtual void dismissFilePicker(JSValueRef) { notImplemented(); }
virtual void dismissFormAccessoryView() { notImplemented(); }
virtual void selectFormAccessoryPickerRow(long) { notImplemented(); }
virtual bool selectFormAccessoryHasCheckedItemAtRow(long) const { return false; }
virtual JSRetainPtr<JSStringRef> textContentType() const { notImplemented(); return nullptr; }
virtual JSRetainPtr<JSStringRef> selectFormPopoverTitle() const { notImplemented(); return nullptr; }
virtual JSRetainPtr<JSStringRef> formInputLabel() const { notImplemented(); return nullptr; }
virtual void setTimePickerValue(long, long) { notImplemented(); }
virtual double timePickerValueHour() const { notImplemented(); return -1; }
virtual double timePickerValueMinute() const { notImplemented(); return -1; }
virtual bool isShowingDateTimePicker() const { notImplemented(); return false; }
virtual double dateTimePickerValue() const { notImplemented(); return 0; }
virtual void chooseDateTimePickerValue() { notImplemented(); }
virtual bool isShowingDataListSuggestions() const { notImplemented(); return false; }
virtual JSObjectRef calendarType() const { notImplemented(); return nullptr; }
virtual void setDefaultCalendarType(JSStringRef, JSStringRef) { notImplemented(); }
virtual JSObjectRef inputViewBounds() const { notImplemented(); return nullptr; }
virtual void activateDataListSuggestion(unsigned, JSValueRef) { notImplemented(); }
virtual void setSelectedColorForColorPicker(double, double, double) { notImplemented(); }
// Find in Page
virtual void findString(JSStringRef, unsigned long, unsigned long) { notImplemented(); }
// Accessibility
virtual void simulateAccessibilitySettingsChangeNotification(JSValueRef) { notImplemented(); }
virtual void retrieveSpeakSelectionContent(JSValueRef) { notImplemented(); }
virtual JSRetainPtr<JSStringRef> accessibilitySpeakSelectionContent() const { notImplemented(); return nullptr; }
virtual JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const { notImplemented(); return nullptr; }
// Swipe
virtual void beginBackSwipe(JSValueRef) { notImplemented(); }
virtual void completeBackSwipe(JSValueRef) { notImplemented(); }
// Child View Controllers
virtual bool isShowingPopover() const { notImplemented(); return false; }
virtual bool isPresentingModally() const { notImplemented(); return false; }
// Context Menus
virtual bool isDismissingMenu() const { notImplemented(); return false; }
virtual bool isShowingMenu() const { notImplemented(); return false; }
virtual JSObjectRef rectForMenuAction(JSStringRef) const { notImplemented(); return nullptr; }
virtual JSObjectRef menuRect() const { notImplemented(); return nullptr; }
virtual JSObjectRef contextMenuRect() const { notImplemented(); return nullptr; }
virtual bool isShowingContextMenu() const { notImplemented(); return false; }
// Selection
virtual JSObjectRef textSelectionRangeRects() const { notImplemented(); return nullptr; }
virtual JSObjectRef textSelectionCaretRect() const { notImplemented(); return nullptr; }
virtual JSObjectRef selectionStartGrabberViewRect() const { notImplemented(); return nullptr; }
virtual JSObjectRef selectionEndGrabberViewRect() const { notImplemented(); return nullptr; }
virtual JSObjectRef selectionCaretViewRect() const { notImplemented(); return nullptr; }
virtual JSObjectRef selectionRangeViewRects() const { notImplemented(); return nullptr; }
// Rotation
virtual void simulateRotation(DeviceOrientation*, JSValueRef) { notImplemented(); }
virtual void simulateRotationLikeSafari(DeviceOrientation*, JSValueRef) { notImplemented(); }
// Undo/Redo
virtual JSRetainPtr<JSStringRef> lastUndoLabel() const { notImplemented(); return nullptr; }
virtual JSRetainPtr<JSStringRef> firstRedoLabel() const { notImplemented(); return nullptr; }
// Attachment Elements
virtual JSObjectRef attachmentInfo(JSStringRef) { notImplemented(); return nullptr; }
virtual void insertAttachmentForFilePath(JSStringRef, JSStringRef, JSValueRef) { notImplemented(); }
// Contact Picker
virtual void setDidShowContactPickerCallback(JSValueRef);
JSValueRef didShowContactPickerCallback() const;
virtual bool isShowingContactPicker() const { notImplemented(); return false; }
virtual void setDidHideContactPickerCallback(JSValueRef);
JSValueRef didHideContactPickerCallback() const;
virtual void dismissContactPickerWithContacts(JSValueRef) { notImplemented(); }
// Callbacks
virtual void setDidStartFormControlInteractionCallback(JSValueRef);
JSValueRef didStartFormControlInteractionCallback() const;
virtual void setDidEndFormControlInteractionCallback(JSValueRef);
JSValueRef didEndFormControlInteractionCallback() const;
virtual void setDidShowContextMenuCallback(JSValueRef);
JSValueRef didShowContextMenuCallback() const;
virtual void setDidDismissContextMenuCallback(JSValueRef);
JSValueRef didDismissContextMenuCallback() const;
virtual void setWillBeginZoomingCallback(JSValueRef);
JSValueRef willBeginZoomingCallback() const;
virtual void setDidEndZoomingCallback(JSValueRef);
JSValueRef didEndZoomingCallback() const;
virtual void setWillCreateNewPageCallback(JSValueRef);
JSValueRef willCreateNewPageCallback() const;
virtual void setDidShowKeyboardCallback(JSValueRef);
JSValueRef didShowKeyboardCallback() const;
virtual void setDidHideKeyboardCallback(JSValueRef);
JSValueRef didHideKeyboardCallback() const;
virtual void setWillStartInputSessionCallback(JSValueRef);
JSValueRef willStartInputSessionCallback() const;
virtual void setDidHideMenuCallback(JSValueRef);
JSValueRef didHideMenuCallback() const;
virtual void setDidShowMenuCallback(JSValueRef);
JSValueRef didShowMenuCallback() const;
virtual void setDidDismissPopoverCallback(JSValueRef);
JSValueRef didDismissPopoverCallback() const;
virtual void setWillPresentPopoverCallback(JSValueRef);
JSValueRef willPresentPopoverCallback() const;
virtual void setDidEndScrollingCallback(JSValueRef);
JSValueRef didEndScrollingCallback() const;
protected:
explicit UIScriptController(UIScriptContext&);
UIScriptContext* context() { return m_context; }
virtual void clearAllCallbacks() { /* notImplemented(); */ }
#if PLATFORM(COCOA)
virtual NSUndoManager *platformUndoManager() const { notImplemented(); return nullptr; }
#endif
#if PLATFORM(IOS_FAMILY)
virtual UIView *platformContentView() const { notImplemented(); return nullptr; }
#endif
#if PLATFORM(MAC)
virtual NSView *platformContentView() const { notImplemented(); return nullptr; }
#endif
JSClassRef wrapperClass() final;
JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
UIScriptContext* m_context;
#if PLATFORM(COCOA)
bool m_capsLockOn { false };
#endif
};
}