2 * Copyright (C) 2010, 2011 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.
27 #include "WKBundlePage.h"
28 #include "WKBundlePagePrivate.h"
30 #include "InjectedBundleBackForwardList.h"
31 #include "InjectedBundleNodeHandle.h"
32 #include "WKAPICast.h"
33 #include "WKBundleAPICast.h"
34 #include "WebFullScreenManager.h"
38 #include "WebURLRequest.h"
40 #include <WebCore/KURL.h>
42 using namespace WebKit;
44 WKTypeID WKBundlePageGetTypeID()
46 return toAPI(WebPage::APIType);
49 void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClient* wkClient)
51 toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient);
54 void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClient* wkClient)
56 toImpl(pageRef)->initializeInjectedBundleEditorClient(wkClient);
59 void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClient* wkClient)
61 toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient);
64 void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient)
66 toImpl(pageRef)->initializeInjectedBundleLoaderClient(wkClient);
69 void WKBundlePageSetResourceLoadClient(WKBundlePageRef pageRef, WKBundlePageResourceLoadClient* wkClient)
71 toImpl(pageRef)->initializeInjectedBundleResourceLoadClient(wkClient);
74 void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClient* wkClient)
76 toImpl(pageRef)->initializeInjectedBundlePolicyClient(wkClient);
79 void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient)
81 toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient);
84 void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClient* wkClient)
86 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
87 toImpl(pageRef)->initializeInjectedBundleFullScreenClient(wkClient);
91 void WKBundlePageWillEnterFullScreen(WKBundlePageRef pageRef)
93 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
94 toImpl(pageRef)->fullScreenManager()->willEnterFullScreen();
98 void WKBundlePageDidEnterFullScreen(WKBundlePageRef pageRef)
100 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
101 toImpl(pageRef)->fullScreenManager()->didEnterFullScreen();
105 void WKBundlePageWillExitFullScreen(WKBundlePageRef pageRef)
107 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
108 toImpl(pageRef)->fullScreenManager()->willExitFullScreen();
112 void WKBundlePageDidExitFullScreen(WKBundlePageRef pageRef)
114 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
115 toImpl(pageRef)->fullScreenManager()->didExitFullScreen();
119 WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef pageRef)
121 return toAPI(toImpl(pageRef)->pageGroup());
124 WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
126 return toAPI(toImpl(pageRef)->mainFrame());
129 void WKBundlePageStopLoading(WKBundlePageRef pageRef)
131 toImpl(pageRef)->stopLoading();
134 void WKBundlePageSetDefersLoading(WKBundlePageRef pageRef, bool defersLoading)
136 toImpl(pageRef)->setDefersLoading(defersLoading);
139 WKStringRef WKBundlePageCopyRenderTreeExternalRepresentation(WKBundlePageRef pageRef)
141 return toCopiedAPI(toImpl(pageRef)->renderTreeExternalRepresentation());
144 void WKBundlePageExecuteEditingCommand(WKBundlePageRef pageRef, WKStringRef name, WKStringRef argument)
146 toImpl(pageRef)->executeEditingCommand(toImpl(name)->string(), toImpl(argument)->string());
149 bool WKBundlePageIsEditingCommandEnabled(WKBundlePageRef pageRef, WKStringRef name)
151 return toImpl(pageRef)->isEditingCommandEnabled(toImpl(name)->string());
154 void WKBundlePageClearMainFrameName(WKBundlePageRef pageRef)
156 toImpl(pageRef)->clearMainFrameName();
159 void WKBundlePageClose(WKBundlePageRef pageRef)
161 toImpl(pageRef)->sendClose();
164 double WKBundlePageGetTextZoomFactor(WKBundlePageRef pageRef)
166 return toImpl(pageRef)->textZoomFactor();
169 void WKBundlePageSetTextZoomFactor(WKBundlePageRef pageRef, double zoomFactor)
171 toImpl(pageRef)->setTextZoomFactor(zoomFactor);
174 double WKBundlePageGetPageZoomFactor(WKBundlePageRef pageRef)
176 return toImpl(pageRef)->pageZoomFactor();
179 void WKBundlePageSetPageZoomFactor(WKBundlePageRef pageRef, double zoomFactor)
181 toImpl(pageRef)->setPageZoomFactor(zoomFactor);
184 void WKBundlePageSetScaleAtOrigin(WKBundlePageRef pageRef, double scale, WKPoint origin)
186 toImpl(pageRef)->scalePage(scale, toIntPoint(origin));
189 WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRef)
191 return toAPI(toImpl(pageRef)->backForwardList());
194 void WKBundlePageSetUnderlayPage(WKBundlePageRef pageRef, WKBundlePageRef pageUnderlayRef)
196 toImpl(pageRef)->setUnderlayPage(toImpl(pageUnderlayRef));
199 void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
201 toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef));
204 void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
206 toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), false);
209 bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef)
211 return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()));
214 bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef)
216 return WebPage::canHandleRequest(toImpl(requestRef)->resourceRequest());
219 bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindOptions findOptions)
221 return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions));
224 WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
226 RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInViewCoordinates(toIntRect(rect), toImageOptions(options));
227 return toAPI(webImage.release().leakRef());
230 WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, WKImageOptions options)
232 RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInDocumentCoordinates(toIntRect(rect), toImageOptions(options));
233 return toAPI(webImage.release().leakRef());
236 WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, double scaleFactor, WKImageOptions options)
238 RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotInDocumentCoordinates(toIntRect(rect), scaleFactor, toImageOptions(options));
239 return toAPI(webImage.release().leakRef());
242 #if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
243 WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef)
245 return toAPI(toImpl(pageRef)->inspector());
249 void WKBundlePageForceRepaint(WKBundlePageRef page)
251 toImpl(page)->forceRepaintWithoutCallback();
254 void WKBundlePageSimulateMouseDown(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time)
256 toImpl(page)->simulateMouseDown(button, toIntPoint(position), clickCount, modifiers, time);
259 void WKBundlePageSimulateMouseUp(WKBundlePageRef page, int button, WKPoint position, int clickCount, WKEventModifiers modifiers, double time)
261 toImpl(page)->simulateMouseUp(button, toIntPoint(position), clickCount, modifiers, time);
264 void WKBundlePageSimulateMouseMotion(WKBundlePageRef page, WKPoint position, double time)
266 toImpl(page)->simulateMouseMotion(toIntPoint(position), time);
269 uint64_t WKBundlePageGetRenderTreeSize(WKBundlePageRef pageRef)
271 return toImpl(pageRef)->renderTreeSize();