diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/API/c')
47 files changed, 2016 insertions, 814 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp index 8fee4cc51..3320f610b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp @@ -26,13 +26,20 @@ #include "config.h" #include "WKBundle.h" -#include "ImmutableArray.h" +#include "APIArray.h" +#include "APIData.h" #include "InjectedBundle.h" +#include "InjectedBundleScriptWorld.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WKBundlePrivate.h" -#include "WebData.h" +#include "WebConnection.h" +#include "WebFrame.h" +#include "WebPage.h" +#include "WebPageGroupProxy.h" +#include <WebCore/DatabaseManager.h> +using namespace WebCore; using namespace WebKit; WKTypeID WKBundleGetTypeID() @@ -40,7 +47,7 @@ WKTypeID WKBundleGetTypeID() return toAPI(InjectedBundle::APIType); } -void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClient * wkClient) +void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClientBase *wkClient) { toImpl(bundleRef)->initializeClient(wkClient); } @@ -52,7 +59,7 @@ void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTy void WKBundlePostSynchronousMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef) { - RefPtr<APIObject> returnData; + RefPtr<API::Object> returnData; toImpl(bundleRef)->postSynchronousMessage(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData); if (returnDataRef) *returnDataRef = toAPI(returnData.release().leakRef()); @@ -63,26 +70,6 @@ WKConnectionRef WKBundleGetApplicationConnection(WKBundleRef bundleRef) return toAPI(toImpl(bundleRef)->webConnectionToUIProcess()); } -void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundleRef, bool shouldTrackVisitedLinks) -{ - toImpl(bundleRef)->setShouldTrackVisitedLinks(shouldTrackVisitedLinks); -} - -void WKBundleRemoveAllVisitedLinks(WKBundleRef bundleRef) -{ - toImpl(bundleRef)->removeAllVisitedLinks(); -} - -void WKBundleActivateMacFontAscentHack(WKBundleRef bundleRef) -{ - toImpl(bundleRef)->activateMacFontAscentHack(); -} - -void WKBundleSetCacheModel(WKBundleRef bundleRef, uint32_t cacheModel) -{ - toImpl(bundleRef)->setCacheModel(cacheModel); -} - void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundleRef) { toImpl(bundleRef)->garbageCollectJavaScriptObjects(); @@ -98,12 +85,7 @@ size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundleRef) return toImpl(bundleRef)->javaScriptObjectsCount(); } -void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundleRef, bool accept) -{ - toImpl(bundleRef)->setAlwaysAcceptCookies(accept); -} - -void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef) +void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, _WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef) { toImpl(bundleRef)->addUserScript(toImpl(pageGroupRef), toImpl(scriptWorldRef), toWTFString(sourceRef), toWTFString(urlRef), toImpl(whitelistRef), toImpl(blacklistRef), toUserScriptInjectionTime(injectionTimeRef), toUserContentInjectedFrames(injectedFramesRef)); } @@ -183,11 +165,6 @@ void WKBundleSetPopupBlockingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef toImpl(bundleRef)->setPopupBlockingEnabled(toImpl(pageGroupRef), enabled); } -void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundleRef) -{ - toImpl(bundleRef)->switchNetworkLoaderToNewTestingSession(); -} - void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled) { toImpl(bundleRef)->setAuthorAndUserStylesEnabled(toImpl(pageGroupRef), enabled); @@ -223,56 +200,21 @@ void WKBundleReportException(JSContextRef context, JSValueRef exception) InjectedBundle::reportException(context, exception); } -void WKBundleClearAllDatabases(WKBundleRef bundleRef) +void WKBundleClearAllDatabases(WKBundleRef) { - toImpl(bundleRef)->clearAllDatabases(); + DatabaseManager::singleton().deleteAllDatabases(); } void WKBundleSetDatabaseQuota(WKBundleRef bundleRef, uint64_t quota) { - toImpl(bundleRef)->setDatabaseQuota(quota); -} - -void WKBundleClearApplicationCache(WKBundleRef bundleRef) -{ - toImpl(bundleRef)->clearApplicationCache(); -} - -void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundleRef, WKStringRef origin) -{ - toImpl(bundleRef)->clearApplicationCacheForOrigin(toWTFString(origin)); -} - -void WKBundleSetAppCacheMaximumSize(WKBundleRef bundleRef, uint64_t size) -{ - toImpl(bundleRef)->setAppCacheMaximumSize(size); -} - -uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef origin) -{ - return toImpl(bundleRef)->appCacheUsageForOrigin(toWTFString(origin)); -} - -void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes) -{ - toImpl(bundleRef)->setApplicationCacheOriginQuota(toWTFString(origin), bytes); -} - -void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin) -{ - toImpl(bundleRef)->resetApplicationCacheOriginQuota(toWTFString(origin)); -} - -WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundleRef) -{ - RefPtr<ImmutableArray> origins = toImpl(bundleRef)->originsWithApplicationCache(); - return toAPI(origins.release().leakRef()); + // Historically, we've used the following (somewhat non-sensical) string + // for the databaseIdentifier of local files. + DatabaseManager::singleton().setQuota(SecurityOrigin::createFromDatabaseIdentifier("file__0").ptr(), quota); } WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data) { - RefPtr<WebData> webData = toImpl(bundle)->createWebDataFromUint8Array(context, data); - return toAPI(webData.release().leakRef()); + return toAPI(toImpl(bundle)->createWebDataFromUint8Array(context, data).leakRef()); } int WKBundleNumberOfPages(WKBundleRef bundleRef, WKBundleFrameRef frameRef, double pageWidthInPixels, double pageHeightInPixels) @@ -324,23 +266,3 @@ void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageR { toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled); } - -void WKBundleSetSerialLoadingEnabled(WKBundleRef bundleRef, bool enabled) -{ - toImpl(bundleRef)->setSerialLoadingEnabled(enabled); -} - -void WKBundleSetShadowDOMEnabled(WKBundleRef bundleRef, bool enabled) -{ - toImpl(bundleRef)->setShadowDOMEnabled(enabled); -} - -void WKBundleSetSeamlessIFramesEnabled(WKBundleRef bundleRef, bool enabled) -{ - toImpl(bundleRef)->setSeamlessIFramesEnabled(enabled); -} - -void WKBundleDispatchPendingLoadRequests(WKBundleRef bundleRef) -{ - toImpl(bundleRef)->dispatchPendingLoadRequests(); -} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h index 86232e607..60014f78e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h @@ -27,7 +27,7 @@ #define WKBundle_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -40,9 +40,25 @@ typedef void (*WKBundleDidInitializePageGroupCallback)(WKBundleRef bundle, WKBun typedef void (*WKBundleDidReceiveMessageCallback)(WKBundleRef bundle, WKStringRef name, WKTypeRef messageBody, const void* clientInfo); typedef void (*WKBundleDidReceiveMessageToPageCallback)(WKBundleRef bundle, WKBundlePageRef page, WKStringRef name, WKTypeRef messageBody, const void* clientInfo); -struct WKBundleClient { +typedef struct WKBundleClientBase { int version; const void * clientInfo; +} WKBundleClientBase; + +typedef struct WKBundleClientV0 { + WKBundleClientBase base; + + // Version 0. + WKBundleDidCreatePageCallback didCreatePage; + WKBundleWillDestroyPageCallback willDestroyPage; + WKBundleDidInitializePageGroupCallback didInitializePageGroup; + WKBundleDidReceiveMessageCallback didReceiveMessage; +} WKBundleClientV0; + +typedef struct WKBundleClientV1 { + WKBundleClientBase base; + + // Version 0. WKBundleDidCreatePageCallback didCreatePage; WKBundleWillDestroyPageCallback willDestroyPage; WKBundleDidInitializePageGroupCallback didInitializePageGroup; @@ -50,14 +66,11 @@ struct WKBundleClient { // Version 1. WKBundleDidReceiveMessageToPageCallback didReceiveMessageToPage; -}; -typedef struct WKBundleClient WKBundleClient; - -enum { kWKBundleClientCurrentVersion = 1 }; +} WKBundleClientV1; WK_EXPORT WKTypeID WKBundleGetTypeID(); -WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient* client); +WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClientBase* client); WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody); WK_EXPORT void WKBundlePostSynchronousMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h index 15ac158bd..9ed888536 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h @@ -33,32 +33,31 @@ #include <WebCore/EditorInsertAction.h> #include <WebCore/TextAffinity.h> -namespace WebCore { - class CSSStyleDeclaration; -} - namespace WebKit { class InjectedBundle; class InjectedBundleBackForwardList; class InjectedBundleBackForwardListItem; +class InjectedBundleCSSStyleDeclarationHandle; class InjectedBundleDOMWindowExtension; +class InjectedBundleFileHandle; class InjectedBundleHitTestResult; class InjectedBundleNavigationAction; class InjectedBundleNodeHandle; class InjectedBundleRangeHandle; class InjectedBundleScriptWorld; class PageBanner; -class PageOverlay; class WebFrame; class WebInspector; class WebPage; class WebPageGroupProxy; +class WebPageOverlay; WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem) WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList) -WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration) +WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclarationHandle) WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension) +WK_ADD_API_MAPPING(WKBundleFileHandleRef, InjectedBundleFileHandle) WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame) WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult) WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector) @@ -66,7 +65,7 @@ WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction) WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle) WK_ADD_API_MAPPING(WKBundlePageBannerRef, PageBanner) WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy) -WK_ADD_API_MAPPING(WKBundlePageOverlayRef, PageOverlay) +WK_ADD_API_MAPPING(WKBundlePageOverlayRef, WebPageOverlay) WK_ADD_API_MAPPING(WKBundlePageRef, WebPage) WK_ADD_API_MAPPING(WKBundleRangeHandleRef, InjectedBundleRangeHandle) WK_ADD_API_MAPPING(WKBundleRef, InjectedBundle) @@ -77,13 +76,10 @@ inline WKInsertActionType toAPI(WebCore::EditorInsertAction action) switch (action) { case WebCore::EditorInsertActionTyped: return kWKInsertActionTyped; - break; case WebCore::EditorInsertActionPasted: return kWKInsertActionPasted; - break; case WebCore::EditorInsertActionDropped: return kWKInsertActionDropped; - break; } ASSERT_NOT_REACHED(); return kWKInsertActionTyped; @@ -94,10 +90,8 @@ inline WKAffinityType toAPI(WebCore::EAffinity affinity) switch (affinity) { case WebCore::UPSTREAM: return kWKAffinityUpstream; - break; case WebCore::DOWNSTREAM: return kWKAffinityDownstream; - break; } ASSERT_NOT_REACHED(); return kWKAffinityUpstream; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h index 7aa573aa6..03e36e051 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h @@ -26,7 +26,7 @@ #ifndef WKBundleBackForwardList_h #define WKBundleBackForwardList_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp index 3a49bbf26..c6ef6ad6c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "WKBundleBackForwardListItem.h" -#include "ImmutableArray.h" +#include "APIArray.h" #include "InjectedBundleBackForwardListItem.h" #include "WKBundleAPICast.h" @@ -79,6 +79,6 @@ bool WKBundleBackForwardListItemHasCachedPageExpired(WKBundleBackForwardListItem WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef itemRef) { - return toAPI(toImpl(itemRef)->children().leakRef()); + return toAPI(&toImpl(itemRef)->children().leakRef()); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h index 5ad9abe79..409c16faf 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h @@ -26,7 +26,7 @@ #ifndef WKBundleBackForwardListItem_h #define WKBundleBackForwardListItem_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp index 6e5bd62a8..b660e815f 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp @@ -27,7 +27,9 @@ #include "WKBundleDOMWindowExtension.h" #include "InjectedBundleDOMWindowExtension.h" +#include "InjectedBundleScriptWorld.h" #include "WKBundleAPICast.h" +#include "WebFrame.h" using namespace WebKit; diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h index 409a74289..61a3a753b 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.h @@ -26,7 +26,7 @@ #ifndef WKBundleDOMWindowExtension_h #define WKBundleDOMWindowExtension_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp new file mode 100644 index 000000000..da8cae86e --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2015 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 "WKBundleFileHandleRef.h" + +#include "InjectedBundleFileHandle.h" +#include "WKAPICast.h" +#include "WKBundleAPICast.h" + +using namespace WebKit; + +WKTypeID WKBundleFileHandleGetTypeID() +{ + return toAPI(InjectedBundleFileHandle::APIType); +} + +WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef pathRef) +{ + return toAPI(InjectedBundleFileHandle::create(toWTFString(pathRef)).leakRef()); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h index ed04b0c5f..e1a16fb69 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,25 +23,22 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKBundlePageBannerMac_h -#define WKBundlePageBannerMac_h +#ifndef WKBundleFileHandleRef_h +#define WKBundleFileHandleRef_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKBundlePageBanner.h> - -@class CALayer; +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { #endif -WK_EXPORT WKBundlePageBannerRef WKBundlePageBannerCreateBannerWithCALayer(CALayer *layer, int height, WKBundlePageBannerClient * client); +WK_EXPORT WKTypeID WKBundleFileHandleGetTypeID(); -WK_EXPORT CALayer * WKBundlePageBannerGetLayer(WKBundlePageBannerRef pageBanner); +WK_EXPORT WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef path); #ifdef __cplusplus } #endif -#endif /* WKBundlePageBannerMac_h */ +#endif /* WKBundleFileHandleRef_h */ diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp index 61b380803..0b6dc7f7a 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp @@ -27,16 +27,24 @@ #include "WKBundleFrame.h" #include "WKBundleFramePrivate.h" +#include "APIArray.h" +#include "APISecurityOrigin.h" +#include "InjectedBundleFileHandle.h" #include "InjectedBundleHitTestResult.h" +#include "InjectedBundleNodeHandle.h" +#include "InjectedBundleRangeHandle.h" +#include "InjectedBundleScriptWorld.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WKData.h" #include "WebFrame.h" -#include "WebSecurityOrigin.h" +#include "WebPage.h" #include <WebCore/Document.h> +#include <WebCore/FocusController.h> #include <WebCore/Frame.h> #include <WebCore/FrameLoader.h> #include <WebCore/FrameView.h> +#include <WebCore/Page.h> using namespace WebCore; using namespace WebKit; @@ -72,11 +80,7 @@ WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frameRef) if (!coreFrame) return kWKFrameLoadStateFinished; - FrameLoader* loader = coreFrame->loader(); - if (!loader) - return kWKFrameLoadStateFinished; - - switch (loader->state()) { + switch (coreFrame->loader().state()) { case FrameStateProvisional: return kWKFrameLoadStateProvisional; case FrameStateCommittedPage: @@ -91,7 +95,7 @@ WKFrameLoadState WKBundleFrameGetFrameLoadState(WKBundleFrameRef frameRef) WKArrayRef WKBundleFrameCopyChildFrames(WKBundleFrameRef frameRef) { - return toAPI(toImpl(frameRef)->childFrames().leakRef()); + return toAPI(&toImpl(frameRef)->childFrames().leakRef()); } JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frameRef) @@ -119,6 +123,11 @@ JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef fr return toImpl(frameRef)->jsWrapperForWorld(toImpl(rangeHandleRef), toImpl(worldRef)); } +JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frameRef, WKBundleFileHandleRef fileHandleRef, WKBundleScriptWorldRef worldRef) +{ + return toImpl(frameRef)->jsWrapperForWorld(toImpl(fileHandleRef), toImpl(worldRef)); +} + WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef) { return toCopiedAPI(toImpl(frameRef)->name()); @@ -148,7 +157,7 @@ void WKBundleFrameClearOpener(WKBundleFrameRef frameRef) { Frame* coreFrame = toImpl(frameRef)->coreFrame(); if (coreFrame) - coreFrame->loader()->setOpener(0); + coreFrame->loader().setOpener(0); } void WKBundleFrameStopLoading(WKBundleFrameRef frameRef) @@ -163,7 +172,7 @@ WKStringRef WKBundleFrameCopyLayerTreeAsText(WKBundleFrameRef frameRef) bool WKBundleFrameAllowsFollowingLink(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toImpl(frameRef)->allowsFollowingLink(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))); + return toImpl(frameRef)->allowsFollowingLink(WebCore::URL(WebCore::URL(), toWTFString(urlRef))); } bool WKBundleFrameHandlesPageScaleGesture(WKBundleFrameRef frameRef) @@ -208,12 +217,12 @@ bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frameRef, double* WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)))); + return toCopiedAPI(toImpl(frameRef)->suggestedFilenameForResourceWithURL(WebCore::URL(WebCore::URL(), toWTFString(urlRef)))); } WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frameRef, WKURLRef urlRef) { - return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef)))); + return toCopiedAPI(toImpl(frameRef)->mimeTypeForResourceWithURL(WebCore::URL(WebCore::URL(), toWTFString(urlRef)))); } bool WKBundleFrameContainsAnyFormElements(WKBundleFrameRef frameRef) @@ -231,6 +240,11 @@ void WKBundleFrameSetTextDirection(WKBundleFrameRef frameRef, WKStringRef direct toImpl(frameRef)->setTextDirection(toWTFString(directionRef)); } +void WKBundleFrameSetAccessibleName(WKBundleFrameRef frameRef, WKStringRef accessibleNameRef) +{ + toImpl(frameRef)->setAccessibleName(toWTFString(accessibleNameRef)); +} + WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef) { return WKBundleFrameCopyWebArchiveFilteringSubframes(frameRef, 0, 0); @@ -238,7 +252,7 @@ WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frameRef) WKDataRef WKBundleFrameCopyWebArchiveFilteringSubframes(WKBundleFrameRef frameRef, WKBundleFrameFrameFilterCallback frameFilterCallback, void* context) { -#if PLATFORM(MAC) +#if PLATFORM(COCOA) RetainPtr<CFDataRef> data = toImpl(frameRef)->webArchiveData(frameFilterCallback, context); if (data) return WKDataCreate(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get())); @@ -257,7 +271,7 @@ bool WKBundleFrameCallShouldCloseOnWebView(WKBundleFrameRef frameRef) if (!coreFrame) return true; - return coreFrame->loader()->shouldClose(); + return coreFrame->loader().shouldClose(); } WKBundleHitTestResultRef WKBundleFrameCreateHitTestResult(WKBundleFrameRef frameRef, WKPoint point) @@ -273,3 +287,12 @@ WKSecurityOriginRef WKBundleFrameCopySecurityOrigin(WKBundleFrameRef frameRef) return toCopiedAPI(coreFrame->document()->securityOrigin()); } + +void WKBundleFrameFocus(WKBundleFrameRef frameRef) +{ + Frame* coreFrame = toImpl(frameRef)->coreFrame(); + if (!coreFrame) + return; + + coreFrame->page()->focusController().setFocusedFrame(coreFrame); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h index 8c2b875f5..6654f0029 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h @@ -27,9 +27,9 @@ #define WKBundleFrame_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKFrame.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKFrame.h> +#include <WebKit/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -55,6 +55,7 @@ WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef contex WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world); WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef frame, WKBundleRangeHandleRef rangeHandle, WKBundleScriptWorldRef world); +WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frame, WKBundleFileHandleRef fileHandle, WKBundleScriptWorldRef world); WK_EXPORT WKBundlePageRef WKBundleFrameGetPage(WKBundleFrameRef frame); @@ -73,6 +74,8 @@ WK_EXPORT bool WKBundleFrameGetDocumentBackgroundColor(WKBundleFrameRef frame, d WK_EXPORT WKStringRef WKBundleFrameCopySuggestedFilenameForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); WK_EXPORT WKStringRef WKBundleFrameCopyMIMETypeForResourceWithURL(WKBundleFrameRef frame, WKURLRef url); +WK_EXPORT void WKBundleFrameSetAccessibleName(WKBundleFrameRef frame, WKStringRef accessibleName); + WK_EXPORT WKDataRef WKBundleFrameCopyWebArchive(WKBundleFrameRef frame); typedef bool (*WKBundleFrameFrameFilterCallback)(WKBundleFrameRef frame, WKBundleFrameRef subframe, void* context); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h index 4e81d898e..0e83d35c8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h @@ -27,7 +27,8 @@ #define WKBundleFramePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> #ifndef __cplusplus #include <stdbool.h> @@ -53,6 +54,8 @@ WK_EXPORT WKBundleHitTestResultRef WKBundleFrameCreateHitTestResult(WKBundleFram WK_EXPORT bool WKBundleFrameHandlesPageScaleGesture(WKBundleFrameRef frame); +WK_EXPORT void WKBundleFrameFocus(WKBundleFrameRef frame); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp index 60a4c68b0..46f699926 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp @@ -30,6 +30,7 @@ #include "InjectedBundleNodeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WebFrame.h" using namespace WebKit; @@ -44,6 +45,12 @@ WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultR return toAPI(nodeHandle.release().leakRef()); } +WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResultRef) +{ + RefPtr<InjectedBundleNodeHandle> urlElementNodeHandle = toImpl(hitTestResultRef)->urlElementHandle(); + return toAPI(urlElementNodeHandle.release().leakRef()); +} + WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef hitTestResultRef) { return toAPI(toImpl(hitTestResultRef)->frame()); @@ -84,6 +91,11 @@ bool WKBundleHitTestResultMediaHasAudio(WKBundleHitTestResultRef hitTestResultRe return toImpl(hitTestResultRef)->mediaHasAudio(); } +bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef) +{ + return toImpl(hitTestResultRef)->isDownloadableMedia(); +} + WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResultRef) { return toAPI(toImpl(hitTestResultRef)->mediaType()); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h index 839e9850d..941becab3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h @@ -26,8 +26,8 @@ #ifndef WKBundleHitTestResult_h #define WKBundleHitTestResult_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -43,6 +43,7 @@ typedef uint32_t WKBundleHitTestResultMediaType; WK_EXPORT WKTypeID WKBundleHitTestResultGetTypeID(); WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyNodeHandle(WKBundleHitTestResultRef hitTestResult); +WK_EXPORT WKBundleNodeHandleRef WKBundleHitTestResultCopyURLElementHandle(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetTargetFrame(WKBundleHitTestResultRef hitTestResult); @@ -53,6 +54,7 @@ WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteLinkURL(WKBundleHitTestResul WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteMediaURL(WKBundleHitTestResultRef hitTestResult); WK_EXPORT bool WKBundleHitTestResultMediaIsInFullscreen(WKBundleHitTestResultRef hitTestResult); WK_EXPORT bool WKBundleHitTestResultMediaHasAudio(WKBundleHitTestResultRef hitTestResult); +WK_EXPORT bool WKBundleHitTestResultIsDownloadableMedia(WKBundleHitTestResultRef hitTestResultRef); WK_EXPORT WKBundleHitTestResultMediaType WKBundleHitTestResultGetMediaType(WKBundleHitTestResultRef hitTestResult); WK_EXPORT WKRect WKBundleHitTestResultGetImageRect(WKBundleHitTestResultRef hitTestResult); diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h index f10b7b400..86a897e39 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInitialize.h @@ -26,7 +26,7 @@ #ifndef WKBundleInitialize_h #define WKBundleInitialize_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp index cc22499a0..0f0e0afe9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp @@ -26,8 +26,6 @@ #include "config.h" #include "WKBundleInspector.h" -#if ENABLE(INSPECTOR) - #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebInspector.h" @@ -42,17 +40,17 @@ WKTypeID WKBundleInspectorGetTypeID() void WKBundleInspectorShow(WKBundleInspectorRef inspectorRef) { - return toImpl(inspectorRef)->show(); + toImpl(inspectorRef)->show(); } void WKBundleInspectorClose(WKBundleInspectorRef inspectorRef) { - return toImpl(inspectorRef)->close(); + toImpl(inspectorRef)->close(); } -void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, long callID, WKStringRef script) +void WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspectorRef, WKStringRef script) { - return toImpl(inspectorRef)->evaluateScriptForTest(callID, toWTFString(script)); + toImpl(inspectorRef)->evaluateScriptForTest(toWTFString(script)); } void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, bool enabled) @@ -62,5 +60,3 @@ void WKBundleInspectorSetPageProfilingEnabled(WKBundleInspectorRef inspectorRef, 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 index e32fdf25e..ddc3318b7 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleInspector.h @@ -26,9 +26,7 @@ #ifndef WKBundleInspector_h #define WKBundleInspector_h -#include <WebKit2/WKBase.h> - -#if ENABLE(INSPECTOR) +#include <WebKit/WKBase.h> #ifndef __cplusplus #include <stdbool.h> @@ -43,14 +41,12 @@ 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 WKBundleInspectorEvaluateScriptForTest(WKBundleInspectorRef inspector, 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 index c26ec3ecf..84392c7d1 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "WKBundleNavigationAction.h" +#include "WKBundleNavigationActionPrivate.h" #include "InjectedBundleHitTestResult.h" #include "InjectedBundleNavigationAction.h" @@ -65,3 +66,13 @@ WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigation RefPtr<InjectedBundleNodeHandle> formElement = toImpl(navigationActionRef)->formElement(); return toAPI(formElement.release().leakRef()); } + +bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef navigationActionRef) +{ + return toImpl(navigationActionRef)->shouldOpenExternalURLs(); +} + +bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef navigationActionRef) +{ + return toImpl(navigationActionRef)->shouldTryAppLinks(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h index 03f083a29..3b95cf1bf 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h @@ -26,9 +26,9 @@ #ifndef WKBundleNavigationAction_h #define WKBundleNavigationAction_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKEvent.h> -#include <WebKit2/WKPageLoadTypes.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKEvent.h> +#include <WebKit/WKPageLoadTypes.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h new file mode 100644 index 000000000..474692963 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015 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 WKBundleNavigationActionPrivate_h +#define WKBundleNavigationActionPrivate_h + +#include <WebKit/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef); +WK_EXPORT bool WKBundleNavigationActionGetShouldTryAppLinks(WKBundleNavigationActionRef); + +#ifdef __cplusplus +} +#endif + +#endif // WKBundleNavigationActionPrivate_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index cb3f9b6e6..8a913013e 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -28,13 +28,29 @@ #include "WKBundleNodeHandlePrivate.h" #include "InjectedBundleNodeHandle.h" +#include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebFrame.h" #include "WebImage.h" +#include <WebCore/HTMLTextFormControlElement.h> using namespace WebKit; +static WebCore::AutoFillButtonType toAutoFillButtonType(WKAutoFillButtonType wkAutoFillButtonType) +{ + switch (wkAutoFillButtonType) { + case kWKAutoFillButtonTypeNone: + return WebCore::AutoFillButtonType::None; + case kWKAutoFillButtonTypeContacts: + return WebCore::AutoFillButtonType::Contacts; + case kWKAutoFillButtonTypeCredentials: + return WebCore::AutoFillButtonType::Credentials; + } + ASSERT_NOT_REACHED(); + return WebCore::AutoFillButtonType::None; +} + WKTypeID WKBundleNodeHandleGetTypeID() { return toAPI(InjectedBundleNodeHandle::APIType); @@ -63,6 +79,12 @@ WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeH return toAPI(image.release().leakRef()); } +WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandleRef) +{ + RefPtr<InjectedBundleRangeHandle> rangeHandle = toImpl(nodeHandleRef)->visibleRange(); + return toAPI(rangeHandle.release().leakRef()); +} + WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandleRef) { return toAPI(toImpl(elementHandleRef)->elementBounds()); @@ -73,14 +95,29 @@ void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htm toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef)); } -bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) +bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef) { - return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutofilled(); + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); } -void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) +void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) { - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); +} + +bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFillButtonEnabled(); +} + +void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandleRef, WKAutoFillButtonType autoFillButtonType) +{ + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(toAutoFillButtonType(autoFillButtonType)); +} + +WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toAPI(toImpl(htmlInputElementHandleRef)->htmlInputElementAutoFillButtonBounds()); } bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef) @@ -116,3 +153,23 @@ WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNod RefPtr<WebFrame> frame = toImpl(htmlIFrameElementHandleRef)->htmlIFrameElementContentFrame(); return toAPI(frame.release().leakRef()); } + +// Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef). +bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); +} + +// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool). +void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) +{ + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); +} + +// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef, WKAutoFillButtonType). +void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled) +{ + WebCore::AutoFillButtonType autoFillButtonType = enabled ? WebCore::AutoFillButtonType::Credentials : WebCore::AutoFillButtonType::None; + + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(autoFillButtonType); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h index 3cdad1761..6b0bfe958 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h @@ -26,7 +26,7 @@ #ifndef WKBundleNodeHandle_h #define WKBundleNodeHandle_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h index 1ad192915..696d464a8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h @@ -27,14 +27,21 @@ #define WKBundleNodeHandlePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKGeometry.h> -#include <WebKit2/WKImage.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> +#include <WebKit/WKImage.h> #ifdef __cplusplus extern "C" { #endif +enum { + kWKAutoFillButtonTypeNone, + kWKAutoFillButtonTypeCredentials, + kWKAutoFillButtonTypeContacts +}; +typedef uint8_t WKAutoFillButtonType; + WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCreate(JSContextRef context, JSObjectRef object); /* Convenience Operations */ @@ -45,14 +52,18 @@ WK_EXPORT WKBundleNodeHandleRef WKBundleNodeHandleCopyDocument(WKBundleNodeHandl WK_EXPORT WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandle, bool* isReplaced); WK_EXPORT WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeHandle, WKSnapshotOptions options); +WK_EXPORT WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandle); /* Element Specific Operations */ WK_EXPORT WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandle); /* HTMLInputElement Specific Operations */ WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value); -WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); -WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); +WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle); +WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); +WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle); +WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandle, WKAutoFillButtonType autoFillButtonType); +WK_EXPORT WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandle); WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandle); /* HTMLTextAreaElement Specific Operations */ @@ -70,6 +81,14 @@ WK_EXPORT WKBundleFrameRef WKBundleNodeHandleCopyHTMLFrameElementContentFrame(WK /* HTMLIFrameElement Specific Operations */ WK_EXPORT WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNodeHandleRef htmlIFrameElementHandle); + +/* Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef) */ +WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle); +/* Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool) */ +WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled); +/* Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef, WKAutoFillButtonType)*/ +WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle, bool enabled); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp index d45e48e88..44c29e883 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2013, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,14 @@ #include "WKBundlePage.h" #include "WKBundlePagePrivate.h" +#include "APIArray.h" +#include "APIString.h" +#include "APIURL.h" +#include "APIURLRequest.h" #include "InjectedBundleBackForwardList.h" #include "InjectedBundleNodeHandle.h" +#include "InjectedBundlePageFormClient.h" +#include "InjectedBundlePageUIClient.h" #include "PageBanner.h" #include "WKAPICast.h" #include "WKArray.h" @@ -40,19 +46,22 @@ #include "WebFrame.h" #include "WebFullScreenManager.h" #include "WebImage.h" +#include "WebInspector.h" #include "WebPage.h" +#include "WebPageGroupProxy.h" +#include "WebPageOverlay.h" #include "WebRenderLayer.h" #include "WebRenderObject.h" -#include "WebString.h" -#include "WebURL.h" -#include "WebURLRequest.h" - #include <WebCore/AXObjectCache.h> #include <WebCore/AccessibilityObject.h> -#include <WebCore/Frame.h> -#include <WebCore/KURL.h> +#include <WebCore/ApplicationCacheStorage.h> +#include <WebCore/MainFrame.h> #include <WebCore/Page.h> -#include <wtf/OwnArrayPtr.h> +#include <WebCore/PageOverlay.h> +#include <WebCore/PageOverlayController.h> +#include <WebCore/URL.h> +#include <WebCore/WheelEventTestTrigger.h> +#include <wtf/StdLibExtras.h> using namespace WebKit; @@ -61,47 +70,53 @@ WKTypeID WKBundlePageGetTypeID() return toAPI(WebPage::APIType); } -void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClient* wkClient) +void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClientBase* wkClient) { #if ENABLE(CONTEXT_MENUS) - toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient); + toImpl(pageRef)->setInjectedBundleContextMenuClient(std::make_unique<InjectedBundlePageContextMenuClient>(wkClient)); +#else + UNUSED_PARAM(pageRef); + UNUSED_PARAM(wkClient); #endif } -void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClient* wkClient) +void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClientBase* wkClient) { toImpl(pageRef)->initializeInjectedBundleEditorClient(wkClient); } -void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClient* wkClient) +void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClientBase* wkClient) { - toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient); + toImpl(pageRef)->setInjectedBundleFormClient(std::make_unique<InjectedBundlePageFormClient>(wkClient)); } -void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient) +void WKBundlePageSetPageLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClientBase* wkClient) { toImpl(pageRef)->initializeInjectedBundleLoaderClient(wkClient); } -void WKBundlePageSetResourceLoadClient(WKBundlePageRef pageRef, WKBundlePageResourceLoadClient* wkClient) +void WKBundlePageSetResourceLoadClient(WKBundlePageRef pageRef, WKBundlePageResourceLoadClientBase* wkClient) { toImpl(pageRef)->initializeInjectedBundleResourceLoadClient(wkClient); } -void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClient* wkClient) +void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClientBase* wkClient) { toImpl(pageRef)->initializeInjectedBundlePolicyClient(wkClient); } -void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient) +void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClientBase* wkClient) { - toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient); + toImpl(pageRef)->setInjectedBundleUIClient(std::make_unique<InjectedBundlePageUIClient>(wkClient)); } -void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClient* wkClient) +void WKBundlePageSetFullScreenClient(WKBundlePageRef pageRef, WKBundlePageFullScreenClientBase* wkClient) { #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API toImpl(pageRef)->initializeInjectedBundleFullScreenClient(wkClient); +#else + UNUSED_PARAM(pageRef); + UNUSED_PARAM(wkClient); #endif } @@ -109,6 +124,8 @@ void WKBundlePageWillEnterFullScreen(WKBundlePageRef pageRef) { #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API toImpl(pageRef)->fullScreenManager()->willEnterFullScreen(); +#else + UNUSED_PARAM(pageRef); #endif } @@ -116,6 +133,8 @@ void WKBundlePageDidEnterFullScreen(WKBundlePageRef pageRef) { #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API toImpl(pageRef)->fullScreenManager()->didEnterFullScreen(); +#else + UNUSED_PARAM(pageRef); #endif } @@ -123,6 +142,8 @@ void WKBundlePageWillExitFullScreen(WKBundlePageRef pageRef) { #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API toImpl(pageRef)->fullScreenManager()->willExitFullScreen(); +#else + UNUSED_PARAM(pageRef); #endif } @@ -130,10 +151,12 @@ void WKBundlePageDidExitFullScreen(WKBundlePageRef pageRef) { #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API toImpl(pageRef)->fullScreenManager()->didExitFullScreen(); +#else + UNUSED_PARAM(pageRef); #endif } -void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef pageRef, WKBundlePageDiagnosticLoggingClient* client) +void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef pageRef, WKBundlePageDiagnosticLoggingClientBase* client) { toImpl(pageRef)->initializeInjectedBundleDiagnosticLoggingClient(client); } @@ -148,19 +171,40 @@ WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef) return toAPI(toImpl(pageRef)->mainWebFrame()); } -WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef pageRef) +void WKBundlePageClickMenuItem(WKBundlePageRef pageRef, WKContextMenuItemRef item) +{ +#if ENABLE(CONTEXT_MENUS) + toImpl(pageRef)->contextMenu()->itemSelected(toImpl(item)->data()); +#else + UNUSED_PARAM(pageRef); + UNUSED_PARAM(item); +#endif +} + +#if ENABLE(CONTEXT_MENUS) +static PassRefPtr<API::Array> contextMenuItems(const WebContextMenu& contextMenu) +{ + auto items = contextMenu.items(); + + Vector<RefPtr<API::Object>> menuItems; + menuItems.reserveInitialCapacity(items.size()); + + for (const auto& item : items) + menuItems.uncheckedAppend(WebContextMenuItem::create(item)); + + return API::Array::create(WTFMove(menuItems)); +} +#endif + +WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef) { #if ENABLE(CONTEXT_MENUS) WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu(); - const Vector<WebContextMenuItemData> &items = contextMenu->items(); - size_t arrayLength = items.size(); - OwnArrayPtr<WKTypeRef> itemNames = adoptArrayPtr(new WKTypeRef[arrayLength]); - for (size_t i = 0; i < arrayLength; ++i) - itemNames[i] = WKStringCreateWithUTF8CString(items[i].title().utf8().data()); - return WKArrayCreateAdoptingValues(itemNames.get(), arrayLength); + return toAPI(contextMenuItems(*contextMenu).leakRef()); #else - return 0; + UNUSED_PARAM(pageRef); + return nullptr; #endif } @@ -169,19 +213,13 @@ WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef pageRef, W #if ENABLE(CONTEXT_MENUS) WebContextMenu* contextMenu = toImpl(pageRef)->contextMenuAtPointInWindow(toIntPoint(point)); if (!contextMenu) - return 0; + return nullptr; - const Vector<WebContextMenuItemData>& items = contextMenu->items(); - size_t arrayLength = items.size(); - - RefPtr<MutableArray> menuArray = MutableArray::create(); - menuArray->reserveCapacity(arrayLength); - for (unsigned i = 0; i < arrayLength; ++i) - menuArray->append(WebContextMenuItem::create(items[i]).get()); - - return toAPI(menuArray.release().leakRef()); + return toAPI(contextMenuItems(*contextMenu).leakRef()); #else - return 0; + UNUSED_PARAM(pageRef); + UNUSED_PARAM(point); + return nullptr; #endif } @@ -195,13 +233,13 @@ void* WKAccessibilityRootObject(WKBundlePageRef pageRef) if (!page) return 0; - WebCore::Frame* core = page->mainFrame(); - if (!core || !core->document()) + WebCore::Frame& core = page->mainFrame(); + if (!core.document()) return 0; WebCore::AXObjectCache::enableAccessibility(); - WebCore::AccessibilityObject* root = core->document()->axObjectCache()->rootObject(); + WebCore::AccessibilityObject* root = core.document()->axObjectCache()->rootObject(); if (!root) return 0; @@ -235,6 +273,22 @@ void* WKAccessibilityFocusedObject(WKBundlePageRef pageRef) #endif } +void WKAccessibilityEnableEnhancedAccessibility(bool enable) +{ +#if HAVE(ACCESSIBILITY) + WebCore::AXObjectCache::setEnhancedUserInterfaceAccessibility(enable); +#endif +} + +bool WKAccessibilityEnhancedAccessibilityEnabled() +{ +#if HAVE(ACCESSIBILITY) + return WebCore::AXObjectCache::accessibilityEnhancedUserInterfaceEnabled(); +#else + return false; +#endif +} + void WKBundlePageStopLoading(WKBundlePageRef pageRef) { toImpl(pageRef)->stopLoading(); @@ -305,29 +359,24 @@ WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRe return toAPI(toImpl(pageRef)->backForwardList()); } -void WKBundlePageSetUnderlayPage(WKBundlePageRef pageRef, WKBundlePageRef pageUnderlayRef) -{ - toImpl(pageRef)->setUnderlayPage(toImpl(pageUnderlayRef)); -} - void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef)); + toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade); } void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef)); + toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::DoNotFade); } void WKBundlePageInstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef), true); + toImpl(pageRef)->mainFrame()->pageOverlayController().installPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade); } void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) { - toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), true); + toImpl(pageRef)->mainFrame()->pageOverlayController().uninstallPageOverlay(toImpl(pageOverlayRef)->coreOverlay(), WebCore::PageOverlay::FadeMode::Fade); } void WKBundlePageSetTopOverhangImage(WKBundlePageRef pageRef, WKImageRef imageRef) @@ -350,6 +399,7 @@ void WKBundlePageSetBottomOverhangImage(WKBundlePageRef pageRef, WKImageRef imag #endif } +#if !PLATFORM(IOS) void WKBundlePageSetHeaderBanner(WKBundlePageRef pageRef, WKBundlePageBannerRef bannerRef) { toImpl(pageRef)->setHeaderPageBanner(toImpl(bannerRef)); @@ -359,10 +409,11 @@ void WKBundlePageSetFooterBanner(WKBundlePageRef pageRef, WKBundlePageBannerRef { toImpl(pageRef)->setFooterPageBanner(toImpl(bannerRef)); } +#endif // !PLATFORM(IOS) bool WKBundlePageHasLocalDataForURL(WKBundlePageRef pageRef, WKURLRef urlRef) { - return toImpl(pageRef)->hasLocalDataForURL(WebCore::KURL(WebCore::KURL(), toWTFString(urlRef))); + return toImpl(pageRef)->hasLocalDataForURL(WebCore::URL(WebCore::URL(), toWTFString(urlRef))); } bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef) @@ -413,12 +464,7 @@ void WKBundlePageListenForLayoutMilestones(WKBundlePageRef pageRef, WKLayoutMile WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef) { -#if ENABLE(INSPECTOR) return toAPI(toImpl(pageRef)->inspector()); -#else - UNUSED_PARAM(pageRef); - return 0; -#endif } void WKBundlePageForceRepaint(WKBundlePageRef page) @@ -479,7 +525,7 @@ void WKBundlePageResetTrackedRepaints(WKBundlePageRef pageRef) WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef) { - return toAPI(toImpl(pageRef)->trackedRepaintRects().leakRef()); + return toAPI(&toImpl(pageRef)->trackedRepaintRects().leakRef()); } void WKBundlePageSetComposition(WKBundlePageRef pageRef, WKStringRef text, int from, int length) @@ -516,3 +562,121 @@ void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef pa { toImpl(pageRef)->stopExtendingIncrementalRenderingSuppression(token); } + +bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef pageRef) +{ + return toImpl(pageRef)->usesEphemeralSession(); +} + +#if TARGET_OS_IPHONE +void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef pageRef, bool useTestingViewportConfiguration) +{ + toImpl(pageRef)->setUseTestingViewportConfiguration(useTestingViewportConfiguration); +} +#endif + +void WKBundlePageStartMonitoringScrollOperations(WKBundlePageRef pageRef) +{ + WebKit::WebPage* webPage = toImpl(pageRef); + WebCore::Page* page = webPage ? webPage->corePage() : nullptr; + + if (!page) + return; + + page->ensureTestTrigger(); +} + +void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context) +{ + if (!callback) + return; + + WebKit::WebPage* webPage = toImpl(pageRef); + WebCore::Page* page = webPage ? webPage->corePage() : nullptr; + if (!page || !page->expectsWheelEventTriggers()) + return; + + page->ensureTestTrigger().setTestCallbackAndStartNotificationTimer([=]() { + callback(context); + }); +} + +void WKBundlePagePostMessage(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef) +{ + toImpl(pageRef)->postMessage(toWTFString(messageNameRef), toImpl(messageBodyRef)); +} + +void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef, WKTypeRef* returnDataRef) +{ + WebPage* page = toImpl(pageRef); + page->layoutIfNeeded(); + + RefPtr<API::Object> returnData; + page->postSynchronousMessageForTesting(toWTFString(messageNameRef), toImpl(messageBodyRef), returnData); + if (returnDataRef) + *returnDataRef = toAPI(returnData.release().leakRef()); +} + +void WKBundlePageAddUserScript(WKBundlePageRef pageRef, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames) +{ + toImpl(pageRef)->addUserScript(toWTFString(source), toUserContentInjectedFrames(injectedFrames), toUserScriptInjectionTime(injectionTime)); +} + +void WKBundlePageAddUserStyleSheet(WKBundlePageRef pageRef, WKStringRef source, WKUserContentInjectedFrames injectedFrames) +{ + toImpl(pageRef)->addUserStyleSheet(toWTFString(source), toUserContentInjectedFrames(injectedFrames)); +} + +void WKBundlePageRemoveAllUserContent(WKBundlePageRef pageRef) +{ + toImpl(pageRef)->removeAllUserContent(); +} + +WKStringRef WKBundlePageCopyGroupIdentifier(WKBundlePageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->pageGroup()->identifier()); +} + +void WKBundlePageClearApplicationCache(WKBundlePageRef page) +{ + toImpl(page)->corePage()->applicationCacheStorage().deleteAllEntries(); +} + +void WKBundlePageClearApplicationCacheForOrigin(WKBundlePageRef page, WKStringRef origin) +{ + toImpl(page)->corePage()->applicationCacheStorage().deleteCacheForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string())); +} + +void WKBundlePageSetAppCacheMaximumSize(WKBundlePageRef page, uint64_t size) +{ + toImpl(page)->corePage()->applicationCacheStorage().setMaximumSize(size); +} + +uint64_t WKBundlePageGetAppCacheUsageForOrigin(WKBundlePageRef page, WKStringRef origin) +{ + return toImpl(page)->corePage()->applicationCacheStorage().diskUsageForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string())); +} + +void WKBundlePageSetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin, uint64_t bytes) +{ + toImpl(page)->corePage()->applicationCacheStorage().storeUpdatedQuotaForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()).ptr(), bytes); +} + +void WKBundlePageResetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin) +{ + toImpl(page)->corePage()->applicationCacheStorage().storeUpdatedQuotaForOrigin(WebCore::SecurityOrigin::createFromString(toImpl(origin)->string()).ptr(), toImpl(page)->corePage()->applicationCacheStorage().defaultOriginQuota()); +} + +WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page) +{ + HashSet<RefPtr<WebCore::SecurityOrigin>> origins; + toImpl(page)->corePage()->applicationCacheStorage().getOriginsWithCache(origins); + + Vector<RefPtr<API::Object>> originIdentifiers; + originIdentifiers.reserveInitialCapacity(origins.size()); + + for (const auto& origin : origins) + originIdentifiers.uncheckedAppend(API::String::create(origin->databaseIdentifier())); + + return toAPI(&API::Array::create(WTFMove(originIdentifiers)).leakRef()); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h index 103f478a1..0564481c3 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,11 +27,18 @@ #define WKBundlePage_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKEvent.h> -#include <WebKit2/WKFindOptions.h> -#include <WebKit2/WKImage.h> -#include <WebKit2/WKPageLoadTypes.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKBundlePageContextMenuClient.h> +#include <WebKit/WKBundlePageDiagnosticLoggingClient.h> +#include <WebKit/WKBundlePageEditorClient.h> +#include <WebKit/WKBundlePageFormClient.h> +#include <WebKit/WKBundlePageFullScreenClient.h> +#include <WebKit/WKBundlePageLoaderClient.h> +#include <WebKit/WKBundlePagePolicyClient.h> +#include <WebKit/WKBundlePageResourceLoadClient.h> +#include <WebKit/WKBundlePageUIClient.h> +#include <WebKit/WKFindOptions.h> +#include <WebKit/WKImage.h> #ifndef __cplusplus #include <stdbool.h> @@ -43,378 +50,6 @@ extern "C" { #endif -enum { - kWKInsertActionTyped = 0, - kWKInsertActionPasted = 1, - kWKInsertActionDropped = 2 -}; -typedef uint32_t WKInsertActionType; - -enum { - kWKAffinityUpstream, - kWKAffinityDownstream -}; -typedef uint32_t WKAffinityType; - -enum { - WKInputFieldActionTypeMoveUp, - WKInputFieldActionTypeMoveDown, - WKInputFieldActionTypeCancel, - WKInputFieldActionTypeInsertTab, - WKInputFieldActionTypeInsertBacktab, - WKInputFieldActionTypeInsertNewline, - WKInputFieldActionTypeInsertDelete -}; -typedef uint32_t WKInputFieldActionType; - -enum { - WKFullScreenNoKeyboard, - WKFullScreenKeyboard, -}; -typedef uint32_t WKFullScreenKeyboardRequestType; - -enum { - WKScrollDirectionLeft, - WKScrollDirectionRight -}; -typedef uint32_t WKScrollDirection; - -// Loader Client -typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidCommitLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidDocumentFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFinishDocumentLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFinishProgressCallback)(WKBundlePageRef page, const void *clientInfo); -typedef void (*WKBundlePageDidFailLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidSameDocumentNavigationForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidReceiveTitleForFrameCallback)(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidRemoveFrameFromHierarchyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidDisplayInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidRunInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidDetectXSSForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFirstLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKBundlePageRef page, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageDidLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo); -typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo); -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 (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo); -typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); -typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); -typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); -typedef bool (*WKBundlePageShouldForceUniversalAccessFromLocalURLCallback)(WKBundlePageRef, WKStringRef url, const void* clientInfo); -typedef void (*WKBundlePageDidLayoutCallback)(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo); -typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo); -typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo); -typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo); - -struct WKBundlePageLoaderClient { - int version; - const void * clientInfo; - - // Version 0. - WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; - WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; - WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; - WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; - WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; - WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; - WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; - WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; - WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; - WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; - WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; - WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; - WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; - WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; - WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; - WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; - WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; - WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; - - // Version 1. - WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; - WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback didNewFirstVisuallyNonEmptyLayout; - WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; - WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; - WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; - WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; - WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; - WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; - - // Version 2 - WKBundlePageDidFinishProgressCallback didFinishProgress; - WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; - - // Version 3 - void * didReceiveIntentForFrame_unavailable; - void * registerIntentServiceForFrame_unavailable; - - // Version 4 - WKBundlePageDidLayoutCallback didLayout; - - // Version 5 - WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; - - // Version 6 - WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; - WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; -}; -typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient; - -enum { kWKBundlePageLoaderClientCurrentVersion = 6 }; - -enum { - WKBundlePagePolicyActionPassThrough, - WKBundlePagePolicyActionUse -}; -typedef uint32_t WKBundlePagePolicyAction; - -// Policy Client -typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); -typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo); -typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForResponseCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); -typedef void (*WKBundlePageUnableToImplementPolicyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void* clientInfo); - -struct WKBundlePagePolicyClient { - int version; - const void * clientInfo; - WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; - WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; - WKBundlePageDecidePolicyForResponseCallback decidePolicyForResponse; - WKBundlePageUnableToImplementPolicyCallback unableToImplementPolicy; -}; -typedef struct WKBundlePagePolicyClient WKBundlePagePolicyClient; - -enum { kWKBundlePagePolicyClientCurrentVersion = 0 }; - -// 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); -typedef bool (*WKBundlePageShouldCacheResponseCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo); -typedef bool (*WKBundlePageShouldUseCredentialStorageCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo); - -struct WKBundlePageResourceLoadClient { - int version; - const void * clientInfo; - - // Version 0. - WKBundlePageDidInitiateLoadForResourceCallback didInitiateLoadForResource; - - // willSendRequestForFrame is supposed to return a retained reference to the URL request. - WKBundlePageWillSendRequestForFrameCallback willSendRequestForFrame; - - WKBundlePageDidReceiveResponseForResourceCallback didReceiveResponseForResource; - WKBundlePageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; - WKBundlePageDidFinishLoadForResourceCallback didFinishLoadForResource; - WKBundlePageDidFailLoadForResourceCallback didFailLoadForResource; - - // Version 1. - WKBundlePageShouldCacheResponseCallback shouldCacheResponse; - WKBundlePageShouldUseCredentialStorageCallback shouldUseCredentialStorage; -}; -typedef struct WKBundlePageResourceLoadClient WKBundlePageResourceLoadClient; - -enum { kWKBundlePageResourceLoadClientCurrentVersion = 1 }; - -enum { - WKBundlePageUIElementVisibilityUnknown, - WKBundlePageUIElementVisible, - WKBundlePageUIElementHidden -}; -typedef uint32_t WKBundlePageUIElementVisibility; - -enum { - WKBundlePageLabelSizeSmall, - WKBundlePageLabelSizeLarge, -}; -typedef uint32_t WKBundlePageLabelSize; - -// 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); -typedef void (*WKBundlePageWillRunJavaScriptAlertCallback)(WKBundlePageRef page, WKStringRef alertText, WKBundleFrameRef frame, const void *clientInfo); -typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo); -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); -typedef WKStringRef (*WKBundlePageGenerateFileForUploadCallback)(WKBundlePageRef page, WKStringRef originalFilePath, const void* clientInfo); -typedef bool (*WKBundlePageShouldRubberBandInDirectionCallback)(WKBundlePageRef page, WKScrollDirection scrollDirection, const void* clientInfo); -typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); -typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); -typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo); -typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo); -typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo); -typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(WKStringRef mimeType, const void *clientInfo); -typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(WKStringRef mimeType, const void *clientInfo); -typedef WKStringRef (*WKBundlePagePlugInCreateExtraStyleSheetCallback)(const void *clientInfo); -typedef WKStringRef (*WKBundlePagePlugInCreateExtraScriptCallback)(const void *clientInfo); - -struct WKBundlePageUIClient { - int version; - const void * clientInfo; - WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; - WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText; - WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert; - WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm; - WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; - WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; - WKBundlePageDidScrollCallback pageDidScroll; - WKBundlePagePaintCustomOverhangAreaCallback paintCustomOverhangArea; - WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; - WKBundlePageGenerateFileForUploadCallback generateFileForUpload; - WKBundlePageShouldRubberBandInDirectionCallback shouldRubberBandInDirection; - WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; - WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; - WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; - - // Version 1. - WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota; - - // Version 2. - WKBundlePageExceededDatabaseQuotaCallback didExceedDatabaseQuota; - WKBundlePagePlugInCreateStartLabelTitleCallback createPlugInStartLabelTitle; - WKBundlePagePlugInCreateStartLabelSubtitleCallback createPlugInStartLabelSubtitle; - WKBundlePagePlugInCreateExtraStyleSheetCallback createPlugInExtraStyleSheet; - WKBundlePagePlugInCreateExtraScriptCallback createPlugInExtraScript; -}; -typedef struct WKBundlePageUIClient WKBundlePageUIClient; - -enum { kWKBundlePageUIClientCurrentVersion = 2 }; - -// Editor client -typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); -typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); -typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); -typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); -typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); -typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo); -typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo); -typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo); -typedef void (*WKBundlePageWillWriteToPasteboard)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); -typedef void (*WKBundlePageGetPasteboardDataForRange)(WKBundlePageRef page, WKBundleRangeHandleRef range, WKArrayRef* pasteboardTypes, WKArrayRef* pasteboardData, const void* clientInfo); -typedef void (*WKBundlePageDidWriteToPasteboard)(WKBundlePageRef page, const void* clientInfo); - -struct WKBundlePageEditorClient { - int version; - const void * clientInfo; - WKBundlePageShouldBeginEditingCallback shouldBeginEditing; - WKBundlePageShouldEndEditingCallback shouldEndEditing; - WKBundlePageShouldInsertNodeCallback shouldInsertNode; - WKBundlePageShouldInsertTextCallback shouldInsertText; - WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; - WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; - WKBundlePageShouldApplyStyle shouldApplyStyle; - WKBundlePageEditingNotification didBeginEditing; - WKBundlePageEditingNotification didEndEditing; - WKBundlePageEditingNotification didChange; - WKBundlePageEditingNotification didChangeSelection; - // Version 1. - WKBundlePageWillWriteToPasteboard willWriteToPasteboard; - WKBundlePageGetPasteboardDataForRange getPasteboardDataForRange; - WKBundlePageDidWriteToPasteboard didWriteToPasteboard; -}; -typedef struct WKBundlePageEditorClient WKBundlePageEditorClient; - -enum { kWKBundlePageEditorClientCurrentVersion = 1 }; - -// Form client -typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); -typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); -typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); -typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo); -typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo); -typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo); -typedef void (*WKBundlePageWillSendSubmitEventCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, const void* clientInfo); -typedef void (*WKBundlePageDidFocusTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); -typedef bool (*WKBundlePageShouldNotifyOnFormChangesCallback)(WKBundlePageRef page, const void* clientInfo); -typedef void (*WKBundlePageDidAssociateFormControlsCallback)(WKBundlePageRef page, WKArrayRef elementHandles, const void* clientInfo); - -struct WKBundlePageFormClient { - int version; - const void * clientInfo; - - // Version 0. - WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing; - WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing; - WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField; - WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea; - WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField; - WKBundlePageWillSubmitFormCallback willSubmitForm; - - // Version 1. - WKBundlePageWillSendSubmitEventCallback willSendSubmitEvent; - - // version 2. - WKBundlePageDidFocusTextFieldCallback didFocusTextField; - WKBundlePageShouldNotifyOnFormChangesCallback shouldNotifyOnFormChanges; - WKBundlePageDidAssociateFormControlsCallback didAssociateFormControls; -}; -typedef struct WKBundlePageFormClient WKBundlePageFormClient; - -enum { kWKBundlePageFormClientCurrentVersion = 2 }; - -// ContextMenu client -typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo); - -struct WKBundlePageContextMenuClient { - int version; - const void * clientInfo; - WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu; -}; -typedef struct WKBundlePageContextMenuClient WKBundlePageContextMenuClient; - -enum { kWKBundlePageContextMenuClientCurrentVersion = 0 }; - -// Full Screen client -typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType); -typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); -typedef void (*WKBundlePageExitFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); -typedef void (*WKBundlePageBeganEnterFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame); -typedef void (*WKBundlePageBeganExitFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame); -typedef void (*WKBundlePageCloseFullScreen)(WKBundlePageRef page); - -struct WKBundlePageFullScreenClient { - int version; - const void * clientInfo; - - // Version 0: - WKBundlePageSupportsFullScreen supportsFullScreen; - WKBundlePageEnterFullScreenForElement enterFullScreenForElement; - WKBundlePageExitFullScreenForElement exitFullScreenForElement; - - // Version 1: - WKBundlePageBeganEnterFullScreen beganEnterFullScreen; - WKBundlePageBeganExitFullScreen beganExitFullScreen; - WKBundlePageCloseFullScreen closeFullScreen; -}; -typedef struct WKBundlePageFullScreenClient WKBundlePageFullScreenClient; - -enum { kWKBundlePageFullScreenClientCurrentVersion = 1 }; - -// MessageTrace client -typedef void (*WKBundlePageDiagnosticLoggingCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef success, const void* clientInfo); - -struct WKBundlePageDiagnosticLoggingClient { - int version; - const void * clientInfo; - WKBundlePageDiagnosticLoggingCallback logDiagnosticMessage; -}; -typedef struct WKBundlePageDiagnosticLoggingClient WKBundlePageDiagnosticLoggingClient; - -enum { kWKBundlePageDiagnosticLoggingClientCurrentVersion = 0 }; - WK_EXPORT void WKBundlePageWillEnterFullScreen(WKBundlePageRef page); WK_EXPORT void WKBundlePageDidEnterFullScreen(WKBundlePageRef page); WK_EXPORT void WKBundlePageWillExitFullScreen(WKBundlePageRef page); @@ -422,23 +57,21 @@ WK_EXPORT void WKBundlePageDidExitFullScreen(WKBundlePageRef page); 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 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 void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePageFullScreenClient* client); -WK_EXPORT void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef page, WKBundlePageDiagnosticLoggingClient* client); +WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClientBase* client); +WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClientBase* client); +WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClientBase* client); +WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClientBase* client); +WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClientBase* client); +WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClientBase* client); +WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClientBase* client); +WK_EXPORT void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePageFullScreenClientBase* client); +WK_EXPORT void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef page, WKBundlePageDiagnosticLoggingClientBase* client); WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page); WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page); WK_EXPORT WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef page); -WK_EXPORT void WKBundlePageSetUnderlayPage(WKBundlePageRef page, WKBundlePageRef pageUnderlay); - WK_EXPORT void WKBundlePageInstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay); WK_EXPORT void WKBundlePageUninstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay); @@ -448,8 +81,10 @@ WK_EXPORT void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef pag WK_EXPORT void WKBundlePageSetTopOverhangImage(WKBundlePageRef page, WKImageRef image); WK_EXPORT void WKBundlePageSetBottomOverhangImage(WKBundlePageRef page, WKImageRef image); +#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE WK_EXPORT void WKBundlePageSetHeaderBanner(WKBundlePageRef page, WKBundlePageBannerRef banner); WK_EXPORT void WKBundlePageSetFooterBanner(WKBundlePageRef page, WKBundlePageBannerRef banner); +#endif // !TARGET_OS_IPHONE WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url); WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request); @@ -472,6 +107,20 @@ WK_EXPORT void WKBundlePageListenForLayoutMilestones(WKBundlePageRef page, WKLay WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page); +WK_EXPORT bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef page); + +WK_EXPORT void WKBundlePageStartMonitoringScrollOperations(WKBundlePageRef page); + +WK_EXPORT WKStringRef WKBundlePageCopyGroupIdentifier(WKBundlePageRef page); + +typedef void (*WKBundlePageTestNotificationCallback)(void* context); +WK_EXPORT void WKBundlePageRegisterScrollOperationCompletionCallback(WKBundlePageRef, WKBundlePageTestNotificationCallback, void* context); + +WK_EXPORT void WKBundlePagePostMessage(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody); + +// Switches a connection into a fully synchronous mode, so all messages become synchronous until we get a response. +WK_EXPORT void WKBundlePagePostSynchronousMessageForTesting(WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h index 18c0d48f9..13525724c 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageBanner.h @@ -26,9 +26,9 @@ #ifndef WKBundlePageBanner_h #define WKBundlePageBanner_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKEvent.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKEvent.h> +#include <WebKit/WKGeometry.h> #ifndef __cplusplus #include <stdbool.h> @@ -44,18 +44,21 @@ typedef bool (*WKBundlePageBannerMouseUpCallback)(WKBundlePageBannerRef pageBann typedef bool (*WKBundlePageBannerMouseMovedCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, const void* clientInfo); typedef bool (*WKBundlePageBannerMouseDraggedCallback)(WKBundlePageBannerRef pageBanner, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); -struct WKBundlePageBannerClient { +typedef struct WKBundlePageBannerClientBase { int version; const void * clientInfo; +} WKBundlePageBannerClientBase; + +typedef struct WKBundlePageBannerClientV0 { + WKBundlePageBannerClientBase base; + + // Version 0. WKBundlePageBannerMouseDownCallback mouseDown; WKBundlePageBannerMouseUpCallback mouseUp; WKBundlePageBannerMouseMovedCallback mouseMoved; WKBundlePageBannerMouseDraggedCallback mouseDragged; -}; -typedef struct WKBundlePageBannerClient WKBundlePageBannerClient; +} WKBundlePageBannerClientV0; -enum { kWKBundlePageBannerClientCurrentVersion = 0 }; - WK_EXPORT WKTypeID WKBundlePageBannerGetTypeID(); #ifdef __cplusplus diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h new file mode 100644 index 000000000..00b1f048a --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageContextMenuClient.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 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 WKBundlePageContextMenuClient_h +#define WKBundlePageContextMenuClient_h + +#include <WebKit/WKBase.h> + +typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePagePrepareForActionMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKTypeRef* userData, const void* clientInfo); + +typedef struct WKBundlePageContextMenuClientBase { + int version; + const void * clientInfo; +} WKBundlePageContextMenuClientBase; + +typedef struct WKBundlePageContextMenuClientV0 { + WKBundlePageContextMenuClientBase base; + + WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu; +} WKBundlePageContextMenuClientV0; + +typedef struct WKBundlePageContextMenuClientV1 { + WKBundlePageContextMenuClientBase base; + + WKBundlePageGetContextMenuFromDefaultContextMenuCallback getContextMenuFromDefaultMenu; + + // This is actually about immediate actions; we should consider deprecating and renaming. + WKBundlePagePrepareForActionMenuCallback prepareForActionMenu; +} WKBundlePageContextMenuClientV1; + +#endif // WKBundlePageContextMenuClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h new file mode 100644 index 000000000..3925f1035 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageDiagnosticLoggingClient.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 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 WKBundlePageDiagnosticLoggingClient_h +#define WKBundlePageDiagnosticLoggingClient_h + +#include <WebKit/WKBase.h> +#include <WebKit/WKDiagnosticLoggingResultType.h> + +typedef void (*WKBundlePageDiagnosticLoggingCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef success, const void* clientInfo); +typedef void (*WKBundlePageLogDiagnosticMessageCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, const void* clientInfo); +typedef void (*WKBundlePageLogDiagnosticMessageWithResultCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKDiagnosticLoggingResultType result, const void* clientInfo); +typedef void (*WKBundlePageLogDiagnosticMessageWithValueCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef value, const void* clientInfo); + +typedef struct WKBundlePageDiagnosticLoggingClientBase { + int version; + const void * clientInfo; +} WKBundlePageDiagnosticLoggingClientBase; + +typedef struct WKBundlePageDiagnosticLoggingClientV0 { + WKBundlePageDiagnosticLoggingClientBase base; + + // Version 0. + WKBundlePageDiagnosticLoggingCallback logDiagnosticMessage; +} WKBundlePageDiagnosticLoggingClientV0; + +typedef struct WKBundlePageDiagnosticLoggingClientV1 { + WKBundlePageDiagnosticLoggingClientBase base; + + // Version 0. + WKBundlePageDiagnosticLoggingCallback logDiagnosticMessageDeprecated; + + // Version 1. + WKBundlePageLogDiagnosticMessageCallback logDiagnosticMessage; + WKBundlePageLogDiagnosticMessageWithResultCallback logDiagnosticMessageWithResult; + WKBundlePageLogDiagnosticMessageWithValueCallback logDiagnosticMessageWithValue; +} WKBundlePageDiagnosticLoggingClientV1; + +#endif // WKBundlePageDiagnosticLoggingClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h new file mode 100644 index 000000000..998e3e8da --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageEditorClient.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2013 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 WKBundlePageEditorClient_h +#define WKBundlePageEditorClient_h + +#include <WebKit/WKBase.h> + +enum { + kWKInsertActionTyped = 0, + kWKInsertActionPasted = 1, + kWKInsertActionDropped = 2 +}; +typedef uint32_t WKInsertActionType; + +enum { + kWKAffinityUpstream, + kWKAffinityDownstream +}; +typedef uint32_t WKAffinityType; + +enum { + WKInputFieldActionTypeMoveUp, + WKInputFieldActionTypeMoveDown, + WKInputFieldActionTypeCancel, + WKInputFieldActionTypeInsertTab, + WKInputFieldActionTypeInsertBacktab, + WKInputFieldActionTypeInsertNewline, + WKInputFieldActionTypeInsertDelete +}; +typedef uint32_t WKInputFieldActionType; + +enum { + WKFullScreenNoKeyboard, + WKFullScreenKeyboard, +}; +typedef uint32_t WKFullScreenKeyboardRequestType; + +typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); +typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); +typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); +typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); +typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); +typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo); +typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo); +typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo); +typedef void (*WKBundlePageWillWriteToPasteboard)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); +typedef void (*WKBundlePageGetPasteboardDataForRange)(WKBundlePageRef page, WKBundleRangeHandleRef range, WKArrayRef* pasteboardTypes, WKArrayRef* pasteboardData, const void* clientInfo); +typedef void (*WKBundlePageDidWriteToPasteboard)(WKBundlePageRef page, const void* clientInfo); + +typedef struct WKBundlePageEditorClientBase { + int version; + const void * clientInfo; +} WKBundlePageEditorClientBase; + +typedef struct WKBundlePageEditorClientV0 { + WKBundlePageEditorClientBase base; + + // Version 0. + WKBundlePageShouldBeginEditingCallback shouldBeginEditing; + WKBundlePageShouldEndEditingCallback shouldEndEditing; + WKBundlePageShouldInsertNodeCallback shouldInsertNode; + WKBundlePageShouldInsertTextCallback shouldInsertText; + WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; + WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; + WKBundlePageShouldApplyStyle shouldApplyStyle; + WKBundlePageEditingNotification didBeginEditing; + WKBundlePageEditingNotification didEndEditing; + WKBundlePageEditingNotification didChange; + WKBundlePageEditingNotification didChangeSelection; +} WKBundlePageEditorClientV0; + +typedef struct WKBundlePageEditorClientV1 { + WKBundlePageEditorClientBase base; + + // Version 0. + WKBundlePageShouldBeginEditingCallback shouldBeginEditing; + WKBundlePageShouldEndEditingCallback shouldEndEditing; + WKBundlePageShouldInsertNodeCallback shouldInsertNode; + WKBundlePageShouldInsertTextCallback shouldInsertText; + WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; + WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; + WKBundlePageShouldApplyStyle shouldApplyStyle; + WKBundlePageEditingNotification didBeginEditing; + WKBundlePageEditingNotification didEndEditing; + WKBundlePageEditingNotification didChange; + WKBundlePageEditingNotification didChangeSelection; + + // Version 1. + WKBundlePageWillWriteToPasteboard willWriteToPasteboard; + WKBundlePageGetPasteboardDataForRange getPasteboardDataForRange; + WKBundlePageDidWriteToPasteboard didWriteToPasteboard; +} WKBundlePageEditorClientV1; + +#endif // WKBundlePageEditorClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h new file mode 100644 index 000000000..3fc33b98d --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFormClient.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2013 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 WKBundlePageFormClient_h +#define WKBundlePageFormClient_h + +#include <WebKit/WKBase.h> +#include <WebKit/WKBundlePageEditorClient.h> + +typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); +typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); +typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); +typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo); +typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo); +typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePageWillSendSubmitEventCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, const void* clientInfo); +typedef void (*WKBundlePageDidFocusTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo); +typedef bool (*WKBundlePageShouldNotifyOnFormChangesCallback)(WKBundlePageRef page, const void* clientInfo); +typedef void (*WKBundlePageDidAssociateFormControlsCallback)(WKBundlePageRef page, WKArrayRef elementHandles, const void* clientInfo); + +typedef struct WKBundlePageFormClientBase { + int version; + const void * clientInfo; +} WKBundlePageFormClientBase; + +typedef struct WKBundlePageFormClientV0 { + WKBundlePageFormClientBase base; + + // Version 0. + WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing; + WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing; + WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField; + WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea; + WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField; + WKBundlePageWillSubmitFormCallback willSubmitForm; +} WKBundlePageFormClientV0; + +typedef struct WKBundlePageFormClientV1 { + WKBundlePageFormClientBase base; + + // Version 0. + WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing; + WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing; + WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField; + WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea; + WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField; + WKBundlePageWillSubmitFormCallback willSubmitForm; + + // Version 1. + WKBundlePageWillSendSubmitEventCallback willSendSubmitEvent; +} WKBundlePageFormClientV1; + +typedef struct WKBundlePageFormClientV2 { + WKBundlePageFormClientBase base; + + // Version 0. + WKBundlePageTextFieldDidBeginEditingCallback textFieldDidBeginEditing; + WKBundlePageTextFieldDidEndEditingCallback textFieldDidEndEditing; + WKBundlePageTextDidChangeInTextFieldCallback textDidChangeInTextField; + WKBundlePageTextDidChangeInTextAreaCallback textDidChangeInTextArea; + WKBundlePageShouldPerformActionInTextFieldCallback shouldPerformActionInTextField; + WKBundlePageWillSubmitFormCallback willSubmitForm; + + // Version 1. + WKBundlePageWillSendSubmitEventCallback willSendSubmitEvent; + + // version 2. + WKBundlePageDidFocusTextFieldCallback didFocusTextField; + WKBundlePageShouldNotifyOnFormChangesCallback shouldNotifyOnFormChanges; + WKBundlePageDidAssociateFormControlsCallback didAssociateFormControls; +} WKBundlePageFormClientV2; + +#endif // WKBundlePageFormClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h new file mode 100644 index 000000000..687fb122b --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageFullScreenClient.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2013 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 WKBundlePageFullScreenClient_h +#define WKBundlePageFullScreenClient_h + +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> + +typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType); +typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); +typedef void (*WKBundlePageExitFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element); +typedef void (*WKBundlePageBeganEnterFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame); +typedef void (*WKBundlePageBeganExitFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame); +typedef void (*WKBundlePageCloseFullScreen)(WKBundlePageRef page); + +typedef struct WKBundlePageFullScreenClientBase { + int version; + const void * clientInfo; +} WKBundlePageFullScreenClientBase; + +typedef struct WKBundlePageFullScreenClientV0 { + WKBundlePageFullScreenClientBase base; + + // Version 0. + WKBundlePageSupportsFullScreen supportsFullScreen; + WKBundlePageEnterFullScreenForElement enterFullScreenForElement; + WKBundlePageExitFullScreenForElement exitFullScreenForElement; +} WKBundlePageFullScreenClientV0; + +typedef struct WKBundlePageFullScreenClientV1 { + WKBundlePageFullScreenClientBase base; + + // Version 0. + WKBundlePageSupportsFullScreen supportsFullScreen; + WKBundlePageEnterFullScreenForElement enterFullScreenForElement; + WKBundlePageExitFullScreenForElement exitFullScreenForElement; + + // Version 1. + WKBundlePageBeganEnterFullScreen beganEnterFullScreen; + WKBundlePageBeganExitFullScreen beganExitFullScreen; + WKBundlePageCloseFullScreen closeFullScreen; +} WKBundlePageFullScreenClientV1; + +#endif // WKBundlePageFullScreenClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h index e0bf64525..2438943b8 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageGroup.h @@ -26,7 +26,7 @@ #ifndef WKBundlePageGroup_h #define WKBundlePageGroup_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h new file mode 100644 index 000000000..ee142dedf --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h @@ -0,0 +1,467 @@ +/* + * Copyright (C) 2013 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 WKBundlePageLoaderClient_h +#define WKBundlePageLoaderClient_h + +#include <WebKit/WKBase.h> +#include <WebKit/WKPageLoadTypes.h> + +typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidCommitLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidDocumentFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFinishDocumentLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFinishProgressCallback)(WKBundlePageRef page, const void *clientInfo); +typedef void (*WKBundlePageDidFailLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidSameDocumentNavigationForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidReceiveTitleForFrameCallback)(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidRemoveFrameFromHierarchyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidDisplayInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidRunInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidDetectXSSForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFirstLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageDidLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo); +typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo); +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 (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo); +typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); +typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); +typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo); +typedef bool (*WKBundlePageShouldForceUniversalAccessFromLocalURLCallback)(WKBundlePageRef, WKStringRef url, const void* clientInfo); +typedef void (*WKBundlePageDidLayoutCallback)(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo); +typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo); +typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo); +typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo); +typedef WKStringRef (*WKBundlePageUserAgentForURLCallback)(WKBundleFrameRef frame, WKURLRef url, const void *clientInfo); + +typedef struct WKBundlePageLoaderClientBase { + int version; + const void * clientInfo; +} WKBundlePageLoaderClientBase; + +typedef struct WKBundlePageLoaderClientV0 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; +} WKBundlePageLoaderClientV0; + +typedef struct WKBundlePageLoaderClientV1 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; +} WKBundlePageLoaderClientV1; + +typedef struct WKBundlePageLoaderClientV2 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; +} WKBundlePageLoaderClientV2; + +typedef struct WKBundlePageLoaderClientV3 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; +} WKBundlePageLoaderClientV3; + +typedef struct WKBundlePageLoaderClientV4 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; + + // Version 4 + WKBundlePageDidLayoutCallback didLayout; +} WKBundlePageLoaderClientV4; + +typedef struct WKBundlePageLoaderClientV5 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; + + // Version 4 + WKBundlePageDidLayoutCallback didLayout; + + // Version 5 + WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; +} WKBundlePageLoaderClientV5; + +typedef struct WKBundlePageLoaderClientV6 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; + + // Version 4 + WKBundlePageDidLayoutCallback didLayout; + + // Version 5 + WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; + + // Version 6 + WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; + WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; +} WKBundlePageLoaderClientV6; + +typedef struct WKBundlePageLoaderClientV7 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; + + // Version 4 + WKBundlePageDidLayoutCallback didLayout; + + // Version 5 + WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; + + // Version 6 + WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; + WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; + + // Version 7 + void * willDestroyFrame_unavailable; +} WKBundlePageLoaderClientV7; + +typedef struct WKBundlePageLoaderClientV8 { + WKBundlePageLoaderClientBase base; + + // Version 0. + WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; + WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; + WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; + WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; + + // Version 1. + WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; + void * didNewFirstVisuallyNonEmptyLayout_unavailable; + WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; + WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; + WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; + WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; + WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; + WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; + + // Version 2 + WKBundlePageDidFinishProgressCallback didFinishProgress; + WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; + + // Version 3 + void * didReceiveIntentForFrame_unavailable; + void * registerIntentServiceForFrame_unavailable; + + // Version 4 + WKBundlePageDidLayoutCallback didLayout; + + // Version 5 + WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; + + // Version 6 + WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; + WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; + + // Version 7 + void * willDestroyFrame_unavailable; + + // Version 8 + WKBundlePageUserAgentForURLCallback userAgentForURL; +} WKBundlePageLoaderClientV8; + +#endif // WKBundlePageLoaderClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp index 4364ce97c..fc6b635e9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp @@ -26,111 +26,211 @@ #include "config.h" #include "WKBundlePageOverlay.h" -#include "PageOverlay.h" +#include "APIClient.h" +#include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" +#include "WKArray.h" #include "WKBundleAPICast.h" +#include "WKNumber.h" +#include "WKRetainPtr.h" +#include "WKSharedAPICast.h" +#include "WKStringPrivate.h" +#include "WebPage.h" #include <WebCore/GraphicsContext.h> -#include <wtf/PassOwnPtr.h> +#include <WebCore/PageOverlay.h> +#include <WebCore/PlatformMouseEvent.h> +#include <WebKit/WebPageOverlay.h> + +namespace API { + +template<> struct ClientTraits<WKBundlePageOverlayClientBase> { + typedef std::tuple<WKBundlePageOverlayClientV0, WKBundlePageOverlayClientV1> Versions; +}; + +template<> struct ClientTraits<WKBundlePageOverlayAccessibilityClientBase> { + typedef std::tuple<WKBundlePageOverlayAccessibilityClientV0> Versions; +}; + +} using namespace WebCore; using namespace WebKit; -class PageOverlayClientImpl : public PageOverlay::Client { +class PageOverlayClientImpl : API::Client<WKBundlePageOverlayClientBase>, public WebPageOverlay::Client { public: - static PassOwnPtr<PageOverlayClientImpl> create(WKBundlePageOverlayClient* client) + explicit PageOverlayClientImpl(WKBundlePageOverlayClientBase* client) { - return adoptPtr(new PageOverlayClientImpl(client)); + initialize(client); } -private: - explicit PageOverlayClientImpl(WKBundlePageOverlayClient* client) - : m_client() + virtual void setAccessibilityClient(WKBundlePageOverlayAccessibilityClientBase* client) { - if (client) - m_client = *client; + m_accessibilityClient.initialize(client); } - // PageOverlay::Client. - virtual void pageOverlayDestroyed(PageOverlay*) +private: + // WebPageOverlay::Client. + virtual void pageOverlayDestroyed(WebPageOverlay&) override { delete this; } - virtual void willMoveToWebPage(PageOverlay* pageOverlay, WebPage* page) + virtual void willMoveToPage(WebPageOverlay& pageOverlay, WebPage* page) override { if (!m_client.willMoveToPage) return; - m_client.willMoveToPage(toAPI(pageOverlay), toAPI(page), m_client.clientInfo); + m_client.willMoveToPage(toAPI(&pageOverlay), toAPI(page), m_client.base.clientInfo); } - virtual void didMoveToWebPage(PageOverlay* pageOverlay, WebPage* page) + virtual void didMoveToPage(WebPageOverlay& pageOverlay, WebPage* page) override { if (!m_client.didMoveToPage) return; - m_client.didMoveToPage(toAPI(pageOverlay), toAPI(page), m_client.clientInfo); + m_client.didMoveToPage(toAPI(&pageOverlay), toAPI(page), m_client.base.clientInfo); } - virtual void drawRect(PageOverlay* pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect) + virtual void drawRect(WebPageOverlay& pageOverlay, GraphicsContext& graphicsContext, const IntRect& dirtyRect) override { if (!m_client.drawRect) return; - m_client.drawRect(toAPI(pageOverlay), graphicsContext.platformContext(), toAPI(dirtyRect), m_client.clientInfo); + m_client.drawRect(toAPI(&pageOverlay), graphicsContext.platformContext(), toAPI(dirtyRect), m_client.base.clientInfo); } - virtual bool mouseEvent(PageOverlay* pageOverlay, const WebMouseEvent& event) + virtual bool mouseEvent(WebPageOverlay& pageOverlay, const PlatformMouseEvent& event) override { switch (event.type()) { - case WebEvent::MouseDown: { + case PlatformMouseEvent::Type::MousePressed: { if (!m_client.mouseDown) return false; - return m_client.mouseDown(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.clientInfo); + return m_client.mouseDown(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } - case WebEvent::MouseUp: { + case PlatformMouseEvent::Type::MouseReleased: { if (!m_client.mouseUp) return false; - return m_client.mouseUp(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.clientInfo); + return m_client.mouseUp(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } - case WebEvent::MouseMove: { - if (event.button() == WebMouseEvent::NoButton) { + case PlatformMouseEvent::Type::MouseMoved: { + if (event.button() == MouseButton::NoButton) { if (!m_client.mouseMoved) return false; - return m_client.mouseMoved(toAPI(pageOverlay), toAPI(event.position()), m_client.clientInfo); + return m_client.mouseMoved(toAPI(&pageOverlay), toAPI(event.position()), m_client.base.clientInfo); } // This is a MouseMove event with a mouse button pressed. Call mouseDragged. if (!m_client.mouseDragged) return false; - return m_client.mouseDragged(toAPI(pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.clientInfo); + return m_client.mouseDragged(toAPI(&pageOverlay), toAPI(event.position()), toAPI(event.button()), m_client.base.clientInfo); } default: return false; } } + +#if PLATFORM(MAC) + virtual DDActionContext *actionContextForResultAtPoint(WebPageOverlay& pageOverlay, WebCore::FloatPoint location, RefPtr<WebCore::Range>& rangeHandle) override + { + if (m_client.actionContextForResultAtPoint) { + WKBundleRangeHandleRef apiRange = nullptr; + DDActionContext *actionContext = (DDActionContext *)m_client.actionContextForResultAtPoint(toAPI(&pageOverlay), WKPointMake(location.x(), location.y()), &apiRange, m_client.base.clientInfo); + + if (apiRange) + rangeHandle = toImpl(apiRange)->coreRange(); + + return actionContext; + } + + return nil; + } + + virtual void dataDetectorsDidPresentUI(WebPageOverlay& pageOverlay) override + { + if (!m_client.dataDetectorsDidPresentUI) + return; + + m_client.dataDetectorsDidPresentUI(toAPI(&pageOverlay), m_client.base.clientInfo); + } + + virtual void dataDetectorsDidChangeUI(WebPageOverlay& pageOverlay) override + { + if (!m_client.dataDetectorsDidChangeUI) + return; + + m_client.dataDetectorsDidChangeUI(toAPI(&pageOverlay), m_client.base.clientInfo); + } + + virtual void dataDetectorsDidHideUI(WebPageOverlay& pageOverlay) override + { + if (!m_client.dataDetectorsDidHideUI) + return; + + m_client.dataDetectorsDidHideUI(toAPI(&pageOverlay), m_client.base.clientInfo); + } +#endif // PLATFORM(MAC) + + virtual bool copyAccessibilityAttributeStringValueForPoint(WebPageOverlay& pageOverlay, String attribute, WebCore::FloatPoint parameter, String& value) override + { + if (!m_accessibilityClient.client().copyAccessibilityAttributeValue) + return false; + auto wkType = m_accessibilityClient.client().copyAccessibilityAttributeValue(toAPI(&pageOverlay), toCopiedAPI(attribute), WKPointCreate(WKPointMake(parameter.x(), parameter.y())), m_accessibilityClient.client().base.clientInfo); + if (toImpl(wkType)->type() != API::String::APIType) + return false; + value = toWTFString(static_cast<WKStringRef>(wkType)); + return true; + } + + virtual bool copyAccessibilityAttributeBoolValueForPoint(WebPageOverlay& pageOverlay, String attribute, WebCore::FloatPoint parameter, bool& value) override + { + if (!m_accessibilityClient.client().copyAccessibilityAttributeValue) + return false; + auto wkType = m_accessibilityClient.client().copyAccessibilityAttributeValue(toAPI(&pageOverlay), toCopiedAPI(attribute), WKPointCreate(WKPointMake(parameter.x(), parameter.y())), m_accessibilityClient.client().base.clientInfo); + if (toImpl(wkType)->type() != API::Boolean::APIType) + return false; + value = WKBooleanGetValue(static_cast<WKBooleanRef>(wkType)); + return true; + } + + virtual Vector<String> copyAccessibilityAttributeNames(WebPageOverlay& pageOverlay, bool paramerizedNames) override + { + Vector<String> names; + if (!m_accessibilityClient.client().copyAccessibilityAttributeNames) + return names; + auto wkNames = m_accessibilityClient.client().copyAccessibilityAttributeNames(toAPI(&pageOverlay), paramerizedNames, m_accessibilityClient.client().base.clientInfo); + + size_t count = WKArrayGetSize(wkNames); + for (size_t k = 0; k < count; k++) { + WKTypeRef item = WKArrayGetItemAtIndex(wkNames, k); + if (toImpl(item)->type() == API::String::APIType) + names.append(toWTFString(static_cast<WKStringRef>(item))); + } + + return names; + } - WKBundlePageOverlayClient m_client; + API::Client<WKBundlePageOverlayAccessibilityClientBase> m_accessibilityClient; }; WKTypeID WKBundlePageOverlayGetTypeID() { - return toAPI(PageOverlay::APIType); + return toAPI(WebPageOverlay::APIType); } -WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClient* wkClient) +WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* wkClient) { - if (wkClient && wkClient->version) - return 0; - - OwnPtr<PageOverlayClientImpl> clientImpl = PageOverlayClientImpl::create(wkClient); + auto clientImpl = std::make_unique<PageOverlayClientImpl>(wkClient); + return toAPI(&WebPageOverlay::create(WTFMove(clientImpl)).leakRef()); +} - return toAPI(PageOverlay::create(clientImpl.leakPtr()).leakRef()); +void WKBundlePageOverlaySetAccessibilityClient(WKBundlePageOverlayRef bundlePageOverlayRef, WKBundlePageOverlayAccessibilityClientBase* client) +{ + static_cast<PageOverlayClientImpl&>(toImpl(bundlePageOverlayRef)->client()).setAccessibilityClient(client); } void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlayRef, WKRect rect) @@ -138,7 +238,16 @@ void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay toImpl(bundlePageOverlayRef)->setNeedsDisplay(enclosingIntRect(toFloatRect(rect))); } -float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlayRef) +float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef) +{ + // Clients who include the fade opacity during painting interfere + // with composited fade, so we'll pretend we're opaque and do the + // fade on our own. + + return 1; +} + +void WKBundlePageOverlayClear(WKBundlePageOverlayRef bundlePageOverlayRef) { - return toImpl(bundlePageOverlayRef)->fractionFadedIn(); + toImpl(bundlePageOverlayRef)->clear(); } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h index eeb20c902..ae76a5f77 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.h @@ -26,9 +26,9 @@ #ifndef WKBundlePageOverlay_h #define WKBundlePageOverlay_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKEvent.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKEvent.h> +#include <WebKit/WKGeometry.h> #ifndef __cplusplus #include <stdbool.h> @@ -49,9 +49,19 @@ typedef bool (*WKBundlePageOverlayMouseUpCallback)(WKBundlePageOverlayRef pageOv typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo); typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo); -struct WKBundlePageOverlayClient { +typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo); +typedef void (*WKBundlePageOverlayDataDetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); +typedef void (*WKBundlePageOverlayDataDetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); +typedef void (*WKBundlePageOverlayDataDetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo); + +typedef struct WKBundlePageOverlayClientBase { int version; const void * clientInfo; +} WKBundlePageOverlayClientBase; + +typedef struct WKBundlePageOverlayClientV0 { + WKBundlePageOverlayClientBase base; + WKBundlePageOverlayWillMoveToPageCallback willMoveToPage; WKBundlePageOverlayDidMoveToPageCallback didMoveToPage; WKBundlePageOverlayDrawRectCallback drawRect; @@ -59,16 +69,48 @@ struct WKBundlePageOverlayClient { WKBundlePageOverlayMouseUpCallback mouseUp; WKBundlePageOverlayMouseMovedCallback mouseMoved; WKBundlePageOverlayMouseDraggedCallback mouseDragged; -}; -typedef struct WKBundlePageOverlayClient WKBundlePageOverlayClient; +} WKBundlePageOverlayClientV0; + +typedef struct WKBundlePageOverlayClientV1 { + WKBundlePageOverlayClientBase base; + + WKBundlePageOverlayWillMoveToPageCallback willMoveToPage; + WKBundlePageOverlayDidMoveToPageCallback didMoveToPage; + WKBundlePageOverlayDrawRectCallback drawRect; + WKBundlePageOverlayMouseDownCallback mouseDown; + WKBundlePageOverlayMouseUpCallback mouseUp; + WKBundlePageOverlayMouseMovedCallback mouseMoved; + WKBundlePageOverlayMouseDraggedCallback mouseDragged; + + WKBundlePageOverlayActionContextForResultAtPointCallback actionContextForResultAtPoint; + WKBundlePageOverlayDataDetectorsDidPresentUI dataDetectorsDidPresentUI; + WKBundlePageOverlayDataDetectorsDidChangeUI dataDetectorsDidChangeUI; + WKBundlePageOverlayDataDetectorsDidHideUI dataDetectorsDidHideUI; +} WKBundlePageOverlayClientV1; + +typedef WKTypeRef (*WKAccessibilityAttributeValueCallback)(WKBundlePageOverlayRef pageOverlay, WKStringRef attribute, WKTypeRef parameter, const void* clientInfo); +typedef WKArrayRef (*WKAccessibilityAttributeNamesCallback)(WKBundlePageOverlayRef pageOverlay, bool parameterizedNames, const void* clientInfo); + +typedef struct WKBundlePageOverlayAccessibilityClientBase { + int version; + const void * clientInfo; +} WKBundlePageOverlayAccessibilityClientBase; + +typedef struct WKBundlePageOverlayAccessibilityClientV0 { + WKBundlePageOverlayAccessibilityClientBase base; + + // Version 0. + WKAccessibilityAttributeValueCallback copyAccessibilityAttributeValue; + WKAccessibilityAttributeNamesCallback copyAccessibilityAttributeNames; +} WKBundlePageOverlayAccessibilityClientV0; -enum { kWKBundlePageOverlayClientCurrentVersion = 0 }; - WK_EXPORT WKTypeID WKBundlePageOverlayGetTypeID(); -WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClient* client); +WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* client); WK_EXPORT void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay, WKRect rect); WK_EXPORT float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlay); +WK_EXPORT void WKBundlePageOverlaySetAccessibilityClient(WKBundlePageOverlayRef bundlePageOverlay, WKBundlePageOverlayAccessibilityClientBase* client); +WK_EXPORT void WKBundlePageOverlayClear(WKBundlePageOverlayRef bundlePageOverlay); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h new file mode 100644 index 000000000..cb2ef16b3 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePolicyClient.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 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 WKBundlePagePolicyClient_h +#define WKBundlePagePolicyClient_h + +#include <WebKit/WKBase.h> + +enum { + WKBundlePagePolicyActionPassThrough, + WKBundlePagePolicyActionUse +}; +typedef uint32_t WKBundlePagePolicyAction; + +typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); +typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo); +typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForResponseCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); +typedef void (*WKBundlePageUnableToImplementPolicyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void* clientInfo); + +typedef struct WKBundlePagePolicyClientBase { + int version; + const void * clientInfo; +} WKBundlePagePolicyClientBase; + +typedef struct WKBundlePagePolicyClientV0 { + WKBundlePagePolicyClientBase base; + + // Version 0. + WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; + WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; + WKBundlePageDecidePolicyForResponseCallback decidePolicyForResponse; + WKBundlePageUnableToImplementPolicyCallback unableToImplementPolicy; +} WKBundlePagePolicyClientV0; + +#endif // WKBundlePagePolicyClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h index b52dc13cf..6e00abb54 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h @@ -26,7 +26,11 @@ #ifndef WKBundlePagePrivate_h #define WKBundlePagePrivate_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKEvent.h> +#include <WebKit/WKGeometry.h> +#include <WebKit/WKUserContentInjectedFrames.h> +#include <WebKit/WKUserScriptInjectionTime.h> #ifdef __cplusplus extern "C" { @@ -78,7 +82,12 @@ WK_EXPORT bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeType WK_EXPORT void* WKAccessibilityRootObject(WKBundlePageRef); WK_EXPORT void* WKAccessibilityFocusedObject(WKBundlePageRef); -WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef); +WK_EXPORT void WKAccessibilityEnableEnhancedAccessibility(bool); +WK_EXPORT bool WKAccessibilityEnhancedAccessibilityEnabled(); + +WK_EXPORT WKStringRef WKBundlePageCopyContextMenuItemTitle(WKContextMenuItemRef); +WK_EXPORT void WKBundlePageClickMenuItem(WKBundlePageRef, WKContextMenuItemRef); +WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef); WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef, WKPoint); // This only works if the SuppressesIncrementalRendering preference is set as well. @@ -86,6 +95,24 @@ typedef unsigned WKRenderingSuppressionToken; WK_EXPORT WKRenderingSuppressionToken WKBundlePageExtendIncrementalRenderingSuppression(WKBundlePageRef); WK_EXPORT void WKBundlePageStopExtendingIncrementalRenderingSuppression(WKBundlePageRef, WKRenderingSuppressionToken); +// UserContent API (compatible with Modern API, for WKTR) +WK_EXPORT void WKBundlePageAddUserScript(WKBundlePageRef page, WKStringRef source, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); +WK_EXPORT void WKBundlePageAddUserStyleSheet(WKBundlePageRef page, WKStringRef source, WKUserContentInjectedFrames injectedFrames); +WK_EXPORT void WKBundlePageRemoveAllUserContent(WKBundlePageRef page); + +// Application Cache API, for WKTR. +WK_EXPORT void WKBundlePageClearApplicationCache(WKBundlePageRef page); +WK_EXPORT void WKBundlePageClearApplicationCacheForOrigin(WKBundlePageRef page, WKStringRef origin); +WK_EXPORT void WKBundlePageSetAppCacheMaximumSize(WKBundlePageRef page, uint64_t size); +WK_EXPORT uint64_t WKBundlePageGetAppCacheUsageForOrigin(WKBundlePageRef page, WKStringRef origin); +WK_EXPORT void WKBundlePageSetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin, uint64_t bytes); +WK_EXPORT void WKBundlePageResetApplicationCacheOriginQuota(WKBundlePageRef page, WKStringRef origin); +WK_EXPORT WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page); + +#if TARGET_OS_IPHONE +WK_EXPORT void WKBundlePageSetUseTestingViewportConfiguration(WKBundlePageRef, bool); +#endif + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h new file mode 100644 index 000000000..fee6cc2e7 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageResourceLoadClient.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 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 WKBundlePageResourceLoadClient_h +#define WKBundlePageResourceLoadClient_h + +#include <WebKit/WKBase.h> + +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); +typedef bool (*WKBundlePageShouldCacheResponseCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo); +typedef bool (*WKBundlePageShouldUseCredentialStorageCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo); + +typedef struct WKBundlePageResourceLoadClientBase { + int version; + const void * clientInfo; +} WKBundlePageResourceLoadClientBase; + +typedef struct WKBundlePageResourceLoadClientV0 { + WKBundlePageResourceLoadClientBase base; + + // Version 0. + WKBundlePageDidInitiateLoadForResourceCallback didInitiateLoadForResource; + + // willSendRequestForFrame is supposed to return a retained reference to the URL request. + WKBundlePageWillSendRequestForFrameCallback willSendRequestForFrame; + + WKBundlePageDidReceiveResponseForResourceCallback didReceiveResponseForResource; + WKBundlePageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; + WKBundlePageDidFinishLoadForResourceCallback didFinishLoadForResource; + WKBundlePageDidFailLoadForResourceCallback didFailLoadForResource; +} WKBundlePageResourceLoadClientV0; + +typedef struct WKBundlePageResourceLoadClientV1 { + WKBundlePageResourceLoadClientBase base; + + // Version 0. + WKBundlePageDidInitiateLoadForResourceCallback didInitiateLoadForResource; + + // willSendRequestForFrame is supposed to return a retained reference to the URL request. + WKBundlePageWillSendRequestForFrameCallback willSendRequestForFrame; + + WKBundlePageDidReceiveResponseForResourceCallback didReceiveResponseForResource; + WKBundlePageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; + WKBundlePageDidFinishLoadForResourceCallback didFinishLoadForResource; + WKBundlePageDidFailLoadForResourceCallback didFailLoadForResource; + + // Version 1. + WKBundlePageShouldCacheResponseCallback shouldCacheResponse; + WKBundlePageShouldUseCredentialStorageCallback shouldUseCredentialStorage; +} WKBundlePageResourceLoadClientV1; + +#endif // WKBundlePageResourceLoadClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h new file mode 100644 index 000000000..e07a6b2e6 --- /dev/null +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageUIClient.h @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2013 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 WKBundlePageUIClient_h +#define WKBundlePageUIClient_h + +#include <WebKit/WKBase.h> +#include <WebKit/WKEvent.h> + +enum { + WKBundlePageUIElementVisibilityUnknown, + WKBundlePageUIElementVisible, + WKBundlePageUIElementHidden +}; +typedef uint32_t WKBundlePageUIElementVisibility; + + +typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo); +typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo); +typedef void (*WKBundlePageWillRunJavaScriptAlertCallback)(WKBundlePageRef page, WKStringRef alertText, WKBundleFrameRef frame, const void *clientInfo); +typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo); +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 WKStringRef (*WKBundlePageGenerateFileForUploadCallback)(WKBundlePageRef page, WKStringRef originalFilePath, const void* clientInfo); +typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); +typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo); +typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo); +typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo); +typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo); +typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(WKStringRef mimeType, const void *clientInfo); +typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(WKStringRef mimeType, const void *clientInfo); +typedef WKStringRef (*WKBundlePagePlugInCreateExtraStyleSheetCallback)(const void *clientInfo); +typedef WKStringRef (*WKBundlePagePlugInCreateExtraScriptCallback)(const void *clientInfo); +typedef void (*WKBundlePageDidClickAutoFillButtonCallback)(WKBundlePageRef page, WKBundleNodeHandleRef inputElement, WKTypeRef* userData, const void *clientInfo); + +typedef struct WKBundlePageUIClientBase { + int version; + const void * clientInfo; +} WKBundlePageUIClientBase; + +typedef struct WKBundlePageUIClientV0 { + WKBundlePageUIClientBase base; + + // Version 0. + WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; + WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText; + WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert; + WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm; + WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; + WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; + WKBundlePageDidScrollCallback pageDidScroll; + void* unused1; + WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; + WKBundlePageGenerateFileForUploadCallback generateFileForUpload; + void* unused2; + WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; + WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; + WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; +} WKBundlePageUIClientV0; + +typedef struct WKBundlePageUIClientV1 { + WKBundlePageUIClientBase base; + + // Version 0. + WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; + WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText; + WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert; + WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm; + WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; + WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; + WKBundlePageDidScrollCallback pageDidScroll; + void* unused1; + WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; + WKBundlePageGenerateFileForUploadCallback generateFileForUpload; + void* unused2; + WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; + WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; + WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; + + // Version 1. + WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota; +} WKBundlePageUIClientV1; + +typedef struct WKBundlePageUIClientV2 { + WKBundlePageUIClientBase base; + + // Version 0. + WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; + WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText; + WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert; + WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm; + WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; + WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; + WKBundlePageDidScrollCallback pageDidScroll; + void* unused1; + WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; + WKBundlePageGenerateFileForUploadCallback generateFileForUpload; + void* unused2; + WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; + WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; + WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; + + // Version 1. + WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota; + + // Version 2. + WKBundlePageExceededDatabaseQuotaCallback didExceedDatabaseQuota; + WKBundlePagePlugInCreateStartLabelTitleCallback createPlugInStartLabelTitle; + WKBundlePagePlugInCreateStartLabelSubtitleCallback createPlugInStartLabelSubtitle; + WKBundlePagePlugInCreateExtraStyleSheetCallback createPlugInExtraStyleSheet; + WKBundlePagePlugInCreateExtraScriptCallback createPlugInExtraScript; +} WKBundlePageUIClientV2; + +typedef struct WKBundlePageUIClientV3 { + WKBundlePageUIClientBase base; + + // Version 0. + WKBundlePageWillAddMessageToConsoleCallback willAddMessageToConsole; + WKBundlePageWillSetStatusbarTextCallback willSetStatusbarText; + WKBundlePageWillRunJavaScriptAlertCallback willRunJavaScriptAlert; + WKBundlePageWillRunJavaScriptConfirmCallback willRunJavaScriptConfirm; + WKBundlePageWillRunJavaScriptPromptCallback willRunJavaScriptPrompt; + WKBundlePageMouseDidMoveOverElementCallback mouseDidMoveOverElement; + WKBundlePageDidScrollCallback pageDidScroll; + void* unused1; + WKBundlePageGenerateFileForUploadCallback shouldGenerateFileForUpload; + WKBundlePageGenerateFileForUploadCallback generateFileForUpload; + void* unused2; + WKBundlePageStatusBarIsVisibleCallback statusBarIsVisible; + WKBundlePageMenuBarIsVisibleCallback menuBarIsVisible; + WKBundlePageToolbarsAreVisibleCallback toolbarsAreVisible; + + // Version 1. + WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota; + + // Version 2. + WKBundlePageExceededDatabaseQuotaCallback didExceedDatabaseQuota; + WKBundlePagePlugInCreateStartLabelTitleCallback createPlugInStartLabelTitle; + WKBundlePagePlugInCreateStartLabelSubtitleCallback createPlugInStartLabelSubtitle; + WKBundlePagePlugInCreateExtraStyleSheetCallback createPlugInExtraStyleSheet; + WKBundlePagePlugInCreateExtraScriptCallback createPlugInExtraScript; + + // Version 3. + void* unused3; + void* unused4; + void* unused5; + + WKBundlePageDidClickAutoFillButtonCallback didClickAutoFillButton; +} WKBundlePageUIClientV3; + +#endif // WKBundlePageUIClient_h diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h index af18e3c2d..205e72ab9 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h @@ -26,22 +26,21 @@ #ifndef WKBundlePrivate_h #define WKBundlePrivate_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifndef __cplusplus #include <stdbool.h> #endif +#include <JavaScriptCore/JSBase.h> +#include <WebKit/WKUserContentInjectedFrames.h> +#include <WebKit/WKUserScriptInjectionTime.h> + #ifdef __cplusplus extern "C" { #endif -// TestRunner only SPI -WK_EXPORT void WKBundleSetShouldTrackVisitedLinks(WKBundleRef bundle, bool shouldTrackVisitedLinks); -WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool); -WK_EXPORT void WKBundleRemoveAllVisitedLinks(WKBundleRef bundle); -WK_EXPORT void WKBundleActivateMacFontAscentHack(WKBundleRef bundle); -WK_EXPORT void WKBundleSetCacheModel(WKBundleRef bundle, uint32_t cacheModel); +// TestRunner only SPIs. // Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use. WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled); WK_EXPORT void WKBundleSetAllowUniversalAccessFromFileURLs(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); @@ -52,7 +51,6 @@ WK_EXPORT void WKBundleSetPluginsEnabled(WKBundleRef bundle, WKBundlePageGroupRe WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); -WK_EXPORT void WKBundleSwitchNetworkLoaderToNewTestingSession(WKBundleRef bundle); WK_EXPORT void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleSetSpatialNavigationEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled); WK_EXPORT void WKBundleAddOriginAccessWhitelistEntry(WKBundleRef bundle, WKStringRef, WKStringRef, WKStringRef, bool); @@ -70,7 +68,7 @@ WK_EXPORT WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSCon WK_EXPORT void WKBundleSetAsynchronousSpellCheckingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled); // UserContent API -WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); +WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, _WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames); WK_EXPORT void WKBundleAddUserStyleSheet(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames injectedFrames); WK_EXPORT void WKBundleRemoveUserScript(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKURLRef url); WK_EXPORT void WKBundleRemoveUserStyleSheet(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundleScriptWorldRef scriptWorld, WKURLRef url); @@ -82,15 +80,6 @@ WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle, WKBundlePageGrou WK_EXPORT void WKBundleClearAllDatabases(WKBundleRef bundle); WK_EXPORT void WKBundleSetDatabaseQuota(WKBundleRef bundle, uint64_t); -// Application Cache API -WK_EXPORT void WKBundleClearApplicationCache(WKBundleRef bundle); -WK_EXPORT void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundle, WKStringRef origin); -WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size); -WK_EXPORT uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundle, WKStringRef origin); -WK_EXPORT void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin, uint64_t bytes); -WK_EXPORT void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin); -WK_EXPORT WKArrayRef WKBundleCopyOriginsWithApplicationCache(WKBundleRef bundle); - // Garbage collection API WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle); WK_EXPORT void WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(WKBundleRef bundle, bool waitUntilDone); @@ -99,10 +88,6 @@ WK_EXPORT size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundle); WK_EXPORT bool WKBundleIsProcessingUserGesture(WKBundleRef bundle); WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled); -WK_EXPORT void WKBundleSetSerialLoadingEnabled(WKBundleRef bundle, bool enabled); -WK_EXPORT void WKBundleSetShadowDOMEnabled(WKBundleRef bundle, bool enabled); -WK_EXPORT void WKBundleSetSeamlessIFramesEnabled(WKBundleRef bundle, bool enabled); -WK_EXPORT void WKBundleDispatchPendingLoadRequests(WKBundleRef bundle); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp index fb2f7d05f..73b88c134 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.cpp @@ -30,6 +30,8 @@ #include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" +#include "WebImage.h" +#include <WebCore/IntRect.h> using namespace WebKit; @@ -43,3 +45,15 @@ WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef contextRef, JSObje RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::getOrCreate(contextRef, objectRef); return toAPI(rangeHandle.release().leakRef()); } + +WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandleRef) +{ + WebCore::IntRect boundingRect = toImpl(rangeHandleRef)->boundingRectInWindowCoordinates(); + return WKRectMake(boundingRect.x(), boundingRect.y(), boundingRect.width(), boundingRect.height()); +} + +WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandleRef, WKSnapshotOptions options) +{ + RefPtr<WebImage> image = toImpl(rangeHandleRef)->renderedImage(toSnapshotOptions(options)); + return toAPI(image.release().leakRef()); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h index 8d1d35928..b3d542440 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h @@ -26,7 +26,7 @@ #ifndef WKBundleRangeHandle_h #define WKBundleRangeHandle_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h index 54f845024..c6ab5bff2 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleRangeHandlePrivate.h @@ -27,7 +27,9 @@ #define WKBundleRangeHandlePrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> +#include <WebKit/WKImage.h> #ifdef __cplusplus extern "C" { @@ -35,6 +37,9 @@ extern "C" { WK_EXPORT WKBundleRangeHandleRef WKBundleRangeHandleCreate(JSContextRef context, JSObjectRef object); +WK_EXPORT WKRect WKBundleRangeHandleGetBoundingRectInWindowCoordinates(WKBundleRangeHandleRef rangeHandle); +WK_EXPORT WKImageRef WKBundleRangeHandleCopySnapshotWithOptions(WKBundleRangeHandleRef rangeHandle, WKSnapshotOptions options); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp index 87ccf11e9..3ae871201 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.cpp @@ -52,3 +52,8 @@ void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorldRef) { toImpl(scriptWorldRef)->clearWrappers(); } + +void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorldRef) +{ + toImpl(scriptWorldRef)->makeAllShadowRootsOpen(); +} diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h index 013cdc9a3..f1fb5d344 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h @@ -26,7 +26,7 @@ #ifndef WKBundleScriptWorld_h #define WKBundleScriptWorld_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -37,6 +37,7 @@ WK_EXPORT WKTypeID WKBundleScriptWorldGetTypeID(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldCreateWorld(); WK_EXPORT WKBundleScriptWorldRef WKBundleScriptWorldNormalWorld(); WK_EXPORT void WKBundleScriptWorldClearWrappers(WKBundleScriptWorldRef scriptWorld); +WK_EXPORT void WKBundleScriptWorldMakeAllShadowRootsOpen(WKBundleScriptWorldRef scriptWorld); #ifdef __cplusplus } diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm b/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm deleted file mode 100644 index 3b3169e78..000000000 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2013 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 "WKBundlePageBannerMac.h" - -#include "PageBanner.h" -#include "WKAPICast.h" -#include "WKBundleAPICast.h" -#include <wtf/PassOwnPtr.h> - -using namespace WebCore; -using namespace WebKit; - -class PageBannerClientImpl : public PageBanner::Client { -public: - static PassOwnPtr<PageBannerClientImpl> create(WKBundlePageBannerClient* client) - { - return adoptPtr(new PageBannerClientImpl(client)); - } - -private: - explicit PageBannerClientImpl(WKBundlePageBannerClient* client) - : m_client() - { - if (client) - m_client = *client; - } - - // PageBanner::Client. - virtual void pageBannerDestroyed(PageBanner*) - { - delete this; - } - - virtual bool mouseEvent(PageBanner* pageBanner, WebEvent::Type type, WebMouseEvent::Button button, const WebCore::IntPoint& position) - { - switch (type) { - case WebEvent::MouseDown: { - if (!m_client.mouseDown) - return false; - - return m_client.mouseDown(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo); - } - case WebEvent::MouseUp: { - if (!m_client.mouseUp) - return false; - - return m_client.mouseUp(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo); - } - case WebEvent::MouseMove: { - if (button == WebMouseEvent::NoButton) { - if (!m_client.mouseMoved) - return false; - - return m_client.mouseMoved(toAPI(pageBanner), toAPI(position), m_client.clientInfo); - } - - // This is a MouseMove event with a mouse button pressed. Call mouseDragged. - if (!m_client.mouseDragged) - return false; - - return m_client.mouseDragged(toAPI(pageBanner), toAPI(position), toAPI(button), m_client.clientInfo); - } - - default: - return false; - } - } - - WKBundlePageBannerClient m_client; -}; - -WKBundlePageBannerRef WKBundlePageBannerCreateBannerWithCALayer(CALayer *layer, int height, WKBundlePageBannerClient * wkClient) -{ - if (wkClient && wkClient->version) - return 0; - - OwnPtr<PageBannerClientImpl> clientImpl = PageBannerClientImpl::create(wkClient); - return toAPI(PageBanner::create(layer, height, clientImpl.leakPtr()).leakRef()); -} - -CALayer * WKBundlePageBannerGetLayer(WKBundlePageBannerRef pageBanner) -{ - return toImpl(pageBanner)->layer(); -} |