Allow UI clients to handle vertical wheel events.
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / C / WKPage.h
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 <WebKit2/WKBase.h>
30 #include <WebKit2/WKError.h>
31 #include <WebKit2/WKEvent.h>
32 #include <WebKit2/WKFindOptions.h>
33 #include <WebKit2/WKGeometry.h>
34 #include <WebKit2/WKNativeEvent.h>
35 #include <WebKit2/WKPageLoadTypes.h>
36 #include <WebKit2/WKPageVisibilityTypes.h>
37
38 #ifndef __cplusplus
39 #include <stdbool.h>
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 enum {
47     kWKFocusDirectionBackward = 0,
48     kWKFocusDirectionForward = 1
49 };
50 typedef uint32_t WKFocusDirection;
51
52 typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
53
54 // FrameLoad Client
55 typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
56 typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
57 typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
58 typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
59 typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
60 typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
61 typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
62 typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo);
63 typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
64 typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
65 typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
66 typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
67 typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
68 typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
69 typedef void (*WKPageDidDetectXSSForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
70 typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
71 typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
72 typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
73 typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
74 typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
75 typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, WKTypeRef userData, const void *clientInfo);
76 typedef void (*WKPagePluginDidFailCallback)(WKPageRef page, WKErrorCode errorCode, WKStringRef mimeType, WKStringRef pluginIdentifier, WKStringRef pluginVersion, const void* clientInfo);
77 typedef void (*WKPageDidLayoutCallback)(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef userData, const void *clientInfo);
78
79 // Deprecated
80 typedef void (*WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
81
82 struct WKPageLoaderClient {
83     int                                                                 version;
84     const void *                                                        clientInfo;
85     WKPageDidStartProvisionalLoadForFrameCallback                       didStartProvisionalLoadForFrame;
86     WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback    didReceiveServerRedirectForProvisionalLoadForFrame;
87     WKPageDidFailProvisionalLoadWithErrorForFrameCallback               didFailProvisionalLoadWithErrorForFrame;
88     WKPageDidCommitLoadForFrameCallback                                 didCommitLoadForFrame;
89     WKPageDidFinishDocumentLoadForFrameCallback                         didFinishDocumentLoadForFrame;
90     WKPageDidFinishLoadForFrameCallback                                 didFinishLoadForFrame;
91     WKPageDidFailLoadWithErrorForFrameCallback                          didFailLoadWithErrorForFrame;
92     WKPageDidSameDocumentNavigationForFrameCallback                     didSameDocumentNavigationForFrame;
93     WKPageDidReceiveTitleForFrameCallback                               didReceiveTitleForFrame;
94     WKPageDidFirstLayoutForFrameCallback                                didFirstLayoutForFrame;
95     WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback                didFirstVisuallyNonEmptyLayoutForFrame;
96     WKPageDidRemoveFrameFromHierarchyCallback                           didRemoveFrameFromHierarchy;
97     WKPageDidDisplayInsecureContentForFrameCallback                     didDisplayInsecureContentForFrame;
98     WKPageDidRunInsecureContentForFrameCallback                         didRunInsecureContentForFrame;
99     WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback          canAuthenticateAgainstProtectionSpaceInFrame;
100     WKPageDidReceiveAuthenticationChallengeInFrameCallback              didReceiveAuthenticationChallengeInFrame;
101
102     // FIXME: Move to progress client.
103     WKPageCallback                                                      didStartProgress;
104     WKPageCallback                                                      didChangeProgress;
105     WKPageCallback                                                      didFinishProgress;
106
107     // FIXME: These three functions should not be part of this client.
108     WKPageCallback                                                      processDidBecomeUnresponsive;
109     WKPageCallback                                                      processDidBecomeResponsive;
110     WKPageCallback                                                      processDidCrash;
111     WKPageDidChangeBackForwardListCallback                              didChangeBackForwardList;
112     WKPageShouldGoToBackForwardListItemCallback                         shouldGoToBackForwardListItem;
113     WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0      didFailToInitializePlugin_deprecatedForUseWithV0;
114
115     // Version 1
116     WKPageDidDetectXSSForFrameCallback                                  didDetectXSSForFrame;
117
118     // FIXME: didNewFirstVisuallyNonEmptyLayout should be removed. We should consider removing didFirstVisuallyNonEmptyLayoutForFrame
119     // as well. Their functionality is replaced by didLayout.
120     WKPageDidNewFirstVisuallyNonEmptyLayoutCallback                     didNewFirstVisuallyNonEmptyLayout;
121
122     WKPageWillGoToBackForwardListItemCallback                           willGoToBackForwardListItem;
123
124     WKPageCallback                                                      interactionOccurredWhileProcessUnresponsive;
125     WKPagePluginDidFailCallback                                         pluginDidFail;
126
127     // Version 2
128     void                                                                (*didReceiveIntentForFrame_unavailable)(void);
129     void                                                                (*registerIntentServiceForFrame_unavailable)(void);
130
131     WKPageDidLayoutCallback                                             didLayout;
132 };
133 typedef struct WKPageLoaderClient WKPageLoaderClient;
134
135 enum { kWKPageLoaderClientCurrentVersion = 2 };
136
137 // Policy Client.
138 typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
139 typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
140 typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
141 typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);
142
143 struct WKPagePolicyClient {
144     int                                                                 version;
145     const void *                                                        clientInfo;
146     WKPageDecidePolicyForNavigationActionCallback                       decidePolicyForNavigationAction;
147     WKPageDecidePolicyForNewWindowActionCallback                        decidePolicyForNewWindowAction;
148     WKPageDecidePolicyForResponseCallback                               decidePolicyForResponse;
149     WKPageUnableToImplementPolicyCallback                               unableToImplementPolicy;
150 };
151 typedef struct WKPagePolicyClient WKPagePolicyClient;
152
153 enum { kWKPagePolicyClientCurrentVersion = 0 };
154
155 // Form Client.
156 typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
157
158 struct WKPageFormClient {
159     int                                                                 version;
160     const void *                                                        clientInfo;
161     WKPageWillSubmitFormCallback                                        willSubmitForm;
162 };
163 typedef struct WKPageFormClient WKPageFormClient;
164
165 enum { kWKPageFormClientCurrentVersion = 0 };
166
167 enum {
168     kWKPluginUnavailabilityReasonPluginMissing,
169     kWKPluginUnavailabilityReasonPluginCrashed,
170     kWKPluginUnavailabilityReasonInsecurePluginVersion
171 };
172 typedef uint32_t WKPluginUnavailabilityReason;
173
174 enum {
175     kWKPluginLoadPolicyLoadNormally = 0,
176     kWKPluginLoadPolicyBlocked,
177     kWKPluginLoadPolicyInactive,
178 };
179 typedef uint32_t WKPluginLoadPolicy;
180
181 // UI Client
182 typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
183 typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
184 typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
185 typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
186 typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
187 typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
188 typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
189 typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
190 typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
191 typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
192 typedef void (*WKPageDidNotHandleWheelEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
193 typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo);
194 typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo);
195 typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
196 typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo);
197 typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
198 typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo);
199 typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo);
200 typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo);
201 typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
202 typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
203 typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
204 typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo);
205 typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
206 typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
207 typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
208 typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
209 typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
210 typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
211 typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
212 typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
213 typedef bool (*WKPageShouldInterruptJavaScriptCallback)(WKPageRef page, const void *clientInfo);
214 typedef void (*WKPageDecidePolicyForNotificationPermissionRequestCallback)(WKPageRef page, WKSecurityOriginRef origin, WKNotificationPermissionRequestRef permissionRequest, const void *clientInfo);
215 typedef void (*WKPageUnavailablePluginButtonClickedCallback)(WKPageRef page, WKPluginUnavailabilityReason pluginUnavailabilityReason, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
216 typedef void (*WKPageShowColorPickerCallback)(WKPageRef page, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo);
217 typedef void (*WKPageHideColorPickerCallback)(WKPageRef page, const void* clientInfo);
218 typedef WKPluginLoadPolicy (*WKPagePluginLoadPolicyCallback)(WKPageRef page, WKStringRef identifier, WKStringRef displayName, WKURLRef documentURL, WKPluginLoadPolicy currentPluginLoadPolicy, const void* clientInfo);
219
220 // Deprecated    
221 typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
222 typedef void      (*WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
223 typedef void (*WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
224
225 struct WKPageUIClient {
226     int                                                                 version;
227     const void *                                                        clientInfo;
228
229     // Version 0
230     WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
231     WKPageCallback                                                      showPage;
232     WKPageCallback                                                      close;
233     WKPageTakeFocusCallback                                             takeFocus;
234     WKPageFocusCallback                                                 focus;
235     WKPageUnfocusCallback                                               unfocus;
236     WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
237     WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
238     WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
239     WKPageSetStatusTextCallback                                         setStatusText;
240     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
241     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
242     WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
243     WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
244     WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
245     WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
246     WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
247     WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
248     WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
249     WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
250     WKPageGetIsResizableCallback                                        isResizable;
251     WKPageSetIsResizableCallback                                        setIsResizable;
252     WKPageGetWindowFrameCallback                                        getWindowFrame;
253     WKPageSetWindowFrameCallback                                        setWindowFrame;
254     WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
255     WKPageCallback                                                      didDraw;
256     WKPageCallback                                                      pageDidScroll;
257     WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
258     WKPageRunOpenPanelCallback                                          runOpenPanel;
259     WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
260     WKPageHeaderHeightCallback                                          headerHeight;
261     WKPageFooterHeightCallback                                          footerHeight;
262     WKPageDrawHeaderCallback                                            drawHeader;
263     WKPageDrawFooterCallback                                            drawFooter;
264     WKPagePrintFrameCallback                                            printFrame;
265     WKPageCallback                                                      runModal;
266     void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
267     WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
268     WKPageShouldInterruptJavaScriptCallback                             shouldInterruptJavaScript;    
269
270     // Version 1
271     WKPageCreateNewPageCallback                                         createNewPage;
272     WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
273     WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
274     WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
275
276     // Version 2
277     WKPageShowColorPickerCallback                                       showColorPicker;
278     WKPageHideColorPickerCallback                                       hideColorPicker;
279     WKPagePluginLoadPolicyCallback                                      pluginLoadPolicy;
280 };
281 typedef struct WKPageUIClient WKPageUIClient;
282
283 enum { kWKPageUIClientCurrentVersion = 2 };
284
285 // Find client.
286 typedef void (*WKPageDidFindStringCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
287 typedef void (*WKPageDidFailToFindStringCallback)(WKPageRef page, WKStringRef string, const void* clientInfo);
288 typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
289
290 struct WKPageFindClient {
291     int                                                                 version;
292     const void *                                                        clientInfo;
293     WKPageDidFindStringCallback                                         didFindString;
294     WKPageDidFailToFindStringCallback                                   didFailToFindString;
295     WKPageDidCountStringMatchesCallback                                 didCountStringMatches;
296 };
297 typedef struct WKPageFindClient WKPageFindClient;
298
299 enum { kWKPageFindClientCurrentVersion = 0 };
300
301 enum {
302     kWKMoreThanMaximumMatchCount = -1
303 };
304
305 // Find match client.
306 typedef void (*WKPageDidFindStringMatchesCallback)(WKPageRef page, WKStringRef string, WKArrayRef matches, int firstIndex, const void* clientInfo);
307 typedef void (*WKPageDidGetImageForMatchResultCallback)(WKPageRef page, WKImageRef image, uint32_t index, const void* clientInfo);
308
309 struct WKPageFindMatchesClient {
310     int                                                                 version;
311     const void *                                                        clientInfo;
312     WKPageDidFindStringMatchesCallback                                  didFindStringMatches;
313     WKPageDidGetImageForMatchResultCallback                             didGetImageForMatchResult;
314 };
315 typedef struct WKPageFindMatchesClient WKPageFindMatchesClient;
316
317 enum { kWKPageFindMatchesClientCurrentVersion = 0 };
318
319 // ContextMenu client
320 typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
321 typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
322 typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
323
324 // Deprecated
325 typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
326 struct WKPageContextMenuClient {
327     int                                                                          version;
328     const void *                                                                 clientInfo;
329
330     // Version 0
331     WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
332     WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
333
334     // Version 1
335     WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
336
337     // Version 2
338     WKPageGetContextMenuFromProposedContextMenuCallback                          getContextMenuFromProposedMenu;
339 };
340 typedef struct WKPageContextMenuClient WKPageContextMenuClient;
341
342 enum { kWKPageContextMenuClientCurrentVersion = 2 };
343
344 WK_EXPORT WKTypeID WKPageGetTypeID();
345
346 WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page);
347 WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page);
348
349 WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
350 WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest);
351 WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL);
352 WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL);
353 WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString);
354 WK_EXPORT void WKPageLoadWebArchiveData(WKPageRef page, WKDataRef webArchiveData);
355
356 WK_EXPORT void WKPageStopLoading(WKPageRef page);
357 WK_EXPORT void WKPageReload(WKPageRef page);
358 WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
359
360 WK_EXPORT bool WKPageTryClose(WKPageRef page);
361 WK_EXPORT void WKPageClose(WKPageRef page);
362 WK_EXPORT bool WKPageIsClosed(WKPageRef page);
363
364 WK_EXPORT void WKPageGoForward(WKPageRef page);
365 WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
366 WK_EXPORT void WKPageGoBack(WKPageRef page);
367 WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
368 WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
369 WK_EXPORT void WKPageTryRestoreScrollPosition(WKPageRef page);
370 WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
371 WK_EXPORT bool WKPageWillHandleHorizontalScrollEvents(WKPageRef page);
372     
373 WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
374
375 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
376
377 WK_EXPORT WKURLRef WKPageCopyActiveURL(WKPageRef page);
378 WK_EXPORT WKURLRef WKPageCopyProvisionalURL(WKPageRef page);
379 WK_EXPORT WKURLRef WKPageCopyCommittedURL(WKPageRef page);
380
381 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
382 WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
383 WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
384 WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
385
386 WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page);
387
388 WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled);
389
390 WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
391
392 WK_EXPORT WKVibrationRef WKPageGetVibration(WKPageRef page);
393
394 WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
395
396 WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page);
397 WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName);
398
399 WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page);
400 WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
401
402 WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page);
403 WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page);
404 WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName);
405
406 WK_EXPORT void WKPageTerminate(WKPageRef page);
407
408 WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void);
409
410 typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context);
411 WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
412 WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData);
413
414 WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page);
415 WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor);
416
417 WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
418 WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
419 WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);
420 WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
421 WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
422 WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
423
424 WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
425 WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
426
427 WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
428 WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
429 WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
430 WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
431
432 WK_EXPORT void WKPageListenForLayoutMilestones(WKPageRef page, WKLayoutMilestones milestones);
433
434 WK_EXPORT void WKPageSetVisibilityState(WKPageRef page, WKPageVisibilityState state, bool isInitialState);
435
436 WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
437 WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
438
439 WK_EXPORT void WKPageSetSuppressScrollbarAnimations(WKPageRef page, bool suppressAnimations);
440 WK_EXPORT bool WKPageAreScrollbarAnimationsSuppressed(WKPageRef page);
441
442 WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page);
443 WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page);
444 WK_EXPORT bool WKPageIsPinnedToTopSide(WKPageRef page);
445 WK_EXPORT bool WKPageIsPinnedToBottomSide(WKPageRef page);
446
447 WK_EXPORT bool WKPageRubberBandsAtBottom(WKPageRef);
448 WK_EXPORT void WKPageSetRubberBandsAtBottom(WKPageRef, bool rubberBandsAtBottom);
449 WK_EXPORT bool WKPageRubberBandsAtTop(WKPageRef);
450 WK_EXPORT void WKPageSetRubberBandsAtTop(WKPageRef, bool rubberBandsAtTop);
451
452 WK_EXPORT bool WKPageCanDelete(WKPageRef page);
453 WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
454 WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
455
456 WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
457 WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page);
458     
459 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
460 WK_EXPORT void WKPageHideFindUI(WKPageRef page);
461 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
462 WK_EXPORT void WKPageFindStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
463 WK_EXPORT void WKPageGetImageForFindMatch(WKPageRef page, int32_t matchIndex);
464 WK_EXPORT void WKPageSelectFindMatch(WKPageRef page, int32_t matchIndex);
465
466 WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client);
467 WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client);
468 WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClient* client);
469 WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client);
470 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client);
471 WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClient* client);
472 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client);
473
474 typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*);
475 WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
476 #ifdef __BLOCKS__
477 typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef);
478 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
479 #endif
480
481 typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
482 WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
483 #ifdef __BLOCKS__
484 typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
485 WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
486 #endif
487
488 typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
489 WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
490 #ifdef __BLOCKS__
491 typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
492 WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
493 #endif
494
495 typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
496 WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction function);
497
498 typedef void (*WKPageGetSelectionAsWebArchiveDataFunction)(WKDataRef, WKErrorRef, void*);
499 WK_EXPORT void WKPageGetSelectionAsWebArchiveData(WKPageRef page, void* context, WKPageGetSelectionAsWebArchiveDataFunction function);
500
501 typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
502 WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
503
504 /*
505     Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported:
506     
507     "Cut"
508     "Copy"
509     "Paste"
510     "SelectAll"
511     "Undo"
512     "Redo"
513 */
514
515 // 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.
516 typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context);
517 WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
518 WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
519
520 WK_EXPORT void WKPagePostMessageToInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody);
521
522 #ifdef __cplusplus
523 }
524 #endif
525
526 #endif /* WKPage_h */