diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
94 files changed, 11235 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h new file mode 100644 index 0000000..15cb7ee --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -0,0 +1,233 @@ +/* + * 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 WKAPICast_h +#define WKAPICast_h + +#include "CacheModel.h" +#include "FontSmoothingLevel.h" +#include "WKContext.h" +#include "WKCredentialTypes.h" +#include "WKPage.h" +#include "WKPreferencesPrivate.h" +#include "WKProtectionSpaceTypes.h" +#include "WKSharedAPICast.h" +#include <WebCore/Credential.h> +#include <WebCore/FrameLoaderTypes.h> +#include <WebCore/ProtectionSpace.h> + +namespace WebKit { + +class AuthenticationChallengeProxy; +class AuthenticationDecisionListener; +class DownloadProxy; +class GeolocationPermissionRequestProxy; +class WebBackForwardList; +class WebBackForwardListItem; +class WebContext; +class WebCredential; +class WebDatabaseManagerProxy; +class WebFormSubmissionListenerProxy; +class WebFramePolicyListenerProxy; +class WebFrameProxy; +class WebGeolocationManagerProxy; +class WebGeolocationPosition; +class WebInspectorProxy; +class WebNavigationData; +class WebOpenPanelParameters; +class WebOpenPanelResultListenerProxy; +class WebPageGroup; +class WebPageProxy; +class WebPreferences; +class WebProtectionSpace; + +WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy) +WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener) +WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem) +WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList) +WK_ADD_API_MAPPING(WKContextRef, WebContext) +WK_ADD_API_MAPPING(WKCredentialRef, WebCredential) +WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy) +WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy) +WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy) +WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy) +WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy) +WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy) +WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy) +WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition) +WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData) +WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters) +WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy) +WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup) +WK_ADD_API_MAPPING(WKPageRef, WebPageProxy) +WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences) +WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace) + +#if ENABLE(INSPECTOR) +WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy) +#endif + +/* Enum conversions */ + +inline CacheModel toCacheModel(WKCacheModel wkCacheModel) +{ + switch (wkCacheModel) { + case kWKCacheModelDocumentViewer: + return CacheModelDocumentViewer; + case kWKCacheModelDocumentBrowser: + return CacheModelDocumentBrowser; + case kWKCacheModelPrimaryWebBrowser: + return CacheModelPrimaryWebBrowser; + } + + ASSERT_NOT_REACHED(); + return CacheModelDocumentViewer; +} + +inline WKCacheModel toAPI(CacheModel cacheModel) +{ + switch (cacheModel) { + case CacheModelDocumentViewer: + return kWKCacheModelDocumentViewer; + case CacheModelDocumentBrowser: + return kWKCacheModelDocumentBrowser; + case CacheModelPrimaryWebBrowser: + return kWKCacheModelPrimaryWebBrowser; + } + + return kWKCacheModelDocumentViewer; +} + +inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel) +{ + switch (wkLevel) { + case kWKFontSmoothingLevelNoSubpixelAntiAliasing: + return FontSmoothingLevelNoSubpixelAntiAliasing; + case kWKFontSmoothingLevelLight: + return FontSmoothingLevelLight; + case kWKFontSmoothingLevelMedium: + return FontSmoothingLevelMedium; + case kWKFontSmoothingLevelStrong: + return FontSmoothingLevelStrong; +#if PLATFORM(WIN) + case kWKFontSmoothingLevelWindows: + return FontSmoothingLevelWindows; +#endif + } + + ASSERT_NOT_REACHED(); + return FontSmoothingLevelMedium; +} + + +inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level) +{ + switch (level) { + case FontSmoothingLevelNoSubpixelAntiAliasing: + return kWKFontSmoothingLevelNoSubpixelAntiAliasing; + case FontSmoothingLevelLight: + return kWKFontSmoothingLevelLight; + case FontSmoothingLevelMedium: + return kWKFontSmoothingLevelMedium; + case FontSmoothingLevelStrong: + return kWKFontSmoothingLevelStrong; +#if PLATFORM(WIN) + case FontSmoothingLevelWindows: + return kWKFontSmoothingLevelWindows; +#endif + } + + ASSERT_NOT_REACHED(); + return kWKFontSmoothingLevelMedium; +} + +inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type) +{ + switch (type) { + case WebCore::ProtectionSpaceServerHTTP: + return kWKProtectionSpaceServerTypeHTTP; + case WebCore::ProtectionSpaceServerHTTPS: + return kWKProtectionSpaceServerTypeHTTPS; + case WebCore::ProtectionSpaceServerFTP: + return kWKProtectionSpaceServerTypeFTP; + case WebCore::ProtectionSpaceServerFTPS: + return kWKProtectionSpaceServerTypeFTPS; + case WebCore::ProtectionSpaceProxyHTTP: + return kWKProtectionSpaceProxyTypeHTTP; + case WebCore::ProtectionSpaceProxyHTTPS: + return kWKProtectionSpaceProxyTypeHTTPS; + case WebCore::ProtectionSpaceProxyFTP: + return kWKProtectionSpaceProxyTypeFTP; + case WebCore::ProtectionSpaceProxySOCKS: + return kWKProtectionSpaceProxyTypeSOCKS; + } + return kWKProtectionSpaceServerTypeHTTP; +} + +inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type) +{ + switch (type) { + case WebCore::ProtectionSpaceAuthenticationSchemeDefault: + return kWKProtectionSpaceAuthenticationSchemeDefault; + case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic: + return kWKProtectionSpaceAuthenticationSchemeHTTPBasic; + case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest: + return kWKProtectionSpaceAuthenticationSchemeHTTPDigest; + case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm: + return kWKProtectionSpaceAuthenticationSchemeHTMLForm; + case WebCore::ProtectionSpaceAuthenticationSchemeNTLM: + return kWKProtectionSpaceAuthenticationSchemeNTLM; + case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate: + return kWKProtectionSpaceAuthenticationSchemeNegotiate; + case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested: + return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested; + case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested: + return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested; + default: + return kWKProtectionSpaceAuthenticationSchemeUnknown; + } +} + +inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type) +{ + switch (type) { + case kWKCredentialPersistenceNone: + return WebCore::CredentialPersistenceNone; + case kWKCredentialPersistenceForSession: + return WebCore::CredentialPersistenceForSession; + case kWKCredentialPersistencePermanent: + return WebCore::CredentialPersistencePermanent; + default: + return WebCore::CredentialPersistenceNone; + } +} + +} // namespace WebKit + +#if defined(WIN32) || defined(_WIN32) +#include "WKAPICastWin.h" +#endif + +#endif // WKAPICast_h diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp new file mode 100644 index 0000000..0997577 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp @@ -0,0 +1,58 @@ +/* + * 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 "WKAuthenticationChallenge.h" + +#include "AuthenticationChallengeProxy.h" +#include "WebCredential.h" +#include "WebProtectionSpace.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKAuthenticationChallengeGetTypeID() +{ + return toAPI(AuthenticationChallengeProxy::APIType); +} + +WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef challenge) +{ + return toAPI(toImpl(challenge)->listener()); +} + +WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef challenge) +{ + return toAPI(toImpl(challenge)->protectionSpace()); +} + +WKCredentialRef WKAuthenticationChallengeGetProposedCredential(WKAuthenticationChallengeRef challenge) +{ + return toAPI(toImpl(challenge)->proposedCredential()); +} + +int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef challenge) +{ + return toImpl(challenge)->previousFailureCount(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h new file mode 100644 index 0000000..3802f41 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.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 WKAuthenticationChallenge_h +#define WKAuthenticationChallenge_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKAuthenticationChallengeGetTypeID(); + +WK_EXPORT WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef); +WK_EXPORT WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef); +WK_EXPORT WKCredentialRef WKAuthenticationChallengeGetProposedCredential(WKAuthenticationChallengeRef); +WK_EXPORT int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef); + +#ifdef __cplusplus +} +#endif + +#endif // WKAuthenticationChallenge_h diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp new file mode 100644 index 0000000..959f5c2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp @@ -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. + */ + +#include "WKAuthenticationDecisionListener.h" + +#include "AuthenticationDecisionListener.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKAuthenticationDecisionListenerGetTypeID() +{ + return toAPI(AuthenticationDecisionListener::APIType); +} + +void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential) +{ + toImpl(authenticationListener)->useCredential(toImpl(credential)); +} + +void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener) +{ + toImpl(authenticationListener)->cancel(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h new file mode 100644 index 0000000..f072461 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.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 WKAuthenticationDecisionListener_h +#define WKAuthenticationDecisionListener_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKAuthenticationDecisionListenerGetTypeID(); + +WK_EXPORT void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential); +WK_EXPORT void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener); + +#ifdef __cplusplus +} +#endif + +#endif /* WKFramePolicyListener_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp new file mode 100644 index 0000000..c2343ca --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp @@ -0,0 +1,76 @@ +/* + * 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 "WKBackForwardList.h" + +#include "WebBackForwardList.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKBackForwardListGetTypeID() +{ + return toAPI(WebBackForwardList::APIType); +} + +WKBackForwardListItemRef WKBackForwardListGetCurrentItem(WKBackForwardListRef listRef) +{ + return toAPI(toImpl(listRef)->currentItem()); +} + +WKBackForwardListItemRef WKBackForwardListGetBackItem(WKBackForwardListRef listRef) +{ + return toAPI(toImpl(listRef)->backItem()); +} + +WKBackForwardListItemRef WKBackForwardListGetForwardItem(WKBackForwardListRef listRef) +{ + return toAPI(toImpl(listRef)->forwardItem()); +} + +WKBackForwardListItemRef WKBackForwardListGetItemAtIndex(WKBackForwardListRef listRef, int index) +{ + return toAPI(toImpl(listRef)->itemAtIndex(index)); +} + +unsigned WKBackForwardListGetBackListCount(WKBackForwardListRef listRef) +{ + return toImpl(listRef)->backListCount(); +} + +unsigned WKBackForwardListGetForwardListCount(WKBackForwardListRef listRef) +{ + return toImpl(listRef)->forwardListCount(); +} + +WKArrayRef WKBackForwardListCopyBackListWithLimit(WKBackForwardListRef listRef, unsigned limit) +{ + return toAPI(toImpl(listRef)->backListAsImmutableArrayWithLimit(limit).releaseRef()); +} + +WKArrayRef WKBackForwardListCopyForwardListWithLimit(WKBackForwardListRef listRef, unsigned limit) +{ + return toAPI(toImpl(listRef)->forwardListAsImmutableArrayWithLimit(limit).releaseRef()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h new file mode 100644 index 0000000..214a6bc --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h @@ -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. + */ + +#ifndef WKBackForwardList_h +#define WKBackForwardList_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKBackForwardListGetTypeID(); + +WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetCurrentItem(WKBackForwardListRef list); +WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetBackItem(WKBackForwardListRef list); +WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetForwardItem(WKBackForwardListRef list); +WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetItemAtIndex(WKBackForwardListRef list, int index); + +WK_EXPORT unsigned WKBackForwardListGetBackListCount(WKBackForwardListRef list); +WK_EXPORT unsigned WKBackForwardListGetForwardListCount(WKBackForwardListRef list); + +WK_EXPORT WKArrayRef WKBackForwardListCopyBackListWithLimit(WKBackForwardListRef list, unsigned limit); +WK_EXPORT WKArrayRef WKBackForwardListCopyForwardListWithLimit(WKBackForwardListRef list, unsigned limit); + +#ifdef __cplusplus +} +#endif + +#endif // WKBackForwardList_h diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp new file mode 100644 index 0000000..2165737 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp @@ -0,0 +1,46 @@ +/* + * 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 "WKBackForwardListItem.h" + +#include "WKAPICast.h" +#include "WebBackForwardListItem.h" + +using namespace WebKit; + +WKTypeID WKBackForwardListItemGetTypeID() +{ + return toAPI(WebBackForwardListItem::APIType); +} + +WKURLRef WKBackForwardListItemCopyURL(WKBackForwardListItemRef itemRef) +{ + return toCopiedURLAPI(toImpl(itemRef)->url()); +} + +WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef itemRef) +{ + return toCopiedAPI(toImpl(itemRef)->title()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h new file mode 100644 index 0000000..b0bf1de --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#ifndef WKBackForwardListItem_h +#define WKBackForwardListItem_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKBackForwardListItemGetTypeID(); + +WK_EXPORT WKURLRef WKBackForwardListItemCopyURL(WKBackForwardListItemRef item); +WK_EXPORT WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef item); + +#ifdef __cplusplus +} +#endif + +#endif /* WKBackForwardListItem_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp new file mode 100644 index 0000000..c207225 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -0,0 +1,178 @@ +/* + * 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 "WKContext.h" +#include "WKContextPrivate.h" + +#include "WKAPICast.h" +#include "WebContext.h" +#include "WebURLRequest.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +using namespace WebKit; + +WKTypeID WKContextGetTypeID() +{ + return toAPI(WebContext::APIType); +} + +WKContextRef WKContextCreate() +{ + RefPtr<WebContext> context = WebContext::create(String()); + return toAPI(context.release().releaseRef()); +} + +WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef) +{ + RefPtr<WebContext> context = WebContext::create(toImpl(pathRef)->string()); + return toAPI(context.release().releaseRef()); +} + +WKContextRef WKContextGetSharedProcessContext() +{ + return toAPI(WebContext::sharedProcessContext()); +} + +WKContextRef WKContextGetSharedThreadContext() +{ + return toAPI(WebContext::sharedThreadContext()); +} + +void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(contextRef)->initializeInjectedBundleClient(wkClient); +} + +void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(contextRef)->initializeHistoryClient(wkClient); +} + +void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownloadClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(contextRef)->initializeDownloadClient(wkClient); +} + +void WKContextDownloadURLRequest(WKContextRef contextRef, const WKURLRequestRef requestRef) +{ + toImpl(contextRef)->download(0, toImpl(requestRef)->resourceRequest()); +} + +void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef contextRef, WKTypeRef userDataRef) +{ + toImpl(contextRef)->setInjectedBundleInitializationUserData(toImpl(userDataRef)); +} + +void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef) +{ + toImpl(contextRef)->postMessageToInjectedBundle(toImpl(messageNameRef)->string(), toImpl(messageBodyRef)); +} + +void WKContextGetGlobalStatistics(WKContextStatistics* statistics) +{ + const WebContext::Statistics& webContextStatistics = WebContext::statistics(); + + statistics->wkViewCount = webContextStatistics.wkViewCount; + statistics->wkPageCount = webContextStatistics.wkPageCount; + statistics->wkFrameCount = webContextStatistics.wkViewCount; +} + +void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL) +{ + toImpl(contextRef)->addVisitedLink(toImpl(visitedURL)->string()); +} + +void WKContextSetCacheModel(WKContextRef contextRef, WKCacheModel cacheModel) +{ + toImpl(contextRef)->setCacheModel(toCacheModel(cacheModel)); +} + +WKCacheModel WKContextGetCacheModel(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->cacheModel()); +} + +void _WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef contextRef, bool alwaysUseComplexTextCodePath) +{ + toImpl(contextRef)->setAlwaysUsesComplexTextCodePath(alwaysUseComplexTextCodePath); +} + +void _WKContextSetAdditionalPluginsDirectory(WKContextRef contextRef, WKStringRef pluginsDirectory) +{ + toImpl(contextRef)->setAdditionalPluginsDirectory(toImpl(pluginsDirectory)->string()); +} + +void _WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef contextRef, WKStringRef urlScheme) +{ + toImpl(contextRef)->registerURLSchemeAsEmptyDocument(toImpl(urlScheme)->string()); +} + +void WKContextRegisterURLSchemeAsSecure(WKContextRef contextRef, WKStringRef urlScheme) +{ + toImpl(contextRef)->registerURLSchemeAsSecure(toImpl(urlScheme)->string()); +} + +void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme) +{ + toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string()); +} + +void WKContextClearResourceCaches(WKContextRef contextRef) +{ + toImpl(contextRef)->clearResourceCaches(); +} + +void WKContextClearApplicationCache(WKContextRef contextRef) +{ + toImpl(contextRef)->clearApplicationCache(); +} + +WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->databaseManagerProxy()); +} + +WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->geolocationManagerProxy()); +} + +void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval) +{ + toImpl(contextRef)->startMemorySampler(toImpl(interval)->value()); +} + +void WKContextStopMemorySampler(WKContextRef contextRef) +{ + toImpl(contextRef)->stopMemorySampler(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h new file mode 100644 index 0000000..810ad20 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKContext.h @@ -0,0 +1,133 @@ +/* + * 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 WKContext_h +#define WKContext_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKCacheModelDocumentViewer = 0, + kWKCacheModelDocumentBrowser = 1, + kWKCacheModelPrimaryWebBrowser = 2 +}; +typedef uint32_t WKCacheModel; + +// Injected Bundle Client +typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo); +typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo); + +struct WKContextInjectedBundleClient { + int version; + const void * clientInfo; + WKContextDidReceiveMessageFromInjectedBundleCallback didReceiveMessageFromInjectedBundle; + WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback didReceiveSynchronousMessageFromInjectedBundle; +}; +typedef struct WKContextInjectedBundleClient WKContextInjectedBundleClient; + +// History Client +typedef void (*WKContextDidNavigateWithNavigationDataCallback)(WKContextRef context, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo); +typedef void (*WKContextDidPerformClientRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo); +typedef void (*WKContextDidPerformServerRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo); +typedef void (*WKContextDidUpdateHistoryTitleCallback)(WKContextRef context, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo); +typedef void (*WKContextPopulateVisitedLinksCallback)(WKContextRef context, const void *clientInfo); + +struct WKContextHistoryClient { + int version; + const void * clientInfo; + WKContextDidNavigateWithNavigationDataCallback didNavigateWithNavigationData; + WKContextDidPerformClientRedirectCallback didPerformClientRedirect; + WKContextDidPerformServerRedirectCallback didPerformServerRedirect; + WKContextDidUpdateHistoryTitleCallback didUpdateHistoryTitle; + WKContextPopulateVisitedLinksCallback populateVisitedLinks; +}; +typedef struct WKContextHistoryClient WKContextHistoryClient; + +// Download Client +typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); +typedef void (*WKContextDownloadDidReceiveResponseCallback)(WKContextRef context, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo); +typedef void (*WKContextDownloadDidReceiveDataCallback)(WKContextRef context, WKDownloadRef download, uint64_t length, const void *clientInfo); +typedef bool (*WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback)(WKContextRef context, WKDownloadRef download, WKStringRef mimeType, const void *clientInfo); +typedef WKStringRef (*WKContextDownloadDecideDestinationWithSuggestedFilenameCallback)(WKContextRef context, WKDownloadRef download, WKStringRef filename, bool* allowOverwrite, const void *clientInfo); +typedef void (*WKContextDownloadDidCreateDestinationCallback)(WKContextRef context, WKDownloadRef download, WKStringRef path, const void *clientInfo); +typedef void (*WKContextDownloadDidFinishCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); +typedef void (*WKContextDownloadDidFailCallback)(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void *clientInfo); +typedef void (*WKContextDownloadDidCancel)(WKContextRef context, WKDownloadRef download, const void *clientInfo); +typedef void (*WKContextDownloadProcessDidCrashCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); + +struct WKContextDownloadClient { + int version; + const void * clientInfo; + WKContextDownloadDidStartCallback didStart; + WKContextDownloadDidReceiveResponseCallback didReceiveResponse; + WKContextDownloadDidReceiveDataCallback didReceiveData; + WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType; + WKContextDownloadDecideDestinationWithSuggestedFilenameCallback decideDestinationWithSuggestedFilename; + WKContextDownloadDidCreateDestinationCallback didCreateDestination; + WKContextDownloadDidFinishCallback didFinish; + WKContextDownloadDidFailCallback didFail; + WKContextDownloadDidCancel didCancel; + WKContextDownloadProcessDidCrashCallback processDidCrash; +}; +typedef struct WKContextDownloadClient WKContextDownloadClient; + +WK_EXPORT WKTypeID WKContextGetTypeID(); + +WK_EXPORT WKContextRef WKContextCreate(); +WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path); +WK_EXPORT WKContextRef WKContextGetSharedProcessContext(); + +WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client); +WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client); +WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client); + +WK_EXPORT void WKContextDownloadURLRequest(WKContextRef context, const WKURLRequestRef request); + +WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData); +WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody); + +WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visitedURL); + +WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel); +WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context); + +WK_EXPORT void WKContextClearResourceCaches(WKContextRef context); +WK_EXPORT void WKContextClearApplicationCache(WKContextRef context); + +WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval); +WK_EXPORT void WKContextStopMemorySampler(WKContextRef context); + +WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context); +WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context); + +#ifdef __cplusplus +} +#endif + +#endif /* WKContext_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h new file mode 100644 index 0000000..8bcb1b6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.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 WKContextPrivate_h +#define WKContextPrivate_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKContext.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct WKContextStatistics { + unsigned wkViewCount; + unsigned wkPageCount; + unsigned wkFrameCount; +}; +typedef struct WKContextStatistics WKContextStatistics; + +WK_EXPORT void WKContextGetGlobalStatistics(WKContextStatistics* statistics); + +WK_EXPORT WKContextRef WKContextGetSharedThreadContext(); + +WK_EXPORT void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory); + +WK_EXPORT void _WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context, WKStringRef urlScheme); + +WK_EXPORT void _WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef context, bool alwaysUseComplexTextCodePath); + +WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme); + +WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme); + +#ifdef __cplusplus +} +#endif + +#endif /* WKContextPrivate_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKCredential.cpp b/Source/WebKit2/UIProcess/API/C/WKCredential.cpp new file mode 100644 index 0000000..25e1185 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKCredential.cpp @@ -0,0 +1,49 @@ +/* + * 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 "WKCredential.h" + +#include "WebCredential.h" +#include "WebString.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKCredentialGetTypeID() +{ + return toAPI(WebCredential::APIType); +} + +WKCredentialRef WKCredentialCreate(WKStringRef username, WKStringRef password, WKCredentialPersistence persistence) +{ + RefPtr<WebCredential> credential = WebCredential::create(toImpl(username), toImpl(password), toCredentialPersistence(persistence)); + return toAPI(credential.release().releaseRef()); +} + +WKStringRef WKCredentialCopyUser(WKCredentialRef credentialRef) +{ + return toCopiedAPI(toImpl(credentialRef)->user()); +} + diff --git a/Source/WebKit2/UIProcess/API/C/WKCredential.h b/Source/WebKit2/UIProcess/API/C/WKCredential.h new file mode 100644 index 0000000..8b2602e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKCredential.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 WKCredential_h +#define WKCredential_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKCredentialTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKCredentialGetTypeID(); + +WK_EXPORT WKCredentialRef WKCredentialCreate(WKStringRef username, WKStringRef password, WKCredentialPersistence); +WK_EXPORT WKStringRef WKCredentialCopyUser(WKCredentialRef); + +#ifdef __cplusplus +} +#endif + +#endif // WKCredential_h diff --git a/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h b/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h new file mode 100644 index 0000000..bba31ac --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.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 WKCredentialTypes_h +#define WKCredentialTypes_h + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKCredentialPersistenceNone, + kWKCredentialPersistenceForSession, + kWKCredentialPersistencePermanent +}; +typedef uint32_t WKCredentialPersistence; + +#ifdef __cplusplus +} +#endif + +#endif /* WKCredentialTypes_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp new file mode 100644 index 0000000..226ef8c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp @@ -0,0 +1,153 @@ +/* + * 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 "WKDatabaseManager.h" + +#include "WebDatabaseManagerProxy.h" +#include "WKAPICast.h" + +#ifdef __BLOCKS__ +#include <Block.h> +#endif + +using namespace WebKit; + +WKTypeID WKDatabaseManagerGetTypeID() +{ + return toAPI(WebDatabaseManagerProxy::APIType); +} + +WKStringRef WKDatabaseManagerGetOriginKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::originKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetOriginQuotaKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::originQuotaKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetOriginUsageKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::originUsageKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetDatabaseDetailsKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).releaseRef(); + return toAPI(key); +} + +WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey() +{ + static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).releaseRef(); + return toAPI(key); +} + +void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManagerRef, const WKDatabaseManagerClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(databaseManagerRef)->initializeClient(wkClient); +} + +void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabasesByOriginFunction callback) +{ + toImpl(databaseManagerRef)->getDatabasesByOrigin(ArrayCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callGetDatabasesByOriginBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context) +{ + WKDatabaseManagerGetDatabasesByOriginBlock block = (WKDatabaseManagerGetDatabasesByOriginBlock)context; + block(resultValue, errorRef); + Block_release(block); +} + +void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabasesByOriginBlock block) +{ + WKDatabaseManagerGetDatabasesByOrigin(databaseManagerRef, Block_copy(block), callGetDatabasesByOriginBlockAndDispose); +} +#endif + +void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback) +{ + toImpl(databaseManagerRef)->getDatabaseOrigins(ArrayCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callGetDatabaseOriginsBlockBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context) +{ + WKDatabaseManagerGetDatabaseOriginsBlock block = (WKDatabaseManagerGetDatabaseOriginsBlock)context; + block(resultValue, errorRef); + Block_release(block); +} + +void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabaseOriginsBlock block) +{ + WKDatabaseManagerGetDatabaseOrigins(databaseManagerRef, Block_copy(block), callGetDatabaseOriginsBlockBlockAndDispose); +} +#endif + +void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManagerRef, WKStringRef databaseNameRef, WKSecurityOriginRef originRef) +{ + toImpl(databaseManagerRef)->deleteDatabaseWithNameForOrigin(toWTFString(databaseNameRef), toImpl(originRef)); +} + +void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef) +{ + toImpl(databaseManagerRef)->deleteDatabasesForOrigin(toImpl(originRef)); +} + +void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManagerRef) +{ + toImpl(databaseManagerRef)->deleteAllDatabases(); +} + +void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef, uint64_t quota) +{ + toImpl(databaseManagerRef)->setQuotaForOrigin(toImpl(originRef), quota); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h new file mode 100644 index 0000000..0a5eff6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h @@ -0,0 +1,106 @@ +/* + * 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 WKDatabaseManager_h +#define WKDatabaseManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Value type: WKSecurityOriginRef */ +WK_EXPORT WKStringRef WKDatabaseManagerGetOriginKey(); + +/* Value type: WKUInt64Ref */ +WK_EXPORT WKStringRef WKDatabaseManagerGetOriginQuotaKey(); + +/* Value type: WKUInt64Ref */ +WK_EXPORT WKStringRef WKDatabaseManagerGetOriginUsageKey(); + +/* Value type: WKArrayRef (array of WKDictionaryRef's with keys that include: + - WKDatabaseManagerGetDatabaseNameKey() + - WKDatabaseManagerGetDatabaseDisplayNameKey() + - WKDatabaseManagerGetDatabaseExpectedUsageKey() + - WKDatabaseManagerGetDatabaseCurrentUsageKey() + */ +WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsKey(); + +/* Value type: WKStringRef */ +WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey(); + +/* Value type: WKStringRef */ +WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey(); + +/* Value type: WKUInt64Ref */ +WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey(); + +/* Value type: WKUInt64Ref */ +WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey(); + + +// Database Manager Client +typedef void (*WKDatabaseManagerDidModifyOriginCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, const void *clientInfo); +typedef void (*WKDatabaseManagerDidModifyDatabaseCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, WKStringRef databaseIdentifier, const void *clientInfo); + +struct WKDatabaseManagerClient { + int version; + const void * clientInfo; + WKDatabaseManagerDidModifyOriginCallback didModifyOrigin; + WKDatabaseManagerDidModifyDatabaseCallback didModifyDatabase; +}; +typedef struct WKDatabaseManagerClient WKDatabaseManagerClient; + + +WK_EXPORT WKTypeID WKDatabaseManagerGetTypeID(); + +WK_EXPORT void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManager, const WKDatabaseManagerClient* client); + +typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function); +#ifdef __BLOCKS__ +typedef void (^WKDatabaseManagerGetDatabasesByOriginBlock)(WKArrayRef, WKErrorRef); +WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabasesByOriginBlock block); +#endif + +typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*); +WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function); +#ifdef __BLOCKS__ +typedef void (^WKDatabaseManagerGetDatabaseOriginsBlock)(WKArrayRef, WKErrorRef); +WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabaseOriginsBlock block); +#endif + +WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin); +WK_EXPORT void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin); +WK_EXPORT void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManager); + +WK_EXPORT void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, uint64_t quota); + +#ifdef __cplusplus +} +#endif + +#endif // WKDatabaseManager_h diff --git a/Source/WebKit2/UIProcess/API/C/WKDownload.cpp b/Source/WebKit2/UIProcess/API/C/WKDownload.cpp new file mode 100644 index 0000000..8960e2a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKDownload.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 "WKDownload.h" + +#include "DownloadProxy.h" +#include "WKAPICast.h" +#include "WebURLRequest.h" + +using namespace WebKit; + +WKTypeID WKDownloadGetTypeID() +{ + return toAPI(DownloadProxy::APIType); +} + +WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download) +{ + return toAPI(WebURLRequest::create(toImpl(download)->request()).leakRef()); +} + +WKDataRef WKDownloadGetResumeData(WKDownloadRef download) +{ + return toAPI(toImpl(download)->resumeData()); +} + +void WKDownloadCancel(WKDownloadRef download) +{ + return toImpl(download)->cancel(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKDownload.h b/Source/WebKit2/UIProcess/API/C/WKDownload.h new file mode 100644 index 0000000..b812681 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKDownload.h @@ -0,0 +1,49 @@ +/* + * 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 WKDownload_h +#define WKDownload_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKDownloadGetTypeID(); + +WK_EXPORT WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download); +WK_EXPORT WKDataRef WKDownloadGetResumeData(WKDownloadRef download); +WK_EXPORT void WKDownloadCancel(WKDownloadRef download); + +#ifdef __cplusplus +} +#endif + +#endif // WKDownload_h diff --git a/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp new file mode 100644 index 0000000..ae98831 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp @@ -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. + */ + +#include "WKFormSubmissionListener.h" + +#include "WKAPICast.h" +#include "WebFormSubmissionListenerProxy.h" + +using namespace WebKit; + +WKTypeID WKFormSubmissionListenerGetTypeID() +{ + return toAPI(WebFormSubmissionListenerProxy::APIType); +} + +void WKFormSubmissionListenerContinue(WKFormSubmissionListenerRef submissionListener) +{ + toImpl(submissionListener)->continueSubmission(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h new file mode 100644 index 0000000..4b9b79a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.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 WKFormSubmissionListener_h +#define WKFormSubmissionListener_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKFormSubmissionListenerGetTypeID(); + +WK_EXPORT void WKFormSubmissionListenerContinue(WKFormSubmissionListenerRef submissionListener); + +#ifdef __cplusplus +} +#endif + +#endif /* WKFormSubmissionListener_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp new file mode 100644 index 0000000..7c9ae11 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp @@ -0,0 +1,164 @@ +/* + * 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 "WKFrame.h" + +#include "WKAPICast.h" +#include "WebFrameProxy.h" + +#ifdef __BLOCKS__ +#include <Block.h> +#endif + +using namespace WebKit; + +WKTypeID WKFrameGetTypeID() +{ + return toAPI(WebFrameProxy::APIType); +} + +bool WKFrameIsMainFrame(WKFrameRef frameRef) +{ + return toImpl(frameRef)->isMainFrame(); +} + +WKFrameLoadState WKFrameGetFrameLoadState(WKFrameRef frameRef) +{ + WebFrameProxy* frame = toImpl(frameRef); + switch (frame->loadState()) { + case WebFrameProxy::LoadStateProvisional: + return kWKFrameLoadStateProvisional; + case WebFrameProxy::LoadStateCommitted: + return kWKFrameLoadStateCommitted; + case WebFrameProxy::LoadStateFinished: + return kWKFrameLoadStateFinished; + } + + ASSERT_NOT_REACHED(); + return kWKFrameLoadStateFinished; +} + +WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frameRef) +{ + return toCopiedURLAPI(toImpl(frameRef)->provisionalURL()); +} + +WKURLRef WKFrameCopyURL(WKFrameRef frameRef) +{ + return toCopiedURLAPI(toImpl(frameRef)->url()); +} + +WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frameRef) +{ + return toCopiedURLAPI(toImpl(frameRef)->unreachableURL()); +} + +WKStringRef WKFrameCopyMIMEType(WKFrameRef frameRef) +{ + return toCopiedAPI(toImpl(frameRef)->mimeType()); +} + +WKStringRef WKFrameCopyTitle(WKFrameRef frameRef) +{ + return toCopiedAPI(toImpl(frameRef)->title()); +} + +WKPageRef WKFrameGetPage(WKFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->page()); +} + +WKArrayRef WKFrameCopyChildFrames(WKFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->childFrames().releaseRef()); +} + +WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frameRef) +{ + return toAPI(toImpl(frameRef)->certificateInfo()); +} + +bool WKFrameCanProvideSource(WKFrameRef frameRef) +{ + return toImpl(frameRef)->canProvideSource(); +} + +bool WKFrameCanShowMIMEType(WKFrameRef frameRef, WKStringRef mimeTypeRef) +{ + return toImpl(frameRef)->canShowMIMEType(toWTFString(mimeTypeRef)); +} + +bool WKFrameIsDisplayingStandaloneImageDocument(WKFrameRef frameRef) +{ + return toImpl(frameRef)->isDisplayingStandaloneImageDocument(); +} + +bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frameRef) +{ + return toImpl(frameRef)->isDisplayingMarkupDocument(); +} + +bool WKFrameIsFrameSet(WKFrameRef frameRef) +{ + return toImpl(frameRef)->isFrameSet(); +} + +void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetMainResourceDataFunction callback, void* context) +{ + toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callGetMainResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context) +{ + WKFrameGetMainResourceDataBlock block = (WKFrameGetMainResourceDataBlock)context; + block(data, error); + Block_release(block); +} + +void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetMainResourceDataBlock block) +{ + WKFrameGetMainResourceData(frameRef, callGetMainResourceDataBlockAndDispose, Block_copy(block)); +} +#endif + +void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context) +{ + toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callGetWebArchiveBlockAndDispose(WKDataRef archiveData, WKErrorRef error, void* context) +{ + WKFrameGetWebArchiveBlock block = (WKFrameGetWebArchiveBlock)context; + block(archiveData, error); + Block_release(block); +} + +void WKFrameGetWebArchive_b(WKFrameRef frameRef, WKFrameGetWebArchiveBlock block) +{ + WKFrameGetWebArchive(frameRef, callGetWebArchiveBlockAndDispose, Block_copy(block)); +} +#endif diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.h b/Source/WebKit2/UIProcess/API/C/WKFrame.h new file mode 100644 index 0000000..f812aeb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h @@ -0,0 +1,89 @@ +/* + * 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 WKFrame_h +#define WKFrame_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +enum WKFrameLoadState { + kWKFrameLoadStateProvisional = 0, + kWKFrameLoadStateCommitted = 1, + kWKFrameLoadStateFinished = 2 +}; +typedef enum WKFrameLoadState WKFrameLoadState; + +WK_EXPORT WKTypeID WKFrameGetTypeID(); + +WK_EXPORT bool WKFrameIsMainFrame(WKFrameRef frame); +WK_EXPORT WKFrameLoadState WKFrameGetFrameLoadState(WKFrameRef frame); +WK_EXPORT WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frame); +WK_EXPORT WKURLRef WKFrameCopyURL(WKFrameRef frame); +WK_EXPORT WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frame); + +WK_EXPORT WKStringRef WKFrameCopyMIMEType(WKFrameRef frame); +WK_EXPORT WKStringRef WKFrameCopyTitle(WKFrameRef frame); + +WK_EXPORT WKPageRef WKFrameGetPage(WKFrameRef frame); + +WK_EXPORT WKArrayRef WKFrameCopyChildFrames(WKFrameRef frame); + +WK_EXPORT WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frame); + +WK_EXPORT bool WKFrameCanProvideSource(WKFrameRef frame); +WK_EXPORT bool WKFrameCanShowMIMEType(WKFrameRef frame, WKStringRef mimeType); + +WK_EXPORT bool WKFrameIsDisplayingStandaloneImageDocument(WKFrameRef frame); +WK_EXPORT bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frame); + +WK_EXPORT bool WKFrameIsFrameSet(WKFrameRef frame); + +typedef void (*WKFrameGetMainResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext); +WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetMainResourceDataFunction function, void* functionContext); +#ifdef __BLOCKS__ +typedef void (^WKFrameGetMainResourceDataBlock)(WKDataRef data, WKErrorRef error); +WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetMainResourceDataBlock block); +#endif + +typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext); +WK_EXPORT void WKFrameGetWebArchive(WKFrameRef frame, WKFrameGetWebArchiveFunction function, void* functionContext); +#ifdef __BLOCKS__ +typedef void (^WKFrameGetWebArchiveBlock)(WKDataRef archiveData, WKErrorRef error); +WK_EXPORT void WKFrameGetWebArchive_b(WKFrameRef frame, WKFrameGetWebArchiveBlock block); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WKFrame_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp new file mode 100644 index 0000000..d44d0d3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.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 "WKFramePolicyListener.h" + +#include "WKAPICast.h" +#include "WebFramePolicyListenerProxy.h" +#include "WebFrameProxy.h" + +using namespace WebKit; + +WKTypeID WKFramePolicyListenerGetTypeID() +{ + return toAPI(WebFramePolicyListenerProxy::APIType); +} + +void WKFramePolicyListenerUse(WKFramePolicyListenerRef policyListenerRef) +{ + toImpl(policyListenerRef)->use(); +} + +void WKFramePolicyListenerDownload(WKFramePolicyListenerRef policyListenerRef) +{ + toImpl(policyListenerRef)->download(); +} + +void WKFramePolicyListenerIgnore(WKFramePolicyListenerRef policyListenerRef) +{ + toImpl(policyListenerRef)->ignore(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h new file mode 100644 index 0000000..99b013d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.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 WKFramePolicyListener_h +#define WKFramePolicyListener_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKFramePolicyListenerGetTypeID(); + +WK_EXPORT void WKFramePolicyListenerUse(WKFramePolicyListenerRef policyListener); +WK_EXPORT void WKFramePolicyListenerDownload(WKFramePolicyListenerRef policyListener); +WK_EXPORT void WKFramePolicyListenerIgnore(WKFramePolicyListenerRef policyListener); + +#ifdef __cplusplus +} +#endif + +#endif /* WKFramePolicyListener_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp new file mode 100644 index 0000000..ed399ad --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKGeolocationManager.h" + +#include "WKAPICast.h" +#include "WebGeolocationManagerProxy.h" + +using namespace WebKit; + +WKTypeID WKGeolocationManagerGetTypeID() +{ + return toAPI(WebGeolocationManagerProxy::APIType); +} + +void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManagerRef, const WKGeolocationProvider* wkProvider) +{ + if (wkProvider && wkProvider->version) + return; + toImpl(geolocationManagerRef)->initializeProvider(wkProvider); +} + +void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManagerRef, WKGeolocationPositionRef positionRef) +{ + toImpl(geolocationManagerRef)->providerDidChangePosition(toImpl(positionRef)); +} + +void WKGeolocationManagerProviderDidFailToDeterminePosition(WKGeolocationManagerRef geolocationManagerRef) +{ + toImpl(geolocationManagerRef)->providerDidFailToDeterminePosition(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h new file mode 100644 index 0000000..07cbd79 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKGeolocationManager_h +#define WKGeolocationManager_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// Provider. +typedef void (*WKGeolocationProviderStartUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo); +typedef void (*WKGeolocationProviderStopUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo); + +struct WKGeolocationProvider { + int version; + const void * clientInfo; + WKGeolocationProviderStartUpdatingCallback startUpdating; + WKGeolocationProviderStopUpdatingCallback stopUpdating; +}; +typedef struct WKGeolocationProvider WKGeolocationProvider; + +WK_EXPORT WKTypeID WKGeolocationManagerGetTypeID(); + +WK_EXPORT void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManager, const WKGeolocationProvider* provider); + +WK_EXPORT void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManager, WKGeolocationPositionRef position); +WK_EXPORT void WKGeolocationManagerProviderDidFailToDeterminePosition(WKGeolocationManagerRef geolocationManager); + +#ifdef __cplusplus +} +#endif + +#endif /* WKGeolocationManager_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp new file mode 100644 index 0000000..ca52798 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKGeolocationPermissionRequest.h" + +#include "GeolocationPermissionRequestProxy.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKGeolocationPermissionRequestGetTypeID() +{ + return toAPI(GeolocationPermissionRequestProxy::APIType); +} + +void WKGeolocationPermissionRequestAllow(WKGeolocationPermissionRequestRef geolocationPermissionRequestRef) +{ + return toImpl(geolocationPermissionRequestRef)->allow(); +} + +void WKGeolocationPermissionRequestDeny(WKGeolocationPermissionRequestRef geolocationPermissionRequestRef) +{ + return toImpl(geolocationPermissionRequestRef)->deny(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h new file mode 100644 index 0000000..ee27b66 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKGeolocationPermissionRequest_h +#define WKGeolocationPermissionRequest_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKGeolocationPermissionRequestGetTypeID(); + +WK_EXPORT void WKGeolocationPermissionRequestAllow(WKGeolocationPermissionRequestRef geolocationPermissionRequest); +WK_EXPORT void WKGeolocationPermissionRequestDeny(WKGeolocationPermissionRequestRef geolocationPermissionRequest); + +#ifdef __cplusplus +} +#endif + +#endif /* WKGeolocationPermissionRequest_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp new file mode 100644 index 0000000..7977369 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "WKGeolocationPosition.h" + +#include "WKAPICast.h" +#include "WebGeolocationPosition.h" + +using namespace WebKit; + +WKTypeID WKGeolocationPositionGetTypeID() +{ + return toAPI(WebGeolocationPosition::APIType); +} + +WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy) +{ + RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy); + return toAPI(position.release().releaseRef()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h new file mode 100644 index 0000000..85183fd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WKGeolocationPosition_h +#define WKGeolocationPosition_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKGeolocationPositionGetTypeID(); + +WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy); + +#ifdef __cplusplus +} +#endif + +#endif /* WKGeolocationPosition_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp new file mode 100644 index 0000000..7a87265 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp @@ -0,0 +1,110 @@ +/* + * 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 "WKInspector.h" + +#if ENABLE(INSPECTOR) + +#include "WKAPICast.h" +#include "WebInspectorProxy.h" + +using namespace WebKit; + +WKTypeID WKInspectorGetTypeID() +{ + return toAPI(WebInspectorProxy::APIType); +} + +WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef) +{ + return toAPI(toImpl(inspectorRef)->page()); +} + +bool WKInspectorIsVisible(WKInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->isVisible(); +} + +void WKInspectorShow(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->show(); +} + +void WKInspectorClose(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->close(); +} + +void WKInspectorShowConsole(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->showConsole(); +} + +bool WKInspectorIsAttached(WKInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->isAttached(); +} + +void WKInspectorAttach(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->attach(); +} + +void WKInspectorDetach(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->detach(); +} + +bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->isDebuggingJavaScript(); +} + +void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->toggleJavaScriptDebugging(); +} + +bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->isProfilingJavaScript(); +} + +void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->toggleJavaScriptProfiling(); +} + +bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef) +{ + return toImpl(inspectorRef)->isProfilingPage(); +} + +void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef) +{ + toImpl(inspectorRef)->togglePageProfiling(); +} + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.h b/Source/WebKit2/UIProcess/API/C/WKInspector.h new file mode 100644 index 0000000..c147015 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKInspector.h @@ -0,0 +1,70 @@ +/* + * 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 WKInspector_h +#define WKInspector_h + +#include <WebKit2/WKBase.h> + +#if ENABLE(INSPECTOR) + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKInspectorGetTypeID(); + +WK_EXPORT WKPageRef WKInspectorGetPage(WKInspectorRef inspector); + +WK_EXPORT bool WKInspectorIsVisible(WKInspectorRef inspector); +WK_EXPORT void WKInspectorShow(WKInspectorRef inspector); +WK_EXPORT void WKInspectorClose(WKInspectorRef inspector); + +WK_EXPORT void WKInspectorShowConsole(WKInspectorRef inspector); + +WK_EXPORT bool WKInspectorIsAttached(WKInspectorRef inspector); +WK_EXPORT void WKInspectorAttach(WKInspectorRef inspector); +WK_EXPORT void WKInspectorDetach(WKInspectorRef inspector); + +WK_EXPORT bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspector); +WK_EXPORT void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspector); + +WK_EXPORT bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspector); +WK_EXPORT void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspector); + +WK_EXPORT bool WKInspectorIsProfilingPage(WKInspectorRef inspector); +WK_EXPORT void WKInspectorTogglePageProfiling(WKInspectorRef inspector); + +#ifdef __cplusplus +} +#endif + +#endif // ENABLE(INSPECTOR) + +#endif // WKInspector_h diff --git a/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h new file mode 100644 index 0000000..ee0bd17 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h @@ -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. + */ + +#ifndef WKNativeEvent_h +#define WKNativeEvent_h + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ +#ifdef __OBJC__ +@class NSEvent; +#elif __cplusplus +class NSEvent; +#else +struct NSEvent; +#endif +typedef NSEvent *WKNativeEventPtr; +#elif defined(WIN32) || defined(_WIN32) +typedef const struct tagMSG* WKNativeEventPtr; +#else +typedef const void* WKNativeEventPtr; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WKNativeEvent_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp b/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp new file mode 100644 index 0000000..90eb142 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp @@ -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. + */ + +#include "WKNavigationData.h" + +#include "WKAPICast.h" +#include "WebNavigationData.h" + +using namespace WebKit; + +WKTypeID WKNavigationDataGetTypeID() +{ + return toAPI(WebNavigationData::APIType); +} + +WKStringRef WKNavigationDataCopyTitle(WKNavigationDataRef navigationDataRef) +{ + return toCopiedAPI(toImpl(navigationDataRef)->title()); +} + +WKURLRef WKNavigationDataCopyURL(WKNavigationDataRef navigationDataRef) +{ + return toCopiedURLAPI(toImpl(navigationDataRef)->url()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKNavigationData.h b/Source/WebKit2/UIProcess/API/C/WKNavigationData.h new file mode 100644 index 0000000..c855b54 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.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 WKNavigationData_h +#define WKNavigationData_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKNavigationDataGetTypeID(); + +WK_EXPORT WKStringRef WKNavigationDataCopyTitle(WKNavigationDataRef navigationData); +WK_EXPORT WKURLRef WKNavigationDataCopyURL(WKNavigationDataRef navigationData); + +#ifdef __cplusplus +} +#endif + +#endif /* WKNavigationData_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp new file mode 100644 index 0000000..3cf89cf --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp @@ -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. + */ + +#include "WKOpenPanelParameters.h" + +#include "WKAPICast.h" +#include "WebOpenPanelParameters.h" + +using namespace WebKit; + +WKTypeID WKOpenPanelParametersGetTypeID() +{ + return toAPI(WebOpenPanelParameters::APIType); +} + +bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef) +{ + return toImpl(parametersRef)->allowMultipleFiles(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h new file mode 100644 index 0000000..f32731c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.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 WKOpenPanelParameters_h +#define WKOpenPanelParameters_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKOpenPanelParametersGetTypeID(); + +WK_EXPORT bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parameters); + +#ifdef __cplusplus +} +#endif + +#endif /* WKOpenPanelParameters_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp new file mode 100644 index 0000000..5b143f2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp @@ -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. + */ + +#include "WKOpenPanelResultListener.h" + +#include "WKAPICast.h" +#include "WebOpenPanelResultListenerProxy.h" + +using namespace WebKit; + +WKTypeID WKOpenPanelResultListenerGetTypeID() +{ + return toAPI(WebOpenPanelResultListenerProxy::APIType); +} + +void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef) +{ + toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef)); +} + +void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef) +{ + toImpl(listenerRef)->cancel(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h new file mode 100644 index 0000000..d581738 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.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 WKOpenPanelResultListener_h +#define WKOpenPanelResultListener_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKOpenPanelResultListenerGetTypeID(); + +WK_EXPORT void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listener, WKArrayRef fileURLs); +WK_EXPORT void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listener); + +#ifdef __cplusplus +} +#endif + +#endif /* WKOpenPanelResultListener_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp new file mode 100644 index 0000000..edcbf87 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -0,0 +1,431 @@ +/* + * 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 "WKPage.h" +#include "WKPagePrivate.h" + +#include "WKAPICast.h" +#include "WebBackForwardList.h" +#include "WebData.h" +#include "WebPageProxy.h" + +#ifdef __BLOCKS__ +#include <Block.h> +#endif + +using namespace WebKit; + +WKTypeID WKPageGetTypeID() +{ + return toAPI(WebPageProxy::APIType); +} + +WKContextRef WKPageGetContext(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->context()); +} + +WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->pageGroup()); +} + +void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef) +{ + toImpl(pageRef)->loadURL(toImpl(URLRef)->string()); +} + +void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef) +{ + toImpl(pageRef)->loadURLRequest(toImpl(urlRequestRef)); +} + +void WKPageLoadHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef) +{ + toImpl(pageRef)->loadHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef)); +} + +void WKPageLoadAlternateHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef) +{ + toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef), toWTFString(unreachableURLRef)); +} + +void WKPageLoadPlainTextString(WKPageRef pageRef, WKStringRef plainTextStringRef) +{ + toImpl(pageRef)->loadPlainTextString(toWTFString(plainTextStringRef)); +} + +void WKPageStopLoading(WKPageRef pageRef) +{ + toImpl(pageRef)->stopLoading(); +} + +void WKPageReload(WKPageRef pageRef) +{ + toImpl(pageRef)->reload(false); +} + +void WKPageReloadFromOrigin(WKPageRef pageRef) +{ + toImpl(pageRef)->reload(true); +} + +bool WKPageTryClose(WKPageRef pageRef) +{ + return toImpl(pageRef)->tryClose(); +} + +void WKPageClose(WKPageRef pageRef) +{ + toImpl(pageRef)->close(); +} + +bool WKPageIsClosed(WKPageRef pageRef) +{ + return toImpl(pageRef)->isClosed(); +} + +void WKPageGoForward(WKPageRef pageRef) +{ + toImpl(pageRef)->goForward(); +} + +bool WKPageCanGoForward(WKPageRef pageRef) +{ + return toImpl(pageRef)->canGoForward(); +} + +void WKPageGoBack(WKPageRef pageRef) +{ + toImpl(pageRef)->goBack(); +} + +bool WKPageCanGoBack(WKPageRef pageRef) +{ + return toImpl(pageRef)->canGoBack(); +} + +void WKPageGoToBackForwardListItem(WKPageRef pageRef, WKBackForwardListItemRef itemRef) +{ + toImpl(pageRef)->goToBackForwardItem(toImpl(itemRef)); +} + +WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->backForwardList()); +} + +WKStringRef WKPageCopyTitle(WKPageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->pageTitle()); +} + +WKFrameRef WKPageGetMainFrame(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->mainFrame()); +} + +WKFrameRef WKPageGetFocusedFrame(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->focusedFrame()); +} + +WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->frameSetLargestFrame()); +} + +#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR +WKInspectorRef WKPageGetInspector(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->inspector()); +} +#endif + +double WKPageGetEstimatedProgress(WKPageRef pageRef) +{ + return toImpl(pageRef)->estimatedProgress(); +} + +WKStringRef WKPageCopyUserAgent(WKPageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->userAgent()); +} + +WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->applicationNameForUserAgent()); +} + +void WKPageSetApplicationNameForUserAgent(WKPageRef pageRef, WKStringRef applicationNameRef) +{ + toImpl(pageRef)->setApplicationNameForUserAgent(toWTFString(applicationNameRef)); +} + +WKStringRef WKPageCopyCustomUserAgent(WKPageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->customUserAgent()); +} + +void WKPageSetCustomUserAgent(WKPageRef pageRef, WKStringRef userAgentRef) +{ + toImpl(pageRef)->setCustomUserAgent(toWTFString(userAgentRef)); +} + +bool WKPageSupportsTextEncoding(WKPageRef pageRef) +{ + return toImpl(pageRef)->supportsTextEncoding(); +} + +WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef pageRef) +{ + return toCopiedAPI(toImpl(pageRef)->customTextEncodingName()); +} + +void WKPageSetCustomTextEncodingName(WKPageRef pageRef, WKStringRef encodingNameRef) +{ + toImpl(pageRef)->setCustomTextEncodingName(toWTFString(encodingNameRef)); +} + +void WKPageTerminate(WKPageRef pageRef) +{ + toImpl(pageRef)->terminateProcess(); +} + +WKStringRef WKPageGetSessionHistoryURLValueType() +{ + static WebString* sessionHistoryURLValueType = WebString::create("SessionHistoryURL").releaseRef(); + return toAPI(sessionHistoryURLValueType); +} + +WKDataRef WKPageCopySessionState(WKPageRef pageRef, void *context, WKPageSessionStateFilterCallback filter) +{ + return toAPI(toImpl(pageRef)->sessionStateData(filter, context).releaseRef()); +} + +void WKPageRestoreFromSessionState(WKPageRef pageRef, WKDataRef sessionStateData) +{ + toImpl(pageRef)->restoreFromSessionStateData(toImpl(sessionStateData)); +} + +double WKPageGetTextZoomFactor(WKPageRef pageRef) +{ + return toImpl(pageRef)->textZoomFactor(); +} + +bool WKPageSupportsTextZoom(WKPageRef pageRef) +{ + return toImpl(pageRef)->supportsTextZoom(); +} + +void WKPageSetTextZoomFactor(WKPageRef pageRef, double zoomFactor) +{ + toImpl(pageRef)->setTextZoomFactor(zoomFactor); +} + +double WKPageGetPageZoomFactor(WKPageRef pageRef) +{ + return toImpl(pageRef)->pageZoomFactor(); +} + +void WKPageSetPageZoomFactor(WKPageRef pageRef, double zoomFactor) +{ + toImpl(pageRef)->setPageZoomFactor(zoomFactor); +} + +void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, double textZoomFactor) +{ + toImpl(pageRef)->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor); +} + +void WKPageScaleWebView(WKPageRef pageRef, double scale, WKPoint origin) +{ + toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin)); +} + +void WKPageSetUseFixedLayout(WKPageRef pageRef, bool fixed) +{ + toImpl(pageRef)->setUseFixedLayout(fixed); +} + +void WKPageSetFixedLayoutSize(WKPageRef pageRef, WKSize size) +{ + toImpl(pageRef)->setFixedLayoutSize(toIntSize(size)); +} + +bool WKPageUseFixedLayout(WKPageRef pageRef) +{ + return toImpl(pageRef)->useFixedLayout(); +} + +WKSize WKPageFixedLayoutSize(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->fixedLayoutSize()); +} + +double WKPageGetViewScaleFactor(WKPageRef pageRef) +{ + return toImpl(pageRef)->viewScaleFactor(); +} + +void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) +{ + toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount); +} + +void WKPageHideFindUI(WKPageRef pageRef) +{ + toImpl(pageRef)->hideFindUI(); +} + +void WKPageCountStringMatches(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount) +{ + toImpl(pageRef)->countStringMatches(toImpl(string)->string(), toFindOptions(options), maxMatchCount); +} + +void WKPageSetPageContextMenuClient(WKPageRef pageRef, const WKPageContextMenuClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeContextMenuClient(wkClient); +} + +void WKPageSetPageFindClient(WKPageRef pageRef, const WKPageFindClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeFindClient(wkClient); +} + +void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeFormClient(wkClient); +} + +void WKPageSetPageLoaderClient(WKPageRef pageRef, const WKPageLoaderClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeLoaderClient(wkClient); +} + +void WKPageSetPagePolicyClient(WKPageRef pageRef, const WKPagePolicyClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializePolicyClient(wkClient); +} + +void WKPageSetPageResourceLoadClient(WKPageRef pageRef, const WKPageResourceLoadClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeResourceLoadClient(wkClient); +} + +void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient* wkClient) +{ + if (wkClient && wkClient->version) + return; + toImpl(pageRef)->initializeUIClient(wkClient); +} + +void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback) +{ + toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), StringCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callRunJavaScriptBlockAndRelease(WKStringRef resultValue, WKErrorRef error, void* context) +{ + WKPageRunJavaScriptBlock block = (WKPageRunJavaScriptBlock)context; + block(resultValue, error); + Block_release(block); +} + +void WKPageRunJavaScriptInMainFrame_b(WKPageRef pageRef, WKStringRef scriptRef, WKPageRunJavaScriptBlock block) +{ + WKPageRunJavaScriptInMainFrame(pageRef, scriptRef, Block_copy(block), callRunJavaScriptBlockAndRelease); +} +#endif + +void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback) +{ + toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callRenderTreeExternalRepresentationBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context) +{ + WKPageRenderTreeExternalRepresentationBlock block = (WKPageRenderTreeExternalRepresentationBlock)context; + block(resultValue, error); + Block_release(block); +} + +void WKPageRenderTreeExternalRepresentation_b(WKPageRef pageRef, WKPageRenderTreeExternalRepresentationBlock block) +{ + WKPageRenderTreeExternalRepresentation(pageRef, Block_copy(block), callRenderTreeExternalRepresentationBlockAndDispose); +} +#endif + +void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback) +{ + toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callGetSourceForFrameBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context) +{ + WKPageGetSourceForFrameBlock block = (WKPageGetSourceForFrameBlock)context; + block(resultValue, error); + Block_release(block); +} + +void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGetSourceForFrameBlock block) +{ + WKPageGetSourceForFrame(pageRef, frameRef, Block_copy(block), callGetSourceForFrameBlockBlockAndDispose); +} +#endif + +void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback) +{ + toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback)); +} + +#ifdef __BLOCKS__ +static void callContentsAsStringBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context) +{ + WKPageGetContentsAsStringBlock block = (WKPageGetContentsAsStringBlock)context; + block(resultValue, error); + Block_release(block); +} + +void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock block) +{ + WKPageGetContentsAsString(pageRef, Block_copy(block), callContentsAsStringBlockBlockAndDispose); +} +#endif diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h new file mode 100644 index 0000000..05730e5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -0,0 +1,352 @@ +/* + * 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 WKPage_h +#define WKPage_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKEvent.h> +#include <WebKit2/WKFindOptions.h> +#include <WebKit2/WKGeometry.h> +#include <WebKit2/WKNativeEvent.h> +#include <WebKit2/WKPageLoadTypes.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// FrameLoad Client +typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo); +typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo); +typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo); + +// Progress Client +typedef void (*WKPageDidStartProgressCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageDidChangeProgressCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageDidFinishProgressCallback)(WKPageRef page, const void *clientInfo); + +// WebProcess Client +// FIXME: These three functions should not be part of this client. +typedef void (*WKPageProcessDidBecomeUnresponsiveCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageProcessDidBecomeResponsiveCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageProcessDidCrashCallback)(WKPageRef page, const void *clientInfo); + +typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, const void *clientInfo); + +struct WKPageLoaderClient { + int version; + const void * clientInfo; + WKPageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; + WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; + WKPageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; + WKPageDidCommitLoadForFrameCallback didCommitLoadForFrame; + WKPageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; + WKPageDidFinishLoadForFrameCallback didFinishLoadForFrame; + WKPageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; + WKPageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; + WKPageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; + WKPageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; + WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; + WKPageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; + WKPageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; + WKPageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; + WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback canAuthenticateAgainstProtectionSpaceInFrame; + WKPageDidReceiveAuthenticationChallengeInFrameCallback didReceiveAuthenticationChallengeInFrame; + + // FIXME: Move to progress client. + WKPageDidStartProgressCallback didStartProgress; + WKPageDidChangeProgressCallback didChangeProgress; + WKPageDidFinishProgressCallback didFinishProgress; + + // FIXME: These three functions should not be part of this client. + WKPageProcessDidBecomeUnresponsiveCallback processDidBecomeUnresponsive; + WKPageProcessDidBecomeResponsiveCallback processDidBecomeResponsive; + WKPageProcessDidCrashCallback processDidCrash; + + WKPageDidChangeBackForwardListCallback didChangeBackForwardList; +}; +typedef struct WKPageLoaderClient WKPageLoaderClient; + +// Policy Client. +typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo); +typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo); +typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo); + +struct WKPagePolicyClient { + int version; + const void * clientInfo; + WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction; + WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction; + WKPageDecidePolicyForMIMETypeCallback decidePolicyForMIMEType; +}; +typedef struct WKPagePolicyClient WKPagePolicyClient; + +// Form Client. +typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo); + +struct WKPageFormClient { + int version; + const void * clientInfo; + WKPageWillSubmitFormCallback willSubmitForm; +}; +typedef struct WKPageFormClient WKPageFormClient; + +// Resource Load Client. +typedef void (*WKPageDidInitiateLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, const void* clientInfo); +typedef void (*WKPageDidSendRequestForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo); +typedef void (*WKPageDidReceiveResponseForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLResponseRef response, const void* clientInfo); +typedef void (*WKPageDidReceiveContentLengthForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo); +typedef void (*WKPageDidFinishLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo); +typedef void (*WKPageDidFailLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo); + +struct WKPageResourceLoadClient { + int version; + const void * clientInfo; + WKPageDidInitiateLoadForResourceCallback didInitiateLoadForResource; + WKPageDidSendRequestForResourceCallback didSendRequestForResource; + WKPageDidReceiveResponseForResourceCallback didReceiveResponseForResource; + WKPageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource; + WKPageDidFinishLoadForResourceCallback didFinishLoadForResource; + WKPageDidFailLoadForResourceCallback didFailLoadForResource; +}; +typedef struct WKPageResourceLoadClient WKPageResourceLoadClient; + +// UI Client +typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo); +typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageCloseCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo); +typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo); +typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo); +typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo); +typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo); +typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, const void* clientInfo); +typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo); +typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo); +typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo); +typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo); +typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo); +typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo); +typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo); +typedef void (*WKPageDidDrawCallback)(WKPageRef page, const void *clientInfo); +typedef void (*WKPageDidScrollCallback)(WKPageRef page, const void *clientInfo); +typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo); +typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo); +typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo); + +struct WKPageUIClient { + int version; + const void * clientInfo; + WKPageCreateNewPageCallback createNewPage; + WKPageShowPageCallback showPage; + WKPageCloseCallback close; + WKPageRunJavaScriptAlertCallback runJavaScriptAlert; + WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm; + WKPageRunJavaScriptPromptCallback runJavaScriptPrompt; + WKPageSetStatusTextCallback setStatusText; + WKPageMouseDidMoveOverElementCallback mouseDidMoveOverElement; + WKPageMissingPluginButtonClickedCallback missingPluginButtonClicked; + WKPageDidNotHandleKeyEventCallback didNotHandleKeyEvent; + WKPageGetToolbarsAreVisibleCallback toolbarsAreVisible; + WKPageSetToolbarsAreVisibleCallback setToolbarsAreVisible; + WKPageGetMenuBarIsVisibleCallback menuBarIsVisible; + WKPageSetMenuBarIsVisibleCallback setMenuBarIsVisible; + WKPageGetStatusBarIsVisibleCallback statusBarIsVisible; + WKPageSetStatusBarIsVisibleCallback setStatusBarIsVisible; + WKPageGetIsResizableCallback isResizable; + WKPageSetIsResizableCallback setIsResizable; + WKPageGetWindowFrameCallback getWindowFrame; + WKPageSetWindowFrameCallback setWindowFrame; + WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel; + WKPageDidDrawCallback didDraw; + WKPageDidScrollCallback pageDidScroll; + WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota; + WKPageRunOpenPanelCallback runOpenPanel; + WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest; +}; +typedef struct WKPageUIClient WKPageUIClient; + +// Find client. +typedef void (*WKPageDidFindStringCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo); +typedef void (*WKPageDidFailToFindStringCallback)(WKPageRef page, WKStringRef string, const void* clientInfo); +typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo); + +struct WKPageFindClient { + int version; + const void * clientInfo; + WKPageDidFindStringCallback didFindString; + WKPageDidFailToFindStringCallback didFailToFindString; + WKPageDidCountStringMatchesCallback didCountStringMatches; +}; +typedef struct WKPageFindClient WKPageFindClient; + +enum { + kWKMoreThanMaximumMatchCount = -1 +}; + +// ContextMenu client +typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo); +typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo); + +struct WKPageContextMenuClient { + int version; + const void * clientInfo; + WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu; + WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected; +}; +typedef struct WKPageContextMenuClient WKPageContextMenuClient; + +WK_EXPORT WKTypeID WKPageGetTypeID(); + +WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page); +WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page); + +WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url); +WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest); +WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL); +WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL); +WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString); + +WK_EXPORT void WKPageStopLoading(WKPageRef page); +WK_EXPORT void WKPageReload(WKPageRef page); +WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page); + +WK_EXPORT bool WKPageTryClose(WKPageRef page); +WK_EXPORT void WKPageClose(WKPageRef page); +WK_EXPORT bool WKPageIsClosed(WKPageRef page); + +WK_EXPORT void WKPageGoForward(WKPageRef page); +WK_EXPORT bool WKPageCanGoForward(WKPageRef page); +WK_EXPORT void WKPageGoBack(WKPageRef page); +WK_EXPORT bool WKPageCanGoBack(WKPageRef page); +WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item); +WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page); + +WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page); + +WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page); +WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive. +WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page); +WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page); + +#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR +WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page); +#endif + +WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page); + +WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page); +WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName); + +WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page); +WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent); + +WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page); +WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page); +WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName); + +WK_EXPORT void WKPageTerminate(WKPageRef page); + +WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void); + +typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context); +WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback); +WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData); + +WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page); +WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page); +WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor); +WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page); +WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor); +WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor); + +WK_EXPORT void WKPageScaleWebView(WKPageRef page, double scale, WKPoint origin); +WK_EXPORT double WKPageGetViewScaleFactor(WKPageRef page); + +WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed); +WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size); +WK_EXPORT bool WKPageUseFixedLayout(WKPageRef pageRef); +WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef pageRef); + +WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); +WK_EXPORT void WKPageHideFindUI(WKPageRef page); +WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount); + +WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client); +WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client); +WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client); +WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client); +WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClient* client); +WK_EXPORT void WKPageSetPageResourceLoadClient(WKPageRef page, const WKPageResourceLoadClient* client); +WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client); + +typedef void (*WKPageRunJavaScriptFunction)(WKStringRef, WKErrorRef, void*); +WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function); +#ifdef __BLOCKS__ +typedef void (^WKPageRunJavaScriptBlock)(WKStringRef, WKErrorRef); +WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block); +#endif + +typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*); +WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function); +#ifdef __BLOCKS__ +typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef); +WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block); +#endif + +typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*); +WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function); +#ifdef __BLOCKS__ +typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef); +WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WKPage_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp new file mode 100644 index 0000000..6c10014 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp @@ -0,0 +1,58 @@ +/* + * 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 "WKPageGroup.h" + +#include "WKAPICast.h" +#include "WebPageGroup.h" +#include "WebPreferences.h" + +using namespace WebKit; + +WKTypeID WKPageGroupGetTypeID() +{ + return toAPI(WebPageGroup::APIType); +} + +WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier) +{ + RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(toWTFString(identifier)); + return toAPI(pageGroup.release().leakRef()); +} + +WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroupRef) +{ + return toCopiedAPI(toImpl(pageGroupRef)->identifier()); +} + +void WKPageGroupSetPreferences(WKPageGroupRef pageGroupRef, WKPreferencesRef preferencesRef) +{ + toImpl(pageGroupRef)->setPreferences(toImpl(preferencesRef)); +} + +WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroupRef) +{ + return toAPI(toImpl(pageGroupRef)->preferences()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.h b/Source/WebKit2/UIProcess/API/C/WKPageGroup.h new file mode 100644 index 0000000..705df08 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.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 WKPageGroup_h +#define WKPageGroup_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKPageGroupGetTypeID(); + +WK_EXPORT WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier); + +WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup); + +WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences); +WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup); + +#ifdef __cplusplus +} +#endif + +#endif /* WKPageGroup_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h new file mode 100644 index 0000000..3bf50c3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.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 WKPagePrivate_h +#define WKPagePrivate_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKPage.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*WKPageRenderTreeExternalRepresentationFunction)(WKStringRef, WKErrorRef, void*); +WK_EXPORT void WKPageRenderTreeExternalRepresentation(WKPageRef page, void *context, WKPageRenderTreeExternalRepresentationFunction function); + +#ifdef __BLOCKS__ +typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKErrorRef); +WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WKPagePrivate_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp new file mode 100644 index 0000000..379859c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -0,0 +1,451 @@ +/* + * 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 "WKPreferences.h" +#include "WKPreferencesPrivate.h" + +#include "WKAPICast.h" +#include "WebPreferences.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +using namespace WebKit; + +WKTypeID WKPreferencesGetTypeID() +{ + return toAPI(WebPreferences::APIType); +} + +WKPreferencesRef WKPreferencesCreate() +{ + RefPtr<WebPreferences> preferences = WebPreferences::create(); + return toAPI(preferences.release().leakRef()); +} + +WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef) +{ + RefPtr<WebPreferences> preferences = WebPreferences::create(toWTFString(identifierRef)); + return toAPI(preferences.release().releaseRef()); +} + +void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferencesRef, bool javaScriptEnabled) +{ + toImpl(preferencesRef)->setJavaScriptEnabled(javaScriptEnabled); +} + +bool WKPreferencesGetJavaScriptEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->javaScriptEnabled(); +} + +void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef preferencesRef, bool loadsImagesAutomatically) +{ + toImpl(preferencesRef)->setLoadsImagesAutomatically(loadsImagesAutomatically); +} + +bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->loadsImagesAutomatically(); +} + +void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef, bool offlineWebApplicationCacheEnabled) +{ + toImpl(preferencesRef)->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled); +} + +bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->offlineWebApplicationCacheEnabled(); +} + +void WKPreferencesSetLocalStorageEnabled(WKPreferencesRef preferencesRef, bool localStorageEnabled) +{ + toImpl(preferencesRef)->setLocalStorageEnabled(localStorageEnabled); +} + +bool WKPreferencesGetLocalStorageEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->localStorageEnabled(); +} + +void WKPreferencesSetDatabasesEnabled(WKPreferencesRef preferencesRef, bool databasesEnabled) +{ + toImpl(preferencesRef)->setDatabasesEnabled(databasesEnabled); +} + +bool WKPreferencesGetDatabasesEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->databasesEnabled(); +} + +void WKPreferencesSetXSSAuditorEnabled(WKPreferencesRef preferencesRef, bool xssAuditorEnabled) +{ + toImpl(preferencesRef)->setXSSAuditorEnabled(xssAuditorEnabled); +} + +bool WKPreferencesGetXSSAuditorEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->xssAuditorEnabled(); +} + +void WKPreferencesSetFrameFlatteningEnabled(WKPreferencesRef preferencesRef, bool frameFlatteningEnabled) +{ + toImpl(preferencesRef)->setFrameFlatteningEnabled(frameFlatteningEnabled); +} + +bool WKPreferencesGetFrameFlatteningEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->frameFlatteningEnabled(); +} + +void WKPreferencesSetPluginsEnabled(WKPreferencesRef preferencesRef, bool pluginsEnabled) +{ + toImpl(preferencesRef)->setPluginsEnabled(pluginsEnabled); +} + +bool WKPreferencesGetPluginsEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->pluginsEnabled(); +} + +void WKPreferencesSetJavaEnabled(WKPreferencesRef preferencesRef, bool javaEnabled) +{ + toImpl(preferencesRef)->setJavaEnabled(javaEnabled); +} + +bool WKPreferencesGetJavaEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->javaEnabled(); +} + +void WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef, bool javaScriptCanOpenWindowsAutomatically) +{ + toImpl(preferencesRef)->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically); +} + +bool WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->javaScriptCanOpenWindowsAutomatically(); +} + +void WKPreferencesSetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef, bool hyperlinkAuditingEnabled) +{ + toImpl(preferencesRef)->setHyperlinkAuditingEnabled(hyperlinkAuditingEnabled); +} + +bool WKPreferencesGetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->hyperlinkAuditingEnabled(); +} + +void WKPreferencesSetStandardFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setStandardFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopyStandardFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->standardFontFamily()); +} + +void WKPreferencesSetFixedFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setFixedFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopyFixedFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->fixedFontFamily()); +} + +void WKPreferencesSetSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setSerifFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopySerifFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->serifFontFamily()); +} + +void WKPreferencesSetSansSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setSansSerifFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopySansSerifFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->sansSerifFontFamily()); +} + +void WKPreferencesSetCursiveFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setCursiveFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopyCursiveFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->cursiveFontFamily()); +} + +void WKPreferencesSetFantasyFontFamily(WKPreferencesRef preferencesRef, WKStringRef family) +{ + toImpl(preferencesRef)->setFantasyFontFamily(toWTFString(family)); +} + +WKStringRef WKPreferencesCopyFantasyFontFamily(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->fantasyFontFamily()); +} + +void WKPreferencesSetDefaultFontSize(WKPreferencesRef preferencesRef, uint32_t size) +{ + toImpl(preferencesRef)->setDefaultFontSize(size); +} + +uint32_t WKPreferencesGetDefaultFontSize(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->defaultFontSize(); +} + +void WKPreferencesSetDefaultFixedFontSize(WKPreferencesRef preferencesRef, uint32_t size) +{ + toImpl(preferencesRef)->setDefaultFixedFontSize(size); +} + +uint32_t WKPreferencesGetDefaultFixedFontSize(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->defaultFixedFontSize(); +} + +void WKPreferencesSetMinimumFontSize(WKPreferencesRef preferencesRef, uint32_t size) +{ + toImpl(preferencesRef)->setMinimumFontSize(size); +} + +uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->minimumFontSize(); +} + +void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name) +{ + toImpl(preferencesRef)->setDefaultTextEncodingName(toWTFString(name)); +} + +WKStringRef WKPreferencesCopyDefaultTextEncodingName(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->defaultTextEncodingName()); +} + +void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setPrivateBrowsingEnabled(enabled); +} + +bool WKPreferencesGetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->privateBrowsingEnabled(); +} + +void WKPreferencesSetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setDeveloperExtrasEnabled(enabled); +} + +bool WKPreferencesGetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->developerExtrasEnabled(); +} + +void WKPreferencesSetTextAreasAreResizable(WKPreferencesRef preferencesRef, bool resizable) +{ + toImpl(preferencesRef)->setTextAreasAreResizable(resizable); +} + +bool WKPreferencesGetTextAreasAreResizable(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->textAreasAreResizable(); +} + +void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef preferencesRef, WKFontSmoothingLevel wkLevel) +{ + toImpl(preferencesRef)->setFontSmoothingLevel(toFontSmoothingLevel(wkLevel)); +} + +WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef preferencesRef) +{ + return toAPI(static_cast<FontSmoothingLevel>(toImpl(preferencesRef)->fontSmoothingLevel())); +} + +void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setAcceleratedCompositingEnabled(flag); +} + +bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->acceleratedCompositingEnabled(); +} + +void WKPreferencesSetCompositingBordersVisible(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setCompositingBordersVisible(flag); +} + +bool WKPreferencesGetCompositingBordersVisible(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->compositingBordersVisible(); +} + +void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setCompositingRepaintCountersVisible(flag); +} + +bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->compositingRepaintCountersVisible(); +} + +void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setNeedsSiteSpecificQuirks(flag); +} + +bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->needsSiteSpecificQuirks(); +} + +void WKPreferencesSetForceFTPDirectoryListings(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setForceFTPDirectoryListings(flag); +} + +bool WKPreferencesGetForceFTPDirectoryListings(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->forceFTPDirectoryListings(); +} + +void WKPreferencesSetFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef, WKStringRef pathRef) +{ + toImpl(preferencesRef)->setFTPDirectoryTemplatePath(toWTFString(pathRef)); +} + +WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef) +{ + return toCopiedAPI(toImpl(preferencesRef)->ftpDirectoryTemplatePath()); +} + +void WKPreferencesSetTabsToLinks(WKPreferencesRef preferencesRef, bool tabsToLinks) +{ + toImpl(preferencesRef)->setTabsToLinks(tabsToLinks); +} + +bool WKPreferencesGetTabsToLinks(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->tabsToLinks(); +} + +void WKPreferencesSetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setDNSPrefetchingEnabled(enabled); +} + +bool WKPreferencesGetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->dnsPrefetchingEnabled(); +} + +void WKPreferencesSetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setAuthorAndUserStylesEnabled(enabled); +} + +bool WKPreferencesGetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->authorAndUserStylesEnabled(); +} + +void WKPreferencesSetShouldPrintBackgrounds(WKPreferencesRef preferencesRef, bool flag) +{ + toImpl(preferencesRef)->setShouldPrintBackgrounds(flag); +} + +bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->shouldPrintBackgrounds(); +} + +void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setWebArchiveDebugModeEnabled(enabled); +} + +bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->webArchiveDebugModeEnabled(); +} + +void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setLocalFileContentSniffingEnabled(enabled); +} + +bool WKPreferencesGetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->localFileContentSniffingEnabled(); +} + +void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setUsesPageCache(enabled); +} + +bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->usesPageCache(); +} + +void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setPaginateDuringLayoutEnabled(enabled); +} + +bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->paginateDuringLayoutEnabled(); +} + +void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setDOMPasteAllowed(enabled); +} + +bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->domPasteAllowed(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h new file mode 100644 index 0000000..8116575 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -0,0 +1,153 @@ +/* + * 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 WKPreferences_h +#define WKPreferences_h + +#include <WebKit2/WKBase.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKPreferencesGetTypeID(); + +WK_EXPORT WKPreferencesRef WKPreferencesCreate(); +WK_EXPORT WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifier); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferences, bool javaScriptEnabled); +WK_EXPORT bool WKPreferencesGetJavaScriptEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef preferences, bool loadsImagesAutomatically); +WK_EXPORT bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences, bool offlineWebApplicationCacheEnabled); +WK_EXPORT bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetLocalStorageEnabled(WKPreferencesRef preferences, bool localStorageEnabled); +WK_EXPORT bool WKPreferencesGetLocalStorageEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetDatabasesEnabled(WKPreferencesRef preferences, bool databasesEnabled); +WK_EXPORT bool WKPreferencesGetDatabasesEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetXSSAuditorEnabled(WKPreferencesRef preferences, bool xssAuditorEnabled); +WK_EXPORT bool WKPreferencesGetXSSAuditorEnabled(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetFrameFlatteningEnabled(WKPreferencesRef preferences, bool frameFlatteningEnabled); +WK_EXPORT bool WKPreferencesGetFrameFlatteningEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetPluginsEnabled(WKPreferencesRef preferences, bool pluginsEnabled); +WK_EXPORT bool WKPreferencesGetPluginsEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetJavaEnabled(WKPreferencesRef preferences, bool javaEnabled); +WK_EXPORT bool WKPreferencesGetJavaEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferences, bool javaScriptCanOpenWindowsAutomatically); +WK_EXPORT bool WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetHyperlinkAuditingEnabled(WKPreferencesRef preferences, bool hyperlinkAuditingEnabled); +WK_EXPORT bool WKPreferencesGetHyperlinkAuditingEnabled(WKPreferencesRef preferences); + +WK_EXPORT void WKPreferencesSetStandardFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopyStandardFontFamily(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetFixedFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopyFixedFontFamily(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopySerifFontFamily(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetSansSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopySansSerifFontFamily(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetCursiveFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopyCursiveFontFamily(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetFantasyFontFamily(WKPreferencesRef preferencesRef, WKStringRef family); +WK_EXPORT WKStringRef WKPreferencesCopyFantasyFontFamily(WKPreferencesRef preferencesRef); + +// Defaults to 16. +WK_EXPORT void WKPreferencesSetDefaultFontSize(WKPreferencesRef preferencesRef, uint32_t); +WK_EXPORT uint32_t WKPreferencesGetDefaultFontSize(WKPreferencesRef preferencesRef); + +// Defaults to 13. +WK_EXPORT void WKPreferencesSetDefaultFixedFontSize(WKPreferencesRef preferencesRef, uint32_t); +WK_EXPORT uint32_t WKPreferencesGetDefaultFixedFontSize(WKPreferencesRef preferencesRef); + +// Defaults to 0. +WK_EXPORT void WKPreferencesSetMinimumFontSize(WKPreferencesRef preferencesRef, uint32_t); +WK_EXPORT uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef); + +WK_EXPORT void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name); +WK_EXPORT WKStringRef WKPreferencesCopyDefaultTextEncodingName(WKPreferencesRef preferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetTextAreasAreResizable(WKPreferencesRef preferencesRef, bool resizable); +WK_EXPORT bool WKPreferencesGetTextAreasAreResizable(WKPreferencesRef preferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetTabsToLinks(WKPreferencesRef preferences, bool tabsToLinks); +WK_EXPORT bool WKPreferencesGetTabsToLinks(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetDNSPrefetchingEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetDNSPrefetchingEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetAuthorAndUserStylesEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetAuthorAndUserStylesEnabled(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetShouldPrintBackgrounds(WKPreferencesRef preferences, bool shouldPrintBackgrounds); +WK_EXPORT bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferences); + +#ifdef __cplusplus +} +#endif + +#endif /* WKPreferences_h */ diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h new file mode 100644 index 0000000..7408c8e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -0,0 +1,99 @@ +/* + * 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 WKPreferencesPrivate_h +#define WKPreferencesPrivate_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum WKFontSmoothingLevel { + kWKFontSmoothingLevelNoSubpixelAntiAliasing = 0, + kWKFontSmoothingLevelLight = 1, + kWKFontSmoothingLevelMedium = 2, + kWKFontSmoothingLevelStrong = 3, +#if defined(WIN32) || defined(_WIN32) + kWKFontSmoothingLevelWindows = 4, +#endif +}; +typedef enum WKFontSmoothingLevel WKFontSmoothingLevel; + +// Defaults to kWKFontSmoothingLevelMedium. +WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel); +WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetCompositingBordersVisible(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetCompositingBordersVisible(WKPreferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef, bool); +WK_EXPORT bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetForceFTPDirectoryListings(WKPreferencesRef preferences, bool force); +WK_EXPORT bool WKPreferencesGetForceFTPDirectoryListings(WKPreferencesRef preferences); + +// Defaults to the empty string. +WK_EXPORT void WKPreferencesSetFTPDirectoryTemplatePath(WKPreferencesRef preferences, WKStringRef path); +WK_EXPORT WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetLocalFileContentSniffingEnabled(WKPreferencesRef preferences); + +// Defaults to true. +WK_EXPORT void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferences); + +// Defaults to false. +WK_EXPORT void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferences); + +#ifdef __cplusplus +} +#endif + +#endif /* WKPreferencesPrivate_h */ + diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp new file mode 100644 index 0000000..c72ee98 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp @@ -0,0 +1,71 @@ +/* + * 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 "WKProtectionSpace.h" + +#include "WebProtectionSpace.h" +#include "WKAPICast.h" + +using namespace WebKit; + +WKTypeID WKProtectionSpaceGetTypeID() +{ + return toAPI(WebProtectionSpace::APIType); +} + +WKStringRef WKProtectionSpaceCopyHost(WKProtectionSpaceRef protectionSpaceRef) +{ + return toCopiedAPI(toImpl(protectionSpaceRef)->host()); +} + +int WKProtectionSpaceGetPort(WKProtectionSpaceRef protectionSpaceRef) +{ + return toImpl(protectionSpaceRef)->port(); +} + +WKStringRef WKProtectionSpaceCopyRealm(WKProtectionSpaceRef protectionSpaceRef) +{ + return toCopiedAPI(toImpl(protectionSpaceRef)->realm()); +} + +bool WKProtectionSpaceGetIsProxy(WKProtectionSpaceRef protectionSpaceRef) +{ + return toImpl(protectionSpaceRef)->isProxy(); +} + +WKProtectionSpaceServerType WKProtectionSpaceGetServerType(WKProtectionSpaceRef protectionSpaceRef) +{ + return toAPI(toImpl(protectionSpaceRef)->serverType()); +} + +bool WKProtectionSpaceGetReceivesCredentialSecurely(WKProtectionSpaceRef protectionSpaceRef) +{ + return toImpl(protectionSpaceRef)->receivesCredentialSecurely(); +} + +WKProtectionSpaceAuthenticationScheme WKProtectionSpaceGetAuthenticationScheme(WKProtectionSpaceRef protectionSpaceRef) +{ + return toAPI(toImpl(protectionSpaceRef)->authenticationScheme()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h new file mode 100644 index 0000000..c77d93b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.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 WKProtectionSpace_h +#define WKProtectionSpace_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKProtectionSpaceTypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKProtectionSpaceGetTypeID(); + +WK_EXPORT WKStringRef WKProtectionSpaceCopyHost(WKProtectionSpaceRef); +WK_EXPORT int WKProtectionSpaceGetPort(WKProtectionSpaceRef); +WK_EXPORT WKStringRef WKProtectionSpaceCopyRealm(WKProtectionSpaceRef); +WK_EXPORT bool WKProtectionSpaceGetIsProxy(WKProtectionSpaceRef); +WK_EXPORT WKProtectionSpaceServerType WKProtectionSpaceGetServerType(WKProtectionSpaceRef); +WK_EXPORT bool WKProtectionSpaceGetReceivesCredentialSecurely(WKProtectionSpaceRef); +WK_EXPORT WKProtectionSpaceAuthenticationScheme WKProtectionSpaceGetAuthenticationScheme(WKProtectionSpaceRef); + +#ifdef __cplusplus +} +#endif + +#endif // WKProtectionSpace_h diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h b/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h new file mode 100644 index 0000000..fd1bd09 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h @@ -0,0 +1,64 @@ +/* + * 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 WKProtectionSpaceTypes_h +#define WKProtectionSpaceTypes_h + +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + kWKProtectionSpaceServerTypeHTTP = 1, + kWKProtectionSpaceServerTypeHTTPS, + kWKProtectionSpaceServerTypeFTP, + kWKProtectionSpaceServerTypeFTPS, + kWKProtectionSpaceProxyTypeHTTP, + kWKProtectionSpaceProxyTypeHTTPS, + kWKProtectionSpaceProxyTypeFTP, + kWKProtectionSpaceProxyTypeSOCKS, +}; +typedef uint32_t WKProtectionSpaceServerType; + +enum { + kWKProtectionSpaceAuthenticationSchemeDefault = 1, + kWKProtectionSpaceAuthenticationSchemeHTTPBasic, + kWKProtectionSpaceAuthenticationSchemeHTTPDigest, + kWKProtectionSpaceAuthenticationSchemeHTMLForm, + kWKProtectionSpaceAuthenticationSchemeNTLM, + kWKProtectionSpaceAuthenticationSchemeNegotiate, + kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested, + kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested, + kWKProtectionSpaceAuthenticationSchemeUnknown = 100, +}; +typedef uint32_t WKProtectionSpaceAuthenticationScheme; + +#ifdef __cplusplus +} +#endif + +#endif // WKProtectionSpaceTypes_h diff --git a/Source/WebKit2/UIProcess/API/C/WebKit2.h b/Source/WebKit2/UIProcess/API/C/WebKit2.h new file mode 100644 index 0000000..02a339f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/WebKit2.h @@ -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. + */ + +#ifndef WebKit2_h +#define WebKit2_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKType.h> + +#include <WebKit2/WKArray.h> +#include <WebKit2/WKBackForwardList.h> +#include <WebKit2/WKBackForwardListItem.h> +#include <WebKit2/WKContext.h> +#include <WebKit2/WKData.h> +#include <WebKit2/WKDictionary.h> +#include <WebKit2/WKError.h> +#include <WebKit2/WKFormSubmissionListener.h> +#include <WebKit2/WKFrame.h> +#include <WebKit2/WKFramePolicyListener.h> +#include <WebKit2/WKGeolocationManager.h> +#include <WebKit2/WKGeolocationPermissionRequest.h> +#include <WebKit2/WKGeolocationPosition.h> +#include <WebKit2/WKMutableArray.h> +#include <WebKit2/WKMutableDictionary.h> +#include <WebKit2/WKNavigationData.h> +#include <WebKit2/WKNumber.h> +#include <WebKit2/WKOpenPanelParameters.h> +#include <WebKit2/WKOpenPanelResultListener.h> +#include <WebKit2/WKPage.h> +#include <WebKit2/WKPageGroup.h> +#include <WebKit2/WKPreferences.h> +#include <WebKit2/WKString.h> +#include <WebKit2/WKURL.h> +#include <WebKit2/WKURLRequest.h> +#include <WebKit2/WKURLResponse.h> + +#if !(defined(__APPLE__) && __APPLE__) || (defined(__OBJC__) && __OBJC__) +#include <WebKit2/WKView.h> +#endif + +#endif /* WebKit2_h */ diff --git a/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h new file mode 100644 index 0000000..78df4ac --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * 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 WKNativeEvent_h +#define WKNativeEvent_h + +// a Qt specific WKNativeEvent.h file is needed because that the use of __APPLE__ +// in original WKNativeEvent.h file breaks Qt build in MacOS + +class QEvent; +typedef const QEvent* WKNativeEventPtr; + +#endif /* WKNativeEvent_h */ diff --git a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h new file mode 100644 index 0000000..6acb1a6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.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 WKAPICastWin_h +#define WKAPICastWin_h + +#ifndef WKAPICast_h +#error "Please #include \"WKAPICast.h\" instead of this file directly." +#endif + +namespace WebKit { + +class WebView; + +WK_ADD_API_MAPPING(WKViewRef, WebView) + +} + +#endif // WKAPICastWin_h diff --git a/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h b/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h new file mode 100644 index 0000000..e2ee9a7 --- /dev/null +++ b/Source/WebKit2/UIProcess/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/UIProcess/API/C/win/WKContextPrivateWin.h b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h new file mode 100644 index 0000000..c8a9c34 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.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 WKContextPrivateWin_h +#define WKContextPrivateWin_h + +#include <WebKit2/WKBase.h> +#include <WebKit2/WKContext.h> + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// Defaults to true. +WK_EXPORT void WKContextSetShouldPaintNativeControls(WKContextRef, bool); + +#ifdef __cplusplus +} +#endif + +#endif /* WKContextPrivateWin_h */ diff --git a/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp new file mode 100644 index 0000000..9906c81 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.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 "WKContext.h" +#include "WKContextPrivateWin.h" + +#include "WKAPICast.h" +#include "WebContext.h" + +using namespace WebKit; + +void WKContextSetShouldPaintNativeControls(WKContextRef contextRef, bool b) +{ + toImpl(contextRef)->setShouldPaintNativeControls(b); +} diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.cpp b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp new file mode 100644 index 0000000..612661e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp @@ -0,0 +1,72 @@ +/* + * 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 "WKView.h" + +#include "WKAPICast.h" +#include "WebView.h" + +using namespace WebKit; + +WKTypeID WKViewGetTypeID() +{ + return toAPI(APIObject::TypeView); +} + +WKViewRef WKViewCreate(RECT rect, WKContextRef contextRef, WKPageGroupRef pageGroupRef, HWND parentWindow) +{ + RefPtr<WebView> view = WebView::create(rect, toImpl(contextRef), toImpl(pageGroupRef), parentWindow); + return toAPI(view.release().releaseRef()); +} + +HWND WKViewGetWindow(WKViewRef viewRef) +{ + return toImpl(viewRef)->window(); +} + +WKPageRef WKViewGetPage(WKViewRef viewRef) +{ + return toAPI(toImpl(viewRef)->page()); +} + +void WKViewSetParentWindow(WKViewRef viewRef, HWND hostWindow) +{ + toImpl(viewRef)->setParentWindow(hostWindow); +} + +void WKViewWindowAncestryDidChange(WKViewRef viewRef) +{ + toImpl(viewRef)->windowAncestryDidChange(); +} + +void WKViewSetIsInWindow(WKViewRef viewRef, bool isInWindow) +{ + toImpl(viewRef)->setIsInWindow(isInWindow); +} + +void WKViewSetInitialFocus(WKViewRef viewRef, bool forward) +{ + toImpl(viewRef)->setInitialFocus(forward); +} diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.h b/Source/WebKit2/UIProcess/API/C/win/WKView.h new file mode 100644 index 0000000..f4226cd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKView.h @@ -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. + */ + +#ifndef WKView_h +#define WKView_h + +#include <WebKit2/WKBase.h> +#include <windows.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKTypeID WKViewGetTypeID(); + +WK_EXPORT WKViewRef WKViewCreate(RECT rect, WKContextRef context, WKPageGroupRef pageGroup, HWND parentWindow); + +WK_EXPORT HWND WKViewGetWindow(WKViewRef view); + +WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view); + +WK_EXPORT void WKViewSetParentWindow(WKViewRef view, HWND parentWindow); +WK_EXPORT void WKViewWindowAncestryDidChange(WKViewRef view); +WK_EXPORT void WKViewSetIsInWindow(WKViewRef view, bool isInWindow); +WK_EXPORT void WKViewSetInitialFocus(WKViewRef view, bool forward); + +#ifdef __cplusplus +} +#endif + +#endif /* WKView_h */ diff --git a/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp new file mode 100644 index 0000000..00c3595 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.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 "WKViewPrivate.h" + +#include "WKAPICast.h" +#include "WebView.h" + +using namespace WebKit; + +void WKViewSetOverrideCursor(WKViewRef viewRef, HCURSOR overrideCursor) +{ + toImpl(viewRef)->setOverrideCursor(overrideCursor); +} diff --git a/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h new file mode 100644 index 0000000..5f89fd4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.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 WKViewPrivate_h +#define WKViewPrivate_h + +#include <WebKit2/WKBase.h> +#include <windows.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT void WKViewSetOverrideCursor(WKViewRef viewRef, HCURSOR overrideCursor); + +#ifdef __cplusplus +} +#endif + +#endif /* WKViewPrivate_h */ diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h new file mode 100644 index 0000000..cb2a63e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h @@ -0,0 +1,212 @@ +/* + * 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 WKRetainPtr_h +#define WKRetainPtr_h + +#include <WebKit2/WKType.h> +#include <algorithm> + +namespace WebKit { + +enum WKAdoptTag { AdoptWK }; + +template<typename T> class WKRetainPtr { +public: + typedef T PtrType; + + WKRetainPtr() + : m_ptr(0) + { + } + + WKRetainPtr(PtrType ptr) + : m_ptr(ptr) + { + if (ptr) + WKRetain(ptr); + } + + WKRetainPtr(WKAdoptTag, PtrType ptr) + : m_ptr(ptr) + { + } + + template<typename U> WKRetainPtr(const WKRetainPtr<U>& o) + : m_ptr(o.get()) + { + if (PtrType ptr = m_ptr) + WKRetain(ptr); + } + + WKRetainPtr(const WKRetainPtr& o) + : m_ptr(o.m_ptr) + { + if (PtrType ptr = m_ptr) + WKRetain(ptr); + } + + ~WKRetainPtr() + { + if (PtrType ptr = m_ptr) + WKRelease(ptr); + } + + PtrType get() const { return m_ptr; } + + void clear() + { + PtrType ptr = m_ptr; + m_ptr = 0; + if (ptr) + WKRelease(ptr); + } + + PtrType leakRef() + { + PtrType ptr = m_ptr; + m_ptr = 0; + return ptr; + } + + PtrType operator->() const { return m_ptr; } + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef PtrType WKRetainPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &WKRetainPtr::m_ptr : 0; } + + WKRetainPtr& operator=(const WKRetainPtr&); + template<typename U> WKRetainPtr& operator=(const WKRetainPtr<U>&); + WKRetainPtr& operator=(PtrType); + template<typename U> WKRetainPtr& operator=(U*); + + void adopt(PtrType); + void swap(WKRetainPtr&); + +private: + PtrType m_ptr; +}; + +template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(const WKRetainPtr<T>& o) +{ + PtrType optr = o.get(); + if (optr) + WKRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + WKRelease(ptr); + return *this; +} + +template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(const WKRetainPtr<U>& o) +{ + PtrType optr = o.get(); + if (optr) + WKRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + WKRelease(ptr); + return *this; +} + +template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(PtrType optr) +{ + if (optr) + WKRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + WKRelease(ptr); + return *this; +} + +template<typename T> inline void WKRetainPtr<T>::adopt(PtrType optr) +{ + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + WKRelease(ptr); +} + +template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(U* optr) +{ + if (optr) + WKRetain(optr); + PtrType ptr = m_ptr; + m_ptr = optr; + if (ptr) + WKRelease(ptr); + return *this; +} + +template<typename T> inline void WKRetainPtr<T>::swap(WKRetainPtr<T>& o) +{ + std::swap(m_ptr, o.m_ptr); +} + +template<typename T> inline void swap(WKRetainPtr<T>& a, WKRetainPtr<T>& b) +{ + a.swap(b); +} + +template<typename T, typename U> inline bool operator==(const WKRetainPtr<T>& a, const WKRetainPtr<U>& b) +{ + return a.get() == b.get(); +} + +template<typename T, typename U> inline bool operator==(const WKRetainPtr<T>& a, U* b) +{ + return a.get() == b; +} + +template<typename T, typename U> inline bool operator==(T* a, const WKRetainPtr<U>& b) +{ + return a == b.get(); +} + +template<typename T, typename U> inline bool operator!=(const WKRetainPtr<T>& a, const WKRetainPtr<U>& b) +{ + return a.get() != b.get(); +} + +template<typename T, typename U> inline bool operator!=(const WKRetainPtr<T>& a, U* b) +{ + return a.get() != b; +} + +template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr<U>& b) +{ + return a != b.get(); +} + +} // namespace WebKit + +using WebKit::WKRetainPtr; +using WebKit::AdoptWK; + +#endif // WKRetainPtr_h diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp new file mode 100644 index 0000000..0f2c946 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "WKStringQt.h" + +#include "WKAPICast.h" +#include <QString> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +using namespace WebKit; + +WKStringRef WKStringCreateWithQString(const QString& qString) +{ + WTF::String string(qString); + return toCopiedAPI(string); +} + +QString WKStringCopyQString(WKStringRef stringRef) +{ + if (!stringRef) + return QString(); + const WTF::String& string = toImpl(stringRef)->string(); + return QString(reinterpret_cast<const QChar*>(string.characters()), string.length()); +} diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h new file mode 100644 index 0000000..cc46e42 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WKStringQt_h +#define WKStringQt_h + +#include <QString> +#include <WebKit2/WKBase.h> + +WK_EXPORT WKStringRef WKStringCreateWithQString(const QString& string); +WK_EXPORT QString WKStringCopyQString(WKStringRef string); + +#endif /* WKStringQt_h */ diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp new file mode 100644 index 0000000..74eca86 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "WKURLQt.h" + +#include "WKAPICast.h" +#include <QString> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +using namespace WebKit; + +WKURLRef WKURLCreateWithQUrl(const QUrl& qURL) +{ + WTF::String urlString(qURL.toString()); + return toCopiedURLAPI(urlString); +} + +QUrl WKURLCopyQUrl(WKURLRef urlRef) +{ + if (!urlRef) + return QUrl(); + const WTF::String& string = toImpl(urlRef)->string(); + return QUrl(QString(reinterpret_cast<const QChar*>(string.characters()), string.length())); +} diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h new file mode 100644 index 0000000..2e41473 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef WKURLQt_h +#define WKURLQt_h + +#include <QUrl> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKURL.h> + +WK_EXPORT WKURLRef WKURLCreateWithQUrl(const QUrl& url); +QUrl WKURLCopyQUrl(WKURLRef url); + +#endif /* WKURLCF_h */ diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h new file mode 100644 index 0000000..e8889b6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h @@ -0,0 +1,77 @@ +/* + * 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 FindIndicatorWindow_h +#define FindIndicatorWindow_h + +#import <wtf/Noncopyable.h> +#import <wtf/PassOwnPtr.h> +#import <wtf/RefPtr.h> +#import <wtf/RetainPtr.h> +#import "RunLoop.h" +#import "WebKitSystemInterface.h" + +@class WKView; +@class WebFindIndicatorWindowAnimation; + +namespace WebKit { + +class FindIndicator; + +class FindIndicatorWindow { + WTF_MAKE_NONCOPYABLE(FindIndicatorWindow); + +public: + static PassOwnPtr<FindIndicatorWindow> create(WKView *); + ~FindIndicatorWindow(); + + void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut); + +private: + explicit FindIndicatorWindow(WKView *); + void closeWindow(); + + void startFadeOutTimerFired(); + + void fadeOutAnimationCallback(double); + void fadeOutAnimationDidEnd(); + + void bounceAnimationCallback(double); + void bounceAnimationDidEnd(); + + WKView* m_wkView; + RefPtr<FindIndicator> m_findIndicator; + RetainPtr<NSWindow> m_findIndicatorWindow; + + WKWindowBounceAnimationContextRef m_bounceAnimationContext; + RetainPtr<WebFindIndicatorWindowAnimation> m_bounceAnimation; + + RunLoop::Timer<FindIndicatorWindow> m_startFadeOutTimer; + RetainPtr<WebFindIndicatorWindowAnimation> m_fadeOutAnimation; +}; + +} // namespace WebKit + +#endif // FindIndicatorWindow_h diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm new file mode 100644 index 0000000..5b93a9e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm @@ -0,0 +1,245 @@ +/* + * 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 "FindIndicatorWindow.h" + +#include "FindIndicator.h" +#include <WebCore/GraphicsContext.h> + +static const double bounceAnimationDuration = 0.12; +static const double timeBeforeFadeStarts = bounceAnimationDuration + 0.2; +static const double fadeOutAnimationDuration = 0.3; + +using namespace WebCore; + +@interface WebFindIndicatorView : NSView { + RefPtr<WebKit::FindIndicator> _findIndicator; +} + +- (id)_initWithFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator; +@end + +@implementation WebFindIndicatorView + +- (id)_initWithFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator +{ + if ((self = [super initWithFrame:NSZeroRect])) + _findIndicator = findIndicator; + + return self; +} + +- (void)drawRect:(NSRect)rect +{ + GraphicsContext graphicsContext(static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort])); + + _findIndicator->draw(graphicsContext, enclosingIntRect(rect)); +} + +- (BOOL)isFlipped +{ + return YES; +} + +@end + +@interface WebFindIndicatorWindowAnimation : NSAnimation<NSAnimationDelegate> { + WebKit::FindIndicatorWindow* _findIndicatorWindow; + void (WebKit::FindIndicatorWindow::*_animationProgressCallback)(double progress); + void (WebKit::FindIndicatorWindow::*_animationDidEndCallback)(); +} + +- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow + animationDuration:(CFTimeInterval)duration + animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback + animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback; +@end + +@implementation WebFindIndicatorWindowAnimation + +- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow + animationDuration:(CFTimeInterval)animationDuration + animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback + animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback +{ + if ((self = [super initWithDuration:animationDuration animationCurve:NSAnimationEaseInOut])) { + _findIndicatorWindow = findIndicatorWindow; + _animationProgressCallback = animationProgressCallback; + _animationDidEndCallback = animationDidEndCallback; + [self setDelegate:self]; + [self setAnimationBlockingMode:NSAnimationNonblocking]; + } + return self; +} + +- (void)setCurrentProgress:(NSAnimationProgress)progress +{ + (_findIndicatorWindow->*_animationProgressCallback)(progress); +} + +- (void)animationDidEnd:(NSAnimation *)animation +{ + ASSERT(animation == self); + + (_findIndicatorWindow->*_animationDidEndCallback)(); +} + +@end + +namespace WebKit { + +PassOwnPtr<FindIndicatorWindow> FindIndicatorWindow::create(WKView *wkView) +{ + return adoptPtr(new FindIndicatorWindow(wkView)); +} + +FindIndicatorWindow::FindIndicatorWindow(WKView *wkView) + : m_wkView(wkView) + , m_bounceAnimationContext(0) + , m_startFadeOutTimer(RunLoop::main(), this, &FindIndicatorWindow::startFadeOutTimerFired) +{ +} + +FindIndicatorWindow::~FindIndicatorWindow() +{ + closeWindow(); +} + +void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut) +{ + if (m_findIndicator == findIndicator) + return; + + m_findIndicator = findIndicator; + + // Get rid of the old window. + closeWindow(); + + if (!m_findIndicator) + return; + + NSRect contentRect = m_findIndicator->frameRect(); + NSRect windowFrameRect = NSIntegralRect([m_wkView convertRect:contentRect toView:nil]); + windowFrameRect.origin = [[m_wkView window] convertBaseToScreen:windowFrameRect.origin]; + + NSRect windowContentRect = [NSWindow contentRectForFrameRect:windowFrameRect styleMask:NSBorderlessWindowMask]; + + m_findIndicatorWindow.adoptNS([[NSWindow alloc] initWithContentRect:windowContentRect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]); + + [m_findIndicatorWindow.get() setBackgroundColor:[NSColor clearColor]]; + [m_findIndicatorWindow.get() setOpaque:NO]; + [m_findIndicatorWindow.get() setIgnoresMouseEvents:YES]; + + RetainPtr<WebFindIndicatorView> findIndicatorView(AdoptNS, [[WebFindIndicatorView alloc] _initWithFindIndicator:m_findIndicator]); + [m_findIndicatorWindow.get() setContentView:findIndicatorView.get()]; + + [[m_wkView window] addChildWindow:m_findIndicatorWindow.get() ordered:NSWindowAbove]; + [m_findIndicatorWindow.get() setReleasedWhenClosed:NO]; + + // Start the bounce animation. + m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_findIndicatorWindow.get()); + m_bounceAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this + animationDuration:bounceAnimationDuration + animationProgressCallback:&FindIndicatorWindow::bounceAnimationCallback + animationDidEndCallback:&FindIndicatorWindow::bounceAnimationDidEnd]); + [m_bounceAnimation.get() startAnimation]; + + if (fadeOut) + m_startFadeOutTimer.startOneShot(timeBeforeFadeStarts); +} + +void FindIndicatorWindow::closeWindow() +{ + if (!m_findIndicatorWindow) + return; + + m_startFadeOutTimer.stop(); + + if (m_fadeOutAnimation) { + [m_fadeOutAnimation.get() stopAnimation]; + m_fadeOutAnimation = nullptr; + } + + if (m_bounceAnimation) { + [m_bounceAnimation.get() stopAnimation]; + m_bounceAnimation = nullptr; + } + + if (m_bounceAnimationContext) + WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext); + + [[m_findIndicatorWindow.get() parentWindow] removeChildWindow:m_findIndicatorWindow.get()]; + [m_findIndicatorWindow.get() close]; + m_findIndicatorWindow = nullptr; +} + +void FindIndicatorWindow::startFadeOutTimerFired() +{ + ASSERT(!m_fadeOutAnimation); + + m_fadeOutAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this + animationDuration:fadeOutAnimationDuration + animationProgressCallback:&FindIndicatorWindow::fadeOutAnimationCallback + animationDidEndCallback:&FindIndicatorWindow::fadeOutAnimationDidEnd]); + [m_fadeOutAnimation.get() startAnimation]; +} + +void FindIndicatorWindow::fadeOutAnimationCallback(double progress) +{ + ASSERT(m_fadeOutAnimation); + + [m_findIndicatorWindow.get() setAlphaValue:1.0 - progress]; +} + +void FindIndicatorWindow::fadeOutAnimationDidEnd() +{ + ASSERT(m_fadeOutAnimation); + ASSERT(m_findIndicatorWindow); + + closeWindow(); +} + +void FindIndicatorWindow::bounceAnimationCallback(double progress) +{ + ASSERT(m_bounceAnimation); + ASSERT(m_bounceAnimationContext); + + WKWindowBounceAnimationSetAnimationProgress(m_bounceAnimationContext, progress); +} + +void FindIndicatorWindow::bounceAnimationDidEnd() +{ + ASSERT(m_bounceAnimation); + ASSERT(m_bounceAnimationContext); + ASSERT(m_findIndicatorWindow); + + WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext); + m_bounceAnimationContext = 0; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h new file mode 100644 index 0000000..2c4a235 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h @@ -0,0 +1,74 @@ +/* + * 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 PDFViewController_h +#define PDFViewController_h + +#include <wtf/Forward.h> +#include <wtf/Noncopyable.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/RetainPtr.h> + +@class PDFView; +@class WKView; +@class WKPDFView; + +namespace CoreIPC { + class DataReference; +} + +namespace WebKit { + +class PDFViewController { + WTF_MAKE_NONCOPYABLE(PDFViewController); + +public: + static PassOwnPtr<PDFViewController> create(WKView *); + ~PDFViewController(); + + WKView* wkView() const { return m_wkView; } + void setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference&); + + double zoomFactor() const; + void setZoomFactor(double); + + static Class pdfPreviewViewClass(); + + NSPrintOperation *makePrintOperation(NSPrintInfo *); + +private: + explicit PDFViewController(WKView *wkView); + + static Class pdfDocumentClass(); + static NSBundle* pdfKitBundle(); + + WKView* m_wkView; + RetainPtr<WKPDFView> m_wkPDFView; + PDFView* m_pdfView; +}; + +} // namespace WebKit + +#endif // PDFViewController_h diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm new file mode 100644 index 0000000..a92c2d4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm @@ -0,0 +1,297 @@ +/* + * 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. + */ + +#import "PDFViewController.h" + +#import "DataReference.h" +#import "WKAPICast.h" +#import "WKView.h" +#import "WebPageGroup.h" +#import "WebPageProxy.h" +#import "WebPreferences.h" +#import <PDFKit/PDFKit.h> +#import <wtf/text/WTFString.h> + +// Redeclarations of PDFKit notifications. We can't use the API since we use a weak link to the framework. +#define _webkit_PDFViewDisplayModeChangedNotification @"PDFViewDisplayModeChanged" +#define _webkit_PDFViewScaleChangedNotification @"PDFViewScaleChanged" +#define _webkit_PDFViewPageChangedNotification @"PDFViewChangedPage" + +using namespace WebKit; + +@class PDFDocument; +@class PDFView; + +@interface PDFDocument (PDFDocumentDetails) +- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate; +@end + +extern "C" NSString *_NSPathForSystemFramework(NSString *framework); + +@interface WKPDFView : NSView +{ + PDFViewController* _pdfViewController; + + RetainPtr<NSView> _pdfPreviewView; + PDFView *_pdfView; + BOOL _ignoreScaleAndDisplayModeAndPageNotifications; + BOOL _willUpdatePreferencesSoon; +} + +- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController; +- (void)invalidate; +- (PDFView *)pdfView; +- (void)setDocument:(PDFDocument *)pdfDocument; + +- (void)_applyPDFPreferences; + +@end + +@implementation WKPDFView + +- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController +{ + if ((self = [super initWithFrame:frame])) { + _pdfViewController = pdfViewController; + + [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + + Class previewViewClass = PDFViewController::pdfPreviewViewClass(); + ASSERT(previewViewClass); + + _pdfPreviewView.adoptNS([[previewViewClass alloc] initWithFrame:frame]); + [_pdfPreviewView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + [self addSubview:_pdfPreviewView.get()]; + + _pdfView = [_pdfPreviewView.get() performSelector:@selector(pdfView)]; + } + + return self; +} + +- (void)invalidate +{ + _pdfViewController = 0; +} + +- (PDFView *)pdfView +{ + return _pdfView; +} + +- (void)setDocument:(PDFDocument *)pdfDocument +{ + _ignoreScaleAndDisplayModeAndPageNotifications = YES; + [_pdfView setDocument:pdfDocument]; + [self _applyPDFPreferences]; + _ignoreScaleAndDisplayModeAndPageNotifications = NO; +} + +- (void)_applyPDFPreferences +{ + if (!_pdfViewController) + return; + + WebPreferences *preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences(); + + CGFloat scaleFactor = preferences->pdfScaleFactor(); + if (!scaleFactor) + [_pdfView setAutoScales:YES]; + else { + [_pdfView setAutoScales:NO]; + [_pdfView setScaleFactor:scaleFactor]; + } + [_pdfView setDisplayMode:preferences->pdfDisplayMode()]; +} + +- (void)_updatePreferences:(id)ignored +{ + _willUpdatePreferencesSoon = NO; + + if (!_pdfViewController) + return; + + WebPreferences* preferences = toImpl([_pdfViewController->wkView() pageRef])->pageGroup()->preferences(); + + CGFloat scaleFactor = [_pdfView autoScales] ? 0 : [_pdfView scaleFactor]; + preferences->setPDFScaleFactor(scaleFactor); + preferences->setPDFDisplayMode([_pdfView displayMode]); +} + +- (void)_updatePreferencesSoon +{ + if (_willUpdatePreferencesSoon) + return; + + [self performSelector:@selector(_updatePreferences:) withObject:nil afterDelay:0]; + _willUpdatePreferencesSoon = YES; +} + +- (void)_scaleOrDisplayModeOrPageChanged:(NSNotification *)notification +{ + ASSERT_ARG(notification, [notification object] == _pdfView); + if (!_ignoreScaleAndDisplayModeAndPageNotifications) + [self _updatePreferencesSoon]; +} + +- (void)viewDidMoveToWindow +{ + if (![self window]) + return; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewScaleChangedNotification object:_pdfView]; + [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView]; + [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewPageChangedNotification object:_pdfView]; +} + +- (void)viewWillMoveToWindow:(NSWindow *)newWindow +{ + if (![self window]) + return; + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter removeObserver:self name:_webkit_PDFViewScaleChangedNotification object:_pdfView]; + [notificationCenter removeObserver:self name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView]; + [notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView]; +} + +@end + +namespace WebKit { + +PassOwnPtr<PDFViewController> PDFViewController::create(WKView *wkView) +{ + return adoptPtr(new PDFViewController(wkView)); +} + +PDFViewController::PDFViewController(WKView *wkView) + : m_wkView(wkView) + , m_wkPDFView(AdoptNS, [[WKPDFView alloc] initWithFrame:[m_wkView bounds] PDFViewController:this]) + , m_pdfView([m_wkPDFView.get() pdfView]) +{ + [m_wkView addSubview:m_wkPDFView.get()]; +} + +PDFViewController::~PDFViewController() +{ + [m_wkPDFView.get() removeFromSuperview]; + [m_wkPDFView.get() invalidate]; + m_wkPDFView = nullptr; +} + +static RetainPtr<CFDataRef> convertPostScriptDataSourceToPDF(const CoreIPC::DataReference& dataReference) +{ + // Convert PostScript to PDF using Quartz 2D API + // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html + + CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 }; + RetainPtr<CGPSConverterRef> converter(AdoptCF, CGPSConverterCreate(0, &callbacks, 0)); + ASSERT(converter); + + RetainPtr<NSData> nsData(AdoptNS, [[NSData alloc] initWithBytesNoCopy:const_cast<uint8_t*>(dataReference.data()) length:dataReference.size() freeWhenDone:NO]); + + RetainPtr<CGDataProviderRef> provider(AdoptCF, CGDataProviderCreateWithCFData((CFDataRef)nsData.get())); + ASSERT(provider); + + RetainPtr<CFMutableDataRef> result(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0)); + ASSERT(result); + + RetainPtr<CGDataConsumerRef> consumer(AdoptCF, CGDataConsumerCreateWithCFData(result.get())); + ASSERT(consumer); + + CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0); + + if (!result) + return 0; + + return result; +} + +void PDFViewController::setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference& dataReference) +{ + RetainPtr<CFDataRef> data; + + if (equalIgnoringCase(mimeType, "application/postscript")) { + data = convertPostScriptDataSourceToPDF(dataReference); + if (!data) + return; + } else { + // Make sure to copy the data. + data.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size())); + } + + RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data.get()]); + [m_wkPDFView.get() setDocument:pdfDocument.get()]; +} + +double PDFViewController::zoomFactor() const +{ + return [m_pdfView scaleFactor]; +} + +void PDFViewController::setZoomFactor(double zoomFactor) +{ + [m_pdfView setScaleFactor:zoomFactor]; +} + +Class PDFViewController::pdfDocumentClass() +{ + static Class pdfDocumentClass = [pdfKitBundle() classNamed:@"PDFDocument"]; + + return pdfDocumentClass; +} + +Class PDFViewController::pdfPreviewViewClass() +{ + static Class pdfPreviewViewClass = [pdfKitBundle() classNamed:@"PDFPreviewView"]; + + return pdfPreviewViewClass; +} + +NSBundle* PDFViewController::pdfKitBundle() +{ + static NSBundle *pdfKitBundle; + if (pdfKitBundle) + return pdfKitBundle; + + NSString *pdfKitPath = [_NSPathForSystemFramework(@"Quartz.framework") stringByAppendingString:@"/Frameworks/PDFKit.framework"]; + if (!pdfKitPath) { + LOG_ERROR("Couldn't find PDFKit.framework"); + return nil; + } + + pdfKitBundle = [NSBundle bundleWithPath:pdfKitPath]; + if (![pdfKitBundle load]) + LOG_ERROR("Couldn't load PDFKit.framework"); + return pdfKitBundle; +} + +NSPrintOperation *PDFViewController::makePrintOperation(NSPrintInfo *printInfo) +{ + return [[m_pdfView document] getPrintOperationForPrintInfo:printInfo autoRotate:YES]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h new file mode 100644 index 0000000..8322465 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h @@ -0,0 +1,103 @@ +/* + * 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 PageClientImpl_h +#define PageClientImpl_h + +#include "PageClient.h" +#include <wtf/RetainPtr.h> + +@class WKView; +@class WebEditorUndoTargetObjC; + +namespace WebKit { + +class FindIndicatorWindow; + +// NOTE: This does not use String::operator NSString*() since that function +// expects to be called on the thread running WebCore. +NSString* nsStringFromWebCoreString(const String&); + +class PageClientImpl : public PageClient { +public: + static PassOwnPtr<PageClientImpl> create(WKView*); + virtual ~PageClientImpl(); + +private: + PageClientImpl(WKView*); + + virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); + virtual void setViewNeedsDisplay(const WebCore::IntRect&); + virtual void displayView(); + + virtual WebCore::IntSize viewSize(); + virtual bool isViewWindowActive(); + virtual bool isViewFocused(); + virtual bool isViewVisible(); + virtual bool isViewInWindow(); + + virtual void processDidCrash(); + virtual void didRelaunchProcess(); + virtual void takeFocus(bool direction); + virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip); + virtual void setCursor(const WebCore::Cursor&); + virtual void setViewportArguments(const WebCore::ViewportArguments&); + + virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); + virtual void clearAllEditCommands(); + virtual void setEditCommandState(const String& commandName, bool isEnabled, int state); + virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines); + + virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); + virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); + + virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&); + + virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); + virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); + + void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut); + +#if USE(ACCELERATED_COMPOSITING) + virtual void pageDidEnterAcceleratedCompositing(); + virtual void pageDidLeaveAcceleratedCompositing(); +#endif + + virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&); + virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled); + + virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); + virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); + + virtual double customRepresentationZoomFactor(); + virtual void setCustomRepresentationZoomFactor(double); + + WKView* m_wkView; + RetainPtr<WebEditorUndoTargetObjC> m_undoTarget; +}; + +} // namespace WebKit + +#endif // PageClientImpl_h diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm new file mode 100644 index 0000000..c37b641 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -0,0 +1,350 @@ +/* + * 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. + */ + +#import "NativeWebKeyboardEvent.h" +#import "PageClientImpl.h" + +#import "DataReference.h" +#import "FindIndicator.h" +#import "WKAPICast.h" +#import "WKStringCF.h" +#import "WKViewInternal.h" +#import "WebContextMenuProxyMac.h" +#import "WebEditCommandProxy.h" +#import "WebPopupMenuProxyMac.h" +#import <WebCore/Cursor.h> +#import <WebCore/FloatRect.h> +#import <WebCore/FoundationExtras.h> +#import <WebCore/KeyboardEvent.h> +#import <wtf/PassOwnPtr.h> +#import <wtf/text/CString.h> +#import <wtf/text/WTFString.h> + +using namespace WebCore; + +@interface WebEditCommandObjC : NSObject +{ + RefPtr<WebKit::WebEditCommandProxy> m_command; +} + +- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command; +- (WebKit::WebEditCommandProxy*)command; + +@end + +@implementation WebEditCommandObjC + +- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command +{ + self = [super init]; + if (!self) + return nil; + + m_command = command; + return self; +} + +- (WebKit::WebEditCommandProxy*)command +{ + return m_command.get(); +} + +@end + +@interface WebEditorUndoTargetObjC : NSObject + +- (void)undoEditing:(id)sender; +- (void)redoEditing:(id)sender; + +@end + +@implementation WebEditorUndoTargetObjC + +- (void)undoEditing:(id)sender +{ + ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]); + [sender command]->unapply(); +} + +- (void)redoEditing:(id)sender +{ + ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]); + [sender command]->reapply(); +} + +@end + +namespace WebKit { + +NSString* nsStringFromWebCoreString(const String& string) +{ + return string.impl() ? HardAutorelease(WKStringCopyCFString(0, toAPI(string.impl()))) : @""; +} + +PassOwnPtr<PageClientImpl> PageClientImpl::create(WKView* wkView) +{ + return adoptPtr(new PageClientImpl(wkView)); +} + +PageClientImpl::PageClientImpl(WKView* wkView) + : m_wkView(wkView) + , m_undoTarget(AdoptNS, [[WebEditorUndoTargetObjC alloc] init]) +{ +} + +PageClientImpl::~PageClientImpl() +{ +} + +PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() +{ + return [m_wkView _createDrawingAreaProxy]; +} + +void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) +{ + [m_wkView setNeedsDisplayInRect:rect]; +} + +void PageClientImpl::displayView() +{ + [m_wkView displayIfNeeded]; +} + +IntSize PageClientImpl::viewSize() +{ + return IntSize([m_wkView bounds].size); +} + +bool PageClientImpl::isViewWindowActive() +{ + return [[m_wkView window] isKeyWindow]; +} + +bool PageClientImpl::isViewFocused() +{ + return [m_wkView _isFocused]; +} + +bool PageClientImpl::isViewVisible() +{ + if (![m_wkView window]) + return false; + + if ([m_wkView isHiddenOrHasHiddenAncestor]) + return false; + + return true; +} + +bool PageClientImpl::isViewInWindow() +{ + return [m_wkView window]; +} + +void PageClientImpl::processDidCrash() +{ + [m_wkView _processDidCrash]; +} + +void PageClientImpl::didRelaunchProcess() +{ + [m_wkView _didRelaunchProcess]; +} + +void PageClientImpl::takeFocus(bool direction) +{ + [m_wkView _takeFocus:direction]; +} + +void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip) +{ + [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)]; +} + +void PageClientImpl::setCursor(const WebCore::Cursor& cursor) +{ + [m_wkView _setCursor:cursor.platformCursor()]; +} + +void PageClientImpl::setViewportArguments(const WebCore::ViewportArguments&) +{ + +} + +static NSString* nameForEditAction(EditAction editAction) +{ + // FIXME: Use localized strings. + // FIXME: Move this to a platform independent location. + + switch (editAction) { + case EditActionUnspecified: return nil; + case EditActionSetColor: return @"Set Color"; + case EditActionSetBackgroundColor: return @"Set Background Color"; + case EditActionTurnOffKerning: return @"Turn Off Kerning"; + case EditActionTightenKerning: return @"Tighten Kerning"; + case EditActionLoosenKerning: return @"Loosen Kerning"; + case EditActionUseStandardKerning: return @"Use Standard Kerning"; + case EditActionTurnOffLigatures: return @"Turn Off Ligatures"; + case EditActionUseStandardLigatures: return @"Use Standard Ligatures"; + case EditActionUseAllLigatures: return @"Use All Ligatures"; + case EditActionRaiseBaseline: return @"Raise Baseline"; + case EditActionLowerBaseline: return @"Lower Baseline"; + case EditActionSetTraditionalCharacterShape: return @"Set Traditional Character Shape"; + case EditActionSetFont: return @"Set Font"; + case EditActionChangeAttributes: return @"Change Attributes"; + case EditActionAlignLeft: return @"Align Left"; + case EditActionAlignRight: return @"Align Right"; + case EditActionCenter: return @"Center"; + case EditActionJustify: return @"Justify"; + case EditActionSetWritingDirection: return @"Set Writing Direction"; + case EditActionSubscript: return @"Subscript"; + case EditActionSuperscript: return @"Superscript"; + case EditActionUnderline: return @"Underline"; + case EditActionOutline: return @"Outline"; + case EditActionUnscript: return @"Unscript"; + case EditActionDrag: return @"Drag"; + case EditActionCut: return @"Cut"; + case EditActionPaste: return @"Paste"; + case EditActionPasteFont: return @"Paste Font"; + case EditActionPasteRuler: return @"Paste Ruler"; + case EditActionTyping: return @"Typing"; + case EditActionCreateLink: return @"Create Link"; + case EditActionUnlink: return @"Unlink"; + case EditActionInsertList: return @"Insert List"; + case EditActionFormatBlock: return @"Formatting"; + case EditActionIndent: return @"Indent"; + case EditActionOutdent: return @"Outdent"; + } + return nil; +} + +void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo) +{ + RefPtr<WebEditCommandProxy> command = prpCommand; + + RetainPtr<WebEditCommandObjC> commandObjC(AdoptNS, [[WebEditCommandObjC alloc] initWithWebEditCommandProxy:command]); + NSString *actionName = nameForEditAction(command->editAction()); + + NSUndoManager *undoManager = [m_wkView undoManager]; + [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()]; + if (actionName) + [undoManager setActionName:actionName]; +} + +void PageClientImpl::clearAllEditCommands() +{ + [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()]; +} + +void PageClientImpl::setEditCommandState(const String& commandName, bool isEnabled, int newState) +{ + [m_wkView _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:newState]; +} + +void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines) +{ + commandsList = [m_wkView _interceptKeyEvent:event.nativeEvent()]; + [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines]; +} + +FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect) +{ + return [m_wkView _convertToDeviceSpace:rect]; +} + +FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect) +{ + return [m_wkView _convertToUserSpace:rect]; +} + +void PageClientImpl::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event) +{ + NSEvent* nativeEvent = event.nativeEvent(); + if ([nativeEvent type] == NSKeyDown) { + [m_wkView _setEventBeingResent:nativeEvent]; + [[NSApplication sharedApplication] sendEvent:nativeEvent]; + } +} + +PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) +{ + return WebPopupMenuProxyMac::create(m_wkView, page); +} + +PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page) +{ + return WebContextMenuProxyMac::create(m_wkView, page); +} + +void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut) +{ + [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut]; +} + +void PageClientImpl::accessibilityChildTokenReceived(const CoreIPC::DataReference& data) +{ + NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()]; + [m_wkView _setAccessibilityChildToken:remoteToken]; +} + +#if USE(ACCELERATED_COMPOSITING) +void PageClientImpl::pageDidEnterAcceleratedCompositing() +{ + [m_wkView _pageDidEnterAcceleratedCompositing]; +} + +void PageClientImpl::pageDidLeaveAcceleratedCompositing() +{ + [m_wkView _pageDidLeaveAcceleratedCompositing]; +} +#endif // USE(ACCELERATED_COMPOSITING) + +void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) +{ + [m_wkView _setComplexTextInputEnabled:complexTextInputEnabled pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; +} + +void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation) +{ + [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation]; +} + +void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference) +{ + [m_wkView _didFinishLoadingDataForCustomRepresentation:dataReference]; +} + +double PageClientImpl::customRepresentationZoomFactor() +{ + return [m_wkView _customRepresentationZoomFactor]; +} + +void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor) +{ + [m_wkView _setCustomRepresentationZoomFactor:zoomFactor]; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h new file mode 100644 index 0000000..b2ad3b0 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009, 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. ``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 + * 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 WKTextInputWindowController_h +#define WKTextInputWindowController_h + +@class WKTextInputPanel; + +@interface WKTextInputWindowController : NSObject { + WKTextInputPanel *_panel; +} + ++ (WKTextInputWindowController *)sharedTextInputWindowController; + +- (NSTextInputContext *)inputContext; +- (BOOL)interpretKeyEvent:(NSEvent *)event string:(NSString **)string; + +- (void)keyboardInputSourceChanged; + +@end + +#endif // WKTextInputWindowController_h diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm new file mode 100644 index 0000000..b7dae31 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm @@ -0,0 +1,156 @@ +/* + * 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 "WKTextInputWindowController.h" + +#include <WebKitSystemInterface.h> + +@interface WKTextInputPanel : NSPanel { + NSTextView *_inputTextView; +} + +- (NSTextInputContext *)_inputContext; +- (BOOL)_interpretKeyEvent:(NSEvent *)event string:(NSString **)string; + +@end + +#define inputWindowHeight 20 + +@implementation WKTextInputPanel + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_inputTextView release]; + + [super dealloc]; +} + +- (id)init +{ + self = [super initWithContentRect:NSZeroRect styleMask:WKGetInputPanelWindowStyle() backing:NSBackingStoreBuffered defer:YES]; + if (!self) + return nil; + + // Set the frame size. + NSRect visibleFrame = [[NSScreen mainScreen] visibleFrame]; + NSRect frame = NSMakeRect(visibleFrame.origin.x, visibleFrame.origin.y, visibleFrame.size.width, inputWindowHeight); + + [self setFrame:frame display:NO]; + + _inputTextView = [[NSTextView alloc] initWithFrame:[self.contentView frame]]; + _inputTextView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable | NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin; + + NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:[self.contentView frame]]; + scrollView.documentView = _inputTextView; + self.contentView = scrollView; + [scrollView release]; + + [self setFloatingPanel:YES]; + + return self; +} + +- (void)_keyboardInputSourceChanged +{ + [_inputTextView setString:@""]; + [self orderOut:nil]; +} + +- (BOOL)_interpretKeyEvent:(NSEvent *)event string:(NSString **)string +{ + BOOL hadMarkedText = [_inputTextView hasMarkedText]; + + *string = nil; + + if (![[_inputTextView inputContext] handleEvent:event]) + return NO; + + if ([_inputTextView hasMarkedText]) { + // Don't show the input method window for dead keys + if ([[event characters] length] > 0) + [self orderFront:nil]; + + return YES; + } + + if (hadMarkedText) { + [self orderOut:nil]; + + NSString *text = [[_inputTextView textStorage] string]; + if ([text length] > 0) + *string = [[text copy] autorelease]; + } + + [_inputTextView setString:@""]; + return hadMarkedText; +} + +- (NSTextInputContext *)_inputContext +{ + return [_inputTextView inputContext]; +} + +@end + +@implementation WKTextInputWindowController + ++ (WKTextInputWindowController *)sharedTextInputWindowController +{ + static WKTextInputWindowController *textInputWindowController; + if (!textInputWindowController) + textInputWindowController = [[WKTextInputWindowController alloc] init]; + + return textInputWindowController; +} + +- (id)init +{ + self = [super init]; + if (!self) + return nil; + + _panel = [[WKTextInputPanel alloc] init]; + + return self; +} + +- (NSTextInputContext *)inputContext +{ + return [_panel _inputContext]; +} + +- (BOOL)interpretKeyEvent:(NSEvent *)event string:(NSString **)string +{ + return [_panel _interpretKeyEvent:event string:string]; +} + +- (void)keyboardInputSourceChanged +{ + [_panel _keyboardInputSourceChanged]; +} + +@end diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.h b/Source/WebKit2/UIProcess/API/mac/WKView.h new file mode 100644 index 0000000..618bbc4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/WKView.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. + */ + +#import <Cocoa/Cocoa.h> +#import <WebKit2/WKBase.h> + +@class WKViewData; + +WK_EXPORT +@interface WKView : NSView <NSTextInput> { + WKViewData *_data; +} + +- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef; +- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef; + +- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef; +- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef; + +@property(readonly) WKPageRef pageRef; + +@property BOOL drawsBackground; +@property BOOL drawsTransparentBackground; + +@end diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm new file mode 100644 index 0000000..da9b7c9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -0,0 +1,1795 @@ +/* + * 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. + */ + +#import "WKView.h" + +#import "ChunkedUpdateDrawingAreaProxy.h" +#import "DataReference.h" +#import "DrawingAreaProxyImpl.h" +#import "FindIndicator.h" +#import "FindIndicatorWindow.h" +#import "LayerBackedDrawingAreaProxy.h" +#import "Logging.h" +#import "NativeWebKeyboardEvent.h" +#import "PDFViewController.h" +#import "PageClientImpl.h" +#import "PrintInfo.h" +#import "RunLoop.h" +#import "TextChecker.h" +#import "TextCheckerState.h" +#import "WKAPICast.h" +#import "WKStringCF.h" +#import "WKTextInputWindowController.h" +#import "WebContext.h" +#import "WebEventFactory.h" +#import "WebPage.h" +#import "WebPageProxy.h" +#import "WebProcessManager.h" +#import "WebProcessProxy.h" +#import "WebSystemInterface.h" +#import <QuartzCore/QuartzCore.h> +#import <WebCore/ColorMac.h> +#import <WebCore/DragController.h> +#import <WebCore/DragData.h> +#import <WebCore/FloatRect.h> +#import <WebCore/IntRect.h> +#import <WebCore/KeyboardEvent.h> +#import <WebCore/PlatformMouseEvent.h> +#import <WebCore/PlatformScreen.h> +#import <WebKitSystemInterface.h> +#import <wtf/RefPtr.h> +#import <wtf/RetainPtr.h> + +// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized +#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str] + +@interface NSApplication (Details) +- (void)speakString:(NSString *)string; +@end + +@interface NSView (Details) +- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView; +@end + +@interface NSWindow (Details) +- (NSRect)_growBoxRect; +- (BOOL)_updateGrowBoxForWindowFrameChange; +@end + +extern "C" { + // Need to declare this attribute name because AppKit exports it but does not make it available in API or SPI headers. + // <rdar://problem/8631468> tracks the request to make it available. This code should be removed when the bug is closed. + extern NSString *NSTextInputReplacementRangeAttributeName; +} + +using namespace WebKit; +using namespace WebCore; + +namespace WebKit { + +typedef id <NSValidatedUserInterfaceItem> ValidationItem; +typedef Vector<RetainPtr<ValidationItem> > ValidationVector; +typedef HashMap<String, ValidationVector> ValidationMap; + +} + +@interface WKViewData : NSObject { +@public + OwnPtr<PageClientImpl> _pageClient; + RefPtr<WebPageProxy> _page; + + // For ToolTips. + NSToolTipTag _lastToolTipTag; + id _trackingRectOwner; + void* _trackingRectUserData; + +#if USE(ACCELERATED_COMPOSITING) + NSView *_layerHostingView; +#endif + + RetainPtr<id> _remoteAccessibilityChild; + + // For asynchronous validation. + ValidationMap _validationMap; + + OwnPtr<PDFViewController> _pdfViewController; + + OwnPtr<FindIndicatorWindow> _findIndicatorWindow; + // We keep here the event when resending it to + // the application to distinguish the case of a new event from one + // that has been already sent to WebCore. + NSEvent *_keyDownEventBeingResent; + Vector<KeypressCommand> _commandsList; + + // The identifier of the plug-in we want to send complex text input to, or 0 if there is none. + uint64_t _pluginComplexTextInputIdentifier; + + Vector<CompositionUnderline> _underlines; + unsigned _selectionStart; + unsigned _selectionEnd; + + Vector<IntRect> _printingPageRects; + double _totalScaleFactorForPrinting; + + bool _inBecomeFirstResponder; + bool _inResignFirstResponder; +} +@end + +@implementation WKViewData +@end + +@interface WebFrameWrapper : NSObject { +@public + RefPtr<WebFrameProxy> _frame; +} + +- (id)initWithFrameProxy:(WebFrameProxy*)frame; +- (WebFrameProxy*)webFrame; +@end + +@implementation WebFrameWrapper + +- (id)initWithFrameProxy:(WebFrameProxy*)frame +{ + self = [super init]; + if (!self) + return nil; + + _frame = frame; + return self; +} + +- (WebFrameProxy*)webFrame +{ + return _frame.get(); +} + +@end + +NSString * const PrintedFrameKey = @"WebKitPrintedFrameKey"; + +@interface NSObject (NSTextInputContextDetails) +- (BOOL)wantsToHandleMouseEvents; +- (BOOL)handleMouseEvent:(NSEvent *)event; +@end + +@implementation WKView + +static bool useNewDrawingArea() +{ + static bool useNewDrawingArea = getenv("USE_NEW_DRAWING_AREA"); + + return useNewDrawingArea; +} + +- (id)initWithFrame:(NSRect)frame +{ + return [self initWithFrame:frame contextRef:toAPI(WebContext::sharedProcessContext())]; +} + +- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef +{ + return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil]; +} + +static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type"; +static NSString * const WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; +static NSString * const WebURLPboardType = @"public.url"; +static NSString * const WebURLNamePboardType = @"public.url-name"; + +- (void)_registerDraggedTypes +{ + NSArray *editableTypes = [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType, +#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) + NSPICTPboardType, +#endif + NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil]; + NSArray *URLTypes = [NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil]; + NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes]; + [types addObjectsFromArray:URLTypes]; + [self registerForDraggedTypes:[types allObjects]]; + [types release]; +} + +- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef +{ + self = [super initWithFrame:frame]; + if (!self) + return nil; + + InitWebCoreSystemInterface(); + RunLoop::initializeMainRunLoop(); + + NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:frame + options:(NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect) + owner:self + userInfo:nil]; + [self addTrackingArea:trackingArea]; + [trackingArea release]; + + _data = [[WKViewData alloc] init]; + + _data->_pageClient = PageClientImpl::create(self); + _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef)); + _data->_page->initializeWebPage(); + + [self _registerDraggedTypes]; + + WebContext::statistics().wkViewCount++; + +#if !defined(BUILDING_ON_SNOW_LEOPARD) + NSData *remoteToken = (NSData *)WKAXRemoteTokenForElement(self); + CoreIPC::DataReference dataToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteToken bytes]), [remoteToken length]); + _data->_page->sendAccessibilityPresenterToken(dataToken); +#endif + + return self; +} + +- (void)dealloc +{ + _data->_page->close(); + + [_data release]; + + WebContext::statistics().wkViewCount--; + + [super dealloc]; +} + +- (WKPageRef)pageRef +{ + return toAPI(_data->_page.get()); +} + +- (void)setDrawsBackground:(BOOL)drawsBackground +{ + _data->_page->setDrawsBackground(drawsBackground); +} + +- (BOOL)drawsBackground +{ + return _data->_page->drawsBackground(); +} + +- (void)setDrawsTransparentBackground:(BOOL)drawsTransparentBackground +{ + _data->_page->setDrawsTransparentBackground(drawsTransparentBackground); +} + +- (BOOL)drawsTransparentBackground +{ + return _data->_page->drawsTransparentBackground(); +} + +- (BOOL)acceptsFirstResponder +{ + return YES; +} + +- (BOOL)becomeFirstResponder +{ + NSSelectionDirection direction = [[self window] keyViewSelectionDirection]; + + _data->_inBecomeFirstResponder = true; + _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused); + _data->_inBecomeFirstResponder = false; + + if (direction != NSDirectSelection) + _data->_page->setInitialFocus(direction == NSSelectingNext); + + return YES; +} + +- (BOOL)resignFirstResponder +{ + _data->_inResignFirstResponder = true; + _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused); + _data->_inResignFirstResponder = false; + + return YES; +} + +- (BOOL)isFlipped +{ + return YES; +} + +- (void)setFrameSize:(NSSize)size +{ + [super setFrameSize:size]; + + if (!_data->_page->drawingArea()) + return; + + _data->_page->drawingArea()->setSize(IntSize(size)); +} + +- (void)_updateWindowAndViewFrames +{ + NSWindow *window = [self window]; + ASSERT(window); + + NSRect windowFrameInScreenCoordinates = [window frame]; + NSRect viewFrameInWindowCoordinates = [self convertRect:[self frame] toView:nil]; + NSPoint accessibilityPosition = [[self accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue]; + + _data->_page->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates), IntPoint(accessibilityPosition)); +} + +- (void)renewGState +{ + // Hide the find indicator. + _data->_findIndicatorWindow = nullptr; + + // Update the view frame. + if ([self window]) + [self _updateWindowAndViewFrames]; + + [super renewGState]; +} + +typedef HashMap<SEL, String> SelectorNameMap; + +// Map selectors into Editor command names. +// This is not needed for any selectors that have the same name as the Editor command. +static const SelectorNameMap* createSelectorExceptionMap() +{ + SelectorNameMap* map = new HashMap<SEL, String>; + + map->add(@selector(insertNewlineIgnoringFieldEditor:), "InsertNewline"); + map->add(@selector(insertParagraphSeparator:), "InsertNewline"); + map->add(@selector(insertTabIgnoringFieldEditor:), "InsertTab"); + map->add(@selector(pageDown:), "MovePageDown"); + map->add(@selector(pageDownAndModifySelection:), "MovePageDownAndModifySelection"); + map->add(@selector(pageUp:), "MovePageUp"); + map->add(@selector(pageUpAndModifySelection:), "MovePageUpAndModifySelection"); + + return map; +} + +static String commandNameForSelector(SEL selector) +{ + // Check the exception map first. + static const SelectorNameMap* exceptionMap = createSelectorExceptionMap(); + SelectorNameMap::const_iterator it = exceptionMap->find(selector); + if (it != exceptionMap->end()) + return it->second; + + // Remove the trailing colon. + // No need to capitalize the command name since Editor command names are + // not case sensitive. + const char* selectorName = sel_getName(selector); + size_t selectorNameLength = strlen(selectorName); + if (selectorNameLength < 2 || selectorName[selectorNameLength - 1] != ':') + return String(); + return String(selectorName, selectorNameLength - 1); +} + +// Editing commands + +#define WEBCORE_COMMAND(command) - (void)command:(id)sender { _data->_page->executeEditCommand(commandNameForSelector(_cmd)); } + +WEBCORE_COMMAND(copy) +WEBCORE_COMMAND(cut) +WEBCORE_COMMAND(paste) +WEBCORE_COMMAND(delete) +WEBCORE_COMMAND(pasteAsPlainText) +WEBCORE_COMMAND(selectAll) +WEBCORE_COMMAND(takeFindStringFromSelection) + +#undef WEBCORE_COMMAND + +// Menu items validation + +static NSMenuItem *menuItem(id <NSValidatedUserInterfaceItem> item) +{ + if (![(NSObject *)item isKindOfClass:[NSMenuItem class]]) + return nil; + return (NSMenuItem *)item; +} + +static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item) +{ + if (![(NSObject *)item isKindOfClass:[NSToolbarItem class]]) + return nil; + return (NSToolbarItem *)item; +} + +- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item +{ + SEL action = [item action]; + + if (action == @selector(showGuessPanel:)) { + if (NSMenuItem *menuItem = ::menuItem(item)) { + BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible]; + [menuItem setTitle:panelShowing + ? UI_STRING("Hide Spelling and Grammar", "menu item title") + : UI_STRING("Show Spelling and Grammar", "menu item title")]; + } + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:)) + return _data->_page->selectionState().isContentEditable; + + if (action == @selector(toggleContinuousSpellChecking:)) { + bool enabled = TextChecker::isContinuousSpellCheckingAllowed(); + bool checked = enabled && TextChecker::state().isContinuousSpellCheckingEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return enabled; + } + + if (action == @selector(toggleGrammarChecking:)) { + bool checked = TextChecker::state().isGrammarCheckingEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return YES; + } + + if (action == @selector(toggleAutomaticSpellingCorrection:)) { + bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(orderFrontSubstitutionsPanel:)) { + if (NSMenuItem *menuItem = ::menuItem(item)) { + BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible]; + [menuItem setTitle:panelShowing + ? UI_STRING("Hide Substitutions", "menu item title") + : UI_STRING("Show Substitutions", "menu item title")]; + } + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(toggleSmartInsertDelete:)) { + bool checked = _data->_page->isSmartInsertDeleteEnabled(); + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(toggleAutomaticQuoteSubstitution:)) { + bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(toggleAutomaticDashSubstitution:)) { + bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(toggleAutomaticLinkDetection:)) { + bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(toggleAutomaticTextReplacement:)) { + bool checked = TextChecker::state().isAutomaticTextReplacementEnabled; + [menuItem(item) setState:checked ? NSOnState : NSOffState]; + return _data->_page->selectionState().isContentEditable; + } + + if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:)) + return _data->_page->selectionState().selectedRangeLength && _data->_page->selectionState().isContentEditable; + + if (action == @selector(stopSpeaking:)) + return [NSApp isSpeaking]; + + // Next, handle editor commands. Start by returning YES for anything that is not an editor command. + // Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized. + String commandName = commandNameForSelector([item action]); + if (!Editor::commandIsSupportedFromMenuOrKeyBinding(commandName)) + return YES; + + // Add this item to the vector of items for a given command that are awaiting validation. + pair<ValidationMap::iterator, bool> addResult = _data->_validationMap.add(commandName, ValidationVector()); + addResult.first->second.append(item); + if (addResult.second) { + // If we are not already awaiting validation for this command, start the asynchronous validation process. + // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time + // we asked for the same command; there is no guarantee the answer is still valid. + // FIXME: The function called here should be renamed validateCommand because it is not specific to menu items. + _data->_page->validateMenuItem(commandName); + } + + // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called. + // FIXME <rdar://problem/8803459>: This means disabled items will flash enabled at first for a moment. + // But returning NO here would be worse; that would make keyboard commands such as command-C fail. + return YES; +} + +static void speakString(WKStringRef string, WKErrorRef error, void*) +{ + if (error) + return; + if (!string) + return; + + NSString *convertedString = toImpl(string)->string(); + [NSApp speakString:convertedString]; +} + +- (IBAction)startSpeaking:(id)sender +{ + _data->_page->getSelectionOrContentsAsString(StringCallback::create(0, speakString)); +} + +- (IBAction)stopSpeaking:(id)sender +{ + [NSApp stopSpeaking:sender]; +} + +- (IBAction)showGuessPanel:(id)sender +{ + NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker]; + if (!checker) { + LOG_ERROR("No NSSpellChecker"); + return; + } + + NSPanel *spellingPanel = [checker spellingPanel]; + if ([spellingPanel isVisible]) { + [spellingPanel orderOut:sender]; + return; + } + + _data->_page->advanceToNextMisspelling(true); + [spellingPanel orderFront:sender]; +} + +- (IBAction)checkSpelling:(id)sender +{ + _data->_page->advanceToNextMisspelling(false); +} + +- (void)changeSpelling:(id)sender +{ + NSString *word = [[sender selectedCell] stringValue]; + + _data->_page->changeSpellingToWord(word); +} + +- (IBAction)toggleContinuousSpellChecking:(id)sender +{ + bool spellCheckingEnabled = !TextChecker::state().isContinuousSpellCheckingEnabled; + TextChecker::setContinuousSpellCheckingEnabled(spellCheckingEnabled); + + _data->_page->process()->updateTextCheckerState(); + + if (!spellCheckingEnabled) + _data->_page->unmarkAllMisspellings(); +} + +- (IBAction)toggleGrammarChecking:(id)sender +{ + bool grammarCheckingEnabled = !TextChecker::state().isGrammarCheckingEnabled; + TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled); + + _data->_page->process()->updateTextCheckerState(); + + if (!grammarCheckingEnabled) + _data->_page->unmarkAllBadGrammar(); +} + +- (IBAction)toggleAutomaticSpellingCorrection:(id)sender +{ + TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled); + + _data->_page->process()->updateTextCheckerState(); +} + +- (void)orderFrontSubstitutionsPanel:(id)sender +{ + NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker]; + if (!checker) { + LOG_ERROR("No NSSpellChecker"); + return; + } + + NSPanel *substitutionsPanel = [checker substitutionsPanel]; + if ([substitutionsPanel isVisible]) { + [substitutionsPanel orderOut:sender]; + return; + } + [substitutionsPanel orderFront:sender]; +} + +- (IBAction)toggleSmartInsertDelete:(id)sender +{ + _data->_page->setSmartInsertDeleteEnabled(!_data->_page->isSmartInsertDeleteEnabled()); +} + +- (BOOL)isAutomaticQuoteSubstitutionEnabled +{ + return TextChecker::state().isAutomaticQuoteSubstitutionEnabled; +} + +- (void)setAutomaticQuoteSubstitutionEnabled:(BOOL)flag +{ + if (static_cast<bool>(flag) == TextChecker::state().isAutomaticQuoteSubstitutionEnabled) + return; + + TextChecker::setAutomaticQuoteSubstitutionEnabled(flag); + _data->_page->process()->updateTextCheckerState(); +} + +- (void)toggleAutomaticQuoteSubstitution:(id)sender +{ + TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled); + _data->_page->process()->updateTextCheckerState(); +} + +- (BOOL)isAutomaticDashSubstitutionEnabled +{ + return TextChecker::state().isAutomaticDashSubstitutionEnabled; +} + +- (void)setAutomaticDashSubstitutionEnabled:(BOOL)flag +{ + if (static_cast<bool>(flag) == TextChecker::state().isAutomaticDashSubstitutionEnabled) + return; + + TextChecker::setAutomaticDashSubstitutionEnabled(flag); + _data->_page->process()->updateTextCheckerState(); +} + +- (void)toggleAutomaticDashSubstitution:(id)sender +{ + TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled); + _data->_page->process()->updateTextCheckerState(); +} + +- (BOOL)isAutomaticLinkDetectionEnabled +{ + return TextChecker::state().isAutomaticLinkDetectionEnabled; +} + +- (void)setAutomaticLinkDetectionEnabled:(BOOL)flag +{ + if (static_cast<bool>(flag) == TextChecker::state().isAutomaticLinkDetectionEnabled) + return; + + TextChecker::setAutomaticLinkDetectionEnabled(flag); + _data->_page->process()->updateTextCheckerState(); +} + +- (void)toggleAutomaticLinkDetection:(id)sender +{ + TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled); + _data->_page->process()->updateTextCheckerState(); +} + +- (BOOL)isAutomaticTextReplacementEnabled +{ + return TextChecker::state().isAutomaticTextReplacementEnabled; +} + +- (void)setAutomaticTextReplacementEnabled:(BOOL)flag +{ + if (static_cast<bool>(flag) == TextChecker::state().isAutomaticTextReplacementEnabled) + return; + + TextChecker::setAutomaticTextReplacementEnabled(flag); + _data->_page->process()->updateTextCheckerState(); +} + +- (void)toggleAutomaticTextReplacement:(id)sender +{ + TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled); + _data->_page->process()->updateTextCheckerState(); +} + +- (void)uppercaseWord:(id)sender +{ + _data->_page->uppercaseWord(); +} + +- (void)lowercaseWord:(id)sender +{ + _data->_page->lowercaseWord(); +} + +- (void)capitalizeWord:(id)sender +{ + _data->_page->capitalizeWord(); +} + +// Events + +// Override this so that AppKit will send us arrow keys as key down events so we can +// support them via the key bindings mechanism. +- (BOOL)_wantsKeyDownForEvent:(NSEvent *)event +{ + return YES; +} + +#define EVENT_HANDLER(Selector, Type) \ + - (void)Selector:(NSEvent *)theEvent \ + { \ + Web##Type##Event webEvent = WebEventFactory::createWeb##Type##Event(theEvent, self); \ + _data->_page->handle##Type##Event(webEvent); \ + } + +EVENT_HANDLER(mouseEntered, Mouse) +EVENT_HANDLER(mouseExited, Mouse) +EVENT_HANDLER(mouseMoved, Mouse) +EVENT_HANDLER(otherMouseDown, Mouse) +EVENT_HANDLER(otherMouseDragged, Mouse) +EVENT_HANDLER(otherMouseMoved, Mouse) +EVENT_HANDLER(otherMouseUp, Mouse) +EVENT_HANDLER(rightMouseDown, Mouse) +EVENT_HANDLER(rightMouseDragged, Mouse) +EVENT_HANDLER(rightMouseMoved, Mouse) +EVENT_HANDLER(rightMouseUp, Mouse) +EVENT_HANDLER(scrollWheel, Wheel) + +#undef EVENT_HANDLER + +#define MOUSE_EVENT_HANDLER(Selector) \ + - (void)Selector:(NSEvent *)theEvent \ + { \ + NSInputManager *currentInputManager = [NSInputManager currentInputManager]; \ + if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:theEvent]) \ + return; \ + WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(theEvent, self); \ + _data->_page->handleMouseEvent(webEvent); \ + } + +MOUSE_EVENT_HANDLER(mouseDown) +MOUSE_EVENT_HANDLER(mouseDragged) +MOUSE_EVENT_HANDLER(mouseUp) + +#undef MOUSE_EVENT_HANDLER + +- (void)doCommandBySelector:(SEL)selector +{ + if (selector != @selector(noop:)) + _data->_commandsList.append(KeypressCommand(commandNameForSelector(selector))); +} + +- (void)insertText:(id)string +{ + BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString + + LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string); + NSString *text; + bool isFromInputMethod = _data->_page->selectionState().hasComposition; + + if (isAttributedString) { + text = [string string]; + // We deal with the NSTextInputReplacementRangeAttributeName attribute from NSAttributedString here + // simply because it is used by at least one Input Method -- it corresonds to the kEventParamTextInputSendReplaceRange + // event in TSM. This behaviour matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an + // NSAttributedString + NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, [text length])]; + LOG(TextInput, "ReplacementRange: %@", rangeString); + if (rangeString) + isFromInputMethod = YES; + } else + text = string; + + String eventText = text; + + if (!isFromInputMethod) + _data->_commandsList.append(KeypressCommand("insertText", text)); + else { + eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore + _data->_commandsList.append(KeypressCommand("insertText", eventText)); + } +} + +- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event +{ + if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) != NSCommandKeyMask) + return NO; + + // Here we special case cmd+b and cmd+i but not cmd+u, for historic reason. + // This should not be changed, since it could break some Mac applications that + // rely on this inherent behavior. + // See https://bugs.webkit.org/show_bug.cgi?id=24943 + + NSString *string = [event characters]; + if ([string caseInsensitiveCompare:@"b"] == NSOrderedSame) { + _data->_page->executeEditCommand("ToggleBold"); + return YES; + } + if ([string caseInsensitiveCompare:@"i"] == NSOrderedSame) { + _data->_page->executeEditCommand("ToggleItalic"); + return YES; + } + + return NO; +} + +- (BOOL)performKeyEquivalent:(NSEvent *)event +{ + // There's a chance that responding to this event will run a nested event loop, and + // fetching a new event might release the old one. Retaining and then autoreleasing + // the current event prevents that from causing a problem inside WebKit or AppKit code. + [[event retain] autorelease]; + + BOOL eventWasSentToWebCore = (_data->_keyDownEventBeingResent == event); + + // Pass key combos through WebCore if there is a key binding available for + // this event. This lets web pages have a crack at intercepting key-modified keypresses. + // But don't do it if we have already handled the event. + // Pressing Esc results in a fake event being sent - don't pass it to WebCore. + if (!eventWasSentToWebCore && event == [NSApp currentEvent] && self == [[self window] firstResponder]) { + [_data->_keyDownEventBeingResent release]; + _data->_keyDownEventBeingResent = nil; + + _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(event, self)); + return YES; + } + + return [self _handleStyleKeyEquivalent:event] || [super performKeyEquivalent:event]; +} + +- (void)_setEventBeingResent:(NSEvent *)event +{ + _data->_keyDownEventBeingResent = [event retain]; +} + +- (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent +{ + _data->_commandsList.clear(); + // interpretKeyEvents will trigger one or more calls to doCommandBySelector or setText + // that will populate the commandsList vector. + [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; + return _data->_commandsList; +} + +- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines +{ + start = _data->_selectionStart; + end = _data->_selectionEnd; + lines = _data->_underlines; +} + +- (void)keyUp:(NSEvent *)theEvent +{ + _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); +} + +- (void)keyDown:(NSEvent *)theEvent +{ + if (_data->_pluginComplexTextInputIdentifier) { + // Try feeding the keyboard event directly to the plug-in. + NSString *string = nil; + if ([[WKTextInputWindowController sharedTextInputWindowController] interpretKeyEvent:theEvent string:&string]) { + if (string) + _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, string); + return; + } + } + + _data->_underlines.clear(); + _data->_selectionStart = 0; + _data->_selectionEnd = 0; + // We could be receiving a key down from AppKit if we have re-sent an event + // that maps to an action that is currently unavailable (for example a copy when + // there is no range selection). + // If this is the case we should ignore the key down. + if (_data->_keyDownEventBeingResent == theEvent) { + [_data->_keyDownEventBeingResent release]; + _data->_keyDownEventBeingResent = nil; + [super keyDown:theEvent]; + return; + } + _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); +} + +- (NSTextInputContext *)inputContext { + if (_data->_pluginComplexTextInputIdentifier) + return [[WKTextInputWindowController sharedTextInputWindowController] inputContext]; + + return [super inputContext]; +} + +- (NSRange)selectedRange +{ + if (_data->_page->selectionState().isNone || !_data->_page->selectionState().isContentEditable) + return NSMakeRange(NSNotFound, 0); + + LOG(TextInput, "selectedRange -> (%u, %u)", _data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength); + return NSMakeRange(_data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength); +} + +- (BOOL)hasMarkedText +{ + LOG(TextInput, "hasMarkedText -> %u", _data->_page->selectionState().hasComposition); + return _data->_page->selectionState().hasComposition; +} + +- (void)unmarkText +{ + LOG(TextInput, "unmarkText"); + + _data->_commandsList.append(KeypressCommand("unmarkText")); +} + +- (NSArray *)validAttributesForMarkedText +{ + static NSArray *validAttributes; + if (!validAttributes) { + validAttributes = [[NSArray alloc] initWithObjects: + NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName, + NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName, nil]; + // NSText also supports the following attributes, but it's + // hard to tell which are really required for text input to + // work well; I have not seen any input method make use of them yet. + // NSFontAttributeName, NSForegroundColorAttributeName, + // NSBackgroundColorAttributeName, NSLanguageAttributeName. + CFRetain(validAttributes); + } + LOG(TextInput, "validAttributesForMarkedText -> (...)"); + return validAttributes; +} + +static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnderline>& result) +{ + int length = [[string string] length]; + + int i = 0; + while (i < length) { + NSRange range; + NSDictionary *attrs = [string attributesAtIndex:i longestEffectiveRange:&range inRange:NSMakeRange(i, length - i)]; + + if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) { + Color color = Color::black; + if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName]) + color = colorFromNSColor([colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); + result.append(CompositionUnderline(range.location, NSMaxRange(range), color, [style intValue] > 1)); + } + + i = range.location + range.length; + } +} + +- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange +{ + BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString + + LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length); + + NSString *text = string; + + if (isAttributedString) { + text = [string string]; + extractUnderlines(string, _data->_underlines); + } + + _data->_commandsList.append(KeypressCommand("setMarkedText", text)); + _data->_selectionStart = newSelRange.location; + _data->_selectionEnd = NSMaxRange(newSelRange); +} + +- (NSRange)markedRange +{ + uint64_t location; + uint64_t length; + + _data->_page->getMarkedRange(location, length); + LOG(TextInput, "markedRange -> (%u, %u)", location, length); + return NSMakeRange(location, length); +} + +- (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange +{ + // This is not implemented for now. Need to figure out how to serialize the attributed string across processes. + LOG(TextInput, "attributedSubstringFromRange"); + return nil; +} + +- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint +{ + NSWindow *window = [self window]; + + if (window) + thePoint = [window convertScreenToBase:thePoint]; + thePoint = [self convertPoint:thePoint fromView:nil]; // the point is relative to the main frame + + uint64_t result = _data->_page->characterIndexForPoint(IntPoint(thePoint)); + LOG(TextInput, "characterIndexForPoint:(%f, %f) -> %u", thePoint.x, thePoint.y, result); + return result; +} + +- (NSRect)firstRectForCharacterRange:(NSRange)theRange +{ + // Just to match NSTextView's behavior. Regression tests cannot detect this; + // to reproduce, use a test application from http://bugs.webkit.org/show_bug.cgi?id=4682 + // (type something; try ranges (1, -1) and (2, -1). + if ((theRange.location + theRange.length < theRange.location) && (theRange.location + theRange.length != 0)) + theRange.length = 0; + + NSRect resultRect = _data->_page->firstRectForCharacterRange(theRange.location, theRange.length); + resultRect = [self convertRect:resultRect toView:nil]; + + NSWindow *window = [self window]; + if (window) + resultRect.origin = [window convertBaseToScreen:resultRect.origin]; + + LOG(TextInput, "firstRectForCharacterRange:(%u, %u) -> (%f, %f, %f, %f)", theRange.location, theRange.length, resultRect.origin.x, resultRect.origin.y, resultRect.size.width, resultRect.size.height); + return resultRect; +} + +- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo +{ + uint32_t flags = 0; + if ([NSApp modalWindow]) + flags = DragApplicationIsModal; + if ([[self window] attachedSheet]) + flags |= DragApplicationHasAttachedSheet; + if ([draggingInfo draggingSource] == self) + flags |= DragApplicationIsSource; + if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) + flags |= DragApplicationIsCopyKeyDown; + return static_cast<DragApplicationFlags>(flags); +} + +- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo +{ + IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]); + IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); + DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); + + _data->_page->performDragControllerAction(DragControllerActionEntered, &dragData, [[draggingInfo draggingPasteboard] name]); + return NSDragOperationCopy; +} + +- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo +{ + IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]); + IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); + DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); + _data->_page->performDragControllerAction(DragControllerActionUpdated, &dragData, [[draggingInfo draggingPasteboard] name]); + return _data->_page->dragOperation(); +} + +- (void)draggingExited:(id <NSDraggingInfo>)draggingInfo +{ + IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]); + IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); + DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); + _data->_page->performDragControllerAction(DragControllerActionExited, &dragData, [[draggingInfo draggingPasteboard] name]); + _data->_page->resetDragOperation(); +} + +- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo +{ + return YES; +} + +- (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo +{ + IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]); + IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); + DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); + _data->_page->performDragControllerAction(DragControllerActionPerformDrag, &dragData, [[draggingInfo draggingPasteboard] name]); + return YES; +} + +- (void)_updateWindowVisibility +{ + _data->_page->updateWindowIsVisible(![[self window] isMiniaturized]); +} + +- (BOOL)_ownsWindowGrowBox +{ + NSWindow* window = [self window]; + if (!window) + return NO; + + NSView *superview = [self superview]; + if (!superview) + return NO; + + NSRect growBoxRect = [window _growBoxRect]; + if (NSIsEmptyRect(growBoxRect)) + return NO; + + NSRect visibleRect = [self visibleRect]; + if (NSIsEmptyRect(visibleRect)) + return NO; + + NSRect visibleRectInWindowCoords = [self convertRect:visibleRect toView:nil]; + if (!NSIntersectsRect(growBoxRect, visibleRectInWindowCoords)) + return NO; + + return YES; +} + +- (BOOL)_updateGrowBoxForWindowFrameChange +{ + // Temporarily enable the resize indicator to make a the _ownsWindowGrowBox calculation work. + BOOL wasShowingIndicator = [[self window] showsResizeIndicator]; + [[self window] setShowsResizeIndicator:YES]; + + BOOL ownsGrowBox = [self _ownsWindowGrowBox]; + _data->_page->setWindowResizerSize(ownsGrowBox ? enclosingIntRect([[self window] _growBoxRect]).size() : IntSize()); + + // Once WebCore can draw the window resizer, this should read: + // if (wasShowingIndicator) + // [[self window] setShowsResizeIndicator:!ownsGrowBox]; + [[self window] setShowsResizeIndicator:wasShowingIndicator]; + + return ownsGrowBox; +} + +- (void)addWindowObserversForWindow:(NSWindow *)window +{ + if (window) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:) + name:NSWindowDidBecomeKeyNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:) + name:NSWindowDidResignKeyNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidMiniaturize:) + name:NSWindowDidMiniaturizeNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidDeminiaturize:) + name:NSWindowDidDeminiaturizeNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:) + name:NSWindowDidMoveNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:) + name:NSWindowDidResizeNotification object:window]; + } +} + +- (void)removeWindowObservers +{ + NSWindow *window = [self window]; + if (!window) + return; + + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMiniaturizeNotification object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMoveNotification object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:window]; +} + +- (void)viewWillMoveToWindow:(NSWindow *)window +{ + if (window != [self window]) { + [self removeWindowObservers]; + [self addWindowObserversForWindow:window]; + } +} + +- (void)viewDidMoveToWindow +{ + // We want to make sure to update the active state while hidden, so if the view is about to become visible, we + // update the active state first and then make it visible. If the view is about to be hidden, we hide it first and then + // update the active state. + if ([self window]) { + _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible | WebPageProxy::ViewIsInWindow); + [self _updateWindowVisibility]; + [self _updateWindowAndViewFrames]; + } else { + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); + _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow); + } + +} + +- (void)_windowDidBecomeKey:(NSNotification *)notification +{ + NSWindow *keyWindow = [notification object]; + if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) + _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); +} + +- (void)_windowDidResignKey:(NSNotification *)notification +{ + NSWindow *formerKeyWindow = [notification object]; + if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) + _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); +} + +- (void)_windowDidMiniaturize:(NSNotification *)notification +{ + [self _updateWindowVisibility]; +} + +- (void)_windowDidDeminiaturize:(NSNotification *)notification +{ + [self _updateWindowVisibility]; +} + +- (void)_windowFrameDidChange:(NSNotification *)notification +{ + [self _updateWindowAndViewFrames]; +} + +- (void)drawRect:(NSRect)rect +{ + LOG(View, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); + if (useNewDrawingArea()) { + if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) { + CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]); + drawingArea->paint(context, enclosingIntRect(rect)); + } else if (_data->_page->drawsBackground()) { + [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set]; + NSRectFill(rect); + } + + _data->_page->didDraw(); + return; + } + + if (_data->_page->isValid() && _data->_page->drawingArea()) { + CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]); + _data->_page->drawingArea()->paint(IntRect(rect), context); + _data->_page->didDraw(); + } else if (_data->_page->drawsBackground()) { + [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set]; + NSRectFill(rect); + } +} + +- (BOOL)isOpaque +{ + return _data->_page->drawsBackground(); +} + +- (void)viewDidHide +{ + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + +- (void)viewDidUnhide +{ + _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); +} + +- (void)_setAccessibilityChildToken:(NSData *)data +{ +#if !defined(BUILDING_ON_SNOW_LEOPARD) + _data->_remoteAccessibilityChild = WKAXRemoteElementForToken((CFDataRef)data); + WKAXInitializeRemoteElementWithWindow(_data->_remoteAccessibilityChild.get(), [self window]); +#endif +} + +- (BOOL)accessibilityIsIgnored +{ + return NO; +} + +- (id)accessibilityHitTest:(NSPoint)point +{ + return _data->_remoteAccessibilityChild.get(); +} + +- (id)accessibilityAttributeValue:(NSString*)attribute +{ + if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) { + if (!_data->_remoteAccessibilityChild) + return nil; + return [NSArray arrayWithObject:_data->_remoteAccessibilityChild.get()]; + } + if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) + return NSAccessibilityGroupRole; + if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) + return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil); + if ([attribute isEqualToString:NSAccessibilityParentAttribute]) + return NSAccessibilityUnignoredAncestor([self superview]); + if ([attribute isEqualToString:NSAccessibilityEnabledAttribute]) + return [NSNumber numberWithBool:YES]; + + return [super accessibilityAttributeValue:attribute]; +} + +- (NSView *)hitTest:(NSPoint)point +{ + NSView *hitView = [super hitTest:point]; +#if USE(ACCELERATED_COMPOSITING) + if (hitView && _data && hitView == _data->_layerHostingView) + hitView = self; +#endif + return hitView; +} + +- (NSInteger)conversationIdentifier +{ + return (NSInteger)self; +} + +static void setFrameBeingPrinted(NSPrintOperation *printOperation, WebFrameProxy* frame) +{ + RetainPtr<WebFrameWrapper> frameWrapper(AdoptNS, [[WebFrameWrapper alloc] initWithFrameProxy:frame]); + [[[printOperation printInfo] dictionary] setObject:frameWrapper.get() forKey:PrintedFrameKey]; +} + +static WebFrameProxy* frameBeingPrinted() +{ + return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:PrintedFrameKey] webFrame]; +} + +- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef +{ + LOG(View, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data()); + NSPrintOperation *printOperation; + + // Only the top frame can currently contain a PDF view. + if (_data->_pdfViewController) { + ASSERT(toImpl(frameRef)->isMainFrame()); + printOperation = _data->_pdfViewController->makePrintOperation(printInfo); + } else + printOperation = [NSPrintOperation printOperationWithView:self printInfo:printInfo]; + + setFrameBeingPrinted(printOperation, toImpl(frameRef)); + return printOperation; +} + +- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef +{ + // PDF documents are already paginated, so we can't change them to add headers and footers. + return !toImpl(frameRef)->isMainFrame() || !_data->_pdfViewController; +} + +// Return the number of pages available for printing +- (BOOL)knowsPageRange:(NSRangePointer)range +{ + LOG(View, "knowsPageRange:"); + WebFrameProxy* frame = frameBeingPrinted(); + ASSERT(frame); + + if (frame->isMainFrame() && _data->_pdfViewController) + return [super knowsPageRange:range]; + + _data->_page->computePagesForPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo]), _data->_printingPageRects, _data->_totalScaleFactorForPrinting); + + *range = NSMakeRange(1, _data->_printingPageRects.size()); + return YES; +} + +// Take over printing. AppKit applies incorrect clipping, and doesn't print pages beyond the first one. +- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView +{ + // FIXME: This check isn't right for some non-printing cases, such as capturing into a buffer using cacheDisplayInRect:toBitmapImageRep:. + if ([NSGraphicsContext currentContextDrawingToScreen]) { + _data->_page->endPrinting(); + [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView topView:topView]; + return; + } + + LOG(View, "Printing rect x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); + + ASSERT(self == visibleView); + ASSERT(frameBeingPrinted()); + + WebFrameProxy* frame = frameBeingPrinted(); + ASSERT(frame); + + _data->_page->beginPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo])); + + // FIXME: This is optimized for print preview. Get the whole document at once when actually printing. + Vector<uint8_t> pdfData; + _data->_page->drawRectToPDF(frame, IntRect(rect), pdfData); + + RetainPtr<CGDataProviderRef> pdfDataProvider(AdoptCF, CGDataProviderCreateWithData(0, pdfData.data(), pdfData.size(), 0)); + RetainPtr<CGPDFDocumentRef> pdfDocument(AdoptCF, CGPDFDocumentCreateWithProvider(pdfDataProvider.get())); + if (!pdfDocument) { + LOG_ERROR("Couldn't create a PDF document with data passed for printing"); + return; + } + + CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDocument.get(), 1); + if (!pdfPage) { + LOG_ERROR("Printing data doesn't have page 1"); + return; + } + + NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext]; + CGContextRef context = static_cast<CGContextRef>([nsGraphicsContext graphicsPort]); + + CGContextSaveGState(context); + // Flip the destination. + CGContextScaleCTM(context, 1, -1); + CGContextTranslateCTM(context, 0, -rect.size.height); + CGContextDrawPDFPage(context, pdfPage); + CGContextRestoreGState(context); +} + +// FIXME 3491344: This is an AppKit-internal method that we need to override in order +// to get our shrink-to-fit to work with a custom pagination scheme. We can do this better +// if AppKit makes it SPI/API. +- (CGFloat)_provideTotalScaleFactorForPrintOperation:(NSPrintOperation *)printOperation +{ + return _data->_totalScaleFactorForPrinting; +} + +// Return the drawing rectangle for a particular page number +- (NSRect)rectForPage:(NSInteger)page +{ + WebFrameProxy* frame = frameBeingPrinted(); + ASSERT(frame); + + if (frame->isMainFrame() && _data->_pdfViewController) + return [super rectForPage:page]; + + LOG(View, "rectForPage:%d -> x %d, y %d, width %d, height %d\n", (int)page, _data->_printingPageRects[page - 1].x(), _data->_printingPageRects[page - 1].y(), _data->_printingPageRects[page - 1].width(), _data->_printingPageRects[page - 1].height()); + return _data->_printingPageRects[page - 1]; +} + +@end + +@implementation WKView (Internal) + +- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy +{ + if (useNewDrawingArea()) + return DrawingAreaProxyImpl::create(_data->_page.get()); + + return ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get()); +} + +- (BOOL)_isFocused +{ + if (_data->_inBecomeFirstResponder) + return YES; + if (_data->_inResignFirstResponder) + return NO; + return [[self window] firstResponder] == self; +} + +- (void)_processDidCrash +{ + [self setNeedsDisplay:YES]; +} + +- (void)_didRelaunchProcess +{ + [self setNeedsDisplay:YES]; +} + +- (void)_takeFocus:(BOOL)forward +{ + if (forward) + [[self window] selectKeyViewFollowingView:self]; + else + [[self window] selectKeyViewPrecedingView:self]; +} + +- (void)_setCursor:(NSCursor *)cursor +{ + if ([NSCursor currentCursor] == cursor) + return; + [cursor set]; +} + +- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState +{ + ValidationVector items = _data->_validationMap.take(commandName); + size_t size = items.size(); + for (size_t i = 0; i < size; ++i) { + ValidationItem item = items[i].get(); + [menuItem(item) setState:newState]; + [menuItem(item) setEnabled:isEnabled]; + [toolbarItem(item) setEnabled:isEnabled]; + // FIXME <rdar://problem/8803392>: If the item is neither a menu nor toolbar item, it will be left enabled. + } +} + +- (NSRect)_convertToDeviceSpace:(NSRect)rect +{ + return toDeviceSpace(rect, [self window]); +} + +- (NSRect)_convertToUserSpace:(NSRect)rect +{ + return toUserSpace(rect, [self window]); +} + +// Any non-zero value will do, but using something recognizable might help us debug some day. +#define TRACKING_RECT_TAG 0xBADFACE + +- (NSTrackingRectTag)addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside +{ + ASSERT(_data->_trackingRectOwner == nil); + _data->_trackingRectOwner = owner; + _data->_trackingRectUserData = data; + return TRACKING_RECT_TAG; +} + +- (NSTrackingRectTag)_addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside useTrackingNum:(int)tag +{ + ASSERT(tag == 0 || tag == TRACKING_RECT_TAG); + ASSERT(_data->_trackingRectOwner == nil); + _data->_trackingRectOwner = owner; + _data->_trackingRectUserData = data; + return TRACKING_RECT_TAG; +} + +- (void)_addTrackingRects:(NSRect *)rects owner:(id)owner userDataList:(void **)userDataList assumeInsideList:(BOOL *)assumeInsideList trackingNums:(NSTrackingRectTag *)trackingNums count:(int)count +{ + ASSERT(count == 1); + ASSERT(trackingNums[0] == 0 || trackingNums[0] == TRACKING_RECT_TAG); + ASSERT(_data->_trackingRectOwner == nil); + _data->_trackingRectOwner = owner; + _data->_trackingRectUserData = userDataList[0]; + trackingNums[0] = TRACKING_RECT_TAG; +} + +- (void)removeTrackingRect:(NSTrackingRectTag)tag +{ + if (tag == 0) + return; + + if (_data && (tag == TRACKING_RECT_TAG)) { + _data->_trackingRectOwner = nil; + return; + } + + if (_data && (tag == _data->_lastToolTipTag)) { + [super removeTrackingRect:tag]; + _data->_lastToolTipTag = 0; + return; + } + + // If any other tracking rect is being removed, we don't know how it was created + // and it's possible there's a leak involved (see 3500217) + ASSERT_NOT_REACHED(); +} + +- (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count +{ + int i; + for (i = 0; i < count; ++i) { + int tag = tags[i]; + if (tag == 0) + continue; + ASSERT(tag == TRACKING_RECT_TAG); + if (_data != nil) { + _data->_trackingRectOwner = nil; + } + } +} + +- (void)_sendToolTipMouseExited +{ + // Nothing matters except window, trackingNumber, and userData. + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0 + windowNumber:[[self window] windowNumber] + context:NULL + eventNumber:0 + trackingNumber:TRACKING_RECT_TAG + userData:_data->_trackingRectUserData]; + [_data->_trackingRectOwner mouseExited:fakeEvent]; +} + +- (void)_sendToolTipMouseEntered +{ + // Nothing matters except window, trackingNumber, and userData. + NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0 + windowNumber:[[self window] windowNumber] + context:NULL + eventNumber:0 + trackingNumber:TRACKING_RECT_TAG + userData:_data->_trackingRectUserData]; + [_data->_trackingRectOwner mouseEntered:fakeEvent]; +} + +- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data +{ + return nsStringFromWebCoreString(_data->_page->toolTip()); +} + +- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip +{ + if (oldToolTip) + [self _sendToolTipMouseExited]; + + if (newToolTip && [newToolTip length] > 0) { + // See radar 3500217 for why we remove all tooltips rather than just the single one we created. + [self removeAllToolTips]; + NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000); + _data->_lastToolTipTag = [self addToolTipRect:wideOpenRect owner:self userData:NULL]; + [self _sendToolTipMouseEntered]; + } +} + +- (void)_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut +{ + if (!findIndicator) { + _data->_findIndicatorWindow = 0; + return; + } + + if (!_data->_findIndicatorWindow) + _data->_findIndicatorWindow = FindIndicatorWindow::create(self); + + _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut); +} + +#if USE(ACCELERATED_COMPOSITING) +- (void)_startAcceleratedCompositing:(CALayer *)rootLayer +{ + if (!_data->_layerHostingView) { + NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]]; +#if !defined(BUILDING_ON_LEOPARD) + [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; +#endif + + [self addSubview:hostingView]; + [hostingView release]; + _data->_layerHostingView = hostingView; + } + + // Make a container layer, which will get sized/positioned by AppKit and CA. + CALayer *viewLayer = [CALayer layer]; + +#ifndef NDEBUG + [viewLayer setName:@"hosting layer"]; +#endif + +#if defined(BUILDING_ON_LEOPARD) + // Turn off default animations. + NSNull *nullValue = [NSNull null]; + NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys: + nullValue, @"anchorPoint", + nullValue, @"bounds", + nullValue, @"contents", + nullValue, @"contentsRect", + nullValue, @"opacity", + nullValue, @"position", + nullValue, @"sublayerTransform", + nullValue, @"sublayers", + nullValue, @"transform", + nil]; + [viewLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]]; +#endif + +#if !defined(BUILDING_ON_LEOPARD) + // If we aren't in the window yet, we'll use the screen's scale factor now, and reset the scale + // via -viewDidMoveToWindow. + CGFloat scaleFactor = [self window] ? [[self window] userSpaceScaleFactor] : [[NSScreen mainScreen] userSpaceScaleFactor]; + [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)]; +#endif + + [_data->_layerHostingView setLayer:viewLayer]; + [_data->_layerHostingView setWantsLayer:YES]; + + // Parent our root layer in the container layer + [viewLayer addSublayer:rootLayer]; +} + +- (void)_stopAcceleratedCompositing +{ + if (_data->_layerHostingView) { + [_data->_layerHostingView setLayer:nil]; + [_data->_layerHostingView setWantsLayer:NO]; + [_data->_layerHostingView removeFromSuperview]; + _data->_layerHostingView = nil; + } +} + +- (void)_switchToDrawingAreaTypeIfNecessary:(DrawingAreaInfo::Type)type +{ + DrawingAreaInfo::Type existingDrawingAreaType = _data->_page->drawingArea() ? _data->_page->drawingArea()->info().type : DrawingAreaInfo::None; + if (existingDrawingAreaType == type) + return; + + OwnPtr<DrawingAreaProxy> newDrawingArea; + switch (type) { + case DrawingAreaInfo::Impl: + case DrawingAreaInfo::None: + break; + case DrawingAreaInfo::ChunkedUpdate: { + newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get()); + break; + } + case DrawingAreaInfo::LayerBacked: { + newDrawingArea = LayerBackedDrawingAreaProxy::create(self, _data->_page.get()); + break; + } + } + + newDrawingArea->setSize(IntSize([self frame].size)); + + _data->_page->drawingArea()->detachCompositingContext(); + _data->_page->setDrawingArea(newDrawingArea.release()); +} + +- (void)_pageDidEnterAcceleratedCompositing +{ + [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::LayerBacked]; +} + +- (void)_pageDidLeaveAcceleratedCompositing +{ + // FIXME: we may want to avoid flipping back to the non-layer-backed drawing area until the next page load, to avoid thrashing. + [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::ChunkedUpdate]; +} +#endif // USE(ACCELERATED_COMPOSITING) + +- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier +{ + BOOL inputSourceChanged = _data->_pluginComplexTextInputIdentifier; + + if (complexTextInputEnabled) { + // Check if we're already allowing text input for this plug-in. + if (pluginComplexTextInputIdentifier == _data->_pluginComplexTextInputIdentifier) + return; + + _data->_pluginComplexTextInputIdentifier = pluginComplexTextInputIdentifier; + + } else { + // Check if we got a request to disable complex text input for a plug-in that is not the current plug-in. + if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier) + return; + + _data->_pluginComplexTextInputIdentifier = 0; + } + + if (inputSourceChanged) { + // Inform the out of line window that the input source changed. + [[WKTextInputWindowController sharedTextInputWindowController] keyboardInputSourceChanged]; + } +} + +- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation +{ + _data->_pdfViewController = nullptr; + + if (pageHasCustomRepresentation) + _data->_pdfViewController = PDFViewController::create(self); +} + +- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference +{ + ASSERT(_data->_pdfViewController); + + _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), dataReference); +} + +- (double)_customRepresentationZoomFactor +{ + if (!_data->_pdfViewController) + return 1; + + return _data->_pdfViewController->zoomFactor(); +} + +- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor +{ + if (!_data->_pdfViewController) + return; + + _data->_pdfViewController->setZoomFactor(zoomFactor); +} + +@end diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h new file mode 100644 index 0000000..1c70b38 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -0,0 +1,66 @@ +/* + * 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. + */ + +#import "WKView.h" +#import <WebCore/Editor.h> +#import <WebCore/KeyboardEvent.h> + +namespace WebKit { + class DrawingAreaProxy; + class FindIndicator; +} + +@interface WKView (Internal) +- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy; +- (BOOL)_isFocused; +- (void)_processDidCrash; +- (void)_didRelaunchProcess; +- (void)_takeFocus:(BOOL)direction; +- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip; +- (void)_setCursor:(NSCursor *)cursor; +- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState; +- (Vector<WebCore::KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent; +- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines; +- (void)_setEventBeingResent:(NSEvent *)event; +- (NSRect)_convertToDeviceSpace:(NSRect)rect; +- (NSRect)_convertToUserSpace:(NSRect)rect; +- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut; + +#if USE(ACCELERATED_COMPOSITING) +- (void)_startAcceleratedCompositing:(CALayer *)rootLayer; +- (void)_stopAcceleratedCompositing; +- (void)_pageDidEnterAcceleratedCompositing; +- (void)_pageDidLeaveAcceleratedCompositing; +#endif + +- (void)_setAccessibilityChildToken:(NSData *)data; +- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; + +- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation; +- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference; +- (double)_customRepresentationZoomFactor; +- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor; + +@end diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp new file mode 100644 index 0000000..642e529 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp @@ -0,0 +1,169 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "ClientImpl.h" + +#include "WebFrameProxy.h" +#include "WKAPICast.h" +#include "WKStringQt.h" +#include "WKURLQt.h" +#include <qwkpage.h> +#include <qwkpage_p.h> +#include <WKFrame.h> +#include <WKType.h> + +using namespace WebKit; + +static QWKPage* toQWKPage(const void* clientInfo) +{ + if (clientInfo) + return reinterpret_cast<QWKPage*>(const_cast<void*>(clientInfo)); + return 0; +} + +static void loadFinished(WKFrameRef frame, const void* clientInfo, bool ok) +{ + if (!WKFrameIsMainFrame(frame)) + return; + emit toQWKPage(clientInfo)->loadFinished(ok); + QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); +} + +void qt_wk_didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + if (!WKFrameIsMainFrame(frame)) + return; + emit toQWKPage(clientInfo)->loadStarted(); + QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); +} + +void qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ +} + +void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo) +{ + loadFinished(frame, clientInfo, false); +} + +void qt_wk_didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + if (!WKFrameIsMainFrame(frame)) + return; + WebFrameProxy* wkframe = toImpl(frame); + QString urlStr(wkframe->url()); + QUrl qUrl = urlStr; + emit toQWKPage(clientInfo)->urlChanged(qUrl); + QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); +} + +void qt_wk_didFinishDocumentLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + // FIXME: Implement (bug #44934) +} + +void qt_wk_didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + loadFinished(frame, clientInfo, true); +} + +void qt_wk_didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo) +{ + loadFinished(frame, clientInfo, false); +} + +void qt_wk_didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + if (!WKFrameIsMainFrame(frame)) + return; + QString qTitle = WKStringCopyQString(title); + emit toQWKPage(clientInfo)->titleChanged(qTitle); +} + +void qt_wk_didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + if (!WKFrameIsMainFrame(frame)) + return; + emit toQWKPage(clientInfo)->initialLayoutCompleted(); +} + +void qt_wk_didRemoveFrameFromHierarchy(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + // FIXME: Implement (bug #46432) +} + +void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) +{ + if (!WKFrameIsMainFrame(frame)) + return; + // FIXME: emit toWKView(clientInfo)->initialLayoutCompleted(); +} + +void qt_wk_didStartProgress(WKPageRef page, const void* clientInfo) +{ + emit toQWKPage(clientInfo)->loadProgress(0); +} + +void qt_wk_didChangeProgress(WKPageRef page, const void* clientInfo) +{ + emit toQWKPage(clientInfo)->loadProgress(WKPageGetEstimatedProgress(page) * 100); +} + +void qt_wk_didFinishProgress(WKPageRef page, const void* clientInfo) +{ + emit toQWKPage(clientInfo)->loadProgress(100); +} + +void qt_wk_didBecomeUnresponsive(WKPageRef page, const void* clientInfo) +{ +} + +void qt_wk_didBecomeResponsive(WKPageRef page, const void* clientInfo) +{ +} + +WKPageRef qt_wk_createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void* clientInfo) +{ + QWKPage* wkPage = toQWKPage(clientInfo); + QWKPagePrivate* d = QWKPagePrivate::get(wkPage); + QWKPage::CreateNewPageFn createNewPageFn = d->createNewPageFn; + + if (!createNewPageFn) + return 0; + + if (QWKPage* newPage = createNewPageFn(wkPage)) { + WKRetain(newPage->pageRef()); + return newPage->pageRef(); + } + + return 0; +} + +void qt_wk_showPage(WKPageRef page, const void* clientInfo) +{ +} + +void qt_wk_close(WKPageRef page, const void* clientInfo) +{ + emit toQWKPage(clientInfo)->windowCloseRequested(); +} + +void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) +{ +} diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.h b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h new file mode 100644 index 0000000..5d8c062 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef DefaultClientCallbacksQt_h +#define DefaultClientCallbacksQt_h + +#include <WebKit2/WKPage.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// loader client +void qt_wk_didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef, const void* clientInfo); +void qt_wk_didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFinishDocumentLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef, const void* clientInfo); +void qt_wk_didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFirstLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didRemoveFrameFromHierarchy(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo); +void qt_wk_didStartProgress(WKPageRef, const void* clientInfo); +void qt_wk_didChangeProgress(WKPageRef, const void* clientInfo); +void qt_wk_didFinishProgress(WKPageRef, const void* clientInfo); +void qt_wk_didBecomeUnresponsive(WKPageRef, const void* clientInfo); +void qt_wk_didBecomeResponsive(WKPageRef, const void* clientInfo); + +// ui client +WKPageRef qt_wk_createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo); +void qt_wk_showPage(WKPageRef page, const void *clientInfo); +void qt_wk_close(WKPageRef page, const void *clientInfo); +void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo); + +#ifdef __cplusplus +} +#endif + +#endif /* DefaultClientCallbacksQt_h */ + diff --git a/Source/WebKit2/UIProcess/API/qt/WKView.h b/Source/WebKit2/UIProcess/API/qt/WKView.h new file mode 100644 index 0000000..5bb95e8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/WKView.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WKView_h +#define WKView_h + +#include <WebKit2/qgraphicswkview.h> +#include <WebKit2/qwkcontext.h> +#include <WebKit2/qwkpage.h> +#include <WebKit2/qwkpreferences.h> + +#endif /* WKView_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp new file mode 100644 index 0000000..f01c5b2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp @@ -0,0 +1,442 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "qgraphicswkview.h" + +#include "ChunkedUpdateDrawingAreaProxy.h" +#include "IntSize.h" +#include "RunLoop.h" +#include "TiledDrawingAreaProxy.h" +#include "UpdateChunk.h" +#include "WKAPICast.h" +#include "qwkpage.h" +#include "qwkpage_p.h" +#include <QApplication> +#include <QCursor> +#include <QGraphicsSceneMouseEvent> +#include <QGraphicsView> +#include <QMenu> +#include <QPainter> +#include <QScrollBar> +#include <QStyleOptionGraphicsItem> +#include <QUrl> +#include <QtDebug> +#include <WebKit2/WKRetainPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +using namespace WebKit; +using namespace WebCore; + +struct QGraphicsWKViewPrivate { + QGraphicsWKViewPrivate(QGraphicsWKView* view); + WKPageRef pageRef() const { return page->pageRef(); } + + void onScaleChanged(); + void commitScale(); + + QGraphicsWKView* q; + QWKPage* page; + QMenu* activeMenu; + RunLoop::Timer<QGraphicsWKViewPrivate> m_scaleCommitTimer; + bool m_isChangingScale; +}; + +QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingStoreType, QGraphicsItem* parent) + : QGraphicsWidget(parent) + , d(new QGraphicsWKViewPrivate(this)) +{ + setFocusPolicy(Qt::StrongFocus); + setAcceptHoverEvents(true); + + PassOwnPtr<DrawingAreaProxy> drawingAreaProxy; + + d->page = new QWKPage(context); + + switch (backingStoreType) { +#if ENABLE(TILED_BACKING_STORE) + case Tiled: + drawingAreaProxy = TiledDrawingAreaProxy::create(this, toImpl(page()->pageRef())); + connect(this, SIGNAL(scaleChanged()), this, SLOT(onScaleChanged())); + break; +#endif + case Simple: + default: + drawingAreaProxy = ChunkedUpdateDrawingAreaProxy::create(this, toImpl(page()->pageRef())); + break; + } + + d->page->d->init(this, drawingAreaProxy); + connect(d->page, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); + connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted())); + connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool))); + connect(d->page, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); + connect(d->page, SIGNAL(initialLayoutCompleted()), this, SIGNAL(initialLayoutCompleted())); + connect(d->page, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&))); + connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&))); + connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool))); + connect(d->page, SIGNAL(showContextMenu(QMenu*)), this, SLOT(showContextMenu(QMenu*))); +} + +QGraphicsWKView::~QGraphicsWKView() +{ + delete d->page; + delete d; +} + +QWKPage* QGraphicsWKView::page() const +{ + return d->page; +} + +void QGraphicsWKView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*) +{ + page()->d->paint(painter, option->exposedRect.toAlignedRect()); +} + +void QGraphicsWKView::setGeometry(const QRectF& rect) +{ + QSizeF oldSize = geometry().size(); + QGraphicsWidget::setGeometry(rect); + if (geometry().size() == oldSize) + return; + + // NOTE: call geometry() as setGeometry ensures that + // the geometry is within legal bounds (minimumSize, maximumSize) + page()->setViewportSize(geometry().size().toSize()); +} + +void QGraphicsWKView::load(const QUrl& url) +{ + page()->load(url); +} + +void QGraphicsWKView::setUrl(const QUrl& url) +{ + page()->setUrl(url); +} + +QUrl QGraphicsWKView::url() const +{ + return page()->url(); +} + +QString QGraphicsWKView::title() const +{ + return page()->title(); +} + +void QGraphicsWKView::triggerPageAction(QWKPage::WebAction action, bool checked) +{ + page()->triggerAction(action, checked); +} + +void QGraphicsWKView::back() +{ + page()->triggerAction(QWKPage::Back); +} + +void QGraphicsWKView::forward() +{ + page()->triggerAction(QWKPage::Forward); +} + +void QGraphicsWKView::reload() +{ + page()->triggerAction(QWKPage::Reload); +} + +void QGraphicsWKView::stop() +{ + page()->triggerAction(QWKPage::Stop); +} + +void QGraphicsWKView::updateCursor(const QCursor& cursor) +{ + setCursor(cursor); +} + +class FriendlyWidget : public QWidget +{ +public: + bool focusNextPrevChild(bool next); +}; + +void QGraphicsWKView::focusNextPrevChildCallback(bool next) +{ + if (hasFocus()) { + // find the view which has the focus: + QList<QGraphicsView*> views = scene()->views(); + const int viewCount = views.count(); + QGraphicsView* focusedView = 0; + for (int i = 0; i < viewCount; ++i) { + if (views[i]->hasFocus()) { + focusedView = views[i]; + break; + } + } + + if (focusedView) { + QWidget* window = focusedView->window(); + FriendlyWidget* friendlyWindow = static_cast<FriendlyWidget*>(window); + friendlyWindow->focusNextPrevChild(next); + } + } +} + +/*! \reimp +*/ +bool QGraphicsWKView::focusNextPrevChild(bool next) +{ + QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier)); + page()->d->keyPressEvent(&ev); + return true; +} + +/*! \reimp +*/ +QVariant QGraphicsWKView::itemChange(GraphicsItemChange change, const QVariant& value) +{ + // Here so that it can be reimplemented without breaking ABI. + return QGraphicsWidget::itemChange(change, value); +} + +/*! \reimp +*/ +bool QGraphicsWKView::event(QEvent* event) +{ + QEvent::Type eventType = event->type(); + switch (eventType) { + case QEvent::TouchBegin: + case QEvent::TouchEnd: + case QEvent::TouchUpdate: + touchEvent(static_cast<QTouchEvent*>(event)); + return true; + case QEvent::Show: + page()->d->page->drawingArea()->setPageIsVisible(true); + break; + case QEvent::Hide: + page()->d->page->drawingArea()->setPageIsVisible(false); + break; + default: + break; + } + + // Here so that it can be reimplemented without breaking ABI. + return QGraphicsWidget::event(event); +} + +/*! \reimp +*/ +QSizeF QGraphicsWKView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const +{ + if (which == Qt::PreferredSize) + return QSizeF(800, 600); + return QGraphicsWidget::sizeHint(which, constraint); +} + +/*! \reimp +*/ +QVariant QGraphicsWKView::inputMethodQuery(Qt::InputMethodQuery query) const +{ + // implement + return QVariant(); +} + +/*! \reimp +*/ +void QGraphicsWKView::keyPressEvent(QKeyEvent* ev) +{ + page()->d->keyPressEvent(ev); +} + +/*! \reimp +*/ +void QGraphicsWKView::keyReleaseEvent(QKeyEvent* ev) +{ + page()->d->keyReleaseEvent(ev); +} + +void QGraphicsWKView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev) +{ + QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseMove); + me.setPos(ev->pos()); + me.setScreenPos(ev->screenPos()); + + page()->d->mouseMoveEvent(&me); + + if (!ev->isAccepted()) + QGraphicsItem::hoverMoveEvent(ev); +} + +void QGraphicsWKView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) +{ + page()->d->mouseMoveEvent(ev); + if (!ev->isAccepted()) + QGraphicsItem::mouseMoveEvent(ev); +} + +void QGraphicsWKView::mousePressEvent(QGraphicsSceneMouseEvent* ev) +{ + page()->d->mousePressEvent(ev); + if (!ev->isAccepted()) + QGraphicsItem::mousePressEvent(ev); +} + +void QGraphicsWKView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) +{ + page()->d->mouseReleaseEvent(ev); + if (!ev->isAccepted()) + QGraphicsItem::mouseReleaseEvent(ev); +} + +void QGraphicsWKView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) +{ + page()->d->mouseDoubleClickEvent(ev); + if (!ev->isAccepted()) + QGraphicsItem::mouseReleaseEvent(ev); +} + +void QGraphicsWKView::wheelEvent(QGraphicsSceneWheelEvent* ev) +{ + page()->d->wheelEvent(ev); + if (!ev->isAccepted()) + QGraphicsItem::wheelEvent(ev); +} + +void QGraphicsWKView::touchEvent(QTouchEvent* ev) +{ + page()->d->touchEvent(ev); +} + +void QGraphicsWKView::focusInEvent(QFocusEvent*) +{ + page()->d->page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); +} + +void QGraphicsWKView::focusOutEvent(QFocusEvent*) +{ + page()->d->page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); +} + +void QGraphicsWKView::showContextMenu(QMenu* menu) +{ + // Remove the active menu in case this function is called twice. + if (d->activeMenu) + d->activeMenu->hide(); + + d->activeMenu = menu; + + QWidget* view = 0; + if (QGraphicsScene* myScene = scene()) { + const QList<QGraphicsView*> views = myScene->views(); + for (unsigned i = 0; i < views.size(); ++i) { + if (views.at(i) == QApplication::focusWidget()) { + view = views.at(i); + break; + } + } + if (!view) + view = views.value(0, 0); + } + if (view) + menu->setParent(view, menu->windowFlags()); + menu->exec(view->mapToGlobal(menu->pos())); + if (d->activeMenu == menu) + d->activeMenu = 0; +} + +void QGraphicsWKView::takeSnapshot(const QSize& size, const QRect& contentsRect) +{ +#if ENABLE(TILED_BACKING_STORE) + DrawingAreaProxy* drawingArea = page()->d->page->drawingArea(); + if (drawingArea->info().type != DrawingAreaInfo::Tiled) + return; + TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea); + tiledDrawingArea->takeSnapshot(size, contentsRect); +#endif +} + +QGraphicsWKViewPrivate::QGraphicsWKViewPrivate(QGraphicsWKView* view) + : q(view) + , activeMenu(0) + , m_scaleCommitTimer(RunLoop::current(), this, &QGraphicsWKViewPrivate::commitScale) + , m_isChangingScale(false) +{ +} + +QRectF QGraphicsWKView::visibleRect() const +{ + if (!scene()) + return QRectF(); + + QList<QGraphicsView*> views = scene()->views(); + if (views.isEmpty()) + return QRectF(); + + QGraphicsView* graphicsView = views.at(0); + int xOffset = graphicsView->horizontalScrollBar()->value(); + int yOffset = graphicsView->verticalScrollBar()->value(); + return mapRectFromScene(QRectF(QPointF(xOffset, yOffset), graphicsView->viewport()->size())); +} + +void QGraphicsWKView::prepareScaleChange() +{ +#if ENABLE(TILED_BACKING_STORE) + ASSERT(!d->m_isChangingScale); + d->m_isChangingScale = true; + d->m_scaleCommitTimer.stop(); +#endif +} + +void QGraphicsWKView::commitScaleChange() +{ +#if ENABLE(TILED_BACKING_STORE) + ASSERT(d->m_isChangingScale); + d->m_isChangingScale = false; + d->commitScale(); +#endif +} + +void QGraphicsWKViewPrivate::onScaleChanged() +{ +#if ENABLE(TILED_BACKING_STORE) + if (!m_isChangingScale) + m_scaleCommitTimer.startOneShot(0.1); +#endif +} + +void QGraphicsWKViewPrivate::commitScale() +{ +#if ENABLE(TILED_BACKING_STORE) + DrawingAreaProxy* drawingArea = page->d->page->drawingArea(); + float newScale = q->scale(); + if (drawingArea->info().type == DrawingAreaInfo::Tiled) { + TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea); + if (tiledDrawingArea->contentsScale() == newScale) + return; + tiledDrawingArea->setContentsScale(newScale); + // For now we block until complete. + tiledDrawingArea->waitUntilUpdatesComplete(); + } +#endif +} + +#include "moc_qgraphicswkview.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h new file mode 100644 index 0000000..caf8e0d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h @@ -0,0 +1,102 @@ +#ifndef qgraphicswkview_h +#define qgraphicswkview_h + +#include "qwebkitglobal.h" + +#include <WebKit2/WKBase.h> +#include <QGraphicsWidget> +#include "qwkpage.h" + +QT_BEGIN_NAMESPACE +class QCursor; +QT_END_NAMESPACE + +class QWKContext; +class QGraphicsWKViewPrivate; + +WKStringRef WKStringCreateWithQString(const QString& qString); +QString WKStringCopyQString(WKStringRef stringRef); + +class QWEBKIT_EXPORT QGraphicsWKView : public QGraphicsWidget { + Q_OBJECT + Q_PROPERTY(QString title READ title) + Q_PROPERTY(QUrl url READ url WRITE setUrl) + +public: + enum BackingStoreType { Simple, Tiled }; + QGraphicsWKView(QWKContext* context, BackingStoreType backingStoreType = Simple, QGraphicsItem* parent = 0); + + virtual ~QGraphicsWKView(); + + QWKPage* page() const; + + virtual void setGeometry(const QRectF&); + + void load(const QUrl&); + void setUrl(const QUrl&); + QUrl url() const; + + QString title() const; + + void triggerPageAction(QWKPage::WebAction action, bool checked = false); + + virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + virtual QVariant itemChange(GraphicsItemChange, const QVariant&); + virtual bool event(QEvent*); + virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF&) const; + virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const; + + void takeSnapshot(const QSize& size, const QRect& documentRect); + + // FIXME: should not be public + virtual QRectF visibleRect() const; + + void prepareScaleChange(); + void commitScaleChange(); + +public: + Q_SIGNAL void titleChanged(const QString& title); + Q_SIGNAL void loadStarted(); + Q_SIGNAL void loadFinished(bool ok); + Q_SIGNAL void loadProgress(int progress); + Q_SIGNAL void initialLayoutCompleted(); + Q_SIGNAL void urlChanged(const QUrl&); + Q_SIGNAL void snapshotTaken(const QImage&); + +public Q_SLOTS: + void back(); + void forward(); + void reload(); + void stop(); + +protected: + virtual void keyPressEvent(QKeyEvent*); + virtual void keyReleaseEvent(QKeyEvent*); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*); + virtual void mousePressEvent(QGraphicsSceneMouseEvent*); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*); + virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); + virtual void wheelEvent(QGraphicsSceneWheelEvent*); + virtual void touchEvent(QTouchEvent*); + + virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*); + + Q_SLOT void updateCursor(const QCursor&); + Q_SLOT void focusNextPrevChildCallback(bool next); + + virtual bool focusNextPrevChild(bool next); + virtual void focusInEvent(QFocusEvent*); + virtual void focusOutEvent(QFocusEvent*); + +private Q_SLOTS: + void showContextMenu(QMenu*); + +private: + Q_PRIVATE_SLOT(d, void onScaleChanged()); + + QGraphicsWKViewPrivate* d; + friend class QGraphicsWKViewPrivate; + friend class TiledDrawingAreaProxy; +}; + +#endif /* qgraphicswkview_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp b/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp new file mode 100644 index 0000000..b17c100 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "qwkcontext.h" +#include "qwkcontext_p.h" + +#include "WebPlatformStrategies.h" + +using namespace WebKit; + +static inline void initializePlatformStrategiesIfNeeded() +{ + static bool initialized = false; + if (initialized) + return; + + WebPlatformStrategies::initialize(); + initialized = true; +} + +QWKContextPrivate::QWKContextPrivate(QWKContext* qq) + : q(qq) +{ + initializePlatformStrategiesIfNeeded(); +} + +QWKContextPrivate::~QWKContextPrivate() +{ +} + +QWKContext::QWKContext(QObject* parent) + : QObject(parent) + , d(new QWKContextPrivate(this)) +{ + d->context = WebContext::create(String()); +} + +QWKContext::QWKContext(WKContextRef contextRef, QObject* parent) + : QObject(parent) + , d(new QWKContextPrivate(this)) +{ + d->context = toImpl(contextRef); +} + +QWKContext::~QWKContext() +{ + delete d; +} + +#include "moc_qwkcontext.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext.h b/Source/WebKit2/UIProcess/API/qt/qwkcontext.h new file mode 100644 index 0000000..384d629 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef qwkcontext_h +#define qwkcontext_h + +#include "qwebkitglobal.h" +#include <QObject> +#include <WebKit2/WKContext.h> + +class QWKContextPrivate; + +class QWEBKIT_EXPORT QWKContext : public QObject { + Q_OBJECT +public: + QWKContext(QObject* parent = 0); + virtual ~QWKContext(); + + // Bridge from the C API + QWKContext(WKContextRef contextRef, QObject* parent = 0); + +private: + QWKContextPrivate* d; + + friend class QWKPagePrivate; +}; + +#endif /* qwkcontext_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h b/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h new file mode 100644 index 0000000..625e87c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef qwkcontext_p_h +#define qwkcontext_p_h + +#include "WebContext.h" +#include <wtf/RefPtr.h> + +class QWKContextPrivate { +public: + QWKContextPrivate(QWKContext*); + ~QWKContextPrivate(); + + QWKContext* q; + + RefPtr<WebKit::WebContext> context; +}; + +#endif /* qkcontext_p_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp b/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp new file mode 100644 index 0000000..3f424b5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config.h" +#include "qwkhistory.h" + +#include <QSharedData> +#include <QString> +#include <QUrl> +#include "qwkhistory_p.h" +#include "WebBackForwardList.h" +#include <WebKit2/WKArray.h> +#include <WebKit2/WKRetainPtr.h> +#include "WKBackForwardList.h" +#include "WKStringQt.h" +#include "WKURL.h" +#include "WKURLQt.h" + +using namespace WebKit; + +QWKHistoryItemPrivate::QWKHistoryItemPrivate(WKBackForwardListItemRef listItem) + : m_backForwardListItem(listItem) +{ +} + +QWKHistoryItemPrivate::~QWKHistoryItemPrivate() +{ +} + +QWKHistoryItem::QWKHistoryItem(const QWKHistoryItem& other) + : d(other.d) +{ +} + +QWKHistoryItem& QWKHistoryItem::QWKHistoryItem::operator=(const QWKHistoryItem& other) +{ + d = other.d; + return *this; +} + +QWKHistoryItem::QWKHistoryItem(WKBackForwardListItemRef item) + : d(new QWKHistoryItemPrivate(item)) +{ +} + +QWKHistoryItem::~QWKHistoryItem() +{ +} + +QString QWKHistoryItem::title() const +{ + if (!d->m_backForwardListItem) + return QString(); + WKRetainPtr<WKStringRef> title = WKBackForwardListItemCopyTitle(d->m_backForwardListItem.get()); + return WKStringCopyQString(title.get()); +} + +QUrl QWKHistoryItem::url() const +{ + if (!d->m_backForwardListItem) + return QUrl(); + WKRetainPtr<WKURLRef> url = WKBackForwardListItemCopyURL(d->m_backForwardListItem.get()); + return WKURLCopyQUrl(url.get()); +} + +QWKHistoryPrivate::QWKHistoryPrivate(WebKit::WebBackForwardList* list) + : m_backForwardList(list) +{ +} + +QWKHistory* QWKHistoryPrivate::createHistory(WebKit::WebBackForwardList* list) +{ + QWKHistory* history = new QWKHistory(); + history->d = new QWKHistoryPrivate(list); + return history; +} + +QWKHistoryPrivate::~QWKHistoryPrivate() +{ +} + +QWKHistory::QWKHistory() +{ +} + +QWKHistory::~QWKHistory() +{ + delete d; +} + +int QWKHistory::backListCount() const +{ + return WKBackForwardListGetBackListCount(toAPI(d->m_backForwardList)); +} + +int QWKHistory::forwardListCount() const +{ + return WKBackForwardListGetForwardListCount(toAPI(d->m_backForwardList)); +} + +int QWKHistory::count() const +{ + return backListCount() + forwardListCount(); +} + +QWKHistoryItem QWKHistory::currentItem() const +{ + WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetCurrentItem(toAPI(d->m_backForwardList)); + QWKHistoryItem item(itemRef.get()); + return item; +} + +QWKHistoryItem QWKHistory::backItem() const +{ + WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetBackItem(toAPI(d->m_backForwardList)); + QWKHistoryItem item(itemRef.get()); + return item; +} + +QWKHistoryItem QWKHistory::forwardItem() const +{ + WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetForwardItem(toAPI(d->m_backForwardList)); + QWKHistoryItem item(itemRef.get()); + return item; +} + +QWKHistoryItem QWKHistory::itemAt(int index) const +{ + WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(toAPI(d->m_backForwardList), index); + QWKHistoryItem item(itemRef.get()); + return item; +} + +QList<QWKHistoryItem> QWKHistory::backItems(int maxItems) const +{ + WKArrayRef arrayRef = WKBackForwardListCopyBackListWithLimit(toAPI(d->m_backForwardList), maxItems); + int size = WKArrayGetSize(arrayRef); + QList<QWKHistoryItem> itemList; + for (int i = 0; i < size; ++i) { + WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i); + WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem); + QWKHistoryItem item(itemRef); + itemList.append(item); + } + return itemList; +} + +QList<QWKHistoryItem> QWKHistory::forwardItems(int maxItems) const +{ + WKArrayRef arrayRef = WKBackForwardListCopyForwardListWithLimit(toAPI(d->m_backForwardList), maxItems); + int size = WKArrayGetSize(arrayRef); + QList<QWKHistoryItem> itemList; + for (int i = 0; i < size; ++i) { + WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i); + WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem); + QWKHistoryItem item(itemRef); + itemList.append(item); + } + return itemList; +} + diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory.h b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h new file mode 100644 index 0000000..81081c9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi) + * + * 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 qwkhistory_h +#define qwkhistory_h + +#include "qwebkitglobal.h" +#include <QObject> +#include <QSharedData> +#include "WKBackForwardListItem.h" + +class QWKHistoryPrivate; +class QWKHistoryItemPrivate; +class QUrl; +class QString; + +namespace WebKit { +class WebBackForwardList; +} + +class QWEBKIT_EXPORT QWKHistoryItem { +public: + QWKHistoryItem(const QWKHistoryItem& other); + QWKHistoryItem &operator=(const QWKHistoryItem& other); + + ~QWKHistoryItem(); + QString title() const; + QUrl url() const; + +private: + QWKHistoryItem(WKBackForwardListItemRef item); + + QExplicitlySharedDataPointer<QWKHistoryItemPrivate> d; + + friend class QWKHistory; + friend class QWKHistoryItemPrivate; +}; + +class QWEBKIT_EXPORT QWKHistory : public QObject { + Q_OBJECT +public: + int backListCount() const; + int forwardListCount() const; + int count() const; + QWKHistoryItem currentItem() const; + QWKHistoryItem backItem() const; + QWKHistoryItem forwardItem() const; + QWKHistoryItem itemAt(int index) const; + QList<QWKHistoryItem> backItems(int maxItems) const; + QList<QWKHistoryItem> forwardItems(int maxItems) const; + +private: + QWKHistory(); + ~QWKHistory(); + + QWKHistoryPrivate* d; + friend class QWKHistoryPrivate; + friend class QWKPagePrivate; +}; +#endif /* qwkhistory_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h b/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h new file mode 100644 index 0000000..dd1d696 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi) + * + * 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 qwkhistory_p_h +#define qwkhistory_p_h + +#include <QSharedData> +#include "qwebkitglobal.h" +#include <WebKit2/WKBase.h> +#include <WebKit2/WKRetainPtr.h> +#include <wtf/PassRefPtr.h> + +namespace WebKit { +class WebBackForwardList; +} + +class QWKHistory; + +class QWEBKIT_EXPORT QWKHistoryItemPrivate : public QSharedData { +public: + ~QWKHistoryItemPrivate(); +private: + QWKHistoryItemPrivate(WKBackForwardListItemRef listItem); + WKRetainPtr<WKBackForwardListItemRef> m_backForwardListItem; + + friend class QWKHistory; + friend class QWKHistoryItem; +}; + +class QWEBKIT_EXPORT QWKHistoryPrivate { +public: + static QWKHistory* createHistory(WebKit::WebBackForwardList* list); + +private: + QWKHistoryPrivate(WebKit::WebBackForwardList* list); + ~QWKHistoryPrivate(); + + WebKit::WebBackForwardList* m_backForwardList; + + friend class QWKHistory; +}; + +#endif /* qwkhistory_p_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp new file mode 100644 index 0000000..638d9e3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp @@ -0,0 +1,759 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "qwkpage.h" +#include "qwkpage_p.h" + +#include "qwkpreferences_p.h" + +#include "ChunkedUpdateDrawingAreaProxy.h" +#include "ClientImpl.h" +#include "qgraphicswkview.h" +#include "qwkcontext.h" +#include "qwkcontext_p.h" +#include "qwkhistory.h" +#include "qwkhistory_p.h" +#include "FindIndicator.h" +#include "LocalizedStrings.h" +#include "NativeWebKeyboardEvent.h" +#include "TiledDrawingAreaProxy.h" +#include "WebContext.h" +#include "WebContextMenuProxyQt.h" +#include "WebEventFactoryQt.h" +#include "WebPopupMenuProxyQt.h" +#include "WKStringQt.h" +#include "WKURLQt.h" +#include "ViewportArguments.h" +#include <QAction> +#include <QApplication> +#include <QGraphicsSceneMouseEvent> +#include <QStyle> +#include <QTouchEvent> +#include <QtDebug> +#include <WebCore/Cursor.h> +#include <WebCore/FloatRect.h> +#include <WebKit2/WKFrame.h> +#include <WebKit2/WKPageGroup.h> +#include <WebKit2/WKRetainPtr.h> + +using namespace WebKit; +using namespace WebCore; + +static WebCore::ContextMenuAction contextMenuActionForWebAction(QWKPage::WebAction action) +{ + switch (action) { + case QWKPage::OpenLink: + return WebCore::ContextMenuItemTagOpenLink; + case QWKPage::OpenLinkInNewWindow: + return WebCore::ContextMenuItemTagOpenLinkInNewWindow; + case QWKPage::CopyLinkToClipboard: + return WebCore::ContextMenuItemTagCopyLinkToClipboard; + case QWKPage::OpenImageInNewWindow: + return WebCore::ContextMenuItemTagOpenImageInNewWindow; + case QWKPage::Cut: + return WebCore::ContextMenuItemTagCut; + case QWKPage::Copy: + return WebCore::ContextMenuItemTagCopy; + case QWKPage::Paste: + return WebCore::ContextMenuItemTagPaste; + case QWKPage::SelectAll: + return WebCore::ContextMenuItemTagSelectAll; + default: + ASSERT(false); + break; + } + return WebCore::ContextMenuItemTagNoAction; +} + +QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c) + : q(qq) + , view(0) + , context(c) + , preferences(0) + , createNewPageFn(0) +{ + memset(actions, 0, sizeof(actions)); + page = context->d->context->createWebPage(this, 0); + history = QWKHistoryPrivate::createHistory(page->backForwardList()); +} + +QWKPagePrivate::~QWKPagePrivate() +{ + page->close(); + delete history; +} + +void QWKPagePrivate::init(QGraphicsItem* view, PassOwnPtr<DrawingAreaProxy> proxy) +{ + this->view = view; + page->setDrawingArea(proxy); + page->initializeWebPage(); +} + +void QWKPagePrivate::setCursor(const WebCore::Cursor& cursor) +{ +#ifndef QT_NO_CURSOR + emit q->cursorChanged(*cursor.platformCursor()); +#endif +} + +void QWKPagePrivate::setViewportArguments(const ViewportArguments& args) +{ + viewportArguments = args; + emit q->viewportChangeRequested(); +} + +void QWKPagePrivate::takeFocus(bool direction) +{ + emit q->focusNextPrevChild(direction); +} + +PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy() +{ + // FIXME: We should avoid this cast by decoupling the view from the page. + QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view); + +#if ENABLE(TILED_BACKING_STORE) + if (page->drawingArea()->info().type == DrawingAreaInfo::Tiled) + return TiledDrawingAreaProxy::create(wkView, page.get()); +#endif + return ChunkedUpdateDrawingAreaProxy::create(wkView, page.get()); +} + +void QWKPagePrivate::setViewNeedsDisplay(const WebCore::IntRect& rect) +{ + view->update(QRect(rect)); +} + +void QWKPagePrivate::displayView() +{ + // FIXME: Implement. +} + +WebCore::IntSize QWKPagePrivate::viewSize() +{ + // FIXME: Implement. + return WebCore::IntSize(); +} + +bool QWKPagePrivate::isViewWindowActive() +{ + // FIXME: Implement. + return true; +} + +bool QWKPagePrivate::isViewFocused() +{ + // FIXME: Implement. + return true; +} + +bool QWKPagePrivate::isViewVisible() +{ + // FIXME: Implement. + return true; +} + +bool QWKPagePrivate::isViewInWindow() +{ + // FIXME: Implement. + return true; +} + +void QWKPagePrivate::pageDidRequestScroll(const IntSize& delta) +{ + emit q->scrollRequested(delta.width(), delta.height()); +} + +void QWKPagePrivate::didChangeContentsSize(const IntSize& newSize) +{ + emit q->contentsSizeChanged(QSize(newSize)); +} + +void QWKPagePrivate::toolTipChanged(const String&, const String& newTooltip) +{ + emit q->statusBarMessage(QString(newTooltip)); +} + +void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) +{ +} + +void QWKPagePrivate::clearAllEditCommands() +{ +} + +FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect) +{ + return rect; +} + +FloatRect QWKPagePrivate::convertToUserSpace(const FloatRect& rect) +{ + return rect; +} + +void QWKPagePrivate::selectionChanged(bool, bool, bool, bool) +{ +} + +void QWKPagePrivate::didNotHandleKeyEvent(const NativeWebKeyboardEvent&) +{ +} + +PassRefPtr<WebPopupMenuProxy> QWKPagePrivate::createPopupMenuProxy(WebPageProxy*) +{ + return WebPopupMenuProxyQt::create(); +} + +PassRefPtr<WebContextMenuProxy> QWKPagePrivate::createContextMenuProxy(WebPageProxy*) +{ + return WebContextMenuProxyQt::create(q); +} + +void QWKPagePrivate::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) +{ +} + +void QWKPagePrivate::didCommitLoadForMainFrame(bool useCustomRepresentation) +{ +} + +void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&) +{ +} + +void QWKPagePrivate::paint(QPainter* painter, QRect area) +{ + if (page->isValid() && page->drawingArea()) + page->drawingArea()->paint(IntRect(area), painter); + else + painter->fillRect(area, Qt::white); +} + +void QWKPagePrivate::keyPressEvent(QKeyEvent* ev) +{ + page->handleKeyboardEvent(NativeWebKeyboardEvent(ev)); +} + +void QWKPagePrivate::keyReleaseEvent(QKeyEvent* ev) +{ + page->handleKeyboardEvent(NativeWebKeyboardEvent(ev)); +} + +void QWKPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev) +{ + // For some reason mouse press results in mouse hover (which is + // converted to mouse move for WebKit). We ignore these hover + // events by comparing lastPos with newPos. + // NOTE: lastPos from the event always comes empty, so we work + // around that here. + static QPointF lastPos = QPointF(); + if (lastPos == ev->pos()) + return; + lastPos = ev->pos(); + + WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0); + page->handleMouseEvent(mouseEvent); +} + +void QWKPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev) +{ + if (tripleClickTimer.isActive() && (ev->pos() - tripleClick).manhattanLength() < QApplication::startDragDistance()) { + WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 3); + page->handleMouseEvent(mouseEvent); + return; + } + + WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 1); + page->handleMouseEvent(mouseEvent); +} + +void QWKPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) +{ + WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0); + page->handleMouseEvent(mouseEvent); +} + +void QWKPagePrivate::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev) +{ + WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 2); + page->handleMouseEvent(mouseEvent); + + tripleClickTimer.start(QApplication::doubleClickInterval(), q); + tripleClick = ev->pos().toPoint(); +} + +void QWKPagePrivate::wheelEvent(QGraphicsSceneWheelEvent* ev) +{ + WebWheelEvent wheelEvent = WebEventFactory::createWebWheelEvent(ev); + page->handleWheelEvent(wheelEvent); +} + +void QWKPagePrivate::setEditCommandState(const WTF::String&, bool, int) +{ +} + +void QWKPagePrivate::updateAction(QWKPage::WebAction action) +{ +#ifdef QT_NO_ACTION + Q_UNUSED(action) +#else + QAction* a = actions[action]; + if (!a) + return; + + RefPtr<WebKit::WebFrameProxy> mainFrame = page->mainFrame(); + if (!mainFrame) + return; + + bool enabled = a->isEnabled(); + bool checked = a->isChecked(); + + switch (action) { + case QWKPage::Back: + enabled = page->canGoBack(); + break; + case QWKPage::Forward: + enabled = page->canGoForward(); + break; + case QWKPage::Stop: + enabled = !(WebFrameProxy::LoadStateFinished == mainFrame->loadState()); + break; + case QWKPage::Reload: + enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState()); + break; + default: + break; + } + + a->setEnabled(enabled); + + if (a->isCheckable()) + a->setChecked(checked); +#endif // QT_NO_ACTION +} + +void QWKPagePrivate::updateNavigationActions() +{ + updateAction(QWKPage::Back); + updateAction(QWKPage::Forward); + updateAction(QWKPage::Stop); + updateAction(QWKPage::Reload); +} + +#ifndef QT_NO_ACTION +void QWKPagePrivate::_q_webActionTriggered(bool checked) +{ + QAction* a = qobject_cast<QAction*>(q->sender()); + if (!a) + return; + QWKPage::WebAction action = static_cast<QWKPage::WebAction>(a->data().toInt()); + q->triggerAction(action, checked); +} +#endif // QT_NO_ACTION + +void QWKPagePrivate::touchEvent(QTouchEvent* event) +{ +#if ENABLE(TOUCH_EVENTS) + WebTouchEvent touchEvent = WebEventFactory::createWebTouchEvent(event); + page->handleTouchEvent(touchEvent); +#else + event->ignore(); +#endif +} + +QWKPage::QWKPage(QWKContext* context) + : d(new QWKPagePrivate(this, context)) +{ + WKPageLoaderClient loadClient = { + 0, /* version */ + this, /* clientInfo */ + qt_wk_didStartProvisionalLoadForFrame, + qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame, + qt_wk_didFailProvisionalLoadWithErrorForFrame, + qt_wk_didCommitLoadForFrame, + qt_wk_didFinishDocumentLoadForFrame, + qt_wk_didFinishLoadForFrame, + qt_wk_didFailLoadWithErrorForFrame, + 0, /* didSameDocumentNavigationForFrame */ + qt_wk_didReceiveTitleForFrame, + qt_wk_didFirstLayoutForFrame, + qt_wk_didFirstVisuallyNonEmptyLayoutForFrame, + qt_wk_didRemoveFrameFromHierarchy, + 0, /* didDisplayInsecureContentForFrame */ + 0, /* didRunInsecureContentForFrame */ + 0, /* canAuthenticateAgainstProtectionSpaceInFrame */ + 0, /* didReceiveAuthenticationChallengeInFrame */ + qt_wk_didStartProgress, + qt_wk_didChangeProgress, + qt_wk_didFinishProgress, + qt_wk_didBecomeUnresponsive, + qt_wk_didBecomeResponsive, + 0, /* processDidCrash */ + 0 /* didChangeBackForwardList */ + }; + WKPageSetPageLoaderClient(pageRef(), &loadClient); + + WKPageUIClient uiClient = { + 0, /* version */ + this, /* clientInfo */ + qt_wk_createNewPage, + qt_wk_showPage, + qt_wk_close, + qt_wk_runJavaScriptAlert, + 0, /* runJavaScriptConfirm */ + 0, /* runJavaScriptPrompt */ + 0, /* setStatusText */ + 0, /* mouseDidMoveOverElement */ + 0, /* missingPluginButtonClicked */ + 0, /* didNotHandleKeyEvent */ + 0, /* toolbarsAreVisible */ + 0, /* setToolbarsAreVisible */ + 0, /* menuBarIsVisible */ + 0, /* setMenuBarIsVisible */ + 0, /* statusBarIsVisible */ + 0, /* setStatusBarIsVisible */ + 0, /* isResizable */ + 0, /* setIsResizable */ + 0, /* getWindowFrame */ + 0, /* setWindowFrame */ + 0, /* runBeforeUnloadConfirmPanel */ + 0, /* didDraw */ + 0, /* pageDidScroll */ + 0, /* exceededDatabaseQuota */ + 0, /* runOpenPanel */ + 0 /* decidePolicyForGeolocationPermissionRequest */ + }; + WKPageSetPageUIClient(pageRef(), &uiClient); +} + +QWKPage::~QWKPage() +{ + delete d; +} + +QWKPage::ViewportAttributes::ViewportAttributes() + : d(0) + , m_initialScaleFactor(-1.0) + , m_minimumScaleFactor(-1.0) + , m_maximumScaleFactor(-1.0) + , m_devicePixelRatio(-1.0) + , m_isUserScalable(true) + , m_isValid(false) +{ + +} + +QWKPage::ViewportAttributes::ViewportAttributes(const QWKPage::ViewportAttributes& other) + : d(other.d) + , m_initialScaleFactor(other.m_initialScaleFactor) + , m_minimumScaleFactor(other.m_minimumScaleFactor) + , m_maximumScaleFactor(other.m_maximumScaleFactor) + , m_devicePixelRatio(other.m_devicePixelRatio) + , m_isUserScalable(other.m_isUserScalable) + , m_isValid(other.m_isValid) + , m_size(other.m_size) +{ + +} + +QWKPage::ViewportAttributes::~ViewportAttributes() +{ + +} + +QWKPage::ViewportAttributes& QWKPage::ViewportAttributes::operator=(const QWKPage::ViewportAttributes& other) +{ + if (this != &other) { + d = other.d; + m_initialScaleFactor = other.m_initialScaleFactor; + m_minimumScaleFactor = other.m_minimumScaleFactor; + m_maximumScaleFactor = other.m_maximumScaleFactor; + m_devicePixelRatio = other.m_devicePixelRatio; + m_isUserScalable = other.m_isUserScalable; + m_isValid = other.m_isValid; + m_size = other.m_size; + } + + return *this; +} + +QWKPage::ViewportAttributes QWKPage::viewportAttributesForSize(const QSize& availableSize) const +{ + static int desktopWidth = 980; + static int deviceDPI = 160; + + ViewportAttributes result; + + if (availableSize.isEmpty()) + return result; // Returns an invalid instance. + + // FIXME: Add a way to get these data via the platform plugin and fall back + // to the size of the view. + int deviceWidth = 480; + int deviceHeight = 864; + + WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize); + + result.m_isValid = true; + result.m_size = conf.layoutSize; + result.m_initialScaleFactor = conf.initialScale; + result.m_minimumScaleFactor = conf.minimumScale; + result.m_maximumScaleFactor = conf.maximumScale; + result.m_devicePixelRatio = conf.devicePixelRatio; + result.m_isUserScalable = conf.userScalable; + + return result; +} + +void QWKPage::setActualVisibleContentsRect(const QRect& rect) const +{ +#if ENABLE(TILED_BACKING_STORE) + d->page->setActualVisibleContentRect(rect); +#endif +} + +void QWKPage::timerEvent(QTimerEvent* ev) +{ + int timerId = ev->timerId(); + if (timerId == d->tripleClickTimer.timerId()) + d->tripleClickTimer.stop(); + else + QObject::timerEvent(ev); +} + +WKPageRef QWKPage::pageRef() const +{ + return toAPI(d->page.get()); +} + +QWKContext* QWKPage::context() const +{ + return d->context; +} + +QWKPreferences* QWKPage::preferences() const +{ + if (!d->preferences) { + WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef()); + d->preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef); + } + + return d->preferences; +} + +void QWKPage::setCreateNewPageFunction(CreateNewPageFn function) +{ + d->createNewPageFn = function; +} + +void QWKPage::setCustomUserAgent(const QString& userAgent) +{ + WKRetainPtr<WKStringRef> wkUserAgent(WKStringCreateWithQString(userAgent)); + WKPageSetCustomUserAgent(pageRef(), wkUserAgent.get()); +} + +QString QWKPage::customUserAgent() const +{ + return WKStringCopyQString(WKPageCopyCustomUserAgent(pageRef())); +} + +void QWKPage::load(const QUrl& url) +{ + WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url)); + WKPageLoadURL(pageRef(), wkurl.get()); +} + +void QWKPage::setUrl(const QUrl& url) +{ + load(url); +} + +QUrl QWKPage::url() const +{ + WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef()); + if (!frame) + return QUrl(); + return WKURLCopyQUrl(WKFrameCopyURL(frame.get())); +} + +QString QWKPage::title() const +{ + return WKStringCopyQString(WKPageCopyTitle(pageRef())); +} + +void QWKPage::setViewportSize(const QSize& size) +{ + if (d->page->drawingArea()) + d->page->drawingArea()->setSize(IntSize(size)); +} + +qreal QWKPage::textZoomFactor() const +{ + return WKPageGetTextZoomFactor(pageRef()); +} + +void QWKPage::setTextZoomFactor(qreal zoomFactor) +{ + WKPageSetTextZoomFactor(pageRef(), zoomFactor); +} + +qreal QWKPage::pageZoomFactor() const +{ + return WKPageGetPageZoomFactor(pageRef()); +} + +void QWKPage::setPageZoomFactor(qreal zoomFactor) +{ + WKPageSetPageZoomFactor(pageRef(), zoomFactor); +} + +void QWKPage::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor) +{ + WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor); +} + +QWKHistory* QWKPage::history() const +{ + return d->history; +} + +void QWKPage::setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize) +{ +#if ENABLE(TILED_BACKING_STORE) + d->page->setResizesToContentsUsingLayoutSize(targetLayoutSize); +#endif +} + +#ifndef QT_NO_ACTION +void QWKPage::triggerAction(WebAction webAction, bool) +{ + switch (webAction) { + case Back: + d->page->goBack(); + return; + case Forward: + d->page->goForward(); + return; + case Stop: + d->page->stopLoading(); + return; + case Reload: + d->page->reload(/* reloadFromOrigin */ true); + return; + default: + break; + } + + QAction* qtAction = action(webAction); + WebKit::WebContextMenuItemData menuItemData(ActionType, contextMenuActionForWebAction(webAction), qtAction->text(), qtAction->isEnabled(), qtAction->isChecked()); + d->page->contextMenuItemSelected(menuItemData); +} +#endif // QT_NO_ACTION + +#ifndef QT_NO_ACTION +QAction* QWKPage::action(WebAction action) const +{ + if (action == QWKPage::NoWebAction || action >= WebActionCount) + return 0; + + if (d->actions[action]) + return d->actions[action]; + + QString text; + QIcon icon; + QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style(); + bool checkable = false; + + switch (action) { + case OpenLink: + text = contextMenuItemTagOpenLink(); + break; + case OpenLinkInNewWindow: + text = contextMenuItemTagOpenLinkInNewWindow(); + break; + case CopyLinkToClipboard: + text = contextMenuItemTagCopyLinkToClipboard(); + break; + case OpenImageInNewWindow: + text = contextMenuItemTagOpenImageInNewWindow(); + break; + case Back: + text = contextMenuItemTagGoBack(); + icon = style->standardIcon(QStyle::SP_ArrowBack); + break; + case Forward: + text = contextMenuItemTagGoForward(); + icon = style->standardIcon(QStyle::SP_ArrowForward); + break; + case Stop: + text = contextMenuItemTagStop(); + icon = style->standardIcon(QStyle::SP_BrowserStop); + break; + case Reload: + text = contextMenuItemTagReload(); + icon = style->standardIcon(QStyle::SP_BrowserReload); + break; + case Cut: + text = contextMenuItemTagCut(); + break; + case Copy: + text = contextMenuItemTagCopy(); + break; + case Paste: + text = contextMenuItemTagPaste(); + break; + case SelectAll: + text = contextMenuItemTagSelectAll(); + break; + default: + return 0; + break; + } + + if (text.isEmpty()) + return 0; + + QAction* a = new QAction(d->q); + a->setText(text); + a->setData(action); + a->setCheckable(checkable); + a->setIcon(icon); + + connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool))); + + d->actions[action] = a; + d->updateAction(action); + return a; +} +#endif // QT_NO_ACTION + +void QWKPage::findZoomableAreaForPoint(const QPoint& point) +{ + d->page->findZoomableAreaForPoint(point); +} + +void QWKPagePrivate::didFindZoomableArea(const IntRect& area) +{ + emit q->zoomableAreaFound(QRect(area)); +} + +#include "moc_qwkpage.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.h b/Source/WebKit2/UIProcess/API/qt/qwkpage.h new file mode 100644 index 0000000..e0bb4c3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.h @@ -0,0 +1,151 @@ +#ifndef qwkpage_h +#define qwkpage_h + +#include "qwebkitglobal.h" +#include <QAction> +#include <QObject> +#include <QPoint> +#include <QRect> +#include <QSize> +#include <QUrl> +#include <WebKit2/WKBase.h> +#include <WebKit2/WKPage.h> + +class QCursor; +class QGraphicsItem; +class QWKContext; +class QWKGraphicsWidget; +class QWKPreferences; +class QWKPagePrivate; +class QtViewportAttributesPrivate; +class QWKHistory; + +class QWEBKIT_EXPORT QWKPage : public QObject { + Q_OBJECT + Q_PROPERTY(QString title READ title) + Q_PROPERTY(QUrl url READ url WRITE setUrl) + +public: + enum WebAction { + NoWebAction = - 1, + + OpenLink, + OpenLinkInNewWindow, + CopyLinkToClipboard, + OpenImageInNewWindow, + + Back, + Forward, + Stop, + Reload, + + Cut, + Copy, + Paste, + SelectAll, + + WebActionCount + }; + + class ViewportAttributes { + public: + ViewportAttributes(); + ViewportAttributes(const QWKPage::ViewportAttributes& other); + + ~ViewportAttributes(); + + QWKPage::ViewportAttributes& operator=(const QWKPage::ViewportAttributes& other); + + inline qreal initialScaleFactor() const { return m_initialScaleFactor; }; + inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; }; + inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; }; + inline qreal devicePixelRatio() const { return m_devicePixelRatio; }; + inline bool isUserScalable() const { return m_isUserScalable; }; + inline bool isValid() const { return m_isValid; }; + inline QSize size() const { return m_size; }; + + private: + QSharedDataPointer<QtViewportAttributesPrivate> d; + qreal m_initialScaleFactor; + qreal m_minimumScaleFactor; + qreal m_maximumScaleFactor; + qreal m_devicePixelRatio; + bool m_isUserScalable; + bool m_isValid; + QSize m_size; + + friend class QWKPage; + }; + + QWKPage(QWKContext*); + virtual ~QWKPage(); + + WKPageRef pageRef() const; + + QWKPreferences* preferences() const; + + void load(const QUrl& url); + void setUrl(const QUrl& url); + QUrl url() const; + + QString title() const; + + void setViewportSize(const QSize&); + ViewportAttributes viewportAttributesForSize(const QSize& availableSize) const; + + void setActualVisibleContentsRect(const QRect& rect) const; + + void setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize); + + QAction* action(WebAction action) const; + void triggerAction(WebAction action, bool checked = false); + + typedef QWKPage* (*CreateNewPageFn)(QWKPage*); + void setCreateNewPageFunction(CreateNewPageFn function); + + void setCustomUserAgent(const QString&); + QString customUserAgent() const; + + qreal textZoomFactor() const; + qreal pageZoomFactor() const; + void setTextZoomFactor(qreal zoomFactor); + void setPageZoomFactor(qreal zoomFactor); + void setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor); + + QWKHistory* history() const; + QWKContext* context() const; + + void findZoomableAreaForPoint(const QPoint&); + +public: + Q_SIGNAL void statusBarMessage(const QString&); + Q_SIGNAL void titleChanged(const QString&); + Q_SIGNAL void loadStarted(); + Q_SIGNAL void loadFinished(bool ok); + Q_SIGNAL void loadProgress(int progress); + Q_SIGNAL void initialLayoutCompleted(); + Q_SIGNAL void urlChanged(const QUrl&); + Q_SIGNAL void contentsSizeChanged(const QSize&); + Q_SIGNAL void scrollRequested(int dx, int dy); + Q_SIGNAL void cursorChanged(const QCursor&); + Q_SIGNAL void viewportChangeRequested(); + Q_SIGNAL void windowCloseRequested(); + Q_SIGNAL void zoomableAreaFound(const QRect&); + Q_SIGNAL void focusNextPrevChild(bool); + Q_SIGNAL void showContextMenu(QMenu*); + +protected: + void timerEvent(QTimerEvent*); + +private: +#ifndef QT_NO_ACTION + Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked)); +#endif + QWKPagePrivate* d; + + friend class QGraphicsWKView; + friend class QGraphicsWKViewPrivate; + friend class QWKPagePrivate; +}; + +#endif /* qwkpage_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h new file mode 100644 index 0000000..85135c2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef qwkpage_p_h +#define qwkpage_p_h + +#include "DrawingAreaProxy.h" +#include "PageClient.h" +#include "qwkpage.h" +#include "WebPageProxy.h" +#include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> +#include <QBasicTimer> +#include <QGraphicsView> +#include <QKeyEvent> + +class QGraphicsWKView; +class QWKPreferences; + +class QWKPagePrivate : WebKit::PageClient { +public: + QWKPagePrivate(QWKPage*, QWKContext*); + ~QWKPagePrivate(); + + static QWKPagePrivate* get(QWKPage* page) { return page->d; } + + void init(QGraphicsItem*, WTF::PassOwnPtr<WebKit::DrawingAreaProxy>); + + // PageClient + virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy(); + virtual void setViewNeedsDisplay(const WebCore::IntRect&); + virtual void displayView(); + + virtual WebCore::IntSize viewSize(); + virtual bool isViewWindowActive(); + virtual bool isViewFocused(); + virtual bool isViewVisible(); + virtual bool isViewInWindow(); + +#if USE(ACCELERATED_COMPOSITING) + void pageDidEnterAcceleratedCompositing() { } + void pageDidLeaveAcceleratedCompositing() { } +#endif // USE(ACCELERATED_COMPOSITING) + virtual void pageDidRequestScroll(const WebCore::IntSize&); + virtual void processDidCrash() { } + virtual void didRelaunchProcess() { } + virtual void didChangeContentsSize(const WebCore::IntSize&); + virtual void didFindZoomableArea(const WebCore::IntRect&); + virtual void setCursor(const WebCore::Cursor&); + virtual void setViewportArguments(const WebCore::ViewportArguments&); + virtual void takeFocus(bool direction); + virtual void toolTipChanged(const WTF::String&, const WTF::String&); + virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo); + virtual void clearAllEditCommands(); + virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); + virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); + virtual void didNotHandleKeyEvent(const WebKit::NativeWebKeyboardEvent&); + virtual void selectionChanged(bool, bool, bool, bool); + virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*); + virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*); + + virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut); + + virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); + virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); + virtual double customRepresentationZoomFactor() { return 1; } + virtual void setCustomRepresentationZoomFactor(double) { } + + void paint(QPainter* painter, QRect); + + void keyPressEvent(QKeyEvent*); + void keyReleaseEvent(QKeyEvent*); + void mouseMoveEvent(QGraphicsSceneMouseEvent*); + void mousePressEvent(QGraphicsSceneMouseEvent*); + void mouseReleaseEvent(QGraphicsSceneMouseEvent*); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); + void wheelEvent(QGraphicsSceneWheelEvent*); + + void updateAction(QWKPage::WebAction action); + void updateNavigationActions(); + void updateEditorActions(); + void setEditCommandState(const WTF::String&, bool, int); + + void _q_webActionTriggered(bool checked); + + void touchEvent(QTouchEvent*); + + QWKPage* q; + + QGraphicsItem* view; + QWKContext* context; + QWKHistory* history; + + QAction* actions[QWKPage::WebActionCount]; + QWKPreferences* preferences; + + RefPtr<WebKit::WebPageProxy> page; + + WebCore::ViewportArguments viewportArguments; + + QWKPage::CreateNewPageFn createNewPageFn; + + QPoint tripleClick; + QBasicTimer tripleClickTimer; +}; + +class QtViewportAttributesPrivate : public QSharedData { +public: + QtViewportAttributesPrivate(QWKPage::ViewportAttributes* qq) + : q(qq) + { } + + QWKPage::ViewportAttributes* q; +}; + + +#endif /* qkpage_p_h */ diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp new file mode 100644 index 0000000..dea18aa --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp @@ -0,0 +1,185 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "qwkpreferences.h" + +#include "WKPageGroup.h" +#include "WKPreferences.h" +#include "WKStringQt.h" +#include "WKRetainPtr.h" +#include "qwkpreferences_p.h" + + +QWKPreferences* QWKPreferencesPrivate::createPreferences(WKPageGroupRef pageGroupRef) +{ + QWKPreferences* prefs = new QWKPreferences; + prefs->d->ref = WKPageGroupGetPreferences(pageGroupRef); + return prefs; +} + +QWKPreferences* QWKPreferencesPrivate::createSharedPreferences() +{ + QWKPreferences* prefs = new QWKPreferences; + prefs->d->ref = WKPreferencesCreate(); + return prefs; +} + +QWKPreferences* QWKPreferences::sharedPreferences() +{ + static QWKPreferences* instance = 0; + + if (!instance) + instance = QWKPreferencesPrivate::createSharedPreferences(); + return instance; +} + +QWKPreferences::QWKPreferences() + : d(new QWKPreferencesPrivate) +{ +} + +QWKPreferences::~QWKPreferences() +{ + delete d; +} + +void QWKPreferences::setFontFamily(FontFamily which, const QString& family) +{ + switch (which) { + case StandardFont: + WKPreferencesSetStandardFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + case FixedFont: + WKPreferencesSetFixedFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + case SerifFont: + WKPreferencesSetSerifFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + case SansSerifFont: + WKPreferencesSetSansSerifFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + case CursiveFont: + WKPreferencesSetCursiveFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + case FantasyFont: + WKPreferencesSetFantasyFontFamily(d->ref, WKStringCreateWithQString(family)); + break; + default: + break; + } +} + +QString QWKPreferences::fontFamily(FontFamily which) const +{ + switch (which) { + case StandardFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + case FixedFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + case SerifFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + case SansSerifFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + case CursiveFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + case FantasyFont: { + WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(d->ref)); + return WKStringCopyQString(stringRef.get()); + } + default: + return QString(); + } +} + +bool QWKPreferences::testAttribute(WebAttribute attr) const +{ + switch (attr) { + case AutoLoadImages: + return WKPreferencesGetLoadsImagesAutomatically(d->ref); + case JavascriptEnabled: + return WKPreferencesGetJavaScriptEnabled(d->ref); + case PluginsEnabled: + return WKPreferencesGetPluginsEnabled(d->ref); + case OfflineWebApplicationCacheEnabled: + return WKPreferencesGetOfflineWebApplicationCacheEnabled(d->ref); + case LocalStorageEnabled: + return WKPreferencesGetLocalStorageEnabled(d->ref); + case XSSAuditingEnabled: + return WKPreferencesGetXSSAuditorEnabled(d->ref); + case FrameFlatteningEnabled: + return WKPreferencesGetFrameFlatteningEnabled(d->ref); + case PrivateBrowsingEnabled: + return WKPreferencesGetPrivateBrowsingEnabled(d->ref); + case DeveloperExtrasEnabled: + return WKPreferencesGetDeveloperExtrasEnabled(d->ref); + case DnsPrefetchEnabled: + return WKPreferencesGetDNSPrefetchingEnabled(d->ref); + default: + ASSERT_NOT_REACHED(); + return false; + } +} + +void QWKPreferences::setAttribute(WebAttribute attr, bool on) +{ + switch (attr) { + case AutoLoadImages: + WKPreferencesSetLoadsImagesAutomatically(d->ref, on); + break; + case JavascriptEnabled: + WKPreferencesSetJavaScriptEnabled(d->ref, on); + break; + case PluginsEnabled: + WKPreferencesSetPluginsEnabled(d->ref, on); + break; + case OfflineWebApplicationCacheEnabled: + WKPreferencesSetOfflineWebApplicationCacheEnabled(d->ref, on); + break; + case LocalStorageEnabled: + WKPreferencesSetLocalStorageEnabled(d->ref, on); + break; + case XSSAuditingEnabled: + WKPreferencesSetXSSAuditorEnabled(d->ref, on); + break; + case FrameFlatteningEnabled: + WKPreferencesSetFrameFlatteningEnabled(d->ref, on); + break; + case PrivateBrowsingEnabled: + WKPreferencesSetPrivateBrowsingEnabled(d->ref, on); + break; + case DeveloperExtrasEnabled: + WKPreferencesSetDeveloperExtrasEnabled(d->ref, on); + break; + case DnsPrefetchEnabled: + WKPreferencesSetDNSPrefetchingEnabled(d->ref, on); + break; + default: + ASSERT_NOT_REACHED(); + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h new file mode 100644 index 0000000..d9f7bc0 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef QWKPREFERENCES_H +#define QWKPREFERENCES_H + +#include "qwebkitglobal.h" + +class QWKPage; +class QWKPreferencesPrivate; + +class QWEBKIT_EXPORT QWKPreferences { +public: + enum FontFamily { + StandardFont, + FixedFont, + SerifFont, + SansSerifFont, + CursiveFont, + FantasyFont + }; + + enum WebAttribute { + AutoLoadImages, + JavascriptEnabled, + PluginsEnabled, + OfflineWebApplicationCacheEnabled, + LocalStorageEnabled, + XSSAuditingEnabled, + FrameFlatteningEnabled, + PrivateBrowsingEnabled, + DeveloperExtrasEnabled, + DnsPrefetchEnabled + }; + + static QWKPreferences* sharedPreferences(); + + void setFontFamily(FontFamily which, const QString& family); + QString fontFamily(FontFamily which) const; + + void setAttribute(WebAttribute attr, bool on); + bool testAttribute(WebAttribute attr) const; + +private: + Q_DISABLE_COPY(QWKPreferences) + + QWKPreferences(); + ~QWKPreferences(); + + QWKPreferencesPrivate *d; + + friend class QWKPage; + friend class QWKPreferencesPrivate; +}; + +#endif // QWKPREFERENCES_H diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h new file mode 100644 index 0000000..7fe2389 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "WKPreferences.h" + +class QWKPreferencesPrivate { +public: + static QWKPreferences* createPreferences(WKPageGroupRef); + static QWKPreferences* createSharedPreferences(); + + WKPreferencesRef ref; +}; |