diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle')
45 files changed, 882 insertions, 60 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 5c4b6e9..a58dbda 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundle.h" #include "WKBundlePrivate.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h index 47ac2d6..db32716 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h @@ -45,11 +45,13 @@ class InjectedBundle; class InjectedBundleBackForwardList; class InjectedBundleBackForwardListItem; class InjectedBundleHitTestResult; +class InjectedBundleNavigationAction; class InjectedBundleNodeHandle; class InjectedBundleRangeHandle; class InjectedBundleScriptWorld; class PageOverlay; class WebFrame; +class WebInspector; class WebPage; class WebPageGroupProxy; @@ -58,6 +60,8 @@ WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList) WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration) WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame) WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult) +WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector) +WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction) WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle) WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy) WK_ADD_API_MAPPING(WKBundlePageOverlayRef, PageOverlay) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp index 288c676..7ffa3ce 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleBackForwardList.h" #include "InjectedBundleBackForwardList.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp index cde15c4..e9845e3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleBackForwardListItem.h" #include "ImmutableArray.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index f02044c..82f616a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleFrame.h" #include "WKBundleFramePrivate.h" @@ -55,6 +56,29 @@ WKURLRef WKBundleFrameCopyProvisionalURL(WKBundleFrameRef frameRef) return toCopiedURLAPI(toImpl(frameRef)->provisionalURL()); } +WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frameRef) +{ + Frame* coreFrame = toImpl(frameRef)->coreFrame(); + if (!coreFrame) + return kWKFrameLoadStateFinished; + + FrameLoader* loader = coreFrame->loader(); + if (!loader) + return kWKFrameLoadStateFinished; + + switch (loader->state()) { + case FrameStateProvisional: + return kWKFrameLoadStateProvisional; + case FrameStateCommittedPage: + return kWKFrameLoadStateCommitted; + case FrameStateComplete: + return kWKFrameLoadStateFinished; + } + + ASSERT_NOT_REACHED(); + return kWKFrameLoadStateFinished; +} + WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frameRef) { return toAPI(toImpl(frameRef)->childFrames().releaseRef()); @@ -152,58 +176,35 @@ bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frameRef, WKURLRef urlRef WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frameRef) { - WKRect contentBounds = { { 0, 0 }, { 0, 0 } }; - - Frame* coreFrame = toImpl(frameRef)->coreFrame(); - if (!coreFrame) - return contentBounds; - - FrameView* view = coreFrame->view(); - if (!view) - return contentBounds; - - contentBounds.size.width = view->contentsWidth(); - contentBounds.size.height = view->contentsHeight(); - - return contentBounds; + return toAPI(toImpl(frameRef)->contentBounds()); } WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frameRef) { - WKRect visibleContentBounds = { { 0, 0 }, { 0, 0 } }; - - Frame* coreFrame = toImpl(frameRef)->coreFrame(); - if (!coreFrame) - return visibleContentBounds; - - FrameView* view = coreFrame->view(); - if (!view) - return visibleContentBounds; - - FloatRect bounds = view->visibleContentRect(true); + return toAPI(toImpl(frameRef)->visibleContentBounds()); +} - visibleContentBounds.size.width = bounds.width(); - visibleContentBounds.size.height = bounds.height(); - - return visibleContentBounds; +WKRect WKBundleFrameGetVisibleContentBoundsExcludingScrollbars(WKBundleFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->visibleContentBoundsExcludingScrollbars()); } -WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frameRef) +WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frameRef) { - WKSize scrollOffset = { 0, 0 }; - - Frame* coreFrame = toImpl(frameRef)->coreFrame(); - if (!coreFrame) - return scrollOffset; - - FrameView* view = coreFrame->view(); - if (!view) - return scrollOffset; - - return toAPI(view->scrollOffset()); + return toAPI(toImpl(frameRef)->scrollOffset()); +} + +bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frameRef, double* red, double* green, double* blue, double* alpha) +{ + return toImpl(frameRef)->getDocumentBackgroundColor(red, green, blue, alpha); } WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) { return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); } + +WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) +{ + return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toImpl(urlRef)->string()))); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index 59c2d75..3c7c52d 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -28,6 +28,7 @@ #include <JavaScriptCore/JavaScript.h> #include <WebKit2/WKBase.h> +#include <WebKit2/WKFrame.h> #include <WebKit2/WKGeometry.h> #ifdef __cplusplus @@ -43,6 +44,8 @@ WK_EXPORT WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frame); WK_EXPORT WKURLRef WKBundleFrameCopyURL(WKBundleFrameRef frame); WK_EXPORT WKURLRef WKBundleFrameCopyProvisionalURL(WKBundleFrameRef frame); +WK_EXPORT WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frame); + WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame); WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world); @@ -57,9 +60,13 @@ WK_EXPORT bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frame, WKURLRef WK_EXPORT WKRect WKBundleFrameGetContentBounds(WKBundleFrameRef frame); WK_EXPORT WKRect WKBundleFrameGetVisibleContentBounds(WKBundleFrameRef frame); +WK_EXPORT WKRect WKBundleFrameGetVisibleContentBoundsExcludingScrollbars(WKBundleFrameRef frame); WK_EXPORT WKSize WKBundleFrameGetScrollOffset(WKBundleFrameRef frame); +WK_EXPORT bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frame, double* red, double* green, double* blue, double* alpha); + WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); +WK_EXPORT WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp index 7e74262..b764ee9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleHitTestResult.h" #include "InjectedBundleHitTestResult.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp new file mode 100644 index 0000000..ae69a53 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WKBundleInspector.h" + +#if ENABLE(INSPECTOR) + +#include "WKAPICast.h" +#include "WKBundleAPICast.h" +#include "WebInspector.h" + +using namespace WebCore; +using namespace WebKit; + +WKTypeID WKBundleInspectorGetTypeID() +{ + return toAPI(WebInspector::APIType); +} + +void WKBundleInspectorShow(WKBundleInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->show(); +} + +void WKBundleInspectorClose(WKBundleInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->close(); +} + +void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script) +{ + return toImpl(inspectorRef)->evaluateScriptForTest(callID, toImpl(script)->string()); +} + +void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled) +{ + if (enabled) + toImpl(inspectorRef)->startPageProfiling(); + else + toImpl(inspectorRef)->stopPageProfiling(); +} + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h new file mode 100644 index 0000000..e32fdf2 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBundleInspector_h +#define WKBundleInspector_h + +#include <WebKit2/WKBase.h> + +#if ENABLE(INSPECTOR) + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKBundleInspectorGetTypeID(); + +WK_EXPORT void WKBundleInspectorShow(WKBundleInspectorRef inspector); +WK_EXPORT void WKBundleInspectorClose(WKBundleInspectorRef inspector); + +WK_EXPORT void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspector, long callID, WKStringRef script); +WK_EXPORT void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspector, bool enabled); + +#ifdef __cplusplus +} +#endif + +#endif // ENABLE(INSPECTOR) + +#endif // WKBundleInspector_h + diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp new file mode 100644 index 0000000..c26ec3e --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WKBundleNavigationAction.h" + +#include "InjectedBundleHitTestResult.h" +#include "InjectedBundleNavigationAction.h" +#include "InjectedBundleNodeHandle.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" + +using namespace WebKit; + +WKTypeID WKBundleNavigationActionGetTypeID() +{ + return toAPI(InjectedBundleNavigationAction::APIType); +} + +WKFrameNavigationType WKBundleNavigationActionGetNavigationType(WKBundleNavigationActionRef navigationActionRef) +{ + return toAPI(toImpl(navigationActionRef)->navigationType()); +} + +WKEventModifiers WKBundleNavigationActionGetEventModifiers(WKBundleNavigationActionRef navigationActionRef) +{ + return toAPI(toImpl(navigationActionRef)->modifiers()); +} + +WKEventMouseButton WKBundleNavigationActionGetEventMouseButton(WKBundleNavigationActionRef navigationActionRef) +{ + return toAPI(toImpl(navigationActionRef)->mouseButton()); +} + +WKBundleHitTestResultRef WKBundleNavigationActionCopyHitTestResult(WKBundleNavigationActionRef navigationActionRef) +{ + RefPtr<InjectedBundleHitTestResult> hitTestResult = toImpl(navigationActionRef)->hitTestResult(); + return toAPI(hitTestResult.release().leakRef()); +} + +WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigationActionRef navigationActionRef) +{ + RefPtr<InjectedBundleNodeHandle> formElement = toImpl(navigationActionRef)->formElement(); + return toAPI(formElement.release().leakRef()); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h new file mode 100644 index 0000000..03f083a --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBundleNavigationAction_h +#define WKBundleNavigationAction_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKPageLoadTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKBundleNavigationActionGetTypeID(); + +WK_EXPORT WKFrameNavigationType WKBundleNavigationActionGetNavigationType(WKBundleNavigationActionRef navigationAction); +WK_EXPORT WKEventModifiers WKBundleNavigationActionGetEventModifiers(WKBundleNavigationActionRef navigationAction); +WK_EXPORT WKEventMouseButton WKBundleNavigationActionGetEventMouseButton(WKBundleNavigationActionRef navigationAction); +WK_EXPORT WKBundleHitTestResultRef WKBundleNavigationActionCopyHitTestResult(WKBundleNavigationActionRef navigationAction); +WK_EXPORT WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigationActionRef navigationAction); + +#ifdef __cplusplus +} +#endif + +#endif /* WKBundleNavigationAction_h */ diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index bf853d1..9b0eaf1 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleNodeHandle.h" #include "WKBundleNodeHandlePrivate.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index 9693b6a..a1a4da3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundlePage.h" #include "WKBundlePagePrivate.h" @@ -64,13 +65,27 @@ void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClient* toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient); } -void WKBundlePageSetLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient) +void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient) { if (wkClient && wkClient->version) return; toImpl(pageRef)->initializeInjectedBundleLoaderClient(wkClient); } +void WKBundlePageSetResourceLoadClient(WKBundlePageRef pageRef, WKBundlePageResourceLoadClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeInjectedBundleResourceLoadClient(wkClient); +} + +void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeInjectedBundlePolicyClient(wkClient); +} + void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient) { if (wkClient && wkClient->version) @@ -184,3 +199,16 @@ WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef pageR RefPtr<WebImage> webImage = toImpl(pageRef)->snapshotInDocumentCoordinates(toIntRect(rect), toImageOptions(options)); return toAPI(webImage.release().leakRef()); } + +WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef pageRef, WKRect rect, double scaleFactor, WKImageOptions options) +{ + RefPtr<WebImage> webImage = toImpl(pageRef)->scaledSnapshotInDocumentCoordinates(toIntRect(rect), scaleFactor, toImageOptions(options)); + return toAPI(webImage.release().leakRef()); +} + +#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR +WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef) +{ + return toAPI(toImpl(pageRef)->inspector()); +} +#endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index 00db56f..944a5b6 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -87,8 +87,6 @@ typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo); typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo); typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo); -typedef bool (*WKBundlePageShouldLoadResourceForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef url, const void *clientInfo); - struct WKBundlePageLoaderClient { int version; @@ -113,10 +111,43 @@ struct WKBundlePageLoaderClient { WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; - WKBundlePageShouldLoadResourceForFrameCallback shouldLoadResourceForFrame; }; typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient; +// Policy Client +typedef void (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); + +struct WKBundlePagePolicyClient { + int version; + const void * clientInfo; + WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; + WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; + WKBundlePageDecidePolicyForMIMETypeCallback decidePolicyForMIMEType; +}; +typedef struct WKBundlePagePolicyClient WKBundlePagePolicyClient; + +// Resource Load Client +typedef void (*WKBundlePageDidInitiateLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, bool pageIsProvisionallyLoading, const void* clientInfo); +typedef WKURLRequestRef (*WKBundlePageWillSendRequestForFrameCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, WKURLResponseRef redirectResponse, const void *clientInfo); +typedef void (*WKBundlePageDidReceiveResponseForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLResponseRef, const void* clientInfo); +typedef void (*WKBundlePageDidReceiveContentLengthForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo); +typedef void (*WKBundlePageDidFinishLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo); +typedef void (*WKBundlePageDidFailLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKErrorRef, const void* clientInfo); + +struct WKBundlePageResourceLoadClient { + int version; + const void * clientInfo; + WKBundlePageDidInitiateLoadForResourceCallback didInitiateLoadForResource; + WKBundlePageWillSendRequestForFrameCallback willSendRequestForFrame; + WKBundlePageDidReceiveResponseForResourceCallback didReceiveResponseForResource; + WKBundlePageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; + WKBundlePageDidFinishLoadForResourceCallback didFinishLoadForResource; + WKBundlePageDidFailLoadForResourceCallback didFailLoadForResource; +}; +typedef struct WKBundlePageResourceLoadClient WKBundlePageResourceLoadClient; + // UI Client typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo); typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo); @@ -125,6 +156,7 @@ typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef pag typedef void (*WKBundlePageWillRunJavaScriptPromptCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void *clientInfo); typedef void (*WKBundlePageMouseDidMoveOverElementCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void *clientInfo); typedef void (*WKBundlePageDidScrollCallback)(WKBundlePageRef page, const void *clientInfo); +typedef void (*WKBundlePagePaintCustomOverhangAreaCallback)(WKBundlePageRef page, WKGraphicsContextRef graphicsContext, WKRect horizontalOverhang, WKRect verticalOverhang, WKRect dirtyRect, const void* clientInfo); struct WKBundlePageUIClient { int version; @@ -136,6 +168,7 @@ struct WKBundlePageUIClient { WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; WKBundlePageDidScrollCallback pageDidScroll; + WKBundlePagePaintCustomOverhangAreaCallback paintCustomOverhangArea; }; typedef struct WKBundlePageUIClient WKBundlePageUIClient; @@ -201,7 +234,9 @@ WK_EXPORT WKTypeID WKBundlePageGetTypeID(); WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClient* client); WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClient* client); WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client); -WK_EXPORT void WKBundlePageSetLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client); +WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client); +WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClient* client); +WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClient* client); WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client); WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page); @@ -219,6 +254,11 @@ WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options); WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options); +WK_EXPORT WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, double scaleFactor, WKImageOptions options); + +#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR +WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page); +#endif #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.cpp index 47d4cf1..e076cb9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundlePageGroup.h" #include "WKAPICast.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp index 48fcab4..d86c2e0 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundlePageOverlay.h" #include "PageOverlay.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp index 78047af..c868fab 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleRangeHandle.h" #include "InjectedBundleRangeHandle.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp index a7a4a8d..1133e3e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "WKBundleScriptWorld.h" #include "InjectedBundleScriptWorld.h" @@ -46,3 +47,8 @@ WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld() { return toAPI(InjectedBundleScriptWorld::normalWorld()); } + +void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorldRef) +{ + toImpl(scriptWorldRef)->clearWrappers(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h index 0763efa..013cdc9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h @@ -36,6 +36,7 @@ WK_EXPORT WKTypeID WKBundleScriptWorldGetTypeID(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld(); +WK_EXPORT void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorld); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp index 6ee3b31..43cf1ef 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleNodeHandle.h" #include "WebFrame.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp index 9186637..e94edfd 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleRangeHandle.h" #include <WebCore/Range.h> diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp index c9f1a6d..b887374 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundle.h" #include "Arguments.h" @@ -70,7 +71,7 @@ void InjectedBundle::initializeClient(WKBundleClient* client) void InjectedBundle::postMessage(const String& messageName, APIObject* messageBody) { - WebProcess::shared().connection()->send(WebContextLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody))); + WebProcess::shared().connection()->deprecatedSend(WebContextLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody))); } void InjectedBundle::postSynchronousMessage(const String& messageName, APIObject* messageBody, RefPtr<APIObject>& returnData) @@ -78,7 +79,7 @@ void InjectedBundle::postSynchronousMessage(const String& messageName, APIObject RefPtr<APIObject> returnDataTmp; InjectedBundleUserMessageDecoder messageDecoder(returnDataTmp); - bool succeeded = WebProcess::shared().connection()->sendSync(WebContextLegacyMessage::PostSynchronousMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody)), CoreIPC::Out(messageDecoder)); + bool succeeded = WebProcess::shared().connection()->deprecatedSendSync(WebContextLegacyMessage::PostSynchronousMessage, 0, CoreIPC::In(messageName, InjectedBundleUserMessageEncoder(messageBody)), CoreIPC::Out(messageDecoder)); if (!succeeded) return; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp index 9f50942..d7fb9ec 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleBackForwardList.h" #include "InjectedBundleBackForwardListItem.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp index 222dfa3..92a7e69 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleBackForwardListItem.h" #include "ImmutableArray.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp index de572d0..f2e4f2b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleClient.h" #include "WKBundleAPICast.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp index ab59226..c359b42 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleHitTestResult.h" #include "InjectedBundleNodeHandle.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp new file mode 100644 index 0000000..7a40ee6 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedBundleNavigationAction.h" + +#include "WebFrame.h" +#include <WebCore/Frame.h> +#include <WebCore/HTMLFormElement.h> +#include <WebCore/MouseEvent.h> +#include <WebCore/NavigationAction.h> +#include <WebCore/UIEventWithKeyState.h> + +using namespace WebCore; + +namespace WebKit { + +static const MouseEvent* mouseEventForNavigationAction(const NavigationAction& navigationAction) +{ + for (const Event* e = navigationAction.event(); e; e = e->underlyingEvent()) { + if (e->isMouseEvent()) + return static_cast<const MouseEvent*>(e); + } + return 0; +} + +static WebMouseEvent::Button mouseButtonForMouseEvent(const MouseEvent* mouseEvent) +{ + if (!mouseEvent) + return WebMouseEvent::NoButton; + + if (!mouseEvent->buttonDown()) + return WebMouseEvent::NoButton; + + return static_cast<WebMouseEvent::Button>(mouseEvent->button()); +} + +WebEvent::Modifiers InjectedBundleNavigationAction::modifiersForNavigationAction(const NavigationAction& navigationAction) +{ + uint32_t modifiers = 0; + if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) { + if (keyStateEvent->shiftKey()) + modifiers |= WebEvent::ShiftKey; + if (keyStateEvent->ctrlKey()) + modifiers |= WebEvent::ControlKey; + if (keyStateEvent->altKey()) + modifiers |= WebEvent::AltKey; + if (keyStateEvent->metaKey()) + modifiers |= WebEvent::MetaKey; + } + + return static_cast<WebEvent::Modifiers>(modifiers); +} + +WebMouseEvent::Button InjectedBundleNavigationAction::mouseButtonForNavigationAction(const NavigationAction& navigationAction) +{ + return mouseButtonForMouseEvent(mouseEventForNavigationAction(navigationAction)); +} + + +PassRefPtr<InjectedBundleNavigationAction> InjectedBundleNavigationAction::create(WebFrame* frame, const NavigationAction& action, PassRefPtr<FormState> formState) +{ + return adoptRef(new InjectedBundleNavigationAction(frame, action, formState)); +} + +InjectedBundleNavigationAction::InjectedBundleNavigationAction(WebFrame* frame, const NavigationAction& navigationAction, PassRefPtr<FormState> prpFormState) +{ + m_navigationType = navigationAction.type(); + m_modifiers = modifiersForNavigationAction(navigationAction); + + if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) { + m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false)); + m_mouseButton = mouseButtonForMouseEvent(mouseEvent); + } + + RefPtr<FormState> formState = prpFormState; + if (formState) { + ASSERT(formState->form()); + m_formElement = InjectedBundleNodeHandle::getOrCreate(formState->form()); + } +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h new file mode 100644 index 0000000..128c9fb --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundleNavigationAction_h +#define InjectedBundleNavigationAction_h + +#include "APIObject.h" +#include "InjectedBundleHitTestResult.h" +#include "InjectedBundleNodeHandle.h" +#include "WebEvent.h" +#include <WebCore/FrameLoaderTypes.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + class FormState; + class NavigationAction; +} + +namespace WebKit { + +class WebFrame; + +class InjectedBundleNavigationAction : public APIObject { +public: + static const Type APIType = TypeBundleNavigationAction; + + static PassRefPtr<InjectedBundleNavigationAction> create(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>); + + static WebEvent::Modifiers modifiersForNavigationAction(const WebCore::NavigationAction&); + static WebMouseEvent::Button mouseButtonForNavigationAction(const WebCore::NavigationAction&); + + WebCore::NavigationType navigationType() const { return m_navigationType; } + WebEvent::Modifiers modifiers() const { return m_modifiers; } + WebMouseEvent::Button mouseButton() const { return m_mouseButton; } + InjectedBundleHitTestResult* hitTestResult() const { return m_hitTestResult.get(); } + InjectedBundleNodeHandle* formElement() const { return m_formElement.get(); } + +private: + InjectedBundleNavigationAction(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>); + + virtual Type type() const { return APIType; } + + WebCore::NavigationType m_navigationType; + WebEvent::Modifiers m_modifiers; + WebMouseEvent::Button m_mouseButton; + RefPtr<InjectedBundleHitTestResult> m_hitTestResult; + RefPtr<InjectedBundleNodeHandle> m_formElement; +}; + +} // namespace WebKit + +#endif // InjectedBundleNavigationAction_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp index a2d16cb..9df0081 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageContextMenuClient.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundlePageContextMenuClient.h" #include "ImmutableArray.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp index 40996c2..633936b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageEditorClient.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundlePageEditorClient.h" #include "InjectedBundleNodeHandle.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp index 4d210f2..39924ec 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundlePageFormClient.h" #include "ImmutableDictionary.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp index 23341c5..58a20cf 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundlePageLoaderClient.h" #include "InjectedBundleScriptWorld.h" @@ -175,14 +176,6 @@ void InjectedBundlePageLoaderClient::didRunInsecureContentForFrame(WebPage* page userData = adoptRef(toImpl(userDataToPass)); } -bool InjectedBundlePageLoaderClient::shouldLoadResourceForFrame(WebPage* page, WebFrame* frame, const String& resourceURL) -{ - if (!m_client.shouldLoadResourceForFrame) - return true; - - return m_client.shouldLoadResourceForFrame(toAPI(page), toAPI(frame), toAPI(resourceURL.impl()), m_client.clientInfo); -} - void InjectedBundlePageLoaderClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, DOMWrapperWorld* world) { if (!m_client.didClearWindowObjectForFrame) diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h index e983b48..88cb824 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h @@ -35,6 +35,8 @@ namespace WebCore { class DOMWrapperWorld; class ResourceError; +class ResourceRequest; +class ResourceResponse; } namespace WebKit { @@ -60,8 +62,6 @@ public: void didDisplayInsecureContentForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData); void didRunInsecureContentForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData); - bool shouldLoadResourceForFrame(WebPage*, WebFrame*, const String&); - void didClearWindowObjectForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*); void didCancelClientRedirectForFrame(WebPage*, WebFrame*); void willPerformClientRedirectForFrame(WebPage*, WebFrame*, const String& url, double delay, double date); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp new file mode 100644 index 0000000..c55e729 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedBundlePagePolicyClient.h" + +#include "WKBundleAPICast.h" +#include "WebURLRequest.h" + +using namespace WebCore; + +namespace WebKit { + +void InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData) +{ + if (!m_client.decidePolicyForNavigationAction) + return; + + RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); + + WKTypeRef userDataToPass = 0; + m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo); + userData = adoptRef(toImpl(userDataToPass)); +} + +void InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData) +{ + if (!m_client.decidePolicyForNewWindowAction) + return; + + RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); + + WKTypeRef userDataToPass = 0; + m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo); + userData = adoptRef(toImpl(userDataToPass)); +} + +void InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData) +{ + if (!m_client.decidePolicyForMIMEType) + return; + + RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); + + WKTypeRef userDataToPass = 0; + m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo); + userData = adoptRef(toImpl(userDataToPass)); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h new file mode 100644 index 0000000..2145ac4 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundlePagePolicyClient_h +#define InjectedBundlePagePolicyClient_h + +#include "APIClient.h" +#include "APIObject.h" +#include "WKBundlePage.h" +#include <wtf/Forward.h> + +namespace WebCore { + class ResourceRequest; +} + +namespace WebKit { + +class InjectedBundleNavigationAction; +class WebFrame; +class WebPage; + +class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient> { +public: + void decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData); + void decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData); + void decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData); +}; + +} // namespace WebKit + +#endif // InjectedBundlePagePolicyClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp new file mode 100644 index 0000000..c2866a8 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedBundlePageResourceLoadClient.h" + +#include "WKAPICast.h" +#include "WKBundleAPICast.h" + +using namespace WebCore; + +namespace WebKit { + +void InjectedBundlePageResourceLoadClient::didInitiateLoadForResource(WebPage* page, WebFrame* frame, uint64_t identifier, const WebCore::ResourceRequest& request, bool pageIsProvisionallyLoading) +{ + if (!m_client.didInitiateLoadForResource) + return; + + m_client.didInitiateLoadForResource(toAPI(page), toAPI(frame), identifier, toAPI(request), pageIsProvisionallyLoading, m_client.clientInfo); +} + +void InjectedBundlePageResourceLoadClient::willSendRequestForFrame(WebPage* page, WebFrame* frame, uint64_t identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) +{ + if (!m_client.willSendRequestForFrame) + return; + + RefPtr<WebURLRequest> returnedRequest = toImpl(m_client.willSendRequestForFrame(toAPI(page), toAPI(frame), identifier, toAPI(request), toAPI(redirectResponse), m_client.clientInfo)); + if (returnedRequest) + request = returnedRequest->resourceRequest(); + else + request = ResourceRequest(); +} + +void InjectedBundlePageResourceLoadClient::didReceiveResponseForResource(WebPage* page, WebFrame* frame, uint64_t identifier, const WebCore::ResourceResponse& response) +{ + if (!m_client.didReceiveResponseForResource) + return; + + m_client.didReceiveResponseForResource(toAPI(page), toAPI(frame), identifier, toAPI(response), m_client.clientInfo); +} + +void InjectedBundlePageResourceLoadClient::didReceiveContentLengthForResource(WebPage* page, WebFrame* frame, uint64_t identifier, uint64_t contentLength) +{ + if (!m_client.didReceiveContentLengthForResource) + return; + + m_client.didReceiveContentLengthForResource(toAPI(page), toAPI(frame), identifier, contentLength, m_client.clientInfo); +} + +void InjectedBundlePageResourceLoadClient::didFinishLoadForResource(WebPage* page, WebFrame* frame, uint64_t identifier) +{ + if (!m_client.didFinishLoadForResource) + return; + + m_client.didFinishLoadForResource(toAPI(page), toAPI(frame), identifier, m_client.clientInfo); +} + +void InjectedBundlePageResourceLoadClient::didFailLoadForResource(WebPage* page, WebFrame* frame, uint64_t identifier, const WebCore::ResourceError& error) +{ + if (!m_client.didFailLoadForResource) + return; + + m_client.didFailLoadForResource(toAPI(page), toAPI(frame), identifier, toAPI(error), m_client.clientInfo); +} + +} // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h new file mode 100644 index 0000000..c2b654f --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageResourceLoadClient.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedBundlePageResourceLoadClient_h +#define InjectedBundlePageResourceLoadClient_h + +#include "APIClient.h" +#include "SameDocumentNavigationType.h" +#include "WKBundlePage.h" +#include <JavaScriptCore/JSBase.h> +#include <wtf/Forward.h> + +namespace WebCore { +class ResourceError; +class ResourceRequest; +class ResourceResponse; +} + +namespace WebKit { + +class APIObject; +class WebPage; +class WebFrame; + +class InjectedBundlePageResourceLoadClient : public APIClient<WKBundlePageResourceLoadClient> { +public: + void didInitiateLoadForResource(WebPage*, WebFrame*, uint64_t identifier, const WebCore::ResourceRequest&, bool pageIsProvisionallyLoading); + void willSendRequestForFrame(WebPage*, WebFrame*, uint64_t identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse&); + void didReceiveResponseForResource(WebPage*, WebFrame*, uint64_t identifier, const WebCore::ResourceResponse&); + void didReceiveContentLengthForResource(WebPage*, WebFrame*, uint64_t identifier, uint64_t contentLength); + void didFinishLoadForResource(WebPage*, WebFrame*, uint64_t identifier); + void didFailLoadForResource(WebPage*, WebFrame*, uint64_t identifier, const WebCore::ResourceError&); +}; + +} // namespace WebKit + +#endif // InjectedBundlePageResourceLoadClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp index 56e4434..7bb4f89 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp @@ -23,10 +23,12 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundlePageUIClient.h" #include "InjectedBundleHitTestResult.h" #include "WKAPICast.h" +#include "WebGraphicsContext.h" #include "WKBundleAPICast.h" #include <wtf/text/WTFString.h> @@ -78,8 +80,23 @@ void InjectedBundlePageUIClient::mouseDidMoveOverElement(WebPage* page, const Hi void InjectedBundlePageUIClient::pageDidScroll(WebPage* page) { - if (m_client.pageDidScroll) - m_client.pageDidScroll(toAPI(page), m_client.clientInfo); + if (!m_client.pageDidScroll) + return; + + m_client.pageDidScroll(toAPI(page), m_client.clientInfo); +} + +bool InjectedBundlePageUIClient::shouldPaintCustomOverhangArea() +{ + return m_client.paintCustomOverhangArea; +} + +void InjectedBundlePageUIClient::paintCustomOverhangArea(WebPage* page, GraphicsContext* graphicsContext, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) +{ + ASSERT(shouldPaintCustomOverhangArea()); + + RefPtr<WebGraphicsContext> context = WebGraphicsContext::create(graphicsContext); + m_client.paintCustomOverhangArea(toAPI(page), toAPI(context.get()), toAPI(horizontalOverhangArea), toAPI(verticalOverhangArea), toAPI(dirtyRect), m_client.clientInfo); } } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h index 93c19e9..94925b7 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h @@ -32,7 +32,9 @@ #include <wtf/Forward.h> namespace WebCore { + class GraphicsContext; class HitTestResult; + class IntRect; } namespace WebKit { @@ -50,6 +52,9 @@ public: void willRunJavaScriptPrompt(WebPage*, const String&, const String&, WebFrame*); void mouseDidMoveOverElement(WebPage*, const WebCore::HitTestResult&, WebEvent::Modifiers, RefPtr<APIObject>& userData); void pageDidScroll(WebPage*); + + bool shouldPaintCustomOverhangArea(); + void paintCustomOverhangArea(WebPage*, WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&); }; } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp index d764cf2..2f40fd3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundleScriptWorld.h" #include <WebCore/DOMWrapperWorld.h> @@ -80,5 +81,10 @@ DOMWrapperWorld* InjectedBundleScriptWorld::coreWorld() const { return m_world.get(); } + +void InjectedBundleScriptWorld::clearWrappers() +{ + m_world->clearWrappers(); +} } // namespace WebKit diff --git a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h index 00dd14a..7562a6f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h @@ -47,6 +47,8 @@ public: virtual ~InjectedBundleScriptWorld(); WebCore::DOMWrapperWorld* coreWorld() const; + + void clearWrappers(); private: InjectedBundleScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp b/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp index f992af2..c75e433 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp @@ -24,6 +24,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundle.h" #include "NotImplemented.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp index f278ea9..00e4dff 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundle.h" #include "WKBundleAPICast.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp b/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp index 9d397e8..a5183b1 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/qt/InjectedBundleQt.cpp @@ -24,6 +24,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundle.h" #include "WKBundleAPICast.h" diff --git a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp index 3fd3333..1e593fc 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp @@ -23,6 +23,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "InjectedBundle.h" #include "WKBundleAPICast.h" |