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