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