diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Shared/API/c | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/Shared/API/c')
58 files changed, 659 insertions, 351 deletions
diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h new file mode 100644 index 000000000..7ab00f53a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2014 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 WKActionMenuItemTypes_h +#define WKActionMenuItemTypes_h + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Deprecated; remove when there are no more clients. +enum { + kWKContextActionItemTagNoAction = 0, + kWKContextActionItemTagOpenLinkInDefaultBrowser, + kWKContextActionItemTagPreviewLink, + kWKContextActionItemTagAddLinkToSafariReadingList, + kWKContextActionItemTagCopyImage, + kWKContextActionItemTagAddImageToPhotos, + kWKContextActionItemTagSaveImageToDownloads, + kWKContextActionItemTagShareImage, + kWKContextActionItemTagCopyText, + kWKContextActionItemTagLookupText, + kWKContextActionItemTagPaste, + kWKContextActionItemTagTextSuggestions, + kWKContextActionItemTagCopyVideoURL, + kWKContextActionItemTagSaveVideoToDownloads, + kWKContextActionItemTagShareVideo, + kWKContextActionItemTagShareLink +}; + +#ifdef __cplusplus +} +#endif + +#endif /* WKActionMenuItemTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h new file mode 100644 index 000000000..4769c390d --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014 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 WKActionMenuTypes_h +#define WKActionMenuTypes_h + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Deprecated; remove when there are no more clients. +enum { + kWKActionMenuNone = 0, + kWKActionMenuLink, + kWKActionMenuImage, + kWKActionMenuDataDetectedItem, + kWKActionMenuReadOnlyText, + kWKActionMenuEditableText, + kWKActionMenuEditableTextWithSuggestions, + kWKActionMenuWhitespaceInEditableArea, + kWKActionMenuVideo, + kWKActionMenuMailtoLink, + kWKActionMenuTelLink +}; +typedef uint32_t _WKActionMenuType; + +#ifdef __cplusplus +} +#endif + +#endif /* WKActionMenuTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKArray.cpp b/Source/WebKit2/Shared/API/c/WKArray.cpp index 30f9781f3..844161124 100644 --- a/Source/WebKit2/Shared/API/c/WKArray.cpp +++ b/Source/WebKit2/Shared/API/c/WKArray.cpp @@ -42,9 +42,9 @@ WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues) elements.reserveInitialCapacity(numberOfValues); for (size_t i = 0; i < numberOfValues; ++i) - elements.uncheckedAppend(const_cast<API::Object*>(static_cast<const API::Object*>(values[i]))); + elements.uncheckedAppend(toImpl(values[i])); - return toAPI(API::Array::create(std::move(elements)).leakRef()); + return toAPI(&API::Array::create(WTFMove(elements)).leakRef()); } WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues) @@ -53,14 +53,14 @@ WKArrayRef WKArrayCreateAdoptingValues(WKTypeRef* values, size_t numberOfValues) elements.reserveInitialCapacity(numberOfValues); for (size_t i = 0; i < numberOfValues; ++i) - elements.uncheckedAppend(adoptRef(const_cast<API::Object*>(static_cast<const API::Object*>(values[i])))); + elements.uncheckedAppend(adoptRef(toImpl(values[i]))); - return toAPI(API::Array::create(std::move(elements)).leakRef()); + return toAPI(&API::Array::create(WTFMove(elements)).leakRef()); } WKTypeRef WKArrayGetItemAtIndex(WKArrayRef arrayRef, size_t index) { - return toImpl(arrayRef)->at(index); + return toAPI(toImpl(arrayRef)->at(index)); } size_t WKArrayGetSize(WKArrayRef arrayRef) diff --git a/Source/WebKit2/Shared/API/c/WKArray.h b/Source/WebKit2/Shared/API/c/WKArray.h index 25900f313..ff8d39bfe 100644 --- a/Source/WebKit2/Shared/API/c/WKArray.h +++ b/Source/WebKit2/Shared/API/c/WKArray.h @@ -26,7 +26,7 @@ #ifndef WKArray_h #define WKArray_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #include <stddef.h> diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h index d41894c13..2e8fbfbbe 100644 --- a/Source/WebKit2/Shared/API/c/WKBase.h +++ b/Source/WebKit2/Shared/API/c/WKBase.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010-2017 Apple Inc. All rights reserved. * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,23 +27,15 @@ #ifndef WKBase_h #define WKBase_h -#include <WebKit2/WKDeclarationSpecifiers.h> +#include <WebKit/WKDeclarationSpecifiers.h> #include <stdint.h> #if defined(BUILDING_GTK__) -#include <WebKit2/WKBaseGtk.h> +#include <WebKit/WKBaseGtk.h> #endif -#if defined(WTF_USE_SOUP) -#include <WebKit2/WKBaseSoup.h> -#endif - -#if defined(BUILDING_EFL__) -#include <WebKit2/WKBaseEfl.h> -#endif - -#if defined(__APPLE__) -#include <WebKit2/WKBaseMac.h> +#if defined(__APPLE__) && !defined(BUILDING_GTK__) +#include <WebKit/WKBaseMac.h> #endif /* WebKit2 shared types */ @@ -89,16 +81,17 @@ typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeR typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef; typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef; typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef; -typedef const struct OpaqueWKBatteryManager* WKBatteryManagerRef; -typedef const struct OpaqueWKBatteryStatus* WKBatteryStatusRef; typedef const struct OpaqueWKResourceCacheManager* WKResourceCacheManagerRef; typedef const struct OpaqueWKColorPickerResultListener* WKColorPickerResultListenerRef; typedef const struct OpaqueWKContext* WKContextRef; +typedef const struct OpaqueWKContextConfiguration* WKContextConfigurationRef; +typedef const struct OpaqueWKContextMenuListener* WKContextMenuListenerRef; typedef const struct OpaqueWKCookieManager* WKCookieManagerRef; typedef const struct OpaqueWKCredential* WKCredentialRef; -typedef const struct OpaqueWKDatabaseManager* WKDatabaseManagerRef; typedef const struct OpaqueWKDownload* WKDownloadRef; typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef; +typedef const struct OpaqueWKFrameHandle* WKFrameHandleRef; +typedef const struct OpaqueWKFrameInfo* WKFrameInfoRef; typedef const struct OpaqueWKFrame* WKFrameRef; typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef; typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef; @@ -109,26 +102,42 @@ typedef const struct OpaqueWKHitTestResult* WKHitTestResultRef; typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef; typedef const struct OpaqueWKInspector* WKInspectorRef; typedef const struct OpaqueWKKeyValueStorageManager* WKKeyValueStorageManagerRef; -typedef const struct OpaqueWKMediaCacheManager* WKMediaCacheManagerRef; +typedef const struct OpaqueWKMediaSessionFocusManager* WKMediaSessionFocusManagerRef; +typedef const struct OpaqueWKMediaSessionMetadata* WKMediaSessionMetadataRef; +typedef const struct OpaqueWKNavigationAction* WKNavigationActionRef; typedef const struct OpaqueWKNavigationData* WKNavigationDataRef; -typedef const struct OpaqueWKNetworkInfoManager* WKNetworkInfoManagerRef; -typedef const struct OpaqueWKNetworkInfo* WKNetworkInfoRef; +typedef const struct OpaqueWKNavigation* WKNavigationRef; +typedef const struct OpaqueWKNavigationResponse* WKNavigationResponseRef; typedef const struct OpaqueWKNotification* WKNotificationRef; typedef const struct OpaqueWKNotificationManager* WKNotificationManagerRef; typedef const struct OpaqueWKNotificationPermissionRequest* WKNotificationPermissionRequestRef; typedef const struct OpaqueWKNotificationProvider* WKNotificationProviderRef; typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef; typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef; -typedef const struct OpaqueWKOriginDataManager* WKOriginDataManagerRef; typedef const struct OpaqueWKPage* WKPageRef; +typedef const struct OpaqueWKPageConfiguration* WKPageConfigurationRef; typedef const struct OpaqueWKPageGroup* WKPageGroupRef; -typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef; typedef const struct OpaqueWKPreferences* WKPreferencesRef; typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef; +typedef const struct OpaqueWKPageRunBeforeUnloadConfirmPanelResultListener* WKPageRunBeforeUnloadConfirmPanelResultListenerRef; +typedef const struct OpaqueWKPageRunJavaScriptAlertResultListener* WKPageRunJavaScriptAlertResultListenerRef; +typedef const struct OpaqueWKPageRunJavaScriptConfirmResultListener* WKPageRunJavaScriptConfirmResultListenerRef; +typedef const struct OpaqueWKPageRunJavaScriptPromptResultListener* WKPageRunJavaScriptPromptResultListenerRef; +typedef const struct OpaqueWKResourceLoadStatisticsManager* WKResourceLoadStatisticsManagerRef; typedef const struct OpaqueWKTextChecker* WKTextCheckerRef; typedef const struct OpaqueWKSession* WKSessionRef; +typedef const struct OpaqueWKSessionState* WKSessionStateRef; +typedef const struct OpaqueWKUserContentController* WKUserContentControllerRef; +typedef const struct OpaqueWKUserContentExtensionStore* WKUserContentExtensionStoreRef; +typedef const struct OpaqueWKUserContentFilter* WKUserContentFilterRef; +typedef const struct OpaqueWKUserMediaPermissionCheck* WKUserMediaPermissionCheckRef; +typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef; +typedef const struct OpaqueWKUserScript* WKUserScriptRef; typedef const struct OpaqueWKVibration* WKVibrationRef; typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef; +typedef const struct OpaqueWKWebsiteDataStore* WKWebsiteDataStoreRef; +typedef const struct OpaqueWKWebsitePolicies* WKWebsitePoliciesRef; +typedef const struct OpaqueWKWindowFeatures* WKWindowFeaturesRef; /* WebKit2 Bundle types */ @@ -137,6 +146,7 @@ typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef; typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef; typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef; typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensionRef; +typedef const struct OpaqueWKBundleFileHandle* WKBundleFileHandleRef; typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef; typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef; typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef; diff --git a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h index d4a2ed91d..f88f93c1a 100644 --- a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h +++ b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h @@ -26,7 +26,7 @@ #ifndef WKCertificateInfo_h #define WKCertificateInfo_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKConnectionRef.h b/Source/WebKit2/Shared/API/c/WKConnectionRef.h index 614024575..fd94cb614 100644 --- a/Source/WebKit2/Shared/API/c/WKConnectionRef.h +++ b/Source/WebKit2/Shared/API/c/WKConnectionRef.h @@ -26,7 +26,7 @@ #ifndef WKConnectionRef_h #define WKConnectionRef_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -48,16 +48,6 @@ typedef struct WKConnectionClientV0 { WKConnectionDidCloseCallback didClose; } WKConnectionClientV0; -enum { WKConnectionClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; -typedef struct WKConnectionClient { - int version; - const void * clientInfo; - - // Version 0. - WKConnectionDidReceiveMessageCallback didReceiveMessage; - WKConnectionDidCloseCallback didClose; -} WKConnectionClient WK_DEPRECATED("Use an explicit versioned struct instead"); - WK_EXPORT WKTypeID WKConnectionGetTypeID(); WK_EXPORT void WKConnectionSetConnectionClient(WKConnectionRef connection, const WKConnectionClientBase* client); diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp index 53064ff50..0514f1825 100644 --- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp @@ -32,10 +32,6 @@ #include "WKAPICast.h" #include "WKContextMenuItemTypes.h" -#if PLATFORM(MAC) -#import <mach-o/dyld.h> -#endif - using namespace WebCore; using namespace WebKit; @@ -51,7 +47,7 @@ WKTypeID WKContextMenuItemGetTypeID() WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled) { #if ENABLE(CONTEXT_MENUS) - return toAPI(WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef()); + return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef()); #else UNUSED_PARAM(tag); UNUSED_PARAM(title); @@ -63,7 +59,7 @@ WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, W WKContextMenuItemRef WKContextMenuItemCreateAsCheckableAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled, bool checked) { #if ENABLE(CONTEXT_MENUS) - return toAPI(WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef()); + return toAPI(&WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef()); #else UNUSED_PARAM(tag); UNUSED_PARAM(title); @@ -94,38 +90,10 @@ WKContextMenuItemRef WKContextMenuItemSeparatorItem() #endif } -#if ENABLE(CONTEXT_MENUS) -#if PLATFORM(MAC) -static WKContextMenuItemTag compatibleContextMenuItemTag(WKContextMenuItemTag tag) -{ - static bool needsWorkaround = ^bool { - const int32_t safariFrameworkVersionWithIncompatibleContextMenuItemTags = 0x02181900; // 536.25.0 (Safari 6.0) - return NSVersionOfRunTimeLibrary("Safari") == safariFrameworkVersionWithIncompatibleContextMenuItemTags; - }(); - - if (!needsWorkaround) - return tag; - - // kWKContextMenuItemTagDictationAlternative was inserted before kWKContextMenuItemTagInspectElement. - // DictationAlternative is now at the end like it should have been. To be compatible we need to return - // InspectElement for DictationAlternative and shift InspectElement and after by one. - if (tag == kWKContextMenuItemTagDictationAlternative) - return kWKContextMenuItemTagInspectElement; - if (tag >= kWKContextMenuItemTagInspectElement && tag < kWKContextMenuItemBaseApplicationTag) - return tag + 1; - return tag; -} -#endif -#endif // ENABLE(CONTEXT_MENUS) - WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) -#if PLATFORM(MAC) - return compatibleContextMenuItemTag(toAPI(toImpl(itemRef)->data()->action())); -#else - return toAPI(toImpl(itemRef)->data()->action()); -#endif + return toAPI(toImpl(itemRef)->data().action()); #else UNUSED_PARAM(itemRef); return toAPI(ContextMenuItemTagNoAction); @@ -135,7 +103,7 @@ WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef) WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toAPI(toImpl(itemRef)->data()->type()); + return toAPI(toImpl(itemRef)->data().type()); #else UNUSED_PARAM(itemRef); return toAPI(ActionType); @@ -145,7 +113,7 @@ WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef) WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toCopiedAPI(toImpl(itemRef)->data()->title().impl()); + return toCopiedAPI(toImpl(itemRef)->data().title().impl()); #else UNUSED_PARAM(itemRef); return 0; @@ -155,7 +123,7 @@ WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef) bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toImpl(itemRef)->data()->enabled(); + return toImpl(itemRef)->data().enabled(); #else UNUSED_PARAM(itemRef); return false; @@ -165,7 +133,7 @@ bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef) bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toImpl(itemRef)->data()->checked(); + return toImpl(itemRef)->data().checked(); #else UNUSED_PARAM(itemRef); return false; @@ -175,7 +143,7 @@ bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef) WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef itemRef) { #if ENABLE(CONTEXT_MENUS) - return toAPI(toImpl(itemRef)->submenuItemsAsAPIArray().leakRef()); + return toAPI(&toImpl(itemRef)->submenuItemsAsAPIArray().leakRef()); #else UNUSED_PARAM(itemRef); return 0; diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h index 9b978400c..caf1b7632 100644 --- a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h @@ -26,8 +26,8 @@ #ifndef WKContextMenuItem_h #define WKContextMenuItem_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKContextMenuItemTypes.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKContextMenuItemTypes.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h index f61703e32..2a67631c4 100644 --- a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h @@ -121,6 +121,8 @@ enum { kWKContextMenuItemTagSelectAll, kWKContextMenuItemTagOpenLinkInThisWindow, kWKContextMenuItemTagToggleVideoFullscreen, + kWKContextMenuItemTagShareMenu, + kWKContextMenuItemTagToggleVideoEnhancedFullscreen, kWKContextMenuItemBaseApplicationTag = 10000 }; typedef uint32_t WKContextMenuItemTag; diff --git a/Source/WebKit2/Shared/API/c/WKData.cpp b/Source/WebKit2/Shared/API/c/WKData.cpp index ebc40b142..fdbca73dc 100644 --- a/Source/WebKit2/Shared/API/c/WKData.cpp +++ b/Source/WebKit2/Shared/API/c/WKData.cpp @@ -38,7 +38,7 @@ WKTypeID WKDataGetTypeID() WKDataRef WKDataCreate(const unsigned char* bytes, size_t size) { - return toAPI(API::Data::create(bytes, size).leakRef()); + return toAPI(&API::Data::create(bytes, size).leakRef()); } const unsigned char* WKDataGetBytes(WKDataRef dataRef) diff --git a/Source/WebKit2/Shared/API/c/WKData.h b/Source/WebKit2/Shared/API/c/WKData.h index a647ee4e4..19e1fff7c 100644 --- a/Source/WebKit2/Shared/API/c/WKData.h +++ b/Source/WebKit2/Shared/API/c/WKData.h @@ -26,7 +26,7 @@ #ifndef WKData_h #define WKData_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #include <stddef.h> diff --git a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h index b5d8f13cb..ce8adcfbb 100644 --- a/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h +++ b/Source/WebKit2/Shared/API/c/WKDeclarationSpecifiers.h @@ -51,15 +51,9 @@ #endif #if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message) -#define WK_DEPRECATED(message) __attribute__((deprecated(message))) +#define WK_C_DEPRECATED(message) __attribute__((deprecated(message))) #else -#define WK_DEPRECATED(message) -#endif - -#if defined(__has_extension) && __has_extension(enumerator_attributes) && __has_extension(attribute_unavailable_with_message) -#define WK_ENUM_DEPRECATED(message) __attribute__((deprecated(message))) -#else -#define WK_ENUM_DEPRECATED(message) +#define WK_C_DEPRECATED(message) #endif #endif /* WKDeclarationSpecifiers_h */ diff --git a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp index 1319b76f3..915f44a7f 100644 --- a/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp +++ b/Source/WebKit2/Shared/API/c/WKDeprecatedFunctions.cpp @@ -25,10 +25,15 @@ #include "config.h" -#include "MutableDictionary.h" +#include "APIDictionary.h" +#include "APIUserContentExtension.h" +#include "WKAPICast.h" #include "WKArray.h" +#include "WKContextPrivate.h" #include "WKMutableDictionary.h" -#include "WKSharedAPICast.h" +#include "WKPreferencesRefPrivate.h" +#include "WebPageGroup.h" +#include "WebUserContentControllerProxy.h" #if PLATFORM(MAC) #include "WKContextPrivateMac.h" @@ -36,53 +41,53 @@ // Deprecated functions that should be removed from the framework once nobody uses them. -using namespace WebKit; - extern "C" { -WK_EXPORT bool WKArrayIsMutable(WKArrayRef array); - -WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); -WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary); -WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key); - -#if PLATFORM(MAC) -WK_EXPORT CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext); -#endif +WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup); +WK_EXPORT void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroup, WKUserContentFilterRef userContentFilter); +WK_EXPORT void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroup, WKStringRef userContentFilterName); +WK_EXPORT void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroup); } -bool WKArrayIsMutable(WKArrayRef) -{ - return false; -} +using namespace WebKit; -bool WKDictionaryIsMutable(WKDictionaryRef dictionaryRef) +void WKContextSetUsesNetworkProcess(WKContextRef, bool) { - return toImpl(dictionaryRef)->isMutable(); } -bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) +void WKContextSetProcessModel(WKContextRef, WKProcessModel) { - return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef)); } -void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef) +WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef) { - toImpl(dictionaryRef)->remove(toImpl(keyRef)->string()); + return nullptr; } - -#if PLATFORM(MAC) -CGContextRef WKGraphicsContextGetCGContext(WKGraphicsContextRef graphicsContext) +void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroupRef, WKUserContentFilterRef userContentFilterRef) { - return nullptr; +#if ENABLE(CONTENT_EXTENSIONS) + toImpl(pageGroupRef)->userContentController().addUserContentExtension(*toImpl(userContentFilterRef)); +#else + UNUSED_PARAM(pageGroupRef); + UNUSED_PARAM(userContentFilterRef); +#endif } -bool WKContextGetProcessSuppressionEnabled(WKContextRef) +void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroupRef, WKStringRef userContentFilterNameRef) { - return true; +#if ENABLE(CONTENT_EXTENSIONS) + toImpl(pageGroupRef)->userContentController().removeUserContentExtension(toWTFString(userContentFilterNameRef)); +#else + UNUSED_PARAM(pageGroupRef); + UNUSED_PARAM(userContentFilterNameRef); +#endif } -void WKContextSetProcessSuppressionEnabled(WKContextRef, bool) +void WKPageGroupRemoveAllUserContentFilters(WKPageGroupRef pageGroupRef) { -} +#if ENABLE(CONTENT_EXTENSIONS) + toImpl(pageGroupRef)->userContentController().removeAllUserContentExtensions(); +#else + UNUSED_PARAM(pageGroupRef); #endif +} diff --git a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h index 600f0857f..581c74f96 100644 --- a/Source/WebKit2/Shared/API/c/soup/WKBaseSoup.h +++ b/Source/WebKit2/Shared/API/c/WKDiagnosticLoggingResultType.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Igalia S.L. + * Copyright (C) 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 @@ -23,14 +23,23 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKBaseSoup_h -#define WKBaseSoup_h +#ifndef WKDiagnosticLoggingResultType_h +#define WKDiagnosticLoggingResultType_h -#ifndef WKBase_h -#error "Please #include \"WKBase.h\" instead of this file directly." +#ifdef __cplusplus +extern "C" { #endif -typedef const struct OpaqueWKSoupRequestManager* WKSoupRequestManagerRef; -typedef const struct OpaqueWKSoupCustomProtocolRequestManager* WKSoupCustomProtocolRequestManagerRef; +enum { + kWKDiagnosticLoggingResultPass = 0, + kWKDiagnosticLoggingResultFail = 1, + kWKDiagnosticLoggingResultNoop = 2, +}; +typedef uint32_t WKDiagnosticLoggingResultType; + +#ifdef __cplusplus +} +#endif + +#endif /* WKDiagnosticLoggingResultType_h */ -#endif /* WKBaseSoup_h */ diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.cpp b/Source/WebKit2/Shared/API/c/WKDictionary.cpp index 44c61e162..654e1e61e 100644 --- a/Source/WebKit2/Shared/API/c/WKDictionary.cpp +++ b/Source/WebKit2/Shared/API/c/WKDictionary.cpp @@ -27,28 +27,28 @@ #include "WKDictionary.h" #include "APIArray.h" -#include "ImmutableDictionary.h" +#include "APIDictionary.h" #include "WKAPICast.h" using namespace WebKit; WKTypeID WKDictionaryGetTypeID() { - return toAPI(ImmutableDictionary::APIType); + return toAPI(API::Dictionary::APIType); } WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues) { - ImmutableDictionary::MapType map; + API::Dictionary::MapType map; for (size_t i = 0; i < numberOfValues; ++i) map.add(toImpl(keys[i])->string(), toImpl(values[i])); - return toAPI(ImmutableDictionary::create(std::move(map)).release().leakRef()); + return toAPI(&API::Dictionary::create(WTFMove(map)).leakRef()); } WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionaryRef, WKStringRef key) { - return toImpl(dictionaryRef)->get(toImpl(key)->string()); + return toAPI(toImpl(dictionaryRef)->get(toImpl(key)->string())); } size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef) @@ -58,6 +58,5 @@ size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef) WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionaryRef) { - RefPtr<API::Array> keys = toImpl(dictionaryRef)->keys(); - return toAPI(keys.release().leakRef()); + return toAPI(&toImpl(dictionaryRef)->keys().leakRef()); } diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.h b/Source/WebKit2/Shared/API/c/WKDictionary.h index c416e3c29..e486cc2a8 100644 --- a/Source/WebKit2/Shared/API/c/WKDictionary.h +++ b/Source/WebKit2/Shared/API/c/WKDictionary.h @@ -26,7 +26,7 @@ #ifndef WKDictionary_h #define WKDictionary_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #include <stddef.h> diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp index 315f43e9f..c1e75eb00 100644 --- a/Source/WebKit2/Shared/API/c/WKError.cpp +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.cpp @@ -24,7 +24,7 @@ */ #include "config.h" -#include "WKError.h" +#include "WKErrorRef.h" #include "APIError.h" #include "WKAPICast.h" diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKErrorRef.h index b099b732c..0d76384d3 100644 --- a/Source/WebKit2/Shared/API/c/WKError.h +++ b/Source/WebKit2/Shared/API/c/WKErrorRef.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010-2016 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,10 +23,10 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKError_h -#define WKError_h +#ifndef WKErrorRef_h +#define WKErrorRef_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -37,6 +37,8 @@ enum { kWKErrorCodeCannotShowURL = 101, kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102, kWKErrorCodeCannotUseRestrictedPort = 103, + kWKErrorCodeFrameLoadBlockedByContentBlocker = 104, + kWKErrorCodeFrameLoadBlockedByContentFilter = 105, kWKErrorCodeCannotFindPlugIn = 200, kWKErrorCodeCannotLoadPlugIn = 201, kWKErrorCodeJavaUnavailable = 202, @@ -45,7 +47,6 @@ enum { kWKErrorCodeInsecurePlugInVersion = 205, kWKErrorInternal = 300, }; -typedef uint32_t WKErrorCode; WK_EXPORT WKTypeID WKErrorGetTypeID(); @@ -60,4 +61,4 @@ WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error); } #endif -#endif // WKError_h +#endif // WKErrorRef_h diff --git a/Source/WebKit2/Shared/API/c/WKEvent.h b/Source/WebKit2/Shared/API/c/WKEvent.h index b15c47ad2..477d554c9 100644 --- a/Source/WebKit2/Shared/API/c/WKEvent.h +++ b/Source/WebKit2/Shared/API/c/WKEvent.h @@ -26,7 +26,7 @@ #ifndef WKEvent_h #define WKEvent_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -36,7 +36,8 @@ enum { kWKEventModifiersShiftKey = 1 << 0, kWKEventModifiersControlKey = 1 << 1, kWKEventModifiersAltKey = 1 << 2, - kWKEventModifiersMetaKey = 1 << 3 + kWKEventModifiersMetaKey = 1 << 3, + kWKEventModifiersCapsLockKey = 1 << 4 }; typedef uint32_t WKEventModifiers; diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.cpp b/Source/WebKit2/Shared/API/c/WKGeometry.cpp index 96c3f19f7..e1ea82435 100644 --- a/Source/WebKit2/Shared/API/c/WKGeometry.cpp +++ b/Source/WebKit2/Shared/API/c/WKGeometry.cpp @@ -48,17 +48,17 @@ WKTypeID WKRectGetTypeID() WKPointRef WKPointCreate(WKPoint point) { - return toAPI(API::Point::create(point).leakRef()); + return toAPI(&API::Point::create(point).leakRef()); } WKSizeRef WKSizeCreate(WKSize size) { - return toAPI(API::Size::create(size).leakRef()); + return toAPI(&API::Size::create(size).leakRef()); } WKRectRef WKRectCreate(WKRect rect) { - return toAPI(API::Rect::create(rect).leakRef()); + return toAPI(&API::Rect::create(rect).leakRef()); } WKSize WKSizeGetValue(WKSizeRef size) diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.h b/Source/WebKit2/Shared/API/c/WKGeometry.h index 97bf242e9..124fe2498 100644 --- a/Source/WebKit2/Shared/API/c/WKGeometry.h +++ b/Source/WebKit2/Shared/API/c/WKGeometry.h @@ -26,7 +26,7 @@ #ifndef WKGeometry_h #define WKGeometry_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKImage.cpp b/Source/WebKit2/Shared/API/c/WKImage.cpp index 23278b3a7..2741199e2 100644 --- a/Source/WebKit2/Shared/API/c/WKImage.cpp +++ b/Source/WebKit2/Shared/API/c/WKImage.cpp @@ -38,8 +38,8 @@ WKTypeID WKImageGetTypeID() WKImageRef WKImageCreate(WKSize size, WKImageOptions options) { - RefPtr<WebImage> webImage = WebImage::create(toIntSize(size), toImageOptions(options)); - return toAPI(webImage.release().leakRef()); + auto webImage = WebImage::create(toIntSize(size), toImageOptions(options)); + return toAPI(webImage.leakRef()); } WKSize WKImageGetSize(WKImageRef imageRef) diff --git a/Source/WebKit2/Shared/API/c/WKImage.h b/Source/WebKit2/Shared/API/c/WKImage.h index 07437bd76..27a34544e 100644 --- a/Source/WebKit2/Shared/API/c/WKImage.h +++ b/Source/WebKit2/Shared/API/c/WKImage.h @@ -26,8 +26,8 @@ #ifndef WKImage_h #define WKImage_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -42,7 +42,10 @@ enum { kWKSnapshotOptionsShareable = 1 << 0, kWKSnapshotOptionsExcludeSelectionHighlighting = 1 << 1, kWKSnapshotOptionsInViewCoordinates = 1 << 2, - kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3 + kWKSnapshotOptionsPaintSelectionRectangle = 1 << 3, + kWKSnapshotOptionsForceBlackText = 1 << 4, + kWKSnapshotOptionsForceWhiteText = 1 << 5, + kWKSnapshotOptionsPrinting = 1 << 6, }; typedef uint32_t WKSnapshotOptions; diff --git a/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h new file mode 100644 index 000000000..5fdc29a9e --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKImmediateActionTypes.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2014 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 WKImmediateActionTypes_h +#define WKImmediateActionTypes_h + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKImmediateActionNone = 0, + kWKImmediateActionLinkPreview, + kWKImmediateActionDataDetectedItem, + kWKImmediateActionLookupText, + kWKImmediateActionMailtoLink, + kWKImmediateActionTelLink +}; + +#ifndef _WKImmediateActionType +#define _WKImmediateActionType uint32_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WKImmediateActionTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp index f06782dae..5dc85260f 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp @@ -33,7 +33,7 @@ using namespace WebKit; WKMutableArrayRef WKMutableArrayCreate() { - return const_cast<WKMutableArrayRef>(toAPI(API::Array::create().leakRef())); + return const_cast<WKMutableArrayRef>(toAPI(&API::Array::create().leakRef())); } void WKArrayAppendItem(WKMutableArrayRef arrayRef, WKTypeRef itemRef) diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.h b/Source/WebKit2/Shared/API/c/WKMutableArray.h index 7f05c2830..80bd8c029 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableArray.h +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.h @@ -26,7 +26,7 @@ #ifndef WKMutableArray_h #define WKMutableArray_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #include <stddef.h> #ifndef __cplusplus diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp index 7ea5a3630..96b89bd45 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp @@ -26,15 +26,14 @@ #include "config.h" #include "WKMutableDictionary.h" -#include "MutableDictionary.h" +#include "APIDictionary.h" #include "WKAPICast.h" using namespace WebKit; WKMutableDictionaryRef WKMutableDictionaryCreate() { - RefPtr<MutableDictionary> dictionary = MutableDictionary::create(); - return toAPI(dictionary.release().leakRef()); + return const_cast<WKMutableDictionaryRef>(toAPI(&API::Dictionary::create().leakRef())); } bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h index e8297daa8..0c3b33a12 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h @@ -26,7 +26,7 @@ #ifndef WKMutableDictionary_h #define WKMutableDictionary_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifndef __cplusplus #include <stdbool.h> diff --git a/Source/WebKit2/Shared/API/c/WKNumber.cpp b/Source/WebKit2/Shared/API/c/WKNumber.cpp index 11300632c..418e029ea 100644 --- a/Source/WebKit2/Shared/API/c/WKNumber.cpp +++ b/Source/WebKit2/Shared/API/c/WKNumber.cpp @@ -38,8 +38,8 @@ WKTypeID WKBooleanGetTypeID() WKBooleanRef WKBooleanCreate(bool value) { - RefPtr<API::Boolean> booleanObject = API::Boolean::create(value); - return toAPI(booleanObject.release().leakRef()); + auto booleanObject = API::Boolean::create(value); + return toAPI(&booleanObject.leakRef()); } bool WKBooleanGetValue(WKBooleanRef booleanRef) @@ -54,8 +54,8 @@ WKTypeID WKDoubleGetTypeID() WKDoubleRef WKDoubleCreate(double value) { - RefPtr<API::Double> doubleObject = API::Double::create(value); - return toAPI(doubleObject.release().leakRef()); + auto doubleObject = API::Double::create(value); + return toAPI(&doubleObject.leakRef()); } double WKDoubleGetValue(WKDoubleRef doubleRef) @@ -70,8 +70,8 @@ WKTypeID WKUInt64GetTypeID() WKUInt64Ref WKUInt64Create(uint64_t value) { - RefPtr<API::UInt64> uint64Object = API::UInt64::create(value); - return toAPI(uint64Object.release().leakRef()); + auto uint64Object = API::UInt64::create(value); + return toAPI(&uint64Object.leakRef()); } uint64_t WKUInt64GetValue(WKUInt64Ref uint64Ref) diff --git a/Source/WebKit2/Shared/API/c/WKNumber.h b/Source/WebKit2/Shared/API/c/WKNumber.h index c8c912965..2ebe73a8c 100644 --- a/Source/WebKit2/Shared/API/c/WKNumber.h +++ b/Source/WebKit2/Shared/API/c/WKNumber.h @@ -26,7 +26,7 @@ #ifndef WKNumber_h #define WKNumber_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp index a4a1ce743..e3ae4f5f0 100644 --- a/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp +++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp @@ -35,8 +35,8 @@ using namespace WebKit; WKStringRef WKPluginInformationBundleIdentifierKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -45,8 +45,8 @@ WKStringRef WKPluginInformationBundleIdentifierKey() WKStringRef WKPluginInformationBundleVersionKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationBundleVersionKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationBundleVersionKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -55,8 +55,8 @@ WKStringRef WKPluginInformationBundleVersionKey() WKStringRef WKPluginInformationBundleShortVersionKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -65,8 +65,8 @@ WKStringRef WKPluginInformationBundleShortVersionKey() WKStringRef WKPluginInformationPathKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationPathKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationPathKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -75,8 +75,8 @@ WKStringRef WKPluginInformationPathKey() WKStringRef WKPluginInformationDisplayNameKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationDisplayNameKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationDisplayNameKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -85,8 +85,8 @@ WKStringRef WKPluginInformationDisplayNameKey() WKStringRef WKPluginInformationDefaultLoadPolicyKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -95,8 +95,8 @@ WKStringRef WKPluginInformationDefaultLoadPolicyKey() WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -105,8 +105,8 @@ WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey() WKStringRef WKPluginInformationHasSandboxProfileKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -115,8 +115,8 @@ WKStringRef WKPluginInformationHasSandboxProfileKey() WKStringRef WKPluginInformationFrameURLKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationFrameURLKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationFrameURLKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -125,8 +125,8 @@ WKStringRef WKPluginInformationFrameURLKey() WKStringRef WKPluginInformationMIMETypeKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationMIMETypeKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationMIMETypeKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -135,8 +135,8 @@ WKStringRef WKPluginInformationMIMETypeKey() WKStringRef WKPluginInformationPageURLKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationPageURLKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationPageURLKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -145,8 +145,8 @@ WKStringRef WKPluginInformationPageURLKey() WKStringRef WKPluginInformationPluginspageAttributeURLKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -155,8 +155,8 @@ WKStringRef WKPluginInformationPluginspageAttributeURLKey() WKStringRef WKPluginInformationPluginURLKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(pluginInformationPluginURLKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(pluginInformationPluginURLKey()).leakRef(); + return toAPI(&key); #else return 0; #endif @@ -165,8 +165,8 @@ WKStringRef WKPluginInformationPluginURLKey() WKStringRef WKPlugInInformationReplacementObscuredKey() { #if ENABLE(NETSCAPE_PLUGIN_API) - static API::String* key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef(); - return toAPI(key); + static API::String& key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef(); + return toAPI(&key); #else return 0; #endif diff --git a/Source/WebKit2/Shared/API/c/WKPluginInformation.h b/Source/WebKit2/Shared/API/c/WKPluginInformation.h index 0bcaef192..08970844b 100644 --- a/Source/WebKit2/Shared/API/c/WKPluginInformation.h +++ b/Source/WebKit2/Shared/API/c/WKPluginInformation.h @@ -26,7 +26,7 @@ #ifndef WKPluginInformation_h #define WKPluginInformation_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp index 82cf959be..da21e69aa 100644 --- a/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp +++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.cpp @@ -53,7 +53,7 @@ WKStringRef WKRenderLayerCopyElementTagName(WKRenderLayerRef renderLayerRef) if (!renderLayer->renderer()->elementTagName().isNull()) return toCopiedAPI(renderLayer->renderer()->elementTagName()); - return 0; + return nullptr; } WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef) @@ -62,7 +62,7 @@ WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef) if (!renderLayer->renderer()->elementID().isNull()) return toCopiedAPI(renderLayer->renderer()->elementID()); - return 0; + return nullptr; } WKArrayRef WKRenderLayerGetElementClassNames(WKRenderLayerRef renderLayerRef) @@ -110,6 +110,11 @@ WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef ren return kWKCompositingLayerTypeNone; } +WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayerRef) +{ + return toImpl(renderLayerRef)->backingStoreMemoryEstimate(); +} + WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayerRef) { return toAPI(toImpl(renderLayerRef)->negativeZOrderList()); @@ -124,3 +129,8 @@ WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayerRef) { return toAPI(toImpl(renderLayerRef)->positiveZOrderList()); } + +WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayerRef) +{ + return toAPI(toImpl(renderLayerRef)->frameContentsLayer()); +} diff --git a/Source/WebKit2/Shared/API/c/WKRenderLayer.h b/Source/WebKit2/Shared/API/c/WKRenderLayer.h index 72f28e0b9..7aeae7855 100644 --- a/Source/WebKit2/Shared/API/c/WKRenderLayer.h +++ b/Source/WebKit2/Shared/API/c/WKRenderLayer.h @@ -27,8 +27,8 @@ #define WKRenderLayer_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -38,7 +38,7 @@ WK_EXPORT WKTypeID WKRenderLayerGetTypeID(); WK_EXPORT WKRenderObjectRef WKRenderLayerGetRenderer(WKRenderLayerRef renderLayer); -// FIXME: Remove this function once Safari does not require it. +// FIXME: Remove this function once Safari does not require it. Clients can access this data via the renderer. WK_EXPORT WKStringRef WKRenderLayerCopyRendererName(WKRenderLayerRef renderLayer); // FIXME: Remove these three functions once Safari does not require them. @@ -62,11 +62,14 @@ enum WKCompositingLayerType { typedef enum WKCompositingLayerType WKCompositingLayerType; WK_EXPORT WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef renderLayer); +WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayer); WK_EXPORT WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayer); WK_EXPORT WKArrayRef WKRenderLayerGetNormalFlowList(WKRenderLayerRef renderLayer); WK_EXPORT WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayer); +WK_EXPORT WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayer); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp index 864b6e7ad..df2e743dd 100644 --- a/Source/WebKit2/Shared/API/c/WKRenderObject.cpp +++ b/Source/WebKit2/Shared/API/c/WKRenderObject.cpp @@ -42,13 +42,27 @@ WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObjectRef) return toCopiedAPI(toImpl(renderObjectRef)->name()); } +WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObjectRef) +{ + WebRenderObject* renderObject = toImpl(renderObjectRef); + if (!renderObject->textSnippet().isNull()) + return toCopiedAPI(renderObject->textSnippet()); + + return nullptr; +} + +unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObjectRef) +{ + return toImpl(renderObjectRef)->textLength(); +} + WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObjectRef) { WebRenderObject* renderObject = toImpl(renderObjectRef); if (!renderObject->elementTagName().isNull()) return toCopiedAPI(renderObject->elementTagName()); - return 0; + return nullptr; } WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef) @@ -57,7 +71,7 @@ WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObjectRef) if (!renderObject->elementID().isNull()) return toCopiedAPI(renderObject->elementID()); - return 0; + return nullptr; } WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObjectRef) diff --git a/Source/WebKit2/Shared/API/c/WKRenderObject.h b/Source/WebKit2/Shared/API/c/WKRenderObject.h index 965cf2a96..0973ae8cf 100644 --- a/Source/WebKit2/Shared/API/c/WKRenderObject.h +++ b/Source/WebKit2/Shared/API/c/WKRenderObject.h @@ -26,8 +26,8 @@ #ifndef WKRenderObject_h #define WKRenderObject_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKGeometry.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKGeometry.h> #ifdef __cplusplus extern "C" { @@ -36,7 +36,8 @@ extern "C" { WK_EXPORT WKTypeID WKRenderObjectGetTypeID(); WK_EXPORT WKStringRef WKRenderObjectCopyName(WKRenderObjectRef renderObject); - +WK_EXPORT WKStringRef WKRenderObjectCopyTextSnippet(WKRenderObjectRef renderObject); +WK_EXPORT unsigned WKRenderObjectGetTextLength(WKRenderObjectRef renderObject); WK_EXPORT WKStringRef WKRenderObjectCopyElementTagName(WKRenderObjectRef renderObject); WK_EXPORT WKStringRef WKRenderObjectCopyElementID(WKRenderObjectRef renderObject); WK_EXPORT WKArrayRef WKRenderObjectGetElementClassNames(WKRenderObjectRef renderObject); diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp index f7291065f..d1160740c 100644 --- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp +++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.cpp @@ -24,59 +24,61 @@ */ #include "config.h" -#include "WKSecurityOrigin.h" +#include "WKSecurityOriginRef.h" +#include "APISecurityOrigin.h" #include "WKAPICast.h" -#include "WebSecurityOrigin.h" +#include <WebCore/SecurityOriginData.h> using namespace WebKit; WKTypeID WKSecurityOriginGetTypeID() { - return toAPI(WebSecurityOrigin::APIType); + return toAPI(API::SecurityOrigin::APIType); } WKSecurityOriginRef WKSecurityOriginCreateFromString(WKStringRef string) { - RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromString(toImpl(string)->string()); - return toAPI(securityOrigin.release().leakRef()); + return toAPI(API::SecurityOrigin::create(WebCore::SecurityOrigin::createFromString(toImpl(string)->string())).leakRef()); } WKSecurityOriginRef WKSecurityOriginCreateFromDatabaseIdentifier(WKStringRef identifier) { - RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::createFromDatabaseIdentifier(toImpl(identifier)->string()); - return toAPI(securityOrigin.release().leakRef()); + auto origin = WebCore::SecurityOriginData::fromDatabaseIdentifier(toImpl(identifier)->string()); + if (!origin) + return nullptr; + return toAPI(API::SecurityOrigin::create(origin.value().securityOrigin()).leakRef()); } WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port) { - RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); - return toAPI(securityOrigin.release().leakRef()); + auto securityOrigin = API::SecurityOrigin::create(toImpl(protocol)->string(), toImpl(host)->string(), port); + return toAPI(securityOrigin.leakRef()); } WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin) { - return toCopiedAPI(toImpl(securityOrigin)->databaseIdentifier()); + return toCopiedAPI(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(securityOrigin)->securityOrigin()).databaseIdentifier()); } WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin) { - return toCopiedAPI(toImpl(securityOrigin)->toString()); + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().toString()); } WKStringRef WKSecurityOriginCopyProtocol(WKSecurityOriginRef securityOrigin) { - return toCopiedAPI(toImpl(securityOrigin)->protocol()); + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().protocol()); } WKStringRef WKSecurityOriginCopyHost(WKSecurityOriginRef securityOrigin) { - return toCopiedAPI(toImpl(securityOrigin)->host()); + return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().host()); } unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin) { - return toImpl(securityOrigin)->port(); + return toImpl(securityOrigin)->securityOrigin().port().value_or(0); } // For backwards ABI compatibility. diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h index d932e93a4..3c3356b38 100644 --- a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h +++ b/Source/WebKit2/Shared/API/c/WKSecurityOriginRef.h @@ -23,10 +23,10 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WKSecurityOrigin_h -#define WKSecurityOrigin_h +#ifndef WKSecurityOriginRef_h +#define WKSecurityOriginRef_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -48,4 +48,4 @@ WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOri } #endif -#endif /* WKSecurityOrigin_h */ +#endif /* WKSecurityOriginRef_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp index f45c388e9..862fd7f60 100644 --- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp @@ -27,26 +27,26 @@ #include "WKSerializedScriptValue.h" #include "WKSerializedScriptValuePrivate.h" +#include "APISerializedScriptValue.h" #include "WKAPICast.h" -#include "WebSerializedScriptValue.h" using namespace WebKit; WKTypeID WKSerializedScriptValueGetTypeID() { - return toAPI(WebSerializedScriptValue::APIType); + return toAPI(API::SerializedScriptValue::APIType); } WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception) { - RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(context, value, exception); - return toAPI(serializedValue.release().leakRef()); + auto serializedValue = API::SerializedScriptValue::create(context, value, exception); + return toAPI(serializedValue.leakRef()); } WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void* internalRepresentation) { - RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation)); - return toAPI(serializedValue.release().leakRef()); + auto serializedValue = API::SerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation)); + return toAPI(&serializedValue.leakRef()); } JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValueRef, JSContextRef contextRef, JSValueRef* exception) diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h index 3f73d7a06..625afe05b 100644 --- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h @@ -27,7 +27,7 @@ #define WKSerializedScriptValue_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h index 27e184906..837067fb7 100644 --- a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h @@ -26,7 +26,7 @@ #ifndef WKSerializedScriptValuePrivate_h #define WKSerializedScriptValuePrivate_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h index 8439dbca4..864baff16 100644 --- a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h +++ b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h @@ -28,7 +28,7 @@ #include "APIError.h" #include "APINumber.h" -#include "APISession.h" +#include "APISecurityOrigin.h" #include "APIString.h" #include "APIURL.h" #include "APIURLRequest.h" @@ -37,6 +37,7 @@ #include "SameDocumentNavigationType.h" #include "WKBase.h" #include "WKContextMenuItemTypes.h" +#include "WKDiagnosticLoggingResultType.h" #include "WKEvent.h" #include "WKFindOptions.h" #include "WKGeometry.h" @@ -48,8 +49,8 @@ #include "WKUserScriptInjectionTime.h" #include "WebEvent.h" #include "WebFindOptions.h" -#include "WebSecurityOrigin.h" #include <WebCore/ContextMenuItem.h> +#include <WebCore/DiagnosticLoggingResultType.h> #include <WebCore/FloatRect.h> #include <WebCore/FrameLoaderTypes.h> #include <WebCore/IntRect.h> @@ -61,34 +62,32 @@ namespace API { class Array; +class Dictionary; class Data; class Point; class Rect; +class SecurityOrigin; +class SerializedScriptValue; class Size; +class UserContentURLPattern; +class WebArchive; +class WebArchiveResource; } namespace WebKit { -class ImmutableDictionary; -class MutableDictionary; class ObjCObjectGraph; -class WebArchive; -class WebArchiveResource; class WebCertificateInfo; class WebConnection; class WebContextMenuItem; -class WebGraphicsContext; class WebImage; -class WebSecurityOrigin; -class WebSerializedScriptValue; -class WebUserContentURLPattern; -template<typename APIType> struct APITypeInfo { }; -template<typename ImplType> struct ImplTypeInfo { }; +template<typename APIType> struct APITypeInfo; +template<typename ImplType> struct ImplTypeInfo; #define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \ - template<> struct APITypeInfo<TheAPIType> { typedef TheImplType* ImplType; }; \ - template<> struct ImplTypeInfo<TheImplType*> { typedef TheAPIType APIType; }; + template<> struct APITypeInfo<TheAPIType> { typedef TheImplType ImplType; }; \ + template<> struct ImplTypeInfo<TheImplType> { typedef TheAPIType APIType; }; WK_ADD_API_MAPPING(WKArrayRef, API::Array) WK_ADD_API_MAPPING(WKBooleanRef, API::Boolean) @@ -96,16 +95,14 @@ WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo) WK_ADD_API_MAPPING(WKConnectionRef, WebConnection) WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem) WK_ADD_API_MAPPING(WKDataRef, API::Data) -WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary) +WK_ADD_API_MAPPING(WKDictionaryRef, API::Dictionary) WK_ADD_API_MAPPING(WKDoubleRef, API::Double) WK_ADD_API_MAPPING(WKErrorRef, API::Error) -WK_ADD_API_MAPPING(WKGraphicsContextRef, WebGraphicsContext) WK_ADD_API_MAPPING(WKImageRef, WebImage) -WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary) WK_ADD_API_MAPPING(WKPointRef, API::Point) WK_ADD_API_MAPPING(WKRectRef, API::Rect) -WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin) -WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue) +WK_ADD_API_MAPPING(WKSecurityOriginRef, API::SecurityOrigin) +WK_ADD_API_MAPPING(WKSerializedScriptValueRef, API::SerializedScriptValue) WK_ADD_API_MAPPING(WKSizeRef, API::Size) WK_ADD_API_MAPPING(WKStringRef, API::String) WK_ADD_API_MAPPING(WKTypeRef, API::Object) @@ -113,24 +110,30 @@ WK_ADD_API_MAPPING(WKUInt64Ref, API::UInt64) WK_ADD_API_MAPPING(WKURLRef, API::URL) WK_ADD_API_MAPPING(WKURLRequestRef, API::URLRequest) WK_ADD_API_MAPPING(WKURLResponseRef, API::URLResponse) -WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern) -WK_ADD_API_MAPPING(WKSessionRef, API::Session) +WK_ADD_API_MAPPING(WKUserContentURLPatternRef, API::UserContentURLPattern) -template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array* ImplType; }; +template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array ImplType; }; +template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef API::Dictionary ImplType; }; -#if PLATFORM(MAC) -WK_ADD_API_MAPPING(WKWebArchiveRef, WebArchive) -WK_ADD_API_MAPPING(WKWebArchiveResourceRef, WebArchiveResource) +#if PLATFORM(COCOA) +WK_ADD_API_MAPPING(WKWebArchiveRef, API::WebArchive) +WK_ADD_API_MAPPING(WKWebArchiveResourceRef, API::WebArchiveResource) WK_ADD_API_MAPPING(WKObjCTypeWrapperRef, ObjCObjectGraph) #endif -template<typename T> -inline typename ImplTypeInfo<T>::APIType toAPI(T t) +template<typename T, typename APIType = typename ImplTypeInfo<T>::APIType> +auto toAPI(T* t) -> APIType +{ + return reinterpret_cast<APIType>(API::Object::wrap(t)); +} + +template<typename T, typename ImplType = typename APITypeInfo<T>::ImplType> +auto toImpl(T t) -> ImplType* { - return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t); + return static_cast<ImplType*>(API::Object::unwrap(static_cast<void*>(const_cast<typename std::remove_const<typename std::remove_pointer<T>::type>::type*>(t)))); } -template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType> +template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType>::APIType> class ProxyingRefPtr { public: ProxyingRefPtr(PassRefPtr<ImplType> impl) @@ -138,26 +141,17 @@ public: { } + ProxyingRefPtr(Ref<ImplType>&& impl) + : m_impl(WTFMove(impl)) + { + } + operator APIType() { return toAPI(m_impl.get()); } private: RefPtr<ImplType> m_impl; }; -/* Opaque typing convenience methods */ - -template<typename T> -inline typename APITypeInfo<T>::ImplType toImpl(T t) -{ - // An example of the conversions that take place: - // const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> API::Array* - - typedef typename std::remove_pointer<T>::type PotentiallyConstValueType; - typedef typename std::remove_const<PotentiallyConstValueType>::type NonConstValueType; - - return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t)); -} - /* Special cases. */ inline ProxyingRefPtr<API::String> toAPI(StringImpl* string) @@ -167,23 +161,21 @@ inline ProxyingRefPtr<API::String> toAPI(StringImpl* string) inline WKStringRef toCopiedAPI(const String& string) { - RefPtr<API::String> apiString = API::String::create(string); - return toAPI(apiString.release().leakRef()); + return toAPI(&API::String::create(string).leakRef()); } inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string) { if (!string) - return ProxyingRefPtr<API::URL>(0); + return ProxyingRefPtr<API::URL>(nullptr); return ProxyingRefPtr<API::URL>(API::URL::create(String(string))); } inline WKURLRef toCopiedURLAPI(const String& string) { if (!string) - return 0; - RefPtr<API::URL> url = API::URL::create(string); - return toAPI(url.release().leakRef()); + return nullptr; + return toAPI(&API::URL::create(string).leakRef()); } inline String toWTFString(WKStringRef stringRef) @@ -219,7 +211,7 @@ inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin) { if (!origin) return 0; - return toAPI(WebSecurityOrigin::create(origin).leakRef()); + return toAPI(API::SecurityOrigin::create(*origin).leakRef()); } /* Geometry conversions */ @@ -300,6 +292,8 @@ inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers) wkModifiers |= kWKEventModifiersAltKey; if (modifiers & WebEvent::MetaKey) wkModifiers |= kWKEventModifiersMetaKey; + if (modifiers & WebEvent::CapsLockKey) + wkModifiers |= kWKEventModifiersCapsLockKey; return wkModifiers; } @@ -342,7 +336,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) return kWKContextMenuItemTagDownloadImageToDisk; case WebCore::ContextMenuItemTagCopyImageToClipboard: return kWKContextMenuItemTagCopyImageToClipboard; -#if PLATFORM(EFL) || PLATFORM(GTK) +#if PLATFORM(GTK) case WebCore::ContextMenuItemTagCopyImageUrlToClipboard: return kWKContextMenuItemTagCopyImageUrlToClipboard; #endif @@ -362,7 +356,7 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) return kWKContextMenuItemTagCut; case WebCore::ContextMenuItemTagPaste: return kWKContextMenuItemTagPaste; -#if PLATFORM(EFL) || PLATFORM(GTK) +#if PLATFORM(GTK) case WebCore::ContextMenuItemTagSelectAll: return kWKContextMenuItemTagSelectAll; #endif @@ -452,10 +446,8 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) return kWKContextMenuItemTagPDFFacingPagesScrolling; case WebCore::ContextMenuItemTagDictationAlternative: return kWKContextMenuItemTagDictationAlternative; -#if ENABLE(INSPECTOR) case WebCore::ContextMenuItemTagInspectElement: return kWKContextMenuItemTagInspectElement; -#endif case WebCore::ContextMenuItemTagTextDirectionMenu: return kWKContextMenuItemTagTextDirectionMenu; case WebCore::ContextMenuItemTagTextDirectionDefault: @@ -478,11 +470,13 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) return kWKContextMenuItemTagToggleVideoFullscreen; case WebCore::ContextMenuItemTagEnterVideoFullscreen: return kWKContextMenuItemTagEnterVideoFullscreen; + case WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen: + return kWKContextMenuItemTagToggleVideoEnhancedFullscreen; case WebCore::ContextMenuItemTagMediaPlayPause: return kWKContextMenuItemTagMediaPlayPause; case WebCore::ContextMenuItemTagMediaMute: return kWKContextMenuItemTagMediaMute; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) case WebCore::ContextMenuItemTagCorrectSpellingAutomatically: return kWKContextMenuItemTagCorrectSpellingAutomatically; case WebCore::ContextMenuItemTagSubstitutionsMenu: @@ -510,11 +504,11 @@ inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) case WebCore::ContextMenuItemTagChangeBack: return kWKContextMenuItemTagChangeBack; #endif - case WebCore::ContextMenuItemTagOpenLinkInThisWindow: - return kWKContextMenuItemTagOpenLinkInThisWindow; + case WebCore::ContextMenuItemTagShareMenu: + return kWKContextMenuItemTagShareMenu; default: - if (action < WebCore::ContextMenuItemBaseApplicationTag) - LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore:: ContextMenuItemBaseApplicationTag); + if (action < WebCore::ContextMenuItemBaseApplicationTag && !(action >= WebCore::ContextMenuItemBaseCustomTag && action <= WebCore::ContextMenuItemLastCustomTag)) + LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore::ContextMenuItemBaseApplicationTag); return static_cast<WKContextMenuItemTag>(action); } } @@ -537,7 +531,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) case kWKContextMenuItemTagCopyImageToClipboard: return WebCore::ContextMenuItemTagCopyImageToClipboard; case kWKContextMenuItemTagOpenFrameInNewWindow: -#if PLATFORM(EFL) || PLATFORM(GTK) +#if PLATFORM(GTK) case kWKContextMenuItemTagCopyImageUrlToClipboard: return WebCore::ContextMenuItemTagCopyImageUrlToClipboard; #endif @@ -556,7 +550,7 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagCut; case kWKContextMenuItemTagPaste: return WebCore::ContextMenuItemTagPaste; -#if PLATFORM(EFL) || PLATFORM(GTK) +#if PLATFORM(GTK) case kWKContextMenuItemTagSelectAll: return WebCore::ContextMenuItemTagSelectAll; #endif @@ -646,10 +640,8 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagPDFFacingPagesScrolling; case kWKContextMenuItemTagDictationAlternative: return WebCore::ContextMenuItemTagDictationAlternative; -#if ENABLE(INSPECTOR) case kWKContextMenuItemTagInspectElement: return WebCore::ContextMenuItemTagInspectElement; -#endif case kWKContextMenuItemTagTextDirectionMenu: return WebCore::ContextMenuItemTagTextDirectionMenu; case kWKContextMenuItemTagTextDirectionDefault: @@ -672,11 +664,13 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagToggleVideoFullscreen; case kWKContextMenuItemTagEnterVideoFullscreen: return WebCore::ContextMenuItemTagEnterVideoFullscreen; + case kWKContextMenuItemTagToggleVideoEnhancedFullscreen: + return WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen; case kWKContextMenuItemTagMediaPlayPause: return WebCore::ContextMenuItemTagMediaPlayPause; case kWKContextMenuItemTagMediaMute: return WebCore::ContextMenuItemTagMediaMute; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) case kWKContextMenuItemTagCorrectSpellingAutomatically: return WebCore::ContextMenuItemTagCorrectSpellingAutomatically; case kWKContextMenuItemTagSubstitutionsMenu: @@ -703,11 +697,12 @@ inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) return WebCore::ContextMenuItemTagCapitalize; case kWKContextMenuItemTagChangeBack: return WebCore::ContextMenuItemTagChangeBack; + case kWKContextMenuItemTagShareMenu: + return WebCore::ContextMenuItemTagShareMenu; #endif case kWKContextMenuItemTagOpenLinkInThisWindow: - return WebCore::ContextMenuItemTagOpenLinkInThisWindow; default: - if (tag < kWKContextMenuItemBaseApplicationTag) + if (tag < kWKContextMenuItemBaseApplicationTag && !(tag >= WebCore::ContextMenuItemBaseCustomTag && tag <= WebCore::ContextMenuItemLastCustomTag)) LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag); return static_cast<WebCore::ContextMenuAction>(tag); } @@ -759,22 +754,22 @@ inline WKFrameNavigationType toAPI(WebCore::NavigationType type) WKFrameNavigationType wkType = kWKFrameNavigationTypeOther; switch (type) { - case WebCore::NavigationTypeLinkClicked: + case WebCore::NavigationType::LinkClicked: wkType = kWKFrameNavigationTypeLinkClicked; break; - case WebCore::NavigationTypeFormSubmitted: + case WebCore::NavigationType::FormSubmitted: wkType = kWKFrameNavigationTypeFormSubmitted; break; - case WebCore::NavigationTypeBackForward: + case WebCore::NavigationType::BackForward: wkType = kWKFrameNavigationTypeBackForward; break; - case WebCore::NavigationTypeReload: + case WebCore::NavigationType::Reload: wkType = kWKFrameNavigationTypeReload; break; - case WebCore::NavigationTypeFormResubmitted: + case WebCore::NavigationType::FormResubmitted: wkType = kWKFrameNavigationTypeFormResubmitted; break; - case WebCore::NavigationTypeOther: + case WebCore::NavigationType::Other: wkType = kWKFrameNavigationTypeOther; break; } @@ -804,6 +799,66 @@ inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type) return wkType; } +inline SameDocumentNavigationType toSameDocumentNavigationType(WKSameDocumentNavigationType wkType) +{ + SameDocumentNavigationType type = SameDocumentNavigationAnchorNavigation; + + switch (wkType) { + case kWKSameDocumentNavigationAnchorNavigation: + type = SameDocumentNavigationAnchorNavigation; + break; + case kWKSameDocumentNavigationSessionStatePush: + type = SameDocumentNavigationSessionStatePush; + break; + case kWKSameDocumentNavigationSessionStateReplace: + type = SameDocumentNavigationSessionStateReplace; + break; + case kWKSameDocumentNavigationSessionStatePop: + type = SameDocumentNavigationSessionStatePop; + break; + } + + return type; +} + +inline WKDiagnosticLoggingResultType toAPI(WebCore::DiagnosticLoggingResultType type) +{ + WKDiagnosticLoggingResultType wkType; + + switch (type) { + case WebCore::DiagnosticLoggingResultPass: + wkType = kWKDiagnosticLoggingResultPass; + break; + case WebCore::DiagnosticLoggingResultFail: + wkType = kWKDiagnosticLoggingResultFail; + break; + case WebCore::DiagnosticLoggingResultNoop: + wkType = kWKDiagnosticLoggingResultNoop; + break; + } + + return wkType; +} + +inline WebCore::DiagnosticLoggingResultType toDiagnosticLoggingResultType(WKDiagnosticLoggingResultType wkType) +{ + WebCore::DiagnosticLoggingResultType type; + + switch (wkType) { + case kWKDiagnosticLoggingResultPass: + type = WebCore::DiagnosticLoggingResultPass; + break; + case kWKDiagnosticLoggingResultFail: + type = WebCore::DiagnosticLoggingResultFail; + break; + case kWKDiagnosticLoggingResultNoop: + type = WebCore::DiagnosticLoggingResultNoop; + break; + } + + return type; +} + inline WKLayoutMilestones toWKLayoutMilestones(WebCore::LayoutMilestones milestones) { unsigned wkMilestones = 0; @@ -848,15 +903,15 @@ inline WebCore::PageVisibilityState toPageVisibilityState(WKPageVisibilityState { switch (wkPageVisibilityState) { case kWKPageVisibilityStateVisible: - return WebCore::PageVisibilityStateVisible; + return WebCore::PageVisibilityState::Visible; case kWKPageVisibilityStateHidden: - return WebCore::PageVisibilityStateHidden; + return WebCore::PageVisibilityState::Hidden; case kWKPageVisibilityStatePrerender: - return WebCore::PageVisibilityStatePrerender; + return WebCore::PageVisibilityState::Prerender; } ASSERT_NOT_REACHED(); - return WebCore::PageVisibilityStateVisible; + return WebCore::PageVisibilityState::Visible; } inline ImageOptions toImageOptions(WKImageOptions wkImageOptions) @@ -891,11 +946,17 @@ inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions) snapshotOptions |= SnapshotOptionsInViewCoordinates; if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle) snapshotOptions |= SnapshotOptionsPaintSelectionRectangle; + if (wkSnapshotOptions & kWKSnapshotOptionsForceBlackText) + snapshotOptions |= SnapshotOptionsForceBlackText; + if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText) + snapshotOptions |= SnapshotOptionsForceWhiteText; + if (wkSnapshotOptions & kWKSnapshotOptionsPrinting) + snapshotOptions |= SnapshotOptionsPrinting; return snapshotOptions; } -inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime) +inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(_WKUserScriptInjectionTime wkInjectedTime) { switch (wkInjectedTime) { case kWKInjectAtDocumentStart: @@ -908,6 +969,19 @@ inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptIn return WebCore::InjectAtDocumentStart; } +inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime) +{ + switch (injectedTime) { + case WebCore::InjectAtDocumentStart: + return kWKInjectAtDocumentStart; + case WebCore::InjectAtDocumentEnd: + return kWKInjectAtDocumentEnd; + } + + ASSERT_NOT_REACHED(); + return kWKInjectAtDocumentStart; +} + inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames) { switch (wkInjectedFrames) { diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp index 5f13b9ca7..650367045 100644 --- a/Source/WebKit2/Shared/API/c/WKString.cpp +++ b/Source/WebKit2/Shared/API/c/WKString.cpp @@ -28,6 +28,9 @@ #include "WKStringPrivate.h" #include "WKAPICast.h" +#include <JavaScriptCore/InitializeThreading.h> +#include <JavaScriptCore/JSStringRef.h> +#include <JavaScriptCore/OpaqueJSString.h> using namespace WebKit; @@ -38,58 +41,101 @@ WKTypeID WKStringGetTypeID() WKStringRef WKStringCreateWithUTF8CString(const char* string) { - RefPtr<API::String> apiString = API::String::createFromUTF8String(string); - return toAPI(apiString.release().leakRef()); + return toAPI(&API::String::create(WTF::String::fromUTF8(string)).leakRef()); } bool WKStringIsEmpty(WKStringRef stringRef) { - return toImpl(stringRef)->isEmpty(); + return toImpl(stringRef)->stringView().isEmpty(); } size_t WKStringGetLength(WKStringRef stringRef) { - return toImpl(stringRef)->length(); + return toImpl(stringRef)->stringView().length(); } size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength) { - COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar); - return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength)); + static_assert(sizeof(WKChar) == sizeof(UChar), "Size of WKChar must match size of UChar"); + + unsigned unsignedBufferLength = std::min<size_t>(bufferLength, std::numeric_limits<unsigned>::max()); + auto substring = toImpl(stringRef)->stringView().substring(0, unsignedBufferLength); + + substring.getCharactersWithUpconvert(reinterpret_cast<UChar*>(buffer)); + return substring.length(); } size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef) { - return toImpl(stringRef)->maximumUTF8CStringSize(); + return toImpl(stringRef)->stringView().length() * 3 + 1; +} + +enum StrictType { NonStrict = false, Strict = true }; + +template <StrictType strict> +size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize) +{ + if (!bufferSize) + return 0; + + auto stringView = toImpl(stringRef)->stringView(); + + char* p = buffer; + WTF::Unicode::ConversionResult result; + + if (stringView.is8Bit()) { + const LChar* characters = stringView.characters8(); + result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1); + } else { + const UChar* characters = stringView.characters16(); + result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict); + } + + if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted) + return 0; + + *p++ = '\0'; + return p - buffer; } size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize) { - return toImpl(stringRef)->getUTF8CString(buffer, bufferSize); + return WKStringGetUTF8CStringImpl<StrictType::Strict>(stringRef, buffer, bufferSize); +} + +size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize) +{ + return WKStringGetUTF8CStringImpl<StrictType::NonStrict>(stringRef, buffer, bufferSize); } bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef) { - return toImpl(aRef)->equal(toImpl(bRef)); + return toImpl(aRef)->stringView() == toImpl(bRef)->stringView(); } bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b) { - return toImpl(aRef)->equalToUTF8String(b); + // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII? + // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings. + return toImpl(aRef)->stringView() == WTF::String::fromUTF8(b); } bool WKStringIsEqualToUTF8CStringIgnoringCase(WKStringRef aRef, const char* b) { - return toImpl(aRef)->equalToUTF8StringIgnoringCase(b); + // FIXME: Should we add a fast path that avoids memory allocation when the string is all ASCII? + // FIXME: We can do even the general case more efficiently if we write a function in StringView that understands UTF-8 C strings. + return equalIgnoringASCIICase(toImpl(aRef)->stringView(), WTF::String::fromUTF8(b)); } WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef) { - RefPtr<API::String> apiString = API::String::create(jsStringRef); - return toAPI(apiString.release().leakRef()); + auto apiString = jsStringRef ? API::String::create(jsStringRef->string()) : API::String::createNull(); + + return toAPI(&apiString.leakRef()); } JSStringRef WKStringCopyJSString(WKStringRef stringRef) { - return toImpl(stringRef)->createJSString(); + JSC::initializeThreading(); + return OpaqueJSString::create(toImpl(stringRef)->string()).leakRef(); } diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h index dd5b877a7..4c6a20422 100644 --- a/Source/WebKit2/Shared/API/c/WKString.h +++ b/Source/WebKit2/Shared/API/c/WKString.h @@ -26,7 +26,7 @@ #ifndef WKString_h #define WKString_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #include <stddef.h> #ifndef __cplusplus @@ -55,6 +55,7 @@ WK_EXPORT size_t WKStringGetCharacters(WKStringRef string, WKChar* buffer, size_ WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string); WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize); +WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize); WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b); WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b); diff --git a/Source/WebKit2/Shared/API/c/WKStringPrivate.h b/Source/WebKit2/Shared/API/c/WKStringPrivate.h index f174f0166..74bc8a1f0 100644 --- a/Source/WebKit2/Shared/API/c/WKStringPrivate.h +++ b/Source/WebKit2/Shared/API/c/WKStringPrivate.h @@ -27,7 +27,7 @@ #define WKStringPrivate_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKType.cpp b/Source/WebKit2/Shared/API/c/WKType.cpp index bb165e4dd..fd20e6fff 100644 --- a/Source/WebKit2/Shared/API/c/WKType.cpp +++ b/Source/WebKit2/Shared/API/c/WKType.cpp @@ -33,16 +33,17 @@ using namespace WebKit; WKTypeID WKGetTypeID(WKTypeRef typeRef) { - return toAPI(static_cast<API::Object*>(const_cast<void*>(typeRef))->type()); + return toAPI(toImpl(typeRef)->type()); } WKTypeRef WKRetain(WKTypeRef typeRef) { - static_cast<API::Object*>(const_cast<void*>(typeRef))->ref(); + toImpl(typeRef)->ref(); + return typeRef; } void WKRelease(WKTypeRef typeRef) { - static_cast<API::Object*>(const_cast<void*>(typeRef))->deref(); + toImpl(typeRef)->deref(); } diff --git a/Source/WebKit2/Shared/API/c/WKType.h b/Source/WebKit2/Shared/API/c/WKType.h index 02f036c6f..e57ea379c 100644 --- a/Source/WebKit2/Shared/API/c/WKType.h +++ b/Source/WebKit2/Shared/API/c/WKType.h @@ -26,7 +26,7 @@ #ifndef WKType_h #define WKType_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKURL.cpp b/Source/WebKit2/Shared/API/c/WKURL.cpp index 80bbb10df..f1a1ea546 100644 --- a/Source/WebKit2/Shared/API/c/WKURL.cpp +++ b/Source/WebKit2/Shared/API/c/WKURL.cpp @@ -37,12 +37,12 @@ WKTypeID WKURLGetTypeID() WKURLRef WKURLCreateWithUTF8CString(const char* string) { - return toAPI(API::URL::create(String::fromUTF8(string)).leakRef()); + return toAPI(&API::URL::create(String::fromUTF8(string)).leakRef()); } WKURLRef WKURLCreateWithBaseURL(WKURLRef baseURL, const char* relative) { - return toAPI(API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef()); + return toAPI(&API::URL::create(toImpl(baseURL), String::fromUTF8(relative)).leakRef()); } WKStringRef WKURLCopyString(WKURLRef url) @@ -52,7 +52,7 @@ WKStringRef WKURLCopyString(WKURLRef url) bool WKURLIsEqual(WKURLRef a, WKURLRef b) { - return toImpl(a)->string() == toImpl(b)->string(); + return API::URL::equals(*toImpl(a), *toImpl(b)); } WKStringRef WKURLCopyHostName(WKURLRef url) diff --git a/Source/WebKit2/Shared/API/c/WKURL.h b/Source/WebKit2/Shared/API/c/WKURL.h index 2c0a02cc4..6bbc2b392 100644 --- a/Source/WebKit2/Shared/API/c/WKURL.h +++ b/Source/WebKit2/Shared/API/c/WKURL.h @@ -26,7 +26,7 @@ #ifndef WKURL_h #define WKURL_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp index edbf219dc..736e1f3e6 100644 --- a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp +++ b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp @@ -28,6 +28,7 @@ #include "APIURLRequest.h" #include "WKAPICast.h" +#include "WKData.h" #include <WebCore/URL.h> using namespace WebCore; @@ -40,7 +41,7 @@ WKTypeID WKURLRequestGetTypeID() WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef url) { - return toAPI(API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef()); + return toAPI(&API::URLRequest::create(URL(URL(), toImpl(url)->string())).leakRef()); } WKURLRef WKURLRequestCopyURL(WKURLRequestRef requestRef) @@ -58,6 +59,13 @@ WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef requestRef) return toCopiedAPI(toImpl(requestRef)->resourceRequest().httpMethod()); } +WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef requestRef, WKDataRef body) +{ + WebCore::ResourceRequest requestCopy(toImpl(requestRef)->resourceRequest()); + requestCopy.setHTTPBody(FormData::create(WKDataGetBytes(body), WKDataGetSize(body))); + return toAPI(&API::URLRequest::create(requestCopy).leakRef()); +} + void WKURLRequestSetDefaultTimeoutInterval(double timeoutInterval) { API::URLRequest::setDefaultTimeoutInterval(timeoutInterval); diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.h b/Source/WebKit2/Shared/API/c/WKURLRequest.h index 85df3d389..174180423 100644 --- a/Source/WebKit2/Shared/API/c/WKURLRequest.h +++ b/Source/WebKit2/Shared/API/c/WKURLRequest.h @@ -26,7 +26,7 @@ #ifndef WKURLRequest_h #define WKURLRequest_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { @@ -42,6 +42,8 @@ WK_EXPORT WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef); WK_EXPORT WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef); +WK_EXPORT WKURLRequestRef WKURLRequestCopySettingHTTPBody(WKURLRequestRef, WKDataRef); + WK_EXPORT void WKURLRequestSetDefaultTimeoutInterval(double); #ifdef __cplusplus diff --git a/Source/WebKit2/Shared/API/c/WKURLResponse.h b/Source/WebKit2/Shared/API/c/WKURLResponse.h index d56027ae9..9093b7791 100644 --- a/Source/WebKit2/Shared/API/c/WKURLResponse.h +++ b/Source/WebKit2/Shared/API/c/WKURLResponse.h @@ -26,7 +26,7 @@ #ifndef WKURLResponse_h #define WKURLResponse_h -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp index f6a204ab6..ceedc7696 100644 --- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp +++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp @@ -26,21 +26,20 @@ #include "config.h" #include "WKUserContentURLPattern.h" +#include "APIUserContentURLPattern.h" #include "WKAPICast.h" #include "WKString.h" -#include "WebUserContentURLPattern.h" using namespace WebKit; WKTypeID WKUserContentURLPatternGetTypeID() { - return toAPI(WebUserContentURLPattern::APIType); + return toAPI(API::UserContentURLPattern::APIType); } WKUserContentURLPatternRef WKUserContentURLPatternCreate(WKStringRef patternRef) { - RefPtr<WebUserContentURLPattern> userContentURLPattern = WebUserContentURLPattern::create(toImpl(patternRef)->string()); - return toAPI(userContentURLPattern.release().leakRef()); + return toAPI(&API::UserContentURLPattern::create(toImpl(patternRef)->string()).leakRef()); } WKStringRef WKUserContentURLPatternCopyHost(WKUserContentURLPatternRef urlPatternRef) diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h index 6e4c6c132..407729663 100644 --- a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h +++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h @@ -27,7 +27,7 @@ #define WKUserContentURLPattern_h #include <JavaScriptCore/JavaScript.h> -#include <WebKit2/WKBase.h> +#include <WebKit/WKBase.h> #ifdef __cplusplus extern "C" { diff --git a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h index f4d38b2c1..45d241072 100644 --- a/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h +++ b/Source/WebKit2/Shared/API/c/WKUserScriptInjectionTime.h @@ -26,10 +26,10 @@ #ifndef WKUserScriptInjectionTime_h #define WKUserScriptInjectionTime_h -enum WKUserScriptInjectionTime { +enum _WKUserScriptInjectionTime { kWKInjectAtDocumentStart, kWKInjectAtDocumentEnd }; -typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime; +typedef enum _WKUserScriptInjectionTime _WKUserScriptInjectionTime; #endif /* WKUserScriptInjectionTime_h */ diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp index afb49932b..bb2485f6a 100644 --- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp +++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp @@ -39,14 +39,14 @@ using namespace WebCore; cairo_surface_t* WKImageCreateCairoSurface(WKImageRef imageRef) { // We cannot pass a RefPtr through the API here, so we just leak the reference. - return toImpl(imageRef)->bitmap()->createCairoSurface().leakRef(); + return toImpl(imageRef)->bitmap().createCairoSurface().leakRef(); } WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options) { IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface)); - RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options)); - auto graphicsContext = webImage->bitmap()->createGraphicsContext(); + auto webImage = WebImage::create(imageSize, toImageOptions(options)); + auto graphicsContext = webImage->bitmap().createGraphicsContext(); cairo_t* cr = graphicsContext->platformContext()->cr(); cairo_set_source_surface(cr, surface, 0, 0); @@ -54,5 +54,5 @@ WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOption cairo_rectangle(cr, 0, 0, imageSize.width(), imageSize.height()); cairo_fill(cr); - return toAPI(webImage.release().leakRef()); + return toAPI(webImage.leakRef()); } diff --git a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h index 5c1e5413f..06749f6a2 100644 --- a/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h +++ b/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h @@ -27,8 +27,8 @@ #ifndef WKImageCairo_h #define WKImageCairo_h -#include <WebKit2/WKBase.h> -#include <WebKit2/WKImage.h> +#include <WebKit/WKBase.h> +#include <WebKit/WKImage.h> typedef struct _cairo_surface cairo_surface_t; |