229a66eb698463f0cb88a8e3bca52618c2f9021f
[WebKit-https.git] / Source / WebKit2 / WebProcess / InjectedBundle / API / c / WKBundlePage.h
1 /*
2  * Copyright (C) 2010 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 WKBundlePage_h
27 #define WKBundlePage_h
28
29 #include <WebKit2/WKBase.h>
30 #include <WebKit2/WKEvent.h>
31 #include <WebKit2/WKFindOptions.h>
32 #include <WebKit2/WKImage.h>
33 #include <WebKit2/WKPageLoadTypes.h>
34
35 #ifndef __cplusplus
36 #include <stdbool.h>
37 #endif
38
39 #include <stdint.h>
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 enum {
46     kWKInsertActionTyped = 0,
47     kWKInsertActionPasted = 1,
48     kWKInsertActionDropped = 2
49 };
50 typedef uint32_t WKInsertActionType;
51
52 enum {
53     kWKAffinityUpstream,
54     kWKAffinityDownstream
55 };
56 typedef uint32_t WKAffinityType;
57
58 enum {
59     WKInputFieldActionTypeMoveUp,
60     WKInputFieldActionTypeMoveDown,
61     WKInputFieldActionTypeCancel,
62     WKInputFieldActionTypeInsertTab,
63     WKInputFieldActionTypeInsertBacktab,
64     WKInputFieldActionTypeInsertNewline,
65     WKInputFieldActionTypeInsertDelete
66 };
67 typedef uint32_t WKInputFieldActionType;
68
69 // Loader Client
70 typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
71 typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
72 typedef void (*WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo);
73 typedef void (*WKBundlePageDidCommitLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
74 typedef void (*WKBundlePageDidDocumentFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
75 typedef void (*WKBundlePageDidFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
76 typedef void (*WKBundlePageDidFinishDocumentLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
77 typedef void (*WKBundlePageDidFailLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo);
78 typedef void (*WKBundlePageDidSameDocumentNavigationForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo);
79 typedef void (*WKBundlePageDidReceiveTitleForFrameCallback)(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
80 typedef void (*WKBundlePageDidFirstLayoutForFrame)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
81 typedef void (*WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrame)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
82 typedef void (*WKBundlePageDidRemoveFrameFromHierarchyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
83 typedef void (*WKBundlePageDidDisplayInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
84 typedef void (*WKBundlePageDidRunInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
85 // FIXME: There are no WKPage equivilent of these functions yet.
86 typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo);
87 typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
88 typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
89 typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
90 typedef WKURLRequestRef (*WKBundlePageWillSendRequestForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void *clientInfo);
91
92
93
94 struct WKBundlePageLoaderClient {
95     int                                                                 version;
96     const void *                                                        clientInfo;
97     WKBundlePageDidStartProvisionalLoadForFrameCallback                 didStartProvisionalLoadForFrame;
98     WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback    didReceiveServerRedirectForProvisionalLoadForFrame;
99     WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback         didFailProvisionalLoadWithErrorForFrame;
100     WKBundlePageDidCommitLoadForFrameCallback                           didCommitLoadForFrame;
101     WKBundlePageDidFinishDocumentLoadForFrameCallback                   didFinishDocumentLoadForFrame;
102     WKBundlePageDidFinishLoadForFrameCallback                           didFinishLoadForFrame;
103     WKBundlePageDidFailLoadWithErrorForFrameCallback                    didFailLoadWithErrorForFrame;
104     WKBundlePageDidSameDocumentNavigationForFrameCallback               didSameDocumentNavigationForFrame;
105     WKBundlePageDidReceiveTitleForFrameCallback                         didReceiveTitleForFrame;
106     WKBundlePageDidFirstLayoutForFrame                                  didFirstLayoutForFrame;
107     WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrame                  didFirstVisuallyNonEmptyLayoutForFrame;
108     WKBundlePageDidRemoveFrameFromHierarchyCallback                     didRemoveFrameFromHierarchy;
109     WKBundlePageDidDisplayInsecureContentForFrameCallback               didDisplayInsecureContentForFrame;
110     WKBundlePageDidRunInsecureContentForFrameCallback                   didRunInsecureContentForFrame;
111
112     // FIXME: There are no WKPage equivilent of these functions yet.
113     WKBundlePageDidClearWindowObjectForFrameCallback                    didClearWindowObjectForFrame;
114     WKBundlePageDidCancelClientRedirectForFrameCallback                 didCancelClientRedirectForFrame;
115     WKBundlePageWillPerformClientRedirectForFrameCallback               willPerformClientRedirectForFrame;
116     WKBundlePageDidHandleOnloadEventsForFrameCallback                   didHandleOnloadEventsForFrame;
117     WKBundlePageWillSendRequestForFrameCallback                         willSendRequestForFrame;
118 };
119 typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
120
121 // UI Client
122 typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo);
123 typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo);
124 typedef void (*WKBundlePageWillRunJavaScriptAlertCallback)(WKBundlePageRef page, WKStringRef alertText, WKBundleFrameRef frame, const void *clientInfo);
125 typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo);
126 typedef void (*WKBundlePageWillRunJavaScriptPromptCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void *clientInfo);
127 typedef void (*WKBundlePageMouseDidMoveOverElementCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void *clientInfo);
128 typedef void (*WKBundlePageDidScrollCallback)(WKBundlePageRef page, const void *clientInfo);
129 typedef void (*WKBundlePagePaintCustomOverhangAreaCallback)(WKBundlePageRef page, WKGraphicsContextRef graphicsContext, WKRect horizontalOverhang, WKRect verticalOverhang, WKRect dirtyRect, const void* clientInfo);
130
131 struct WKBundlePageUIClient {
132     int                                                                 version;
133     const void *                                                        clientInfo;
134     WKBundlePageWillAddMessageToConsoleCallback                         willAddMessageToConsole;
135     WKBundlePageWillSetStatusbarTextCallback                            willSetStatusbarText;
136     WKBundlePageWillRunJavaScriptAlertCallback                          willRunJavaScriptAlert;
137     WKBundlePageWillRunJavaScriptConfirmCallback                        willRunJavaScriptConfirm;
138     WKBundlePageWillRunJavaScriptPromptCallback                         willRunJavaScriptPrompt;
139     WKBundlePageMouseDidMoveOverElementCallback                         mouseDidMoveOverElement;
140     WKBundlePageDidScrollCallback                                       pageDidScroll;
141     WKBundlePagePaintCustomOverhangAreaCallback                         paintCustomOverhangArea;
142 };
143 typedef struct WKBundlePageUIClient WKBundlePageUIClient;
144
145 // Editor client
146 typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
147 typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
148 typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
149 typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
150 typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
151 typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo);
152 typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo);
153 typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo);
154
155 struct WKBundlePageEditorClient {
156     int                                                                 version;
157     const void *                                                        clientInfo;
158     WKBundlePageShouldBeginEditingCallback                              shouldBeginEditing;
159     WKBundlePageShouldEndEditingCallback                                shouldEndEditing;
160     WKBundlePageShouldInsertNodeCallback                                shouldInsertNode;
161     WKBundlePageShouldInsertTextCallback                                shouldInsertText;
162     WKBundlePageShouldDeleteRangeCallback                               shouldDeleteRange;
163     WKBundlePageShouldChangeSelectedRange                               shouldChangeSelectedRange;
164     WKBundlePageShouldApplyStyle                                        shouldApplyStyle;
165     WKBundlePageEditingNotification                                     didBeginEditing;
166     WKBundlePageEditingNotification                                     didEndEditing;
167     WKBundlePageEditingNotification                                     didChange;
168     WKBundlePageEditingNotification                                     didChangeSelection;
169 };
170 typedef struct WKBundlePageEditorClient WKBundlePageEditorClient;
171
172 // Form client
173 typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
174 typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
175 typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
176 typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo);
177 typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo);
178 typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo);
179
180 struct WKBundlePageFormClient {
181     int                                                                 version;
182     const void *                                                        clientInfo;
183     WKBundlePageTextFieldDidBeginEditingCallback                        textFieldDidBeginEditing;
184     WKBundlePageTextFieldDidEndEditingCallback                          textFieldDidEndEditing;
185     WKBundlePageTextDidChangeInTextFieldCallback                        textDidChangeInTextField;
186     WKBundlePageTextDidChangeInTextAreaCallback                         textDidChangeInTextArea;
187     WKBundlePageShouldPerformActionInTextFieldCallback                  shouldPerformActionInTextField;
188     WKBundlePageWillSubmitFormCallback                                  willSubmitForm;
189 };
190 typedef struct WKBundlePageFormClient WKBundlePageFormClient;
191
192 // ContextMenu client
193 typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo);
194
195 struct WKBundlePageContextMenuClient {
196     int                                                                 version;
197     const void *                                                        clientInfo;
198     WKBundlePageGetContextMenuFromDefaultContextMenuCallback            getContextMenuFromDefaultMenu;
199 };
200 typedef struct WKBundlePageContextMenuClient WKBundlePageContextMenuClient;
201
202 WK_EXPORT WKTypeID WKBundlePageGetTypeID();
203  
204 WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClient* client);
205 WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClient* client);
206 WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client);
207 WK_EXPORT void WKBundlePageSetLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client);
208 WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client);
209
210 WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page);
211 WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page);
212
213 WK_EXPORT WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef page);
214
215 WK_EXPORT void WKBundlePageInstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
216 WK_EXPORT void WKBundlePageUninstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
217
218 WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url);
219 WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
220
221 WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions);
222
223 WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
224 WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
225
226 #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
227 WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
228 #endif
229
230 #ifdef __cplusplus
231 }
232 #endif
233
234 #endif /* WKBundlePage_h */