[Attachment Support] Provide the `src` of an attachment to the UI delegate when an...
[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 "WKWebViewConfiguration.h"
32 #import "_WKAttachmentInternal.h"
33 #import <wtf/RefPtr.h>
34 #import <wtf/RetainPtr.h>
35
36 #if PLATFORM(IOS)
37 #import "UIKitSPI.h"
38 #import "WKContentView.h"
39 #import "WKContentViewInteraction.h"
40 #import "WKFullScreenWindowControllerIOS.h"
41 #import <WebCore/FloatRect.h>
42 #import <WebCore/LengthBox.h>
43 #endif
44
45 #if PLATFORM(IOS)
46 #define WK_WEB_VIEW_PROTOCOLS <UIScrollViewDelegate>
47 #endif
48
49 #if !defined(WK_WEB_VIEW_PROTOCOLS)
50 #define WK_WEB_VIEW_PROTOCOLS
51 #endif
52
53 typedef const struct OpaqueWKPage* WKPageRef;
54
55 namespace WebKit {
56 class ViewSnapshot;
57 class WebPageProxy;
58 struct PrintInfo;
59 }
60
61 @class WKWebViewContentProviderRegistry;
62 @class WKPasswordView;
63 @class _WKFrameHandle;
64 @protocol _WKWebViewPrintProvider;
65
66 @interface WKWebView () WK_WEB_VIEW_PROTOCOLS {
67
68 @package
69     RetainPtr<WKWebViewConfiguration> _configuration;
70
71     RefPtr<WebKit::WebPageProxy> _page;
72
73 #if PLATFORM(IOS)
74     NSUInteger _activeFocusedStateRetainCount;
75 #endif
76 }
77
78 #if PLATFORM(IOS)
79 - (void)_processDidExit;
80
81 - (void)_didCommitLoadForMainFrame;
82 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
83 - (void)_layerTreeCommitComplete;
84
85 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID;
86 - (void)_couldNotRestorePageState;
87 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)insets scale:(double)scale;
88 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale; // FIXME: needs scroll origin?
89
90 - (RefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot;
91
92 - (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin;
93 - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
94 - (void)_scrollByContentOffset:(WebCore::FloatPoint)offset;
95 - (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;
96 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
97 - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
98 - (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
99
100 - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType;
101 - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data;
102
103 - (void)_willInvokeUIScrollViewDelegateCallback;
104 - (void)_didInvokeUIScrollViewDelegateCallback;
105
106 - (void)_scheduleVisibleContentRectUpdate;
107
108 - (void)_didFinishLoadForMainFrame;
109 - (void)_didFailLoadForMainFrame;
110 - (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)navigationType;
111
112 - (BOOL)_isShowingVideoPictureInPicture;
113 - (BOOL)_mayAutomaticallyShowVideoPictureInPicture;
114
115 - (void)_updateScrollViewBackground;
116
117 - (void)_navigationGestureDidBegin;
118 - (void)_navigationGestureDidEnd;
119 - (BOOL)_isNavigationSwipeGestureRecognizer:(UIGestureRecognizer *)recognizer;
120
121 - (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler;
122 - (void)_hidePasswordView;
123
124 - (void)_didChangeEditorState;
125
126 - (void)_addShortcut:(id)sender;
127 - (void)_arrowKey:(id)sender;
128 - (void)_define:(id)sender;
129 - (void)_lookup:(id)sender;
130 - (void)_reanalyze:(id)sender;
131 - (void)_share:(id)sender;
132 - (void)_showTextStyleOptions:(id)sender;
133 - (void)_promptForReplace:(id)sender;
134 - (void)_transliterateChinese:(id)sender;
135 - (void)replace:(id)sender;
136
137 @property (nonatomic, readonly) WKPasswordView *_passwordView;
138
139 @property (nonatomic, readonly) BOOL _isBackground;
140
141 @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
142
143 @property (nonatomic, readonly) WKSelectionGranularity _selectionGranularity;
144
145 @property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
146 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
147 @property (nonatomic, readonly) UIEdgeInsets _computedUnobscuredSafeAreaInset;
148 #endif
149
150 #if ENABLE(ATTACHMENT_ELEMENT)
151 - (void)_didRemoveAttachment:(NSString *)identifier;
152 - (void)_didInsertAttachment:(NSString *)identifier withSource:(NSString *)source;
153 #endif
154
155 - (WKPageRef)_pageForTesting;
156 - (WebKit::WebPageProxy*)_page;
157
158 @end
159
160 WKWebView* fromWebPageProxy(WebKit::WebPageProxy&);
161
162 #if ENABLE(FULLSCREEN_API) && PLATFORM(IOS)
163 @interface WKWebView (FullScreenAPI)
164 -(BOOL)hasFullScreenWindowController;
165 -(WKFullScreenWindowController *)fullScreenWindowController;
166 -(void)closeFullScreenWindowController;
167 -(WebCoreFullScreenPlaceholderView *)fullScreenPlaceholderView;
168 @end
169 #endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS)
170
171 #if PLATFORM(IOS)
172 @interface WKWebView (_WKWebViewPrintFormatter)
173 @property (nonatomic, readonly) id <_WKWebViewPrintProvider> _printProvider;
174 @end
175 #endif
176
177 #endif