Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKWebViewInternal.h
1 /*
2  * Copyright (C) 2014-2016 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 "WKWebViewPrivate.h"
27
28 #if WK_API_ENABLED
29
30 #import "SameDocumentNavigationType.h"
31 #import "WKShareSheet.h"
32 #import "WKWebViewConfiguration.h"
33 #import "_WKAttachmentInternal.h"
34 #import "_WKWebViewPrintFormatterInternal.h"
35 #import <wtf/CompletionHandler.h>
36 #import <wtf/RefPtr.h>
37 #import <wtf/RetainPtr.h>
38 #import <wtf/Variant.h>
39
40 #if PLATFORM(IOS_FAMILY)
41 #import "UIKitSPI.h"
42 #import "WKContentView.h"
43 #import "WKContentViewInteraction.h"
44 #import "WKFullScreenWindowControllerIOS.h"
45 #import <WebCore/FloatRect.h>
46 #import <WebCore/LengthBox.h>
47 #endif
48
49 #if PLATFORM(IOS_FAMILY)
50 #define WK_WEB_VIEW_PROTOCOLS <UIScrollViewDelegate>
51 #endif
52
53 #if PLATFORM(MAC)
54 #define WK_WEB_VIEW_PROTOCOLS <WKShareSheetDelegate>
55 #endif
56
57 #if !defined(WK_WEB_VIEW_PROTOCOLS)
58 #define WK_WEB_VIEW_PROTOCOLS
59 #endif
60
61 typedef const struct OpaqueWKPage* WKPageRef;
62
63 namespace API {
64 class Attachment;
65 }
66
67 namespace WebKit {
68 enum class ContinueUnsafeLoad : bool;
69 class SafeBrowsingWarning;
70 class ViewSnapshot;
71 class WebPageProxy;
72 struct PrintInfo;
73 }
74
75 @class WKWebViewContentProviderRegistry;
76 @class WKPasswordView;
77 @class _WKFrameHandle;
78
79 @interface WKWebView () WK_WEB_VIEW_PROTOCOLS {
80
81 @package
82     RetainPtr<WKWebViewConfiguration> _configuration;
83
84     RefPtr<WebKit::WebPageProxy> _page;
85 }
86
87 #if PLATFORM(IOS_FAMILY)
88 - (void)_processDidExit;
89 - (void)_processWillSwap;
90 - (void)_didRelaunchProcess;
91
92 - (void)_didCommitLoadForMainFrame;
93 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
94 - (void)_layerTreeCommitComplete;
95
96 - (void)_couldNotRestorePageState;
97 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)insets scale:(double)scale;
98 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale; // FIXME: needs scroll origin?
99
100 - (RefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot;
101
102 - (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin;
103 - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
104 - (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRect selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates insideFixed:(BOOL)insideFixed fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
105 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
106 - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
107 - (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
108 - (void)_didFinishScrolling;
109
110 - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType;
111 - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data;
112
113 - (void)_willInvokeUIScrollViewDelegateCallback;
114 - (void)_didInvokeUIScrollViewDelegateCallback;
115
116 - (void)_scheduleVisibleContentRectUpdate;
117
118 - (void)_didCompleteAnimatedResize;
119
120 - (void)_didStartProvisionalLoadForMainFrame;
121 - (void)_didFinishLoadForMainFrame;
122 - (void)_didFailLoadForMainFrame;
123 - (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)navigationType;
124
125 - (BOOL)_isShowingVideoPictureInPicture;
126 - (BOOL)_mayAutomaticallyShowVideoPictureInPicture;
127
128 - (void)_updateScrollViewBackground;
129
130 - (void)_videoControlsManagerDidChange;
131
132 - (void)_navigationGestureDidBegin;
133 - (void)_navigationGestureDidEnd;
134 - (BOOL)_isNavigationSwipeGestureRecognizer:(UIGestureRecognizer *)recognizer;
135
136 - (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler;
137 - (void)_hidePasswordView;
138
139 - (void)_didChangeEditorState;
140
141 - (void)_addShortcut:(id)sender;
142 - (void)_define:(id)sender;
143 - (void)_lookup:(id)sender;
144 - (void)_share:(id)sender;
145 - (void)_showTextStyleOptions:(id)sender;
146 - (void)_promptForReplace:(id)sender;
147 - (void)_transliterateChinese:(id)sender;
148 - (void)replace:(id)sender;
149
150 - (void)_nextAccessoryTab:(id)sender;
151 - (void)_previousAccessoryTab:(id)sender;
152
153 - (void)_incrementFocusPreservationCount;
154 - (void)_decrementFocusPreservationCount;
155 - (void)_resetFocusPreservationCount;
156
157 @property (nonatomic, readonly) WKPasswordView *_passwordView;
158
159 @property (nonatomic, readonly) BOOL _isBackground;
160
161 @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
162
163 @property (nonatomic, readonly) WKSelectionGranularity _selectionGranularity;
164
165 @property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
166 @property (nonatomic, readonly) BOOL _stylusTapGestureShouldCreateEditableImage;
167 @property (nonatomic, readonly) BOOL _haveSetObscuredInsets;
168 @property (nonatomic, readonly) UIEdgeInsets _computedObscuredInset;
169 @property (nonatomic, readonly) UIEdgeInsets _computedUnobscuredSafeAreaInset;
170 @property (nonatomic, readonly, getter=_isRetainingActiveFocusedState) BOOL _retainingActiveFocusedState;
171 #endif
172
173 #if ENABLE(ACCESSIBILITY_EVENTS)
174 - (void)_updateAccessibilityEventsEnabled;
175 #endif
176
177 #if ENABLE(ATTACHMENT_ELEMENT)
178 - (void)_didRemoveAttachment:(API::Attachment&)attachment;
179 - (void)_didInsertAttachment:(API::Attachment&)attachment withSource:(NSString *)source;
180 - (void)_didInvalidateDataForAttachment:(API::Attachment&)attachment;
181 #endif
182
183 - (void)_showSafeBrowsingWarning:(const WebKit::SafeBrowsingWarning&)warning completionHandler:(CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&&)completionHandler;
184 - (void)_clearSafeBrowsingWarning;
185
186 - (std::optional<BOOL>)_resolutionForShareSheetImmediateCompletionForTesting;
187
188 - (WKPageRef)_pageForTesting;
189 - (WebKit::WebPageProxy*)_page;
190
191 @end
192
193 WKWebView* fromWebPageProxy(WebKit::WebPageProxy&);
194
195 #if ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
196 @interface WKWebView (FullScreenAPI)
197 -(BOOL)hasFullScreenWindowController;
198 -(WKFullScreenWindowController *)fullScreenWindowController;
199 -(void)closeFullScreenWindowController;
200 @end
201 #endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
202
203 #if PLATFORM(IOS_FAMILY) && !PLATFORM(IOSMAC)
204 @interface WKWebView (_WKWebViewPrintFormatter)
205 @property (nonatomic, readonly) id <_WKWebViewPrintProvider> _printProvider;
206 @end
207 #endif
208
209 #endif