2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef WKBundlePage_h
27 #define WKBundlePage_h
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>
46 kWKInsertActionTyped = 0,
47 kWKInsertActionPasted = 1,
48 kWKInsertActionDropped = 2
50 typedef uint32_t WKInsertActionType;
56 typedef uint32_t WKAffinityType;
59 WKInputFieldActionTypeMoveUp,
60 WKInputFieldActionTypeMoveDown,
61 WKInputFieldActionTypeCancel,
62 WKInputFieldActionTypeInsertTab,
63 WKInputFieldActionTypeInsertBacktab,
64 WKInputFieldActionTypeInsertNewline,
65 WKInputFieldActionTypeInsertDelete
67 typedef uint32_t WKInputFieldActionType;
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 bool (*WKBundlePageShouldLoadResourceForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef url, const void *clientInfo);
93 struct WKBundlePageLoaderClient {
95 const void * clientInfo;
96 WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
97 WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
98 WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
99 WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame;
100 WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame;
101 WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame;
102 WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame;
103 WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame;
104 WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame;
105 WKBundlePageDidFirstLayoutForFrame didFirstLayoutForFrame;
106 WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrame didFirstVisuallyNonEmptyLayoutForFrame;
107 WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy;
108 WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame;
109 WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame;
111 // FIXME: There are no WKPage equivilent of these functions yet.
112 WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame;
113 WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame;
114 WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame;
115 WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame;
116 WKBundlePageShouldLoadResourceForFrameCallback shouldLoadResourceForFrame;
118 typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
121 typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo);
122 typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo);
123 typedef void (*WKBundlePageWillRunJavaScriptAlertCallback)(WKBundlePageRef page, WKStringRef alertText, WKBundleFrameRef frame, const void *clientInfo);
124 typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo);
125 typedef void (*WKBundlePageWillRunJavaScriptPromptCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void *clientInfo);
126 typedef void (*WKBundlePageMouseDidMoveOverElementCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void *clientInfo);
127 typedef void (*WKBundlePageDidScrollCallback)(WKBundlePageRef page, const void *clientInfo);
128 typedef void (*WKBundlePagePaintCustomOverhangAreaCallback)(WKBundlePageRef page, WKGraphicsContextRef graphicsContext, WKRect horizontalOverhang, WKRect verticalOverhang, WKRect dirtyRect, const void* clientInfo);
130 struct WKBundlePageUIClient {
132 const void * clientInfo;
133 WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole;
134 WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText;
135 WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert;
136 WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm;
137 WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt;
138 WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement;
139 WKBundlePageDidScrollCallback pageDidScroll;
140 WKBundlePagePaintCustomOverhangAreaCallback paintCustomOverhangArea;
142 typedef struct WKBundlePageUIClient WKBundlePageUIClient;
145 typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
146 typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
147 typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
148 typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
149 typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
150 typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo);
151 typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo);
152 typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo);
154 struct WKBundlePageEditorClient {
156 const void * clientInfo;
157 WKBundlePageShouldBeginEditingCallback shouldBeginEditing;
158 WKBundlePageShouldEndEditingCallback shouldEndEditing;
159 WKBundlePageShouldInsertNodeCallback shouldInsertNode;
160 WKBundlePageShouldInsertTextCallback shouldInsertText;
161 WKBundlePageShouldDeleteRangeCallback shouldDeleteRange;
162 WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange;
163 WKBundlePageShouldApplyStyle shouldApplyStyle;
164 WKBundlePageEditingNotification didBeginEditing;
165 WKBundlePageEditingNotification didEndEditing;
166 WKBundlePageEditingNotification didChange;
167 WKBundlePageEditingNotification didChangeSelection;
169 typedef struct WKBundlePageEditorClient WKBundlePageEditorClient;
172 typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
173 typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
174 typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
175 typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo);
176 typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo);
177 typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo);
179 struct WKBundlePageFormClient {
181 const void * clientInfo;
182 WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing;
183 WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing;
184 WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField;
185 WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea;
186 WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField;
187 WKBundlePageWillSubmitFormCallback willSubmitForm;
189 typedef struct WKBundlePageFormClient WKBundlePageFormClient;
191 // ContextMenu client
192 typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo);
194 struct WKBundlePageContextMenuClient {
196 const void * clientInfo;
197 WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu;
199 typedef struct WKBundlePageContextMenuClient WKBundlePageContextMenuClient;
201 WK_EXPORT WKTypeID WKBundlePageGetTypeID();
203 WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClient* client);
204 WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClient* client);
205 WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client);
206 WK_EXPORT void WKBundlePageSetLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client);
207 WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client);
209 WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page);
210 WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page);
212 WK_EXPORT WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef page);
214 WK_EXPORT void WKBundlePageInstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
215 WK_EXPORT void WKBundlePageUninstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
217 WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url);
218 WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
220 WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions);
222 WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
223 WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
225 #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
226 WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
233 #endif /* WKBundlePage_h */