1 | /* |
2 | * Copyright (C) 2010, 2011 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 | #ifndef WKPage_h |
27 | #define WKPage_h |
28 | |
29 | #include <WebKit/WKBase.h> |
30 | #include <WebKit/WKDeprecated.h> |
31 | #include <WebKit/WKErrorRef.h> |
32 | #include <WebKit/WKEvent.h> |
33 | #include <WebKit/WKFindOptions.h> |
34 | #include <WebKit/WKGeometry.h> |
35 | #include <WebKit/WKNativeEvent.h> |
36 | #include <WebKit/WKPageContextMenuClient.h> |
37 | #include <WebKit/WKPageDiagnosticLoggingClient.h> |
38 | #include <WebKit/WKPageFindClient.h> |
39 | #include <WebKit/WKPageFindMatchesClient.h> |
40 | #include <WebKit/WKPageFormClient.h> |
41 | #include <WebKit/WKPageInjectedBundleClient.h> |
42 | #include <WebKit/WKPageLoadTypes.h> |
43 | #include <WebKit/WKPageLoaderClient.h> |
44 | #include <WebKit/WKPageNavigationClient.h> |
45 | #include <WebKit/WKPagePolicyClient.h> |
46 | #include <WebKit/WKPageUIClient.h> |
47 | #include <WebKit/WKPageVisibilityTypes.h> |
48 | |
49 | #ifndef __cplusplus |
50 | #include <stdbool.h> |
51 | #endif |
52 | |
53 | #ifdef __cplusplus |
54 | extern "C" { |
55 | #endif |
56 | |
57 | WK_EXPORT WKTypeID WKPageGetTypeID(); |
58 | |
59 | WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page); |
60 | WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page); |
61 | |
62 | WK_EXPORT WKPageConfigurationRef WKPageCopyPageConfiguration(WKPageRef page); |
63 | |
64 | // URL Requests |
65 | WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url); |
66 | WK_EXPORT void WKPageLoadURLWithUserData(WKPageRef page, WKURLRef url, WKTypeRef userData); |
67 | WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest); |
68 | WK_EXPORT void WKPageLoadURLRequestWithUserData(WKPageRef page, WKURLRequestRef urlRequest, WKTypeRef userData); |
69 | WK_EXPORT void WKPageLoadFile(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL); |
70 | WK_EXPORT void WKPageLoadFileWithUserData(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL, WKTypeRef userData); |
71 | |
72 | // Data Requests |
73 | WK_EXPORT void WKPageLoadData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL); |
74 | WK_EXPORT void WKPageLoadDataWithUserData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL, WKTypeRef userData); |
75 | WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL); |
76 | WK_EXPORT void WKPageLoadHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKTypeRef userData); |
77 | WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL); |
78 | WK_EXPORT void WKPageLoadAlternateHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL, WKTypeRef userData); |
79 | WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString); |
80 | WK_EXPORT void WKPageLoadPlainTextStringWithUserData(WKPageRef page, WKStringRef plainTextString, WKTypeRef userData); |
81 | WK_EXPORT void WKPageLoadWebArchiveData(WKPageRef page, WKDataRef webArchiveData); |
82 | WK_EXPORT void WKPageLoadWebArchiveDataWithUserData(WKPageRef page, WKDataRef webArchiveData, WKTypeRef userData); |
83 | |
84 | WK_EXPORT void WKPageStopLoading(WKPageRef page); |
85 | WK_EXPORT void (WKPageRef page); |
86 | WK_EXPORT void (WKPageRef page); |
87 | WK_EXPORT void (WKPageRef page); |
88 | WK_EXPORT void (WKPageRef page); |
89 | |
90 | WK_EXPORT bool WKPageTryClose(WKPageRef page); |
91 | WK_EXPORT void WKPageClose(WKPageRef page); |
92 | WK_EXPORT bool WKPageIsClosed(WKPageRef page); |
93 | |
94 | WK_EXPORT void WKPageGoForward(WKPageRef page); |
95 | WK_EXPORT bool WKPageCanGoForward(WKPageRef page); |
96 | WK_EXPORT void WKPageGoBack(WKPageRef page); |
97 | WK_EXPORT bool WKPageCanGoBack(WKPageRef page); |
98 | WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item); |
99 | WK_EXPORT void WKPageTryRestoreScrollPosition(WKPageRef page); |
100 | WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page); |
101 | WK_EXPORT bool WKPageWillHandleHorizontalScrollEvents(WKPageRef page); |
102 | |
103 | WK_EXPORT void WKPageUpdateWebsitePolicies(WKPageRef, WKWebsitePoliciesRef); |
104 | |
105 | WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page); |
106 | |
107 | WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page); |
108 | |
109 | WK_EXPORT WKURLRef WKPageCopyActiveURL(WKPageRef page); |
110 | WK_EXPORT WKURLRef WKPageCopyProvisionalURL(WKPageRef page); |
111 | WK_EXPORT WKURLRef WKPageCopyCommittedURL(WKPageRef page); |
112 | |
113 | WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page); |
114 | WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive. |
115 | WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page); |
116 | WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page); |
117 | |
118 | WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page); |
119 | |
120 | WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page); |
121 | |
122 | WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page); |
123 | |
124 | WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page); |
125 | WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName); |
126 | |
127 | WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page); |
128 | WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent); |
129 | |
130 | WK_EXPORT void WKPageSetUserContentExtensionsEnabled(WKPageRef, bool); |
131 | |
132 | WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page); |
133 | WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page); |
134 | WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName); |
135 | |
136 | WK_EXPORT void WKPageTerminate(WKPageRef page); |
137 | |
138 | WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void); |
139 | WK_EXPORT WKStringRef WKPageGetSessionBackForwardListItemValueType(void); |
140 | |
141 | typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context); |
142 | |
143 | // FIXME: This should return a WKSessionStateRef object, not a WKTypeRef. |
144 | // It currently returns a WKTypeRef for backwards compatibility with Safari. |
145 | WK_EXPORT WKTypeRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback); |
146 | |
147 | // FIXME: This should take a WKSessionStateRef object, not a WKTypeRef. |
148 | // It currently takes a WKTypeRef for backwards compatibility with Safari. |
149 | WK_EXPORT void (WKPageRef page, WKTypeRef sessionState); |
150 | |
151 | WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page); |
152 | WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor); |
153 | WK_EXPORT void WKPageClearWheelEventTestTrigger(WKPageRef page); |
154 | |
155 | WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page); |
156 | WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page); |
157 | WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor); |
158 | WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page); |
159 | WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor); |
160 | WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor); |
161 | |
162 | WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin); |
163 | WK_EXPORT double WKPageGetScaleFactor(WKPageRef page); |
164 | |
165 | WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed); |
166 | WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size); |
167 | WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page); |
168 | WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page); |
169 | |
170 | WK_EXPORT void WKPageListenForLayoutMilestones(WKPageRef page, WKLayoutMilestones milestones); |
171 | |
172 | WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page); |
173 | WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page); |
174 | |
175 | WK_EXPORT void WKPageSetSuppressScrollbarAnimations(WKPageRef page, bool suppressAnimations); |
176 | WK_EXPORT bool WKPageAreScrollbarAnimationsSuppressed(WKPageRef page); |
177 | |
178 | WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page); |
179 | WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page); |
180 | WK_EXPORT bool WKPageIsPinnedToTopSide(WKPageRef page); |
181 | WK_EXPORT bool WKPageIsPinnedToBottomSide(WKPageRef page); |
182 | |
183 | // This API is poorly named. Even when these values are set to false, rubber-banding will |
184 | // still be allowed to occur at the end of a momentum scroll. These values are used along |
185 | // with pin state to determine if wheel events should be handled in the web process or if |
186 | // they should be passed up to the client. |
187 | WK_EXPORT bool WKPageRubberBandsAtLeft(WKPageRef); |
188 | WK_EXPORT void WKPageSetRubberBandsAtLeft(WKPageRef, bool rubberBandsAtLeft); |
189 | WK_EXPORT bool WKPageRubberBandsAtRight(WKPageRef); |
190 | WK_EXPORT void WKPageSetRubberBandsAtRight(WKPageRef, bool rubberBandsAtRight); |
191 | WK_EXPORT bool WKPageRubberBandsAtTop(WKPageRef); |
192 | WK_EXPORT void WKPageSetRubberBandsAtTop(WKPageRef, bool rubberBandsAtTop); |
193 | WK_EXPORT bool WKPageRubberBandsAtBottom(WKPageRef); |
194 | WK_EXPORT void WKPageSetRubberBandsAtBottom(WKPageRef, bool rubberBandsAtBottom); |
195 | |
196 | // Rubber-banding is enabled by default. |
197 | WK_EXPORT bool WKPageVerticalRubberBandingIsEnabled(WKPageRef); |
198 | WK_EXPORT void WKPageSetEnableVerticalRubberBanding(WKPageRef, bool enableVerticalRubberBanding); |
199 | WK_EXPORT bool WKPageHorizontalRubberBandingIsEnabled(WKPageRef); |
200 | WK_EXPORT void WKPageSetEnableHorizontalRubberBanding(WKPageRef, bool enableHorizontalRubberBanding); |
201 | |
202 | WK_EXPORT void WKPageSetBackgroundExtendsBeyondPage(WKPageRef, bool backgroundExtendsBeyondPage); |
203 | WK_EXPORT bool WKPageBackgroundExtendsBeyondPage(WKPageRef); |
204 | |
205 | WK_EXPORT bool WKPageCanDelete(WKPageRef page); |
206 | WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page); |
207 | WK_EXPORT bool WKPageIsContentEditable(WKPageRef page); |
208 | |
209 | WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection); |
210 | WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page); |
211 | |
212 | WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); |
213 | WK_EXPORT void WKPageHideFindUI(WKPageRef page); |
214 | WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); |
215 | WK_EXPORT void WKPageFindStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); |
216 | WK_EXPORT void WKPageGetImageForFindMatch(WKPageRef page, int32_t matchIndex); |
217 | WK_EXPORT void WKPageSelectFindMatch(WKPageRef page, int32_t matchIndex); |
218 | |
219 | WK_EXPORT void (WKPageRef page, const WKPageContextMenuClientBase* client); |
220 | WK_EXPORT void WKPageSetPageDiagnosticLoggingClient(WKPageRef page, const WKPageDiagnosticLoggingClientBase* client); |
221 | WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClientBase* client); |
222 | WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClientBase* client); |
223 | WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClientBase* client); |
224 | WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClientBase* client); |
225 | WK_EXPORT void WKPageSetPageInjectedBundleClient(WKPageRef page, const WKPageInjectedBundleClientBase* client); |
226 | |
227 | // A client can implement either a navigation client or loader and policy clients, but never both. |
228 | WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClientBase* client) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKPageSetPageNavigationClient, macos(10.14.4)); |
229 | WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClientBase* client) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKPageSetPageNavigationClient, macos(10.14.4)); |
230 | WK_EXPORT void WKPageSetPageNavigationClient(WKPageRef page, const WKPageNavigationClientBase* client); |
231 | |
232 | typedef void (*)(WKSerializedScriptValueRef, WKErrorRef, void*); |
233 | WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function); |
234 | #ifdef __BLOCKS__ |
235 | typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef); |
236 | WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block); |
237 | #endif |
238 | |
239 | typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*); |
240 | WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function); |
241 | |
242 | typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*); |
243 | WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function); |
244 | |
245 | typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*); |
246 | WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, void* context, WKPageGetContentsAsMHTMLDataFunction function); |
247 | |
248 | typedef void (*WKPageGetSelectionAsWebArchiveDataFunction)(WKDataRef, WKErrorRef, void*); |
249 | WK_EXPORT void WKPageGetSelectionAsWebArchiveData(WKPageRef page, void* context, WKPageGetSelectionAsWebArchiveDataFunction function); |
250 | |
251 | typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*); |
252 | WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function); |
253 | |
254 | /* |
255 | Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported: |
256 | |
257 | "Cut" |
258 | "Copy" |
259 | "Paste" |
260 | "SelectAll" |
261 | "Undo" |
262 | "Redo" |
263 | */ |
264 | |
265 | // state represents the state of the command in a menu (on is 1, off is 0, and mixed is -1), typically used to add a checkmark next to the menu item. |
266 | typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context); |
267 | WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback); |
268 | WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command); |
269 | |
270 | WK_EXPORT void WKPagePostMessageToInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody); |
271 | |
272 | WK_EXPORT void (WKPageRef page, WKContextMenuItemRef item); |
273 | |
274 | #ifdef __cplusplus |
275 | } |
276 | #endif |
277 | |
278 | #endif /* WKPage_h */ |
279 | |