Make it possible to test non-stable-state scrolling on iOS
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / Cocoa / WKWebViewPrivate.h
1 /*
2  * Copyright (C) 2014 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 #import <WebKit/WKWebView.h>
27
28 #if WK_API_ENABLED
29
30 #import <WebKit/_WKFindOptions.h>
31 #import <WebKit/_WKLayoutMode.h>
32 #import <WebKit/_WKRenderingProgressEvents.h>
33
34 typedef NS_ENUM(NSInteger, _WKPaginationMode) {
35     _WKPaginationModeUnpaginated,
36     _WKPaginationModeLeftToRight,
37     _WKPaginationModeRightToLeft,
38     _WKPaginationModeTopToBottom,
39     _WKPaginationModeBottomToTop,
40 } WK_API_AVAILABLE(macosx(10.10), ios(8.0));
41
42 #if !TARGET_OS_IPHONE
43
44 typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
45     _WKImmediateActionNone,
46     _WKImmediateActionLinkPreview,
47     _WKImmediateActionDataDetectedItem,
48     _WKImmediateActionLookupText,
49     _WKImmediateActionMailtoLink,
50     _WKImmediateActionTelLink
51 } WK_API_AVAILABLE(macosx(10.12));
52
53 #endif
54
55 @class AVFunctionBarScrubber;
56 @class WKBrowsingContextHandle;
57 @class _WKFrameHandle;
58 @class _WKHitTestResult;
59 @class _WKIconLoadingDelegate;
60 @class _WKRemoteObjectRegistry;
61 @class _WKSessionState;
62 @class _WKWebViewPrintFormatter;
63
64 @protocol WKHistoryDelegatePrivate;
65 @protocol _WKDiagnosticLoggingDelegate;
66 @protocol _WKFindDelegate;
67 @protocol _WKIconLoadingDelegate;
68 @protocol _WKInputDelegate;
69 @protocol _WKFullscreenDelegate;
70
71 @interface WKWebView (WKPrivate)
72
73 // FIXME: This should return a _WKRemoteObjectRegistry *.
74 @property (nonatomic, readonly) id _remoteObjectRegistry;
75 @property (nonatomic, readonly) WKBrowsingContextHandle *_handle;
76
77 @property (nonatomic, setter=_setObservedRenderingProgressEvents:) _WKRenderingProgressEvents _observedRenderingProgressEvents;
78
79 @property (nonatomic, weak, setter=_setHistoryDelegate:) id <WKHistoryDelegatePrivate> _historyDelegate;
80 @property (nonatomic, weak, setter=_setIconLoadingDelegate:) id <_WKIconLoadingDelegate> _iconLoadingDelegate;
81
82 @property (nonatomic, readonly) NSURL *_unreachableURL;
83
84 - (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
85 - (WKNavigation *)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL userData:(id)userData WK_API_AVAILABLE(macosx(10.12), ios(10.0));
86
87 @property (nonatomic, readonly) NSArray *_certificateChain WK_API_DEPRECATED_WITH_REPLACEMENT("certificateChain", macosx(10.10, 10.11), ios(8.0, 9.0));
88 @property (nonatomic, readonly) NSURL *_committedURL;
89 @property (nonatomic, readonly) NSString *_MIMEType;
90 @property (nonatomic, readonly) NSString *_userAgent WK_API_AVAILABLE(macosx(10.11), ios(9.0));
91
92 @property (copy, setter=_setApplicationNameForUserAgent:) NSString *_applicationNameForUserAgent;
93 @property (copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
94
95 @property (nonatomic, setter=_setUserContentExtensionsEnabled:) BOOL _userContentExtensionsEnabled WK_API_AVAILABLE(macosx(10.11), ios(9.0));
96
97 @property (nonatomic, readonly) pid_t _webProcessIdentifier;
98
99 @property (nonatomic, getter=_isEditable, setter=_setEditable:) BOOL _editable WK_API_AVAILABLE(macosx(10.11), ios(9.0));
100
101 // FIXME: Remove these once nobody is using them.
102 @property (nonatomic, readonly) NSData *_sessionStateData;
103 - (void)_restoreFromSessionStateData:(NSData *)sessionStateData;
104
105 @property (nonatomic, readonly) _WKSessionState *_sessionState;
106 - (WKNavigation *)_restoreSessionState:(_WKSessionState *)sessionState andNavigate:(BOOL)navigate;
107 - (_WKSessionState *)_sessionStateWithFilter:(BOOL (^)(WKBackForwardListItem *item))filter;
108
109 @property (nonatomic, setter=_setAllowsRemoteInspection:) BOOL _allowsRemoteInspection;
110 @property (nonatomic, copy, setter=_setRemoteInspectionNameOverride:) NSString *_remoteInspectionNameOverride WK_API_AVAILABLE(macosx(10.12), ios(10.0));
111
112 @property (nonatomic, setter=_setAddsVisitedLinks:) BOOL _addsVisitedLinks;
113
114 @property (nonatomic, readonly) BOOL _networkRequestsInProgress;
115
116 @property (nonatomic, readonly, getter=_isShowingNavigationGestureSnapshot) BOOL _showingNavigationGestureSnapshot;
117
118 - (void)_close;
119
120 @property (nonatomic, setter=_setLayoutMode:) _WKLayoutMode _layoutMode;
121 // For use with _layoutMode = _WKLayoutModeFixedSize:
122 @property (nonatomic, setter=_setFixedLayoutSize:) CGSize _fixedLayoutSize;
123
124 @property (nonatomic, setter=_setViewScale:) CGFloat _viewScale;
125
126 #if TARGET_OS_IPHONE
127 // DERECATED: The setters of the three following function are deprecated, please use overrideLayoutParameters.
128 // Define the smallest size a page take with a regular viewport.
129 @property (nonatomic, readonly) CGSize _minimumLayoutSizeOverride;
130 // Define the largest size the unobscured area can get for the current view bounds. This value is used to define viewport units.
131 @property (nonatomic, readonly) CGSize _maximumUnobscuredSizeOverride;
132
133 // Define the inset of the scrollview unusable by the web page.
134 @property (nonatomic, setter=_setObscuredInsets:) UIEdgeInsets _obscuredInsets;
135
136 // Override the interface orientation. Clients using _beginAnimatedResizeWithUpdates: must update the interface orientation
137 // in the update block.
138 @property (nonatomic, setter=_setInterfaceOrientationOverride:) UIInterfaceOrientation _interfaceOrientationOverride;
139
140 @property (nonatomic, setter=_setAllowsViewportShrinkToFit:) BOOL _allowsViewportShrinkToFit;
141
142 @property (nonatomic, setter=_setBackgroundExtendsBeyondPage:) BOOL _backgroundExtendsBeyondPage;
143
144 // FIXME: Remove these three properties once we expose WKWebViewContentProvider as API.
145 @property (nonatomic, readonly, getter=_isDisplayingPDF) BOOL _displayingPDF;
146 @property (nonatomic, readonly) NSData *_dataForDisplayedPDF;
147 // FIXME: This can be removed once WKNavigation's response property is implemented.
148 @property (nonatomic, readonly) NSString *_suggestedFilenameForDisplayedPDF;
149
150 @property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
151
152 - (void)_beginInteractiveObscuredInsetsChange;
153 - (void)_endInteractiveObscuredInsetsChange;
154 - (void)_hideContentUntilNextUpdate;
155
156 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock;
157 - (void)_endAnimatedResize;
158 - (void)_resizeWhileHidingContentWithUpdates:(void (^)(void))updateBlock;
159
160 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler;
161
162 // Deprecated: Use [_overrideLayoutParametersWithMinimumLayoutSize:maximumUnobscuredSizeOverride:] instead.
163 // This function is kept for binary compatibility with iOS 8.0, it can be removed after the bincompat window.
164 - (void)_overrideLayoutParametersWithMinimumLayoutSize:(CGSize)minimumLayoutSize minimumLayoutSizeForMinimalUI:(CGSize)minimumLayoutSizeForMinimalUI maximumUnobscuredSizeOverride:(CGSize)maximumUnobscuredSizeOverride WK_API_DEPRECATED_WITH_REPLACEMENT("-_overrideLayoutParametersWithMinimumLayoutSize:maximumUnobscuredSizeOverride:", ios(8.0, 9.0));
165
166 - (void)_overrideLayoutParametersWithMinimumLayoutSize:(CGSize)minimumLayoutSize maximumUnobscuredSizeOverride:(CGSize)maximumUnobscuredSizeOverride WK_API_AVAILABLE(ios(9_0));
167
168 - (UIView *)_viewForFindUI;
169
170 - (void)_setOverlaidAccessoryViewsInset:(CGSize)inset;
171
172 - (void)_killWebContentProcess;
173 - (void)_didRelaunchProcess;
174
175 // Puts the view into a state where being taken out of the view hierarchy and resigning first responder
176 // will not count as becoming inactive and unfocused. The returned block must be called to exit the state.
177 - (void (^)(void))_retainActiveFocusedState WK_API_AVAILABLE(ios(9_0));
178
179 - (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler WK_API_AVAILABLE(ios(9_0));
180
181 - (id)_snapshotLayerContentsForBackForwardListItem:(WKBackForwardListItem *)item WK_API_AVAILABLE(ios(9_0));
182 - (NSArray *)_dataDetectionResults;
183
184 #else
185 @property (readonly) NSColor *_pageExtendedBackgroundColor;
186 @property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground;
187 @property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
188
189 @property (nonatomic, setter=_setAutomaticallyAdjustsContentInsets:) BOOL _automaticallyAdjustsContentInsets;
190
191 // Default value is 0. A value of 0 means the window's backing scale factor will be used and automatically update when the window moves screens.
192 @property (nonatomic, setter=_setOverrideDeviceScaleFactor:) CGFloat _overrideDeviceScaleFactor WK_API_AVAILABLE(macosx(10.11));
193
194 @property (nonatomic, setter=_setWindowOcclusionDetectionEnabled:) BOOL _windowOcclusionDetectionEnabled;
195
196 // Clients that want to maintain default behavior can return nil. To disable the immediate action entirely, return NSNull. And to
197 // do something custom, return an object that conforms to the NSImmediateActionAnimationController protocol.
198 - (id)_immediateActionAnimationControllerForHitTestResult:(_WKHitTestResult *)hitTestResult withType:(_WKImmediateActionType)type userData:(id<NSSecureCoding>)userData;
199
200 @property (nonatomic, setter=_setMinimumLayoutWidth:) CGFloat _minimumLayoutWidth WK_API_AVAILABLE(macosx(10.12));
201
202 // When using _minimumLayoutWidth, the web content will lay out to the intrinsic height
203 // of the content; use this property to force it to lay out to the height of the view instead.
204 @property (nonatomic, setter=_setShouldExpandContentToViewHeightForAutoLayout:) BOOL _shouldExpandContentToViewHeightForAutoLayout WK_API_AVAILABLE(macosx(10.12));
205
206 - (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
207 - (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(_WKFrameHandle *)frameHandle WK_API_AVAILABLE(macosx(10.12), ios(10.0));
208
209 // FIXME: This SPI should become a part of the WKUIDelegate. rdar://problem/26561537
210 @property (nonatomic, readwrite, setter=_setWantsMediaPlaybackControlsView:) BOOL _wantsMediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
211 @property (nonatomic, readonly) AVFunctionBarScrubber *_mediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
212 - (void)_addMediaPlaybackControlsView:(AVFunctionBarScrubber *)mediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
213 - (void)_removeMediaPlaybackControlsView WK_API_AVAILABLE(macosx(WK_MAC_TBA));
214
215 #endif
216
217 - (WKNavigation *)_reloadWithoutContentBlockers WK_API_AVAILABLE(macosx(10.12), ios(10.0));
218
219 - (void)_killWebContentProcessAndResetState;
220
221 - (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
222 - (void)_getWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
223
224 @property (nonatomic, setter=_setPaginationMode:) _WKPaginationMode _paginationMode;
225 // Whether the column-break-{before,after} properties are respected instead of the
226 // page-break-{before,after} properties.
227 @property (nonatomic, setter=_setPaginationBehavesLikeColumns:) BOOL _paginationBehavesLikeColumns;
228 // Set to 0 to have the page length equal the view length.
229 @property (nonatomic, setter=_setPageLength:) CGFloat _pageLength;
230 @property (nonatomic, setter=_setGapBetweenPages:) CGFloat _gapBetweenPages;
231 @property (nonatomic, setter=_setPaginationLineGridEnabled:) BOOL _paginationLineGridEnabled;
232 @property (readonly) NSUInteger _pageCount;
233
234 @property (nonatomic, readonly) BOOL _supportsTextZoom;
235 @property (nonatomic, setter=_setTextZoomFactor:) double _textZoomFactor;
236 @property (nonatomic, setter=_setPageZoomFactor:) double _pageZoomFactor;
237
238 @property (nonatomic, weak, setter=_setDiagnosticLoggingDelegate:) id <_WKDiagnosticLoggingDelegate> _diagnosticLoggingDelegate WK_API_AVAILABLE(macosx(10.11), ios(9.0));
239 @property (nonatomic, weak, setter=_setFindDelegate:) id <_WKFindDelegate> _findDelegate;
240 - (void)_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount;
241 - (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount;
242 - (void)_hideFindUI;
243
244 @property (nonatomic, weak, setter=_setInputDelegate:) id <_WKInputDelegate> _inputDelegate WK_API_AVAILABLE(macosx(10.12), ios(10.0));
245
246 @property (nonatomic, readonly, getter=_isDisplayingStandaloneImageDocument) BOOL _displayingStandaloneImageDocument;
247 @property (nonatomic, readonly, getter=_isDisplayingStandaloneMediaDocument) BOOL _displayingStandaloneMediaDocument;
248
249 @property (nonatomic, setter=_setScrollPerformanceDataCollectionEnabled:) BOOL _scrollPerformanceDataCollectionEnabled WK_API_AVAILABLE(macosx(10.11), ios(9.0));
250 @property (nonatomic, readonly) NSArray *_scrollPerformanceData WK_API_AVAILABLE(macosx(10.11), ios(9.0));
251
252 - (void)_saveBackForwardSnapshotForItem:(WKBackForwardListItem *)item WK_API_AVAILABLE(macosx(10.11), ios(9.0));
253
254 @property (nonatomic, getter=_allowsMediaDocumentInlinePlayback, setter=_setAllowsMediaDocumentInlinePlayback:) BOOL _allowsMediaDocumentInlinePlayback;
255
256 @property (nonatomic, readonly) BOOL _webProcessIsResponsive WK_API_AVAILABLE(macosx(10.12), ios(10.0));
257
258 @property (nonatomic, setter=_setFullscreenDelegate:) id<_WKFullscreenDelegate> _fullscreenDelegate WK_API_AVAILABLE(macosx(10.13));
259 @property (nonatomic, readonly) BOOL _isInFullscreen WK_API_AVAILABLE(macosx(WK_MAC_TBA));
260
261 @end
262
263 #if !TARGET_OS_IPHONE
264 @interface WKWebView (WKNSTextFinderClient) <NSTextFinderClient>
265 @end
266 #endif
267
268 @interface WKWebView (WKTesting)
269
270 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
271
272 #if TARGET_OS_IPHONE
273
274 @property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(ios(10.0));
275 - (CGPoint)_convertPointFromContentsToView:(CGPoint)point WK_API_AVAILABLE(ios(10.0));
276 - (CGPoint)_convertPointFromViewToContents:(CGPoint)point WK_API_AVAILABLE(ios(10.0));
277
278 - (void)keyboardAccessoryBarNext WK_API_AVAILABLE(ios(10.0));
279 - (void)keyboardAccessoryBarPrevious WK_API_AVAILABLE(ios(10.0));
280 - (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(WK_IOS_TBA));
281 - (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
282
283 - (void)didStartFormControlInteraction WK_API_AVAILABLE(ios(WK_IOS_TBA));
284 - (void)didEndFormControlInteraction WK_API_AVAILABLE(ios(WK_IOS_TBA));
285
286 - (void)_didShowForcePressPreview WK_API_AVAILABLE(ios(WK_IOS_TBA));
287 - (void)_didDismissForcePressPreview WK_API_AVAILABLE(ios(WK_IOS_TBA));
288
289 @property (nonatomic, readonly) NSArray<UIView *> *_uiTextSelectionRectViews WK_API_AVAILABLE(ios(WK_IOS_TBA));
290
291 @property (nonatomic, readonly) NSString *_scrollingTreeAsText WK_API_AVAILABLE(ios(WK_IOS_TBA));
292
293 @property (nonatomic, readonly) NSNumber *_stableStateOverride WK_API_AVAILABLE(ios(WK_IOS_TBA));
294
295 #endif // TARGET_OS_IPHONE
296
297 #if !TARGET_OS_IPHONE
298 @property (nonatomic, readonly) BOOL _hasActiveVideoForControlsManager WK_API_AVAILABLE(macosx(10.12));
299 - (void)_requestControlledElementID WK_API_AVAILABLE(macosx(WK_MAC_TBA));
300 - (void)_handleControlledElementIDResponse:(NSString *)identifier WK_API_AVAILABLE(macosx(WK_MAC_TBA));
301 - (void)_handleAcceptedCandidate:(NSTextCheckingResult *)candidate WK_API_AVAILABLE(macosx(WK_MAC_TBA));
302 - (void)_didHandleAcceptedCandidate WK_API_AVAILABLE(macosx(WK_MAC_TBA));
303 - (void)_forceRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
304 - (void)_didUpdateCandidateListVisibility:(BOOL)visible WK_API_AVAILABLE(macosx(WK_MAC_TBA));
305 @property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
306 - (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA));
307 - (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA));
308
309 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA));
310 #endif
311
312 - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(WK_IOS_TBA));
313 - (CGFloat)_pageScale WK_API_AVAILABLE(ios(WK_IOS_TBA));
314
315 - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(10.12), ios(10.0));
316
317 - (void)_disableBackForwardSnapshotVolatilityForTesting WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
318
319 @end
320
321 #endif