diff options
Diffstat (limited to 'Source/WebKit2/Shared/API/c')
64 files changed, 3992 insertions, 0 deletions
diff --git a/Source/WebKit2/Shared/API/c/WKArray.cpp b/Source/WebKit2/Shared/API/c/WKArray.cpp new file mode 100644 index 0000000..9e20b7e --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKArray.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKArray.h" + +#include "ImmutableArray.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKArrayGetTypeID() +{ + return toAPI(ImmutableArray::APIType); +} + +WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues) +{ + RefPtr<ImmutableArray> array = ImmutableArray::create(reinterpret_cast<APIObject**>(const_cast<void**>(values)), numberOfValues); + return toAPI(array.release().releaseRef()); +} + +WKTypeRef WKArrayGetItemAtIndex(WKArrayRef arrayRef, size_t index) +{ + return toImpl(arrayRef)->at(index); +} + +size_t WKArrayGetSize(WKArrayRef arrayRef) +{ + return toImpl(arrayRef)->size(); +} diff --git a/Source/WebKit2/Shared/API/c/WKArray.h b/Source/WebKit2/Shared/API/c/WKArray.h new file mode 100644 index 0000000..da4560a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKArray.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKArray_h +#define WKArray_h + +#include <WebKit2/WKBase.h> + +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKArrayGetTypeID(); + +WK_EXPORT WKArrayRef WKArrayCreate(WKTypeRef* values, size_t numberOfValues); + +WK_EXPORT WKTypeRef WKArrayGetItemAtIndex(WKArrayRef array, size_t index); +WK_EXPORT size_t WKArrayGetSize(WKArrayRef array); + +#ifdef __cplusplus +} +#endif + +#endif // WKArray_h diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h new file mode 100644 index 0000000..f906f9f --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKBase.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBase_h +#define WKBase_h + +#include <stdint.h> + +#if defined(WIN32) || defined(_WIN32) +#include <WebKit2/WKBaseWin.h> +#endif + +/* WebKit2 shared types */ + +typedef uint32_t WKTypeID; +typedef const void* WKTypeRef; + +typedef const struct OpaqueWKArray* WKArrayRef; +typedef struct OpaqueWKArray* WKMutableArrayRef; + +typedef const struct OpaqueWKDictionary* WKDictionaryRef; +typedef struct OpaqueWKDictionary* WKMutableDictionaryRef; + +typedef const struct OpaqueWKBoolean* WKBooleanRef; +typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef; +typedef const struct OpaqueWKContextMenuItem* WKContextMenuItemRef; +typedef const struct OpaqueWKData* WKDataRef; +typedef const struct OpaqueWKDouble* WKDoubleRef; +typedef const struct OpaqueWKError* WKErrorRef; +typedef const struct OpaqueWKImage* WKImageRef; +typedef const struct OpaqueWKSecurityOrigin* WKSecurityOriginRef; +typedef const struct OpaqueWKSerializedScriptValue* WKSerializedScriptValueRef; +typedef const struct OpaqueWKString* WKStringRef; +typedef const struct OpaqueWKUInt64* WKUInt64Ref; +typedef const struct OpaqueWKURL* WKURLRef; +typedef const struct OpaqueWKURLRequest* WKURLRequestRef; +typedef const struct OpaqueWKURLResponse* WKURLResponseRef; +typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef; + +/* WebKit2 main API types */ + +typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeRef; +typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef; +typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef; +typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef; +typedef const struct OpaqueWKContext* WKContextRef; +typedef const struct OpaqueWKCredential* WKCredentialRef; +typedef const struct OpaqueWKDatabaseManager* WKDatabaseManagerRef; +typedef const struct OpaqueWKDownload* WKDownloadRef; +typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef; +typedef const struct OpaqueWKFrame* WKFrameRef; +typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef; +typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef; +typedef const struct OpaqueWKGeolocationPermissionRequest* WKGeolocationPermissionRequestRef; +typedef const struct OpaqueWKGeolocationPosition* WKGeolocationPositionRef; +typedef const struct OpaqueWKInspector* WKInspectorRef; +typedef const struct OpaqueWKNavigationData* WKNavigationDataRef; +typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef; +typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef; +typedef const struct OpaqueWKPage* WKPageRef; +typedef const struct OpaqueWKPageGroup* WKPageGroupRef; +typedef const struct OpaqueWKPreferences* WKPreferencesRef; +typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef; + +/* WebKit2 Bundle types */ + +typedef const struct OpaqueWKBundle* WKBundleRef; +typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef; +typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef; +typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef; +typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef; +typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef; +typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef; +typedef const struct OpaqueWKBundlePage* WKBundlePageRef; +typedef const struct OpaqueWKBundlePageGroup* WKBundlePageGroupRef; +typedef const struct OpaqueWKBundlePageOverlay* WKBundlePageOverlayRef; +typedef const struct OpaqueWKBundleRangeHandle* WKBundleRangeHandleRef; +typedef const struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef; + +/* These rules should stay the same as in JavaScriptCore/API/JSBase.h */ + +#undef WK_EXPORT +#if defined(WK_NO_EXPORT) +#define WK_EXPORT +#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) +#define WK_EXPORT __attribute__((visibility("default"))) +#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__) +#if BUILDING_WEBKIT +#define WK_EXPORT __declspec(dllexport) +#else +#define WK_EXPORT __declspec(dllimport) +#endif +#else /* !defined(WK_NO_EXPORT) */ +#define WK_EXPORT +#endif /* defined(WK_NO_EXPORT) */ + +#endif /* WKBase_h */ diff --git a/Source/WebKit2/Shared/API/c/WKCertificateInfo.cpp b/Source/WebKit2/Shared/API/c/WKCertificateInfo.cpp new file mode 100644 index 0000000..c5a3ad9 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKCertificateInfo.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKCertificateInfo.h" + +#include "WebCertificateInfo.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKCertificateInfoGetTypeID() +{ + return toAPI(WebCertificateInfo::APIType); +} diff --git a/Source/WebKit2/Shared/API/c/WKCertificateInfo.h b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h new file mode 100644 index 0000000..d4a2ed9 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKCertificateInfo.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKCertificateInfo_h +#define WKCertificateInfo_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKCertificateInfoGetTypeID(); + +#ifdef __cplusplus +} +#endif + +#endif /* WKCertificateInfo_h */ diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp new file mode 100644 index 0000000..a4eaa53 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKContextMenuItem.h" + +#include "MutableArray.h" +#include "WebContextMenuItem.h" +#include "WebContextMenuItemData.h" +#include "WKAPICast.h" +#include "WKContextMenuItemTypes.h" + +using namespace WebCore; +using namespace WebKit; + +WKTypeID WKContextMenuItemGetTypeID() +{ + return toAPI(WebContextMenuItem::APIType); +} + +WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled) +{ + return toAPI(WebContextMenuItem::create(WebContextMenuItemData(ActionType, toImpl(tag), toImpl(title)->string(), enabled, false)).leakRef()); +} + +WKContextMenuItemRef WKContextMenuItemCreateAsCheckableAction(WKContextMenuItemTag tag, WKStringRef title, bool enabled, bool checked) +{ + return toAPI(WebContextMenuItem::create(WebContextMenuItemData(CheckableActionType, toImpl(tag), toImpl(title)->string(), enabled, checked)).leakRef()); +} + +WKContextMenuItemRef WKContextMenuItemCreateAsSubmenu(WKStringRef title, bool enabled, WKArrayRef submenuItems) +{ + return toAPI(WebContextMenuItem::create(toImpl(title)->string(), enabled, toImpl(submenuItems)).leakRef()); +} + +WKContextMenuItemRef WKContextMenuItemSeparatorItem() +{ + return toAPI(WebContextMenuItem::separatorItem()); +} + +WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef itemRef) +{ + return toAPI(toImpl(itemRef)->data()->action()); +} + +WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef itemRef) +{ + return toAPI(toImpl(itemRef)->data()->type()); +} + +WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef itemRef) +{ + return toCopiedAPI(toImpl(itemRef)->data()->title().impl()); +} + +bool WKContextMenuItemGetEnabled(WKContextMenuItemRef itemRef) +{ + return toImpl(itemRef)->data()->enabled(); +} + +bool WKContextMenuItemGetChecked(WKContextMenuItemRef itemRef) +{ + return toImpl(itemRef)->data()->checked(); +} + +WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef itemRef) +{ + return toAPI(toImpl(itemRef)->submenuItemsAsImmutableArray().leakRef()); +} + +WKTypeRef WKContextMenuItemGetUserData(WKContextMenuItemRef itemRef) +{ + return toAPI(toImpl(itemRef)->userData()); +} + +void WKContextMenuItemSetUserData(WKContextMenuItemRef itemRef, WKTypeRef userDataRef) +{ + toImpl(itemRef)->setUserData(toImpl(userDataRef)); +} diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItem.h b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h new file mode 100644 index 0000000..9b97840 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItem.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKContextMenuItem_h +#define WKContextMenuItem_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKContextMenuItemTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKContextMenuItemGetTypeID(); + +WK_EXPORT WKContextMenuItemRef WKContextMenuItemCreateAsAction(WKContextMenuItemTag, WKStringRef title, bool enabled); +WK_EXPORT WKContextMenuItemRef WKContextMenuItemCreateAsCheckableAction(WKContextMenuItemTag, WKStringRef title, bool enabled, bool checked); +WK_EXPORT WKContextMenuItemRef WKContextMenuItemCreateAsSubmenu(WKStringRef title, bool enabled, WKArrayRef submenuItems); +WK_EXPORT WKContextMenuItemRef WKContextMenuItemSeparatorItem(); + +WK_EXPORT WKContextMenuItemTag WKContextMenuItemGetTag(WKContextMenuItemRef); +WK_EXPORT WKContextMenuItemType WKContextMenuItemGetType(WKContextMenuItemRef); +WK_EXPORT WKStringRef WKContextMenuItemCopyTitle(WKContextMenuItemRef); +WK_EXPORT bool WKContextMenuItemGetEnabled(WKContextMenuItemRef); +WK_EXPORT bool WKContextMenuItemGetChecked(WKContextMenuItemRef); +WK_EXPORT WKArrayRef WKContextMenuCopySubmenuItems(WKContextMenuItemRef); + +WK_EXPORT WKTypeRef WKContextMenuItemGetUserData(WKContextMenuItemRef); +WK_EXPORT void WKContextMenuItemSetUserData(WKContextMenuItemRef, WKTypeRef); + +#ifdef __cplusplus +} +#endif + +#endif /* WKContextMenuItem_h */ diff --git a/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h new file mode 100644 index 0000000..a3536d9 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKContextMenuItemTypes.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKContextMenuItemTypes_h +#define WKContextMenuItemTypes_h + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKContextMenuItemTagNoAction = 0, + kWKContextMenuItemTagOpenLinkInNewWindow, + kWKContextMenuItemTagDownloadLinkToDisk, + kWKContextMenuItemTagCopyLinkToClipboard, + kWKContextMenuItemTagOpenImageInNewWindow, + kWKContextMenuItemTagDownloadImageToDisk, + kWKContextMenuItemTagCopyImageToClipboard, + kWKContextMenuItemTagOpenFrameInNewWindow, + kWKContextMenuItemTagCopy, + kWKContextMenuItemTagGoBack, + kWKContextMenuItemTagGoForward, + kWKContextMenuItemTagStop, + kWKContextMenuItemTagReload, + kWKContextMenuItemTagCut, + kWKContextMenuItemTagPaste, + kWKContextMenuItemTagSpellingGuess, + kWKContextMenuItemTagNoGuessesFound, + kWKContextMenuItemTagIgnoreSpelling, + kWKContextMenuItemTagLearnSpelling, + kWKContextMenuItemTagOther, + kWKContextMenuItemTagSearchInSpotlight, + kWKContextMenuItemTagSearchWeb, + kWKContextMenuItemTagLookUpInDictionary, + kWKContextMenuItemTagOpenWithDefaultApplication, + kWKContextMenuItemTagPDFActualSize, + kWKContextMenuItemTagPDFZoomIn, + kWKContextMenuItemTagPDFZoomOut, + kWKContextMenuItemTagPDFAutoSize, + kWKContextMenuItemTagPDFSinglePage, + kWKContextMenuItemTagPDFFacingPages, + kWKContextMenuItemTagPDFContinuous, + kWKContextMenuItemTagPDFNextPage, + kWKContextMenuItemTagPDFPreviousPage, + kWKContextMenuItemTagOpenLink, + kWKContextMenuItemTagIgnoreGrammar, + kWKContextMenuItemTagSpellingMenu, + kWKContextMenuItemTagShowSpellingPanel, + kWKContextMenuItemTagCheckSpelling, + kWKContextMenuItemTagCheckSpellingWhileTyping, + kWKContextMenuItemTagCheckGrammarWithSpelling, + kWKContextMenuItemTagFontMenu, + kWKContextMenuItemTagShowFonts, + kWKContextMenuItemTagBold, + kWKContextMenuItemTagItalic, + kWKContextMenuItemTagUnderline, + kWKContextMenuItemTagOutline, + kWKContextMenuItemTagStyles, + kWKContextMenuItemTagShowColors, + kWKContextMenuItemTagSpeechMenu, + kWKContextMenuItemTagStartSpeaking, + kWKContextMenuItemTagStopSpeaking, + kWKContextMenuItemTagWritingDirectionMenu, + kWKContextMenuItemTagDefaultDirection, + kWKContextMenuItemTagLeftToRight, + kWKContextMenuItemTagRightToLeft, + kWKContextMenuItemTagPDFSinglePageScrolling, + kWKContextMenuItemTagPDFFacingPagesScrolling, + kWKContextMenuItemTagInspectElement, + kWKContextMenuItemTagTextDirectionMenu, + kWKContextMenuItemTagTextDirectionDefault, + kWKContextMenuItemTagTextDirectionLeftToRight, + kWKContextMenuItemTagTextDirectionRightToLeft, + kWKContextMenuItemTagCorrectSpellingAutomatically, + kWKContextMenuItemTagSubstitutionsMenu, + kWKContextMenuItemTagShowSubstitutions, + kWKContextMenuItemTagSmartCopyPaste, + kWKContextMenuItemTagSmartQuotes, + kWKContextMenuItemTagSmartDashes, + kWKContextMenuItemTagSmartLinks, + kWKContextMenuItemTagTextReplacement, + kWKContextMenuItemTagTransformationsMenu, + kWKContextMenuItemTagMakeUpperCase, + kWKContextMenuItemTagMakeLowerCase, + kWKContextMenuItemTagCapitalize, + kWKContextMenuItemTagChangeBack, + kWKContextMenuItemTagOpenMediaInNewWindow, + kWKContextMenuItemTagCopyMediaLinkToClipboard, + kWKContextMenuItemTagToggleMediaControls, + kWKContextMenuItemTagToggleMediaLoop, + kWKContextMenuItemTagEnterVideoFullscreen, + kWKContextMenuItemTagMediaPlayPause, + kWKContextMenuItemTagMediaMute, + kWKContextMenuItemBaseApplicationTag = 10000 +}; +typedef uint32_t WKContextMenuItemTag; + +enum { + kWKContextMenuItemTypeAction, + kWKContextMenuItemTypeCheckableAction, + kWKContextMenuItemTypeSeparator, + kWKContextMenuItemTypeSubmenu +}; +typedef uint32_t WKContextMenuItemType; + +#ifdef __cplusplus +} +#endif + +#endif /* WKContextMenuItemTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKData.cpp b/Source/WebKit2/Shared/API/c/WKData.cpp new file mode 100644 index 0000000..aefe795 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKData.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKData.h" + +#include "WebData.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKDataGetTypeID() +{ + return toAPI(WebData::APIType); +} + +WKDataRef WKDataCreate(const unsigned char* bytes, size_t size) +{ + RefPtr<WebData> data = WebData::create(bytes, size); + return toAPI(data.release().releaseRef()); +} + +const unsigned char* WKDataGetBytes(WKDataRef dataRef) +{ + return toImpl(dataRef)->bytes(); +} + +size_t WKDataGetSize(WKDataRef dataRef) +{ + return toImpl(dataRef)->size(); +} diff --git a/Source/WebKit2/Shared/API/c/WKData.h b/Source/WebKit2/Shared/API/c/WKData.h new file mode 100644 index 0000000..a647ee4 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKData.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKData_h +#define WKData_h + +#include <WebKit2/WKBase.h> + +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKDataGetTypeID(); + +WK_EXPORT WKDataRef WKDataCreate(const unsigned char* bytes, size_t size); + +WK_EXPORT const unsigned char* WKDataGetBytes(WKDataRef data); +WK_EXPORT size_t WKDataGetSize(WKDataRef data); + +#ifdef __cplusplus +} +#endif + +#endif // WKData_h diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.cpp b/Source/WebKit2/Shared/API/c/WKDictionary.cpp new file mode 100644 index 0000000..6b336bf --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKDictionary.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKDictionary.h" + +#include "ImmutableArray.h" +#include "ImmutableDictionary.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKDictionaryGetTypeID() +{ + return toAPI(ImmutableDictionary::APIType); +} + +WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionaryRef, WKStringRef key) +{ + return toImpl(dictionaryRef)->get(toImpl(key)->string()); +} + +size_t WKDictionaryGetSize(WKDictionaryRef dictionaryRef) +{ + return toImpl(dictionaryRef)->size(); +} + +WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionaryRef) +{ + RefPtr<ImmutableArray> keys = toImpl(dictionaryRef)->keys(); + return toAPI(keys.release().releaseRef()); +} diff --git a/Source/WebKit2/Shared/API/c/WKDictionary.h b/Source/WebKit2/Shared/API/c/WKDictionary.h new file mode 100644 index 0000000..1c39400 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKDictionary.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKDictionary_h +#define WKDictionary_h + +#include <WebKit2/WKBase.h> + +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKDictionaryGetTypeID(); + +WK_EXPORT WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionary, WKStringRef key); +WK_EXPORT size_t WKDictionaryGetSize(WKDictionaryRef dictionary); + +WK_EXPORT WKArrayRef WKDictionaryCopyKeys(WKDictionaryRef dictionary); + +#ifdef __cplusplus +} +#endif + +#endif /* WKDictionary_h */ diff --git a/Source/WebKit2/Shared/API/c/WKError.cpp b/Source/WebKit2/Shared/API/c/WKError.cpp new file mode 100644 index 0000000..395cf3a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKError.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKError.h" + +#include "WebError.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKErrorGetTypeID() +{ + return toAPI(WebError::APIType); +} + +WKStringRef WKErrorCopyWKErrorDomain() +{ + return toCopiedAPI(WebError::webKitErrorDomain()); +} + +WKStringRef WKErrorCopyDomain(WKErrorRef errorRef) +{ + return toCopiedAPI(toImpl(errorRef)->domain()); +} + +int WKErrorGetErrorCode(WKErrorRef errorRef) +{ + return toImpl(errorRef)->errorCode(); +} + +WKURLRef WKErrorCopyFailingURL(WKErrorRef errorRef) +{ + return toCopiedURLAPI(toImpl(errorRef)->failingURL()); +} + +WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef errorRef) +{ + return toCopiedAPI(toImpl(errorRef)->localizedDescription()); +} diff --git a/Source/WebKit2/Shared/API/c/WKError.h b/Source/WebKit2/Shared/API/c/WKError.h new file mode 100644 index 0000000..6f1f4f3 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKError.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKError_h +#define WKError_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKErrorCodeCannotShowMIMEType = 100, + kWKErrorCodeCannotShowURL = 101, + kWKErrorCodeFrameLoadInterruptedByPolicyChange = 102, + kWKErrorCodeCannotUseRestrictedPort = 103, + kWKErrorCodeCannotFindPlugIn = 200, + kWKErrorCodeCannotLoadPlugIn = 201, + kWKErrorCodeJavaUnavailable = 202, + kWKErrorCodePlugInCancelledConnection = 203, + kWKErrorCodePlugInWillHandleLoad = 204, +}; +typedef uint32_t WKErrorCode; + +WK_EXPORT WKTypeID WKErrorGetTypeID(); + +WK_EXPORT WKStringRef WKErrorCopyWKErrorDomain(); + +WK_EXPORT WKStringRef WKErrorCopyDomain(WKErrorRef error); +WK_EXPORT int WKErrorGetErrorCode(WKErrorRef error); +WK_EXPORT WKURLRef WKErrorCopyFailingURL(WKErrorRef error); +WK_EXPORT WKStringRef WKErrorCopyLocalizedDescription(WKErrorRef error); + +#ifdef __cplusplus +} +#endif + +#endif // WKError_h diff --git a/Source/WebKit2/Shared/API/c/WKEvent.h b/Source/WebKit2/Shared/API/c/WKEvent.h new file mode 100644 index 0000000..b15c47a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKEvent.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKEvent_h +#define WKEvent_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKEventModifiersShiftKey = 1 << 0, + kWKEventModifiersControlKey = 1 << 1, + kWKEventModifiersAltKey = 1 << 2, + kWKEventModifiersMetaKey = 1 << 3 +}; +typedef uint32_t WKEventModifiers; + +enum { + kWKEventMouseButtonNoButton = -1, + kWKEventMouseButtonLeftButton = 0, + kWKEventMouseButtonMiddleButton = 1, + kWKEventMouseButtonRightButton = 2, +}; +typedef int32_t WKEventMouseButton; + +#ifdef __cplusplus +} +#endif + +#endif /* WKEvent_h */ diff --git a/Source/WebKit2/Shared/API/c/WKFindOptions.h b/Source/WebKit2/Shared/API/c/WKFindOptions.h new file mode 100644 index 0000000..3330035 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKFindOptions.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKFindOptions_h +#define WKFindOptions_h + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKFindOptionsCaseInsensitive = 1 << 0, + kWKFindOptionsAtWordStarts = 1 << 1, + kWKFindOptionsTreatMedialCapitalAsWordStart = 1 << 2, + kWKFindOptionsBackwards = 1 << 3, + kWKFindOptionsWrapAround = 1 << 4, + kWKFindOptionsShowOverlay = 1 << 5, + kWKFindOptionsShowFindIndicator = 1 << 6 +}; +typedef uint32_t WKFindOptions; + +#ifdef __cplusplus +} +#endif + +#endif // WKFindOptions_h diff --git a/Source/WebKit2/Shared/API/c/WKGeometry.h b/Source/WebKit2/Shared/API/c/WKGeometry.h new file mode 100644 index 0000000..70ef969 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKGeometry.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKGeometry_h +#define WKGeometry_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct WKPoint { + double x; + double y; +}; +typedef struct WKPoint WKPoint; + +struct WKSize { + double width; + double height; +}; +typedef struct WKSize WKSize; + +struct WKRect { + WKPoint origin; + WKSize size; +}; +typedef struct WKRect WKRect; + +#ifdef __cplusplus +} +#endif + +#endif /* WKGeometry_h */ diff --git a/Source/WebKit2/Shared/API/c/WKImage.cpp b/Source/WebKit2/Shared/API/c/WKImage.cpp new file mode 100644 index 0000000..0bf21df --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKImage.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKImage.h" + +#include "WKSharedAPICast.h" +#include "WebImage.h" + +using namespace WebKit; + +WKTypeID WKImageGetTypeID() +{ + return toAPI(WebImage::APIType); +} + +WKImageRef WKImageCreate(WKSize size, WKImageOptions options) +{ + RefPtr<WebImage> webImage = WebImage::create(toIntSize(size), toImageOptions(options)); + return toAPI(webImage.release().leakRef()); +} + +WKSize WKImageGetSize(WKImageRef imageRef) +{ + return toAPI(toImpl(imageRef)->size()); +} diff --git a/Source/WebKit2/Shared/API/c/WKImage.h b/Source/WebKit2/Shared/API/c/WKImage.h new file mode 100644 index 0000000..e3a2f9e --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKImage.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKImage_h +#define WKImage_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKGeometry.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKImageOptionsShareable = 1 << 0, +}; +typedef uint32_t WKImageOptions; + +WK_EXPORT WKTypeID WKImageGetTypeID(); + +WK_EXPORT WKImageRef WKImageCreate(WKSize size, WKImageOptions options); + +WK_EXPORT WKSize WKImageGetSize(WKImageRef image); + +#ifdef __cplusplus +} +#endif + +#endif /* WKImage_h */ diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.cpp b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp new file mode 100644 index 0000000..56bd72f --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKMutableArray.h" + +#include "MutableArray.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKMutableArrayRef WKMutableArrayCreate() +{ + RefPtr<MutableArray> array = MutableArray::create(); + return toAPI(array.release().releaseRef()); +} + +bool WKArrayIsMutable(WKArrayRef arrayRef) +{ + return toImpl(arrayRef)->isMutable(); +} + +void WKArrayAppendItem(WKMutableArrayRef arrayRef, WKTypeRef itemRef) +{ + toImpl(arrayRef)->append(toImpl(itemRef)); +} + +void WKArrayRemoveItemAtIndex(WKMutableArrayRef arrayRef, size_t index) +{ + toImpl(arrayRef)->removeItemAtIndex(index); +} + diff --git a/Source/WebKit2/Shared/API/c/WKMutableArray.h b/Source/WebKit2/Shared/API/c/WKMutableArray.h new file mode 100644 index 0000000..a0dc06a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKMutableArray.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKMutableArray_h +#define WKMutableArray_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKMutableArrayRef WKMutableArrayCreate(); + +WK_EXPORT bool WKArrayIsMutable(WKArrayRef array); + +WK_EXPORT void WKArrayAppendItem(WKMutableArrayRef array, WKTypeRef item); + +WK_EXPORT void WKArrayRemoveItemAtIndex(WKMutableArrayRef array, size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* WKMutableArray_h */ diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp new file mode 100644 index 0000000..df9f5a7 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKMutableDictionary.h" + +#include "MutableDictionary.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKMutableDictionaryRef WKMutableDictionaryCreate() +{ + RefPtr<MutableDictionary> dictionary = MutableDictionary::create(); + return toAPI(dictionary.release().releaseRef()); +} + +bool WKDictionaryIsMutable(WKDictionaryRef dictionaryRef) +{ + return toImpl(dictionaryRef)->isMutable(); +} + +bool WKDictionaryAddItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) +{ + return toImpl(dictionaryRef)->add(toImpl(keyRef)->string(), toImpl(itemRef)); +} + +bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef, WKTypeRef itemRef) +{ + return toImpl(dictionaryRef)->set(toImpl(keyRef)->string(), toImpl(itemRef)); +} diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h new file mode 100644 index 0000000..467c1d4 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKMutableDictionary_h +#define WKMutableDictionary_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKMutableDictionaryRef WKMutableDictionaryCreate(); + +WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary); + +WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); +WK_EXPORT bool WKDictionarySetItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); + +#ifdef __cplusplus +} +#endif + +#endif /* WKMutableDictionary_h */ diff --git a/Source/WebKit2/Shared/API/c/WKNumber.cpp b/Source/WebKit2/Shared/API/c/WKNumber.cpp new file mode 100644 index 0000000..4a413e1 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKNumber.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKNumber.h" + +#include "WKAPICast.h" +#include "WebNumber.h" + +using namespace WebKit; + +WKTypeID WKBooleanGetTypeID() +{ + return toAPI(WebBoolean::APIType); +} + +WKBooleanRef WKBooleanCreate(bool value) +{ + RefPtr<WebBoolean> booleanObject = WebBoolean::create(value); + return toAPI(booleanObject.release().releaseRef()); +} + +bool WKBooleanGetValue(WKBooleanRef booleanRef) +{ + return toImpl(booleanRef)->value(); +} + +WKTypeID WKDoubleGetTypeID() +{ + return toAPI(WebDouble::APIType); +} + +WKDoubleRef WKDoubleCreate(double value) +{ + RefPtr<WebDouble> doubleObject = WebDouble::create(value); + return toAPI(doubleObject.release().releaseRef()); +} + +double WKDoubleGetValue(WKDoubleRef doubleRef) +{ + return toImpl(doubleRef)->value(); +} + +WKTypeID WKUInt64GetTypeID() +{ + return toAPI(WebUInt64::APIType); +} + +WKUInt64Ref WKUInt64Create(uint64_t value) +{ + RefPtr<WebUInt64> uint64Object = WebUInt64::create(value); + return toAPI(uint64Object.release().releaseRef()); +} + +uint64_t WKUInt64GetValue(WKUInt64Ref uint64Ref) +{ + return toImpl(uint64Ref)->value(); +} diff --git a/Source/WebKit2/Shared/API/c/WKNumber.h b/Source/WebKit2/Shared/API/c/WKNumber.h new file mode 100644 index 0000000..1b07bef --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKNumber.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKNumber_h +#define WKNumber_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* WKBoolean */ +WK_EXPORT WKTypeID WKBooleanGetTypeID(); +WK_EXPORT WKBooleanRef WKBooleanCreate(bool value); +WK_EXPORT bool WKBooleanGetValue(WKBooleanRef booleanRef); + +/* WKDouble */ +WK_EXPORT WKTypeID WKDoubleGetTypeID(); +WK_EXPORT WKDoubleRef WKDoubleCreate(double value); +WK_EXPORT double WKDoubleGetValue(WKDoubleRef doubleRef); + +/* WKUInt64 */ +WK_EXPORT WKTypeID WKUInt64GetTypeID(); +WK_EXPORT WKUInt64Ref WKUInt64Create(uint64_t value); +WK_EXPORT uint64_t WKUInt64GetValue(WKUInt64Ref doubleRef); + +#ifdef __cplusplus +} +#endif + +#endif /* WKNumber_h */ diff --git a/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h b/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h new file mode 100644 index 0000000..ec8ae99 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKPageLoadTypes.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKPageLoadTypes_h +#define WKPageLoadTypes_h + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKFrameNavigationTypeLinkClicked = 0, + kWKFrameNavigationTypeFormSubmitted = 1, + kWKFrameNavigationTypeBackForward = 2, + kWKFrameNavigationTypeReload = 3, + kWKFrameNavigationTypeFormResubmitted = 4, + kWKFrameNavigationTypeOther = 5 +}; +typedef uint32_t WKFrameNavigationType; + +enum { + kWKSameDocumentNavigationAnchorNavigation, + kWKSameDocumentNavigationSessionStatePush, + kWKSameDocumentNavigationSessionStateReplace, + kWKSameDocumentNavigationSessionStatePop +}; +typedef uint32_t WKSameDocumentNavigationType; + +#ifdef __cplusplus +} +#endif + +#endif /* WKPageLoadTypes_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp b/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp new file mode 100644 index 0000000..761cbf8 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSecurityOrigin.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKSecurityOrigin.h" + +#include "WKAPICast.h" +#include "WebSecurityOrigin.h" + +using namespace WebKit; + +WKTypeID WKSecurityOriginGetTypeID() +{ + return toAPI(WebSecurityOrigin::APIType); +} + +WKSecurityOriginRef WKSecurityOriginCreateFromIdentifier(WKStringRef identifier) +{ + RefPtr<WebSecurityOrigin> securityOrigin = WebSecurityOrigin::create(toImpl(identifier)->string()); + return toAPI(securityOrigin.release().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()); +} + +WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(toImpl(securityOrigin)->protocol()); +} + +WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin) +{ + return toCopiedAPI(toImpl(securityOrigin)->host()); +} + +unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin) +{ + return toImpl(securityOrigin)->port(); +} diff --git a/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h b/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h new file mode 100644 index 0000000..9bffdd7 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSecurityOrigin.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKSecurityOrigin_h +#define WKSecurityOrigin_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKSecurityOriginGetTypeID(); + +WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreateFromIdentifier(WKStringRef identifier); +WK_EXPORT WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef host, int port); + +WK_EXPORT WKStringRef WKSecurityOriginGetProtocol(WKSecurityOriginRef securityOrigin); +WK_EXPORT WKStringRef WKSecurityOriginGetHost(WKSecurityOriginRef securityOrigin); +WK_EXPORT unsigned short WKSecurityOriginGetPort(WKSecurityOriginRef securityOrigin); + +#ifdef __cplusplus +} +#endif + +#endif /* WKSecurityOrigin_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp new file mode 100644 index 0000000..4c642f0 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKSerializedScriptValue.h" +#include "WKSerializedScriptValuePrivate.h" + +#include "WKAPICast.h" +#include "WebSerializedScriptValue.h" + +using namespace WebKit; + +WKTypeID WKSerializedScriptValueGetTypeID() +{ + return toAPI(WebSerializedScriptValue::APIType); +} + +WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception) +{ + RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(context, value, exception); + return toAPI(serializedValue.release().leakRef()); +} + +WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void* internalRepresentation) +{ + RefPtr<WebSerializedScriptValue> serializedValue = WebSerializedScriptValue::create(static_cast<WebCore::SerializedScriptValue*>(internalRepresentation)); + return toAPI(serializedValue.release().leakRef()); +} + +JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValueRef, JSContextRef contextRef, JSValueRef* exception) +{ + return toImpl(scriptValueRef)->deserialize(contextRef, exception); +} + +void* WKSerializedScriptValueGetInternalRepresentation(WKSerializedScriptValueRef scriptValueRef) +{ + return toImpl(scriptValueRef)->internalRepresentation(); +} diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h new file mode 100644 index 0000000..95fc048 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValue.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKSerializedScriptValue_h +#define WKSerializedScriptValue_h + +#include <JavaScriptCore/JavaScript.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKSerializedScriptValueGetTypeID(); + +WK_EXPORT WKSerializedScriptValueRef WKSerializedScriptValueCreate(JSContextRef context, JSValueRef value, JSValueRef* exception); +WK_EXPORT JSValueRef WKSerializedScriptValueDeserialize(WKSerializedScriptValueRef scriptValue, JSContextRef constext, JSValueRef* exception); + +#ifdef __cplusplus +} +#endif + +#endif /* WKSerializedScriptValue_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h new file mode 100644 index 0000000..27e1849 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSerializedScriptValuePrivate.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKSerializedScriptValuePrivate_h +#define WKSerializedScriptValuePrivate_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT void* WKSerializedScriptValueGetInternalRepresentation(WKSerializedScriptValueRef scriptValueRef); +WK_EXPORT WKSerializedScriptValueRef WKSerializedScriptValueCreateWithInternalRepresentation(void*); + +#ifdef __cplusplus +} +#endif + +#endif /* WKSerializedScriptValuePrivate_h */ diff --git a/Source/WebKit2/Shared/API/c/WKSharedAPICast.h b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h new file mode 100644 index 0000000..6dc80e8 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKSharedAPICast.h @@ -0,0 +1,735 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKSharedAPICast_h +#define WKSharedAPICast_h + +#include "ImageOptions.h" +#include "SameDocumentNavigationType.h" +#include "WKBase.h" +#include "WKContextMenuItemTypes.h" +#include "WKEvent.h" +#include "WKFindOptions.h" +#include "WKGeometry.h" +#include "WKImage.h" +#include "WKPageLoadTypes.h" +#include "WebError.h" +#include "WebEvent.h" +#include "WebFindOptions.h" +#include "WebNumber.h" +#include "WebString.h" +#include "WebURL.h" +#include <WebCore/ContextMenuItem.h> +#include <WebCore/FloatRect.h> +#include <WebCore/FrameLoaderTypes.h> +#include <WebCore/IntRect.h> +#include <wtf/TypeTraits.h> + +namespace WebKit { + +class ImmutableArray; +class ImmutableDictionary; +class MutableArray; +class MutableDictionary; +class WebCertificateInfo; +class WebContextMenuItem; +class WebData; +class WebImage; +class WebSecurityOrigin; +class WebSerializedScriptValue; +class WebURLRequest; +class WebURLResponse; +class WebUserContentURLPattern; + +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; }; + +WK_ADD_API_MAPPING(WKArrayRef, ImmutableArray) +WK_ADD_API_MAPPING(WKBooleanRef, WebBoolean) +WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo) +WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem) +WK_ADD_API_MAPPING(WKDataRef, WebData) +WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary) +WK_ADD_API_MAPPING(WKDoubleRef, WebDouble) +WK_ADD_API_MAPPING(WKErrorRef, WebError) +WK_ADD_API_MAPPING(WKImageRef, WebImage) +WK_ADD_API_MAPPING(WKMutableArrayRef, MutableArray) +WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary) +WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin) +WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue) +WK_ADD_API_MAPPING(WKStringRef, WebString) +WK_ADD_API_MAPPING(WKTypeRef, APIObject) +WK_ADD_API_MAPPING(WKUInt64Ref, WebUInt64) +WK_ADD_API_MAPPING(WKURLRef, WebURL) +WK_ADD_API_MAPPING(WKURLRequestRef, WebURLRequest) +WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse) +WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern) + +template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType> +class ProxyingRefPtr { +public: + ProxyingRefPtr(PassRefPtr<ImplType> impl) + : m_impl(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* -> ImmutableArray* + + typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType; + typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType; + + return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t)); +} + +template<typename T> +inline typename ImplTypeInfo<T>::APIType toAPI(T t) +{ + return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t); +} + +/* Special cases. */ + +inline ProxyingRefPtr<WebString> toAPI(StringImpl* string) +{ + return ProxyingRefPtr<WebString>(WebString::create(string)); +} + +inline WKStringRef toCopiedAPI(const String& string) +{ + RefPtr<WebString> webString = WebString::create(string); + return toAPI(webString.release().releaseRef()); +} + +inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string) +{ + if (!string) + ProxyingRefPtr<WebURL>(0); + return ProxyingRefPtr<WebURL>(WebURL::create(String(string))); +} + +inline WKURLRef toCopiedURLAPI(const String& string) +{ + if (!string) + return 0; + RefPtr<WebURL> webURL = WebURL::create(string); + return toAPI(webURL.release().releaseRef()); +} + +inline String toWTFString(WKStringRef stringRef) +{ + if (!stringRef) + return String(); + return toImpl(stringRef)->string(); +} + +inline String toWTFString(WKURLRef urlRef) +{ + if (!urlRef) + return String(); + return toImpl(urlRef)->string(); +} + +inline ProxyingRefPtr<WebError> toAPI(const WebCore::ResourceError& error) +{ + return ProxyingRefPtr<WebError>(WebError::create(error)); +} + +/* Geometry conversions */ + +inline WebCore::FloatRect toFloatRect(const WKRect& wkRect) +{ + return WebCore::FloatRect(static_cast<float>(wkRect.origin.x), static_cast<float>(wkRect.origin.y), + static_cast<float>(wkRect.size.width), static_cast<float>(wkRect.size.height)); +} + +inline WebCore::IntSize toIntSize(const WKSize& wkSize) +{ + return WebCore::IntSize(static_cast<int>(wkSize.width), static_cast<int>(wkSize.height)); +} + +inline WebCore::IntPoint toIntPoint(const WKPoint& wkPoint) +{ + return WebCore::IntPoint(static_cast<int>(wkPoint.x), static_cast<int>(wkPoint.y)); +} + +inline WebCore::IntRect toIntRect(const WKRect& wkRect) +{ + return WebCore::IntRect(static_cast<int>(wkRect.origin.x), static_cast<int>(wkRect.origin.y), + static_cast<int>(wkRect.size.width), static_cast<int>(wkRect.size.height)); +} + +inline WKRect toAPI(const WebCore::FloatRect& rect) +{ + WKRect wkRect; + wkRect.origin.x = rect.x(); + wkRect.origin.y = rect.y(); + wkRect.size.width = rect.width(); + wkRect.size.height = rect.height(); + return wkRect; +} + +inline WKRect toAPI(const WebCore::IntRect& rect) +{ + WKRect wkRect; + wkRect.origin.x = rect.x(); + wkRect.origin.y = rect.y(); + wkRect.size.width = rect.width(); + wkRect.size.height = rect.height(); + return wkRect; +} + +inline WKSize toAPI(const WebCore::IntSize& size) +{ + WKSize wkSize; + wkSize.width = size.width(); + wkSize.height = size.height(); + return wkSize; +} + +inline WKPoint toAPI(const WebCore::IntPoint& point) +{ + WKPoint wkPoint; + wkPoint.x = point.x(); + wkPoint.y = point.y(); + return wkPoint; +} + +/* Enum conversions */ + +inline WKTypeID toAPI(APIObject::Type type) +{ + return static_cast<WKTypeID>(type); +} + +inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers) +{ + WKEventModifiers wkModifiers = 0; + if (modifiers & WebEvent::ShiftKey) + wkModifiers |= kWKEventModifiersShiftKey; + if (modifiers & WebEvent::ControlKey) + wkModifiers |= kWKEventModifiersControlKey; + if (modifiers & WebEvent::AltKey) + wkModifiers |= kWKEventModifiersAltKey; + if (modifiers & WebEvent::MetaKey) + wkModifiers |= kWKEventModifiersMetaKey; + return wkModifiers; +} + +inline WKEventMouseButton toAPI(WebMouseEvent::Button mouseButton) +{ + WKEventMouseButton wkMouseButton = kWKEventMouseButtonNoButton; + + switch (mouseButton) { + case WebMouseEvent::NoButton: + wkMouseButton = kWKEventMouseButtonNoButton; + break; + case WebMouseEvent::LeftButton: + wkMouseButton = kWKEventMouseButtonLeftButton; + break; + case WebMouseEvent::MiddleButton: + wkMouseButton = kWKEventMouseButtonMiddleButton; + break; + case WebMouseEvent::RightButton: + wkMouseButton = kWKEventMouseButtonRightButton; + break; + } + + return wkMouseButton; +} + +inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action) +{ + switch (action) { + case WebCore::ContextMenuItemTagNoAction: + return kWKContextMenuItemTagNoAction; + case WebCore::ContextMenuItemTagOpenLinkInNewWindow: + return kWKContextMenuItemTagOpenLinkInNewWindow; + case WebCore::ContextMenuItemTagDownloadLinkToDisk: + return kWKContextMenuItemTagDownloadLinkToDisk; + case WebCore::ContextMenuItemTagCopyLinkToClipboard: + return kWKContextMenuItemTagCopyLinkToClipboard; + case WebCore::ContextMenuItemTagOpenImageInNewWindow: + return kWKContextMenuItemTagOpenImageInNewWindow; + case WebCore::ContextMenuItemTagDownloadImageToDisk: + return kWKContextMenuItemTagDownloadImageToDisk; + case WebCore::ContextMenuItemTagCopyImageToClipboard: + return kWKContextMenuItemTagCopyImageToClipboard; + case WebCore::ContextMenuItemTagOpenFrameInNewWindow: + return kWKContextMenuItemTagOpenFrameInNewWindow; + case WebCore::ContextMenuItemTagCopy: + return kWKContextMenuItemTagCopy; + case WebCore::ContextMenuItemTagGoBack: + return kWKContextMenuItemTagGoBack; + case WebCore::ContextMenuItemTagGoForward: + return kWKContextMenuItemTagGoForward; + case WebCore::ContextMenuItemTagStop: + return kWKContextMenuItemTagStop; + case WebCore::ContextMenuItemTagReload: + return kWKContextMenuItemTagReload; + case WebCore::ContextMenuItemTagCut: + return kWKContextMenuItemTagCut; + case WebCore::ContextMenuItemTagPaste: + return kWKContextMenuItemTagPaste; + case WebCore::ContextMenuItemTagSpellingGuess: + return kWKContextMenuItemTagSpellingGuess; + case WebCore::ContextMenuItemTagNoGuessesFound: + return kWKContextMenuItemTagNoGuessesFound; + case WebCore::ContextMenuItemTagIgnoreSpelling: + return kWKContextMenuItemTagIgnoreSpelling; + case WebCore::ContextMenuItemTagLearnSpelling: + return kWKContextMenuItemTagLearnSpelling; + case WebCore::ContextMenuItemTagOther: + return kWKContextMenuItemTagOther; + case WebCore::ContextMenuItemTagSearchInSpotlight: + return kWKContextMenuItemTagSearchInSpotlight; + case WebCore::ContextMenuItemTagSearchWeb: + return kWKContextMenuItemTagSearchWeb; + case WebCore::ContextMenuItemTagLookUpInDictionary: + return kWKContextMenuItemTagLookUpInDictionary; + case WebCore::ContextMenuItemTagOpenWithDefaultApplication: + return kWKContextMenuItemTagOpenWithDefaultApplication; + case WebCore::ContextMenuItemPDFActualSize: + return kWKContextMenuItemTagPDFActualSize; + case WebCore::ContextMenuItemPDFZoomIn: + return kWKContextMenuItemTagPDFZoomIn; + case WebCore::ContextMenuItemPDFZoomOut: + return kWKContextMenuItemTagPDFZoomOut; + case WebCore::ContextMenuItemPDFAutoSize: + return kWKContextMenuItemTagPDFAutoSize; + case WebCore::ContextMenuItemPDFSinglePage: + return kWKContextMenuItemTagPDFSinglePage; + case WebCore::ContextMenuItemPDFFacingPages: + return kWKContextMenuItemTagPDFFacingPages; + case WebCore::ContextMenuItemPDFContinuous: + return kWKContextMenuItemTagPDFContinuous; + case WebCore::ContextMenuItemPDFNextPage: + return kWKContextMenuItemTagPDFNextPage; + case WebCore::ContextMenuItemPDFPreviousPage: + return kWKContextMenuItemTagPDFPreviousPage; + case WebCore::ContextMenuItemTagOpenLink: + return kWKContextMenuItemTagOpenLink; + case WebCore::ContextMenuItemTagIgnoreGrammar: + return kWKContextMenuItemTagIgnoreGrammar; + case WebCore::ContextMenuItemTagSpellingMenu: + return kWKContextMenuItemTagSpellingMenu; + case WebCore::ContextMenuItemTagShowSpellingPanel: + return kWKContextMenuItemTagShowSpellingPanel; + case WebCore::ContextMenuItemTagCheckSpelling: + return kWKContextMenuItemTagCheckSpelling; + case WebCore::ContextMenuItemTagCheckSpellingWhileTyping: + return kWKContextMenuItemTagCheckSpellingWhileTyping; + case WebCore::ContextMenuItemTagCheckGrammarWithSpelling: + return kWKContextMenuItemTagCheckGrammarWithSpelling; + case WebCore::ContextMenuItemTagFontMenu: + return kWKContextMenuItemTagFontMenu; + case WebCore::ContextMenuItemTagShowFonts: + return kWKContextMenuItemTagShowFonts; + case WebCore::ContextMenuItemTagBold: + return kWKContextMenuItemTagBold; + case WebCore::ContextMenuItemTagItalic: + return kWKContextMenuItemTagItalic; + case WebCore::ContextMenuItemTagUnderline: + return kWKContextMenuItemTagUnderline; + case WebCore::ContextMenuItemTagOutline: + return kWKContextMenuItemTagOutline; + case WebCore::ContextMenuItemTagStyles: + return kWKContextMenuItemTagStyles; + case WebCore::ContextMenuItemTagShowColors: + return kWKContextMenuItemTagShowColors; + case WebCore::ContextMenuItemTagSpeechMenu: + return kWKContextMenuItemTagSpeechMenu; + case WebCore::ContextMenuItemTagStartSpeaking: + return kWKContextMenuItemTagStartSpeaking; + case WebCore::ContextMenuItemTagStopSpeaking: + return kWKContextMenuItemTagStopSpeaking; + case WebCore::ContextMenuItemTagWritingDirectionMenu: + return kWKContextMenuItemTagWritingDirectionMenu; + case WebCore::ContextMenuItemTagDefaultDirection: + return kWKContextMenuItemTagDefaultDirection; + case WebCore::ContextMenuItemTagLeftToRight: + return kWKContextMenuItemTagLeftToRight; + case WebCore::ContextMenuItemTagRightToLeft: + return kWKContextMenuItemTagRightToLeft; + case WebCore::ContextMenuItemTagPDFSinglePageScrolling: + return kWKContextMenuItemTagPDFSinglePageScrolling; + case WebCore::ContextMenuItemTagPDFFacingPagesScrolling: + return kWKContextMenuItemTagPDFFacingPagesScrolling; +#if ENABLE(INSPECTOR) + case WebCore::ContextMenuItemTagInspectElement: + return kWKContextMenuItemTagInspectElement; +#endif + case WebCore::ContextMenuItemTagTextDirectionMenu: + return kWKContextMenuItemTagTextDirectionMenu; + case WebCore::ContextMenuItemTagTextDirectionDefault: + return kWKContextMenuItemTagTextDirectionDefault; + case WebCore::ContextMenuItemTagTextDirectionLeftToRight: + return kWKContextMenuItemTagTextDirectionLeftToRight; + case WebCore::ContextMenuItemTagTextDirectionRightToLeft: + return kWKContextMenuItemTagTextDirectionRightToLeft; + case WebCore::ContextMenuItemTagOpenMediaInNewWindow: + return kWKContextMenuItemTagOpenMediaInNewWindow; + case WebCore::ContextMenuItemTagCopyMediaLinkToClipboard: + return kWKContextMenuItemTagCopyMediaLinkToClipboard; + case WebCore::ContextMenuItemTagToggleMediaControls: + return kWKContextMenuItemTagToggleMediaControls; + case WebCore::ContextMenuItemTagToggleMediaLoop: + return kWKContextMenuItemTagToggleMediaLoop; + case WebCore::ContextMenuItemTagEnterVideoFullscreen: + return kWKContextMenuItemTagEnterVideoFullscreen; + case WebCore::ContextMenuItemTagMediaPlayPause: + return kWKContextMenuItemTagMediaPlayPause; + case WebCore::ContextMenuItemTagMediaMute: + return kWKContextMenuItemTagMediaMute; +#if PLATFORM(MAC) + case WebCore::ContextMenuItemTagCorrectSpellingAutomatically: + return kWKContextMenuItemTagCorrectSpellingAutomatically; + case WebCore::ContextMenuItemTagSubstitutionsMenu: + return kWKContextMenuItemTagSubstitutionsMenu; + case WebCore::ContextMenuItemTagShowSubstitutions: + return kWKContextMenuItemTagShowSubstitutions; + case WebCore::ContextMenuItemTagSmartCopyPaste: + return kWKContextMenuItemTagSmartCopyPaste; + case WebCore::ContextMenuItemTagSmartQuotes: + return kWKContextMenuItemTagSmartQuotes; + case WebCore::ContextMenuItemTagSmartDashes: + return kWKContextMenuItemTagSmartDashes; + case WebCore::ContextMenuItemTagSmartLinks: + return kWKContextMenuItemTagSmartLinks; + case WebCore::ContextMenuItemTagTextReplacement: + return kWKContextMenuItemTagTextReplacement; + case WebCore::ContextMenuItemTagTransformationsMenu: + return kWKContextMenuItemTagTransformationsMenu; + case WebCore::ContextMenuItemTagMakeUpperCase: + return kWKContextMenuItemTagMakeUpperCase; + case WebCore::ContextMenuItemTagMakeLowerCase: + return kWKContextMenuItemTagMakeLowerCase; + case WebCore::ContextMenuItemTagCapitalize: + return kWKContextMenuItemTagCapitalize; + case WebCore::ContextMenuItemTagChangeBack: + return kWKContextMenuItemTagChangeBack; +#endif + 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); + return static_cast<WKContextMenuItemTag>(action); + } +} + +inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag) +{ + switch (tag) { + case kWKContextMenuItemTagNoAction: + return WebCore::ContextMenuItemTagNoAction; + case kWKContextMenuItemTagOpenLinkInNewWindow: + return WebCore::ContextMenuItemTagOpenLinkInNewWindow; + case kWKContextMenuItemTagDownloadLinkToDisk: + return WebCore::ContextMenuItemTagDownloadLinkToDisk; + case kWKContextMenuItemTagCopyLinkToClipboard: + return WebCore::ContextMenuItemTagCopyLinkToClipboard; + case kWKContextMenuItemTagOpenImageInNewWindow: + return WebCore::ContextMenuItemTagOpenImageInNewWindow; + case kWKContextMenuItemTagDownloadImageToDisk: + return WebCore::ContextMenuItemTagDownloadImageToDisk; + case kWKContextMenuItemTagCopyImageToClipboard: + return WebCore::ContextMenuItemTagCopyImageToClipboard; + case kWKContextMenuItemTagOpenFrameInNewWindow: + return WebCore::ContextMenuItemTagOpenFrameInNewWindow; + case kWKContextMenuItemTagCopy: + return WebCore::ContextMenuItemTagCopy; + case kWKContextMenuItemTagGoBack: + return WebCore::ContextMenuItemTagGoBack; + case kWKContextMenuItemTagGoForward: + return WebCore::ContextMenuItemTagGoForward; + case kWKContextMenuItemTagStop: + return WebCore::ContextMenuItemTagStop; + case kWKContextMenuItemTagReload: + return WebCore::ContextMenuItemTagReload; + case kWKContextMenuItemTagCut: + return WebCore::ContextMenuItemTagCut; + case kWKContextMenuItemTagPaste: + return WebCore::ContextMenuItemTagPaste; + case kWKContextMenuItemTagSpellingGuess: + return WebCore::ContextMenuItemTagSpellingGuess; + case kWKContextMenuItemTagNoGuessesFound: + return WebCore::ContextMenuItemTagNoGuessesFound; + case kWKContextMenuItemTagIgnoreSpelling: + return WebCore::ContextMenuItemTagIgnoreSpelling; + case kWKContextMenuItemTagLearnSpelling: + return WebCore::ContextMenuItemTagLearnSpelling; + case kWKContextMenuItemTagOther: + return WebCore::ContextMenuItemTagOther; + case kWKContextMenuItemTagSearchInSpotlight: + return WebCore::ContextMenuItemTagSearchInSpotlight; + case kWKContextMenuItemTagSearchWeb: + return WebCore::ContextMenuItemTagSearchWeb; + case kWKContextMenuItemTagLookUpInDictionary: + return WebCore::ContextMenuItemTagLookUpInDictionary; + case kWKContextMenuItemTagOpenWithDefaultApplication: + return WebCore::ContextMenuItemTagOpenWithDefaultApplication; + case kWKContextMenuItemTagPDFActualSize: + return WebCore::ContextMenuItemPDFActualSize; + case kWKContextMenuItemTagPDFZoomIn: + return WebCore::ContextMenuItemPDFZoomIn; + case kWKContextMenuItemTagPDFZoomOut: + return WebCore::ContextMenuItemPDFZoomOut; + case kWKContextMenuItemTagPDFAutoSize: + return WebCore::ContextMenuItemPDFAutoSize; + case kWKContextMenuItemTagPDFSinglePage: + return WebCore::ContextMenuItemPDFSinglePage; + case kWKContextMenuItemTagPDFFacingPages: + return WebCore::ContextMenuItemPDFFacingPages; + case kWKContextMenuItemTagPDFContinuous: + return WebCore::ContextMenuItemPDFContinuous; + case kWKContextMenuItemTagPDFNextPage: + return WebCore::ContextMenuItemPDFNextPage; + case kWKContextMenuItemTagPDFPreviousPage: + return WebCore::ContextMenuItemPDFPreviousPage; + case kWKContextMenuItemTagOpenLink: + return WebCore::ContextMenuItemTagOpenLink; + case kWKContextMenuItemTagIgnoreGrammar: + return WebCore::ContextMenuItemTagIgnoreGrammar; + case kWKContextMenuItemTagSpellingMenu: + return WebCore::ContextMenuItemTagSpellingMenu; + case kWKContextMenuItemTagShowSpellingPanel: + return WebCore::ContextMenuItemTagShowSpellingPanel; + case kWKContextMenuItemTagCheckSpelling: + return WebCore::ContextMenuItemTagCheckSpelling; + case kWKContextMenuItemTagCheckSpellingWhileTyping: + return WebCore::ContextMenuItemTagCheckSpellingWhileTyping; + case kWKContextMenuItemTagCheckGrammarWithSpelling: + return WebCore::ContextMenuItemTagCheckGrammarWithSpelling; + case kWKContextMenuItemTagFontMenu: + return WebCore::ContextMenuItemTagFontMenu; + case kWKContextMenuItemTagShowFonts: + return WebCore::ContextMenuItemTagShowFonts; + case kWKContextMenuItemTagBold: + return WebCore::ContextMenuItemTagBold; + case kWKContextMenuItemTagItalic: + return WebCore::ContextMenuItemTagItalic; + case kWKContextMenuItemTagUnderline: + return WebCore::ContextMenuItemTagUnderline; + case kWKContextMenuItemTagOutline: + return WebCore::ContextMenuItemTagOutline; + case kWKContextMenuItemTagStyles: + return WebCore::ContextMenuItemTagStyles; + case kWKContextMenuItemTagShowColors: + return WebCore::ContextMenuItemTagShowColors; + case kWKContextMenuItemTagSpeechMenu: + return WebCore::ContextMenuItemTagSpeechMenu; + case kWKContextMenuItemTagStartSpeaking: + return WebCore::ContextMenuItemTagStartSpeaking; + case kWKContextMenuItemTagStopSpeaking: + return WebCore::ContextMenuItemTagStopSpeaking; + case kWKContextMenuItemTagWritingDirectionMenu: + return WebCore::ContextMenuItemTagWritingDirectionMenu; + case kWKContextMenuItemTagDefaultDirection: + return WebCore::ContextMenuItemTagDefaultDirection; + case kWKContextMenuItemTagLeftToRight: + return WebCore::ContextMenuItemTagLeftToRight; + case kWKContextMenuItemTagRightToLeft: + return WebCore::ContextMenuItemTagRightToLeft; + case kWKContextMenuItemTagPDFSinglePageScrolling: + return WebCore::ContextMenuItemTagPDFSinglePageScrolling; + case kWKContextMenuItemTagPDFFacingPagesScrolling: + return WebCore::ContextMenuItemTagPDFFacingPagesScrolling; +#if ENABLE(INSPECTOR) + case kWKContextMenuItemTagInspectElement: + return WebCore::ContextMenuItemTagInspectElement; +#endif + case kWKContextMenuItemTagTextDirectionMenu: + return WebCore::ContextMenuItemTagTextDirectionMenu; + case kWKContextMenuItemTagTextDirectionDefault: + return WebCore::ContextMenuItemTagTextDirectionDefault; + case kWKContextMenuItemTagTextDirectionLeftToRight: + return WebCore::ContextMenuItemTagTextDirectionLeftToRight; + case kWKContextMenuItemTagTextDirectionRightToLeft: + return WebCore::ContextMenuItemTagTextDirectionRightToLeft; + case kWKContextMenuItemTagOpenMediaInNewWindow: + return WebCore::ContextMenuItemTagOpenMediaInNewWindow; + case kWKContextMenuItemTagCopyMediaLinkToClipboard: + return WebCore::ContextMenuItemTagCopyMediaLinkToClipboard; + case kWKContextMenuItemTagToggleMediaControls: + return WebCore::ContextMenuItemTagToggleMediaControls; + case kWKContextMenuItemTagToggleMediaLoop: + return WebCore::ContextMenuItemTagToggleMediaLoop; + case kWKContextMenuItemTagEnterVideoFullscreen: + return WebCore::ContextMenuItemTagEnterVideoFullscreen; + case kWKContextMenuItemTagMediaPlayPause: + return WebCore::ContextMenuItemTagMediaPlayPause; + case kWKContextMenuItemTagMediaMute: + return WebCore::ContextMenuItemTagMediaMute; +#if PLATFORM(MAC) + case kWKContextMenuItemTagCorrectSpellingAutomatically: + return WebCore::ContextMenuItemTagCorrectSpellingAutomatically; + case kWKContextMenuItemTagSubstitutionsMenu: + return WebCore::ContextMenuItemTagSubstitutionsMenu; + case kWKContextMenuItemTagShowSubstitutions: + return WebCore::ContextMenuItemTagShowSubstitutions; + case kWKContextMenuItemTagSmartCopyPaste: + return WebCore::ContextMenuItemTagSmartCopyPaste; + case kWKContextMenuItemTagSmartQuotes: + return WebCore::ContextMenuItemTagSmartQuotes; + case kWKContextMenuItemTagSmartDashes: + return WebCore::ContextMenuItemTagSmartDashes; + case kWKContextMenuItemTagSmartLinks: + return WebCore::ContextMenuItemTagSmartLinks; + case kWKContextMenuItemTagTextReplacement: + return WebCore::ContextMenuItemTagTextReplacement; + case kWKContextMenuItemTagTransformationsMenu: + return WebCore::ContextMenuItemTagTransformationsMenu; + case kWKContextMenuItemTagMakeUpperCase: + return WebCore::ContextMenuItemTagMakeUpperCase; + case kWKContextMenuItemTagMakeLowerCase: + return WebCore::ContextMenuItemTagMakeLowerCase; + case kWKContextMenuItemTagCapitalize: + return WebCore::ContextMenuItemTagCapitalize; + case kWKContextMenuItemTagChangeBack: + return WebCore::ContextMenuItemTagChangeBack; +#endif + default: + if (tag < kWKContextMenuItemBaseApplicationTag) + 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); + } +} + +inline WKContextMenuItemType toAPI(WebCore::ContextMenuItemType type) +{ + switch(type) { + case WebCore::ActionType: + return kWKContextMenuItemTypeAction; + case WebCore::CheckableActionType: + return kWKContextMenuItemTypeCheckableAction; + case WebCore::SeparatorType: + return kWKContextMenuItemTypeSeparator; + case WebCore::SubmenuType: + return kWKContextMenuItemTypeSubmenu; + default: + ASSERT_NOT_REACHED(); + return kWKContextMenuItemTypeAction; + } +} + +inline FindOptions toFindOptions(WKFindOptions wkFindOptions) +{ + unsigned findOptions = 0; + + if (wkFindOptions & kWKFindOptionsCaseInsensitive) + findOptions |= FindOptionsCaseInsensitive; + if (wkFindOptions & kWKFindOptionsAtWordStarts) + findOptions |= FindOptionsAtWordStarts; + if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart) + findOptions |= FindOptionsTreatMedialCapitalAsWordStart; + if (wkFindOptions & kWKFindOptionsBackwards) + findOptions |= FindOptionsBackwards; + if (wkFindOptions & kWKFindOptionsWrapAround) + findOptions |= FindOptionsWrapAround; + if (wkFindOptions & kWKFindOptionsShowOverlay) + findOptions |= FindOptionsShowOverlay; + if (wkFindOptions & kWKFindOptionsShowFindIndicator) + findOptions |= FindOptionsShowFindIndicator; + + return static_cast<FindOptions>(findOptions); +} + +inline WKFrameNavigationType toAPI(WebCore::NavigationType type) +{ + WKFrameNavigationType wkType = kWKFrameNavigationTypeOther; + + switch (type) { + case WebCore::NavigationTypeLinkClicked: + wkType = kWKFrameNavigationTypeLinkClicked; + break; + case WebCore::NavigationTypeFormSubmitted: + wkType = kWKFrameNavigationTypeFormSubmitted; + break; + case WebCore::NavigationTypeBackForward: + wkType = kWKFrameNavigationTypeBackForward; + break; + case WebCore::NavigationTypeReload: + wkType = kWKFrameNavigationTypeReload; + break; + case WebCore::NavigationTypeFormResubmitted: + wkType = kWKFrameNavigationTypeFormResubmitted; + break; + case WebCore::NavigationTypeOther: + wkType = kWKFrameNavigationTypeOther; + break; + } + + return wkType; +} + +inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type) +{ + WKFrameNavigationType wkType = kWKSameDocumentNavigationAnchorNavigation; + + switch (type) { + case SameDocumentNavigationAnchorNavigation: + wkType = kWKSameDocumentNavigationAnchorNavigation; + break; + case SameDocumentNavigationSessionStatePush: + wkType = kWKSameDocumentNavigationSessionStatePush; + break; + case SameDocumentNavigationSessionStateReplace: + wkType = kWKSameDocumentNavigationSessionStateReplace; + break; + case SameDocumentNavigationSessionStatePop: + wkType = kWKSameDocumentNavigationSessionStatePop; + break; + } + + return wkType; +} + +inline ImageOptions toImageOptions(WKImageOptions wkImageOptions) +{ + unsigned imageOptions = 0; + + if (wkImageOptions & kWKImageOptionsShareable) + imageOptions |= ImageOptionsShareable; + + return static_cast<ImageOptions>(imageOptions); +} + +} // namespace WebKit + +#endif // WKSharedAPICast_h diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp new file mode 100644 index 0000000..14f40fa --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKString.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKString.h" +#include "WKStringPrivate.h" + +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKStringGetTypeID() +{ + return toAPI(WebString::APIType); +} + +WKStringRef WKStringCreateWithUTF8CString(const char* string) +{ + RefPtr<WebString> webString = WebString::createFromUTF8String(string); + return toAPI(webString.release().leakRef()); +} + +bool WKStringIsEmpty(WKStringRef stringRef) +{ + return toImpl(stringRef)->isEmpty(); +} + +size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef) +{ + return toImpl(stringRef)->maximumUTF8CStringSize(); +} + +size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize) +{ + return toImpl(stringRef)->getUTF8CString(buffer, bufferSize); +} + +bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef) +{ + return toImpl(aRef)->equal(toImpl(bRef)); +} + +bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b) +{ + return toImpl(aRef)->equalToUTF8String(b); +} + +WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef) +{ + RefPtr<WebString> webString = WebString::create(jsStringRef); + return toAPI(webString.release().leakRef()); +} + +JSStringRef WKStringCopyJSString(WKStringRef stringRef) +{ + return toImpl(stringRef)->createJSString(); +} diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h new file mode 100644 index 0000000..e79839e --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKString.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKString_h +#define WKString_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKStringGetTypeID(); + +WK_EXPORT WKStringRef WKStringCreateWithUTF8CString(const char* string); + +WK_EXPORT bool WKStringIsEmpty(WKStringRef string); + +WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string); +WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize); + +WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b); +WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b); + +#ifdef __cplusplus +} +#endif + +#endif /* WKString_h */ diff --git a/Source/WebKit2/Shared/API/c/WKStringPrivate.h b/Source/WebKit2/Shared/API/c/WKStringPrivate.h new file mode 100644 index 0000000..f174f01 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKStringPrivate.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKStringPrivate_h +#define WKStringPrivate_h + +#include <JavaScriptCore/JavaScript.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKStringRef WKStringCreateWithJSString(JSStringRef jsString); +WK_EXPORT JSStringRef WKStringCopyJSString(WKStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif /* WKStringPrivate_h */ diff --git a/Source/WebKit2/Shared/API/c/WKType.cpp b/Source/WebKit2/Shared/API/c/WKType.cpp new file mode 100644 index 0000000..a499737 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKType.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKType.h" + +#include "APIObject.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKGetTypeID(WKTypeRef typeRef) +{ + return toAPI(static_cast<APIObject*>(const_cast<void*>(typeRef))->type()); +} + +WKTypeRef WKRetain(WKTypeRef typeRef) +{ + static_cast<APIObject*>(const_cast<void*>(typeRef))->ref(); + return typeRef; +} + +void WKRelease(WKTypeRef typeRef) +{ + static_cast<APIObject*>(const_cast<void*>(typeRef))->deref(); +} diff --git a/Source/WebKit2/Shared/API/c/WKType.h b/Source/WebKit2/Shared/API/c/WKType.h new file mode 100644 index 0000000..02f036c --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKType.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKType_h +#define WKType_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKGetTypeID(WKTypeRef type); + +WK_EXPORT WKTypeRef WKRetain(WKTypeRef type); +WK_EXPORT void WKRelease(WKTypeRef type); + +#ifdef __cplusplus +} +#endif + +#endif /* WKType_h */ diff --git a/Source/WebKit2/Shared/API/c/WKURL.cpp b/Source/WebKit2/Shared/API/c/WKURL.cpp new file mode 100644 index 0000000..0060b34 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURL.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURL.h" + +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKURLGetTypeID() +{ + return toAPI(WebURL::APIType); +} + +WKURLRef WKURLCreateWithUTF8CString(const char* string) +{ + return toAPI(WebURL::create(String::fromUTF8(string)).leakRef()); +} + +WKStringRef WKURLCopyString(WKURLRef url) +{ + return toCopiedAPI(toImpl(url)->string()); +} + +bool WKURLIsEqual(WKURLRef a, WKURLRef b) +{ + return toImpl(a)->string() == toImpl(b)->string(); +} diff --git a/Source/WebKit2/Shared/API/c/WKURL.h b/Source/WebKit2/Shared/API/c/WKURL.h new file mode 100644 index 0000000..738bce5 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURL.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURL_h +#define WKURL_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKURLGetTypeID(); + +WK_EXPORT WKURLRef WKURLCreateWithUTF8CString(const char* string); + +WK_EXPORT WKStringRef WKURLCopyString(WKURLRef URL); + +WK_EXPORT bool WKURLIsEqual(WKURLRef a, WKURLRef b); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURL_h */ diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.cpp b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp new file mode 100644 index 0000000..6ea66ec --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURLRequest.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLRequest.h" + +#include "WKAPICast.h" +#include "WebURLRequest.h" +#include <WebCore/KURL.h> + +using namespace WebCore; +using namespace WebKit; + +WKTypeID WKURLRequestGetTypeID() +{ + return toAPI(WebURLRequest::APIType); +} + +WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef url) +{ + return toAPI(WebURLRequest::create(KURL(KURL(), toImpl(url)->string())).leakRef()); +} diff --git a/Source/WebKit2/Shared/API/c/WKURLRequest.h b/Source/WebKit2/Shared/API/c/WKURLRequest.h new file mode 100644 index 0000000..d78968d --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURLRequest.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLRequest_h +#define WKURLRequest_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKURLRequestGetTypeID(); + +WK_EXPORT WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLRequest_h */ diff --git a/Source/WebKit2/Shared/API/c/WKURLResponse.cpp b/Source/WebKit2/Shared/API/c/WKURLResponse.cpp new file mode 100644 index 0000000..12537bd --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURLResponse.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLResponse.h" + +#include "WKAPICast.h" +#include "WebURLResponse.h" + +using namespace WebKit; + +WKTypeID WKURLResponseGetTypeID() +{ + return toAPI(WebURLResponse::APIType); +} + diff --git a/Source/WebKit2/Shared/API/c/WKURLResponse.h b/Source/WebKit2/Shared/API/c/WKURLResponse.h new file mode 100644 index 0000000..62e51f4 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKURLResponse.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLResponse_h +#define WKURLResponse_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKURLResponseGetTypeID(); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLResponse_h */ diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp new file mode 100644 index 0000000..3eb24c4 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKUserContentURLPattern.h" + +#include "WKAPICast.h" +#include "WebUserContentURLPattern.h" + +using namespace WebKit; + +WKTypeID WKUserContentURLPatternGetTypeID() +{ + return toAPI(WebUserContentURLPattern::APIType); +} + +WKUserContentURLPatternRef WKUserContentURLPatternCreate(WKStringRef patternRef) +{ + RefPtr<WebUserContentURLPattern> userContentURLPattern = WebUserContentURLPattern::create(toImpl(patternRef)->string()); + return toAPI(userContentURLPattern.release().leakRef()); +} + +bool WKUserContentURLPatternMatchesURL(WKUserContentURLPatternRef urlPatternRef, WKURLRef urlRef) +{ + return toImpl(urlPatternRef)->matchesURL(toWTFString(urlRef)); +} diff --git a/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h new file mode 100644 index 0000000..80c9bab --- /dev/null +++ b/Source/WebKit2/Shared/API/c/WKUserContentURLPattern.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKUserContentURLPattern_h +#define WKUserContentURLPattern_h + +#include <JavaScriptCore/JavaScript.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKUserContentURLPatternGetTypeID(); + +WK_EXPORT WKUserContentURLPatternRef WKUserContentURLPatternCreate(WKStringRef patternRef); + +WK_EXPORT bool WKUserContentURLPatternMatchesURL(WKUserContentURLPatternRef urlPatternRef, WKURLRef urlRef); + +#ifdef __cplusplus +} +#endif + +#endif /* WKUserContentURLPattern_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKStringCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKStringCF.cpp new file mode 100644 index 0000000..b89110e --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKStringCF.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKStringCF.h" + +#include "WKAPICast.h" +#include <wtf/text/WTFString.h> + +using namespace WebCore; +using namespace WebKit; + +WKStringRef WKStringCreateWithCFString(CFStringRef cfString) +{ + String string(cfString); + return toCopiedAPI(string); +} + +CFStringRef WKStringCopyCFString(CFAllocatorRef allocatorRef, WKStringRef stringRef) +{ + ASSERT(!toImpl(stringRef)->string().isNull()); + + // NOTE: This does not use StringImpl::createCFString() since that function + // expects to be called on the thread running WebCore. + return CFStringCreateWithCharacters(allocatorRef, reinterpret_cast<const UniChar*>(toImpl(stringRef)->string().characters()), toImpl(stringRef)->string().length()); +} diff --git a/Source/WebKit2/Shared/API/c/cf/WKStringCF.h b/Source/WebKit2/Shared/API/c/cf/WKStringCF.h new file mode 100644 index 0000000..f946853 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKStringCF.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKStringCF_h +#define WKStringCF_h + +#include <CoreFoundation/CoreFoundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKStringRef WKStringCreateWithCFString(CFStringRef string); +WK_EXPORT CFStringRef WKStringCopyCFString(CFAllocatorRef alloc, WKStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif /* WKStringCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp new file mode 100644 index 0000000..a4627ce --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLCF.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLCF.h" + +#include "WKAPICast.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/RetainPtr.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; +using namespace WebKit; + +WKURLRef WKURLCreateWithCFURL(CFURLRef cfURL) +{ + String urlString(CFURLGetString(cfURL)); + return toCopiedURLAPI(urlString); +} + +CFURLRef WKURLCopyCFURL(CFAllocatorRef allocatorRef, WKURLRef URLRef) +{ + ASSERT(!toImpl(URLRef)->string().isNull()); + + // We first create a CString and then create the CFURL from it. This will ensure that the CFURL is stored in + // UTF-8 which uses less memory and is what WebKit clients might expect. + + // This pattern of using UTF-8 and then falling back to Latin1 on failure matches KURL::createCFString with the + // major differnce being that KURL does not do a UTF-8 conversion and instead chops off the high bits of the UTF-16 + // character sequence. + + CString buffer = toImpl(URLRef)->string().utf8(); + CFURLRef result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingUTF8, 0, true); + if (!result) + result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingISOLatin1, 0, true); + return result; +} diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLCF.h new file mode 100644 index 0000000..394800d --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLCF.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLCF_h +#define WKURLCF_h + +#include <CoreFoundation/CoreFoundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKURLRef WKURLCreateWithCFURL(CFURLRef URL); +WK_EXPORT CFURLRef WKURLCopyCFURL(CFAllocatorRef alloc, WKURLRef URL); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.cpp new file mode 100644 index 0000000..98c801a --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLRequestCF.h" + +#include "WKAPICast.h" +#include "WebURLRequest.h" + +using namespace WebKit; + +WKURLRequestRef WKURLRequestCreateWithCFURLRequest(CFURLRequestRef urlRequest) +{ + CFURLRequestRef copiedURLRequest = CFURLRequestCreateCopy(kCFAllocatorDefault, urlRequest); + RefPtr<WebURLRequest> request = WebURLRequest::create(copiedURLRequest); + return toAPI(request.release().releaseRef()); +} + +CFURLRequestRef WKURLRequestCopyCFURLRequest(CFAllocatorRef alloc, WKURLRequestRef urlRequest) +{ + return CFURLRequestCreateCopy(alloc, toImpl(urlRequest)->platformRequest()); +} diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h new file mode 100644 index 0000000..fb7dab2 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLRequestCF.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLRequestCF_h +#define WKURLRequestCF_h + +#include <CFNetwork/CFURLRequestPriv.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKURLRequestRef WKURLRequestCreateWithCFURLRequest(CFURLRequestRef urlRequest); +WK_EXPORT CFURLRequestRef WKURLRequestCopyCFURLRequest(CFAllocatorRef alloc, WKURLRequestRef urlRequest); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLRequestCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp new file mode 100644 index 0000000..36d3f00 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLResponseCF.h" + +#include "WKAPICast.h" +#include "WebURLResponse.h" + +using namespace WebKit; + +WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse) +{ + CFURLResponseRef copiedURLResponse = CFURLResponseCreateCopy(kCFAllocatorDefault, urlResponse); + RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse); + return toAPI(response.release().releaseRef()); +} + +CFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse) +{ + return CFURLResponseCreateCopy(alloc, toImpl(urlResponse)->platformResponse()); +} diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h new file mode 100644 index 0000000..5ce7184 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLResponseCF_h +#define WKURLResponseCF_h + +#include <CFNetwork/CFURLResponsePriv.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse); +WK_EXPORT CFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLResponseCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp new file mode 100644 index 0000000..34a8bf1 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKImageCG.h" + +#include "ShareableBitmap.h" +#include "WKSharedAPICast.h" +#include "WebImage.h" +#include <WebCore/GraphicsContext.h> + +using namespace WebKit; +using namespace WebCore; + +CGImageRef WKImageCreateCGImage(WKImageRef imageRef) +{ + OwnPtr<GraphicsContext> sourceContext = toImpl(imageRef)->bitmap()->createGraphicsContext(); + return CGBitmapContextCreateImage(sourceContext->platformContext()); +} diff --git a/Source/WebKit2/Shared/API/c/cg/WKImageCG.h b/Source/WebKit2/Shared/API/c/cg/WKImageCG.h new file mode 100644 index 0000000..7705c31 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cg/WKImageCG.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKImageCG_h +#define WKImageCG_h + +#include <CoreGraphics/CGImage.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image); + +#ifdef __cplusplus +} +#endif + +#endif /* WKImageCG_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h new file mode 100644 index 0000000..7d44478 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKCertificateInfoMac_h +#define WKCertificateInfoMac_h + +#include <CoreFoundation/CoreFoundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfo); + +#ifdef __cplusplus +} +#endif + +#endif /* WKCertificateInfoMac_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm new file mode 100644 index 0000000..2ffc1f5 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKCertificateInfoMac.h" + +#include "WKAPICast.h" +#include "WebCertificateInfo.h" + +using namespace WebKit; + +CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfoRef) +{ + return toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain(); +} diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h new file mode 100644 index 0000000..4cdfec8 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLRequestNS_h +#define WKURLRequestNS_h + +#include <Foundation/Foundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKURLRequestRef WKURLRequestCreateWithNSURLRequest(NSURLRequest* urlRequest); +WK_EXPORT NSURLRequest* WKURLRequestCopyNSURLRequest(WKURLRequestRef urlRequest); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLRequestNS_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm new file mode 100644 index 0000000..7cc69fa --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKURLRequestNS.mm @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLRequestNS.h" + +#include "WKAPICast.h" +#include "WebURLRequest.h" + +using namespace WebKit; + +WKURLRequestRef WKURLRequestCreateWithNSURLRequest(NSURLRequest* urlRequest) +{ + RetainPtr<NSURLRequest> copiedURLRequest(AdoptNS, [urlRequest copy]); + RefPtr<WebURLRequest> request = WebURLRequest::create(copiedURLRequest.get()); + return toAPI(request.release().releaseRef()); +} + +NSURLRequest* WKURLRequestCopyNSURLRequest(WKURLRequestRef urlRequest) +{ + return [toImpl(urlRequest)->platformRequest() copy]; +} diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h b/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h new file mode 100644 index 0000000..0bbc149 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKURLResponseNS_h +#define WKURLResponseNS_h + +#include <Foundation/Foundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKURLResponseRef WKURLResponseCreateWithNSURLResponse(NSURLResponse* urlResponse); +WK_EXPORT NSURLResponse* WKURLResponseCopyNSURLResponse(WKURLResponseRef urlResponse); + +#ifdef __cplusplus +} +#endif + +#endif /* WKURLResponseNS_h */ diff --git a/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.mm b/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.mm new file mode 100644 index 0000000..79b874d --- /dev/null +++ b/Source/WebKit2/Shared/API/c/mac/WKURLResponseNS.mm @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKURLResponseNS.h" + +#include "WKAPICast.h" +#include "WebURLResponse.h" + +using namespace WebKit; + +WKURLResponseRef WKURLResponseCreateWithNSURLResponse(NSURLResponse* urlResponse) +{ + RetainPtr<NSURLResponse> copiedURLResponse(AdoptNS, [urlResponse copy]); + RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse.get()); + return toAPI(response.release().releaseRef()); +} + +NSURLResponse* WKURLResponseCopyNSURLResponse(WKURLResponseRef urlResponse) +{ + return [toImpl(urlResponse)->platformResponse() copy]; +} diff --git a/Source/WebKit2/Shared/API/c/win/WKBaseWin.h b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h new file mode 100644 index 0000000..e2ee9a7 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKBaseWin_h +#define WKBaseWin_h + +#ifndef WKBase_h +#error "Please #include \"WKBase.h\" instead of this file directly." +#endif + +typedef const struct OpaqueWKView* WKViewRef; + +#endif /* WKBaseWin_h */ diff --git a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp new file mode 100644 index 0000000..f4c7bb2 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKCertificateInfoWin.h" + +#include "WKAPICast.h" +#include "WebCertificateInfo.h" + +using namespace WebKit; + +size_t WKCertificateInfoGetCertificateChainLength(WKCertificateInfoRef certificateInfoRef) +{ + return toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain().size(); +} + +PCCERT_CONTEXT WKCertificateInfoGetCertificateContextAtIndex(WKCertificateInfoRef certificateInfoRef, size_t index) +{ + const Vector<PCCERT_CONTEXT>& certificateChain = toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain(); + if (index >= certificateChain.size()) + return 0; + return certificateChain[index]; +} diff --git a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h new file mode 100644 index 0000000..0fcd818 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKCertificateInfoWin_h +#define WKCertificateInfoWin_h + +#include <WebKit2/WKBase.h> +#include <Wincrypt.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT size_t WKCertificateInfoGetCertificateChainLength(WKCertificateInfoRef certificateInfo); +WK_EXPORT PCCERT_CONTEXT WKCertificateInfoGetCertificateContextAtIndex(WKCertificateInfoRef certificateInfo, size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* WKCertificateInfoWin_h */ |