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/WKSharedAPICast.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/Shared/API/c/WKSharedAPICast.h')
-rw-r--r-- | Source/WebKit2/Shared/API/c/WKSharedAPICast.h | 228 |
1 files changed, 151 insertions, 77 deletions
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) { |