diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
142 files changed, 6141 insertions, 4764 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h index ba627708e..713b4f896 100644 --- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -142,10 +142,7 @@ WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer) WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject) WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker) WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy) - -#if ENABLE(INSPECTOR) WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy) -#endif /* Enum conversions */ diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp index 7e2187dda..891388c9a 100644 --- a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp @@ -26,8 +26,6 @@ #include "config.h" #include "WKInspector.h" -#if ENABLE(INSPECTOR) - #include "WKAPICast.h" #include "WebInspectorProxy.h" @@ -35,92 +33,142 @@ using namespace WebKit; WKTypeID WKInspectorGetTypeID() { +#if ENABLE(INSPECTOR) return toAPI(WebInspectorProxy::APIType); +#else + return 0; +#endif } WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toAPI(toImpl(inspectorRef)->page()); +#else + return 0; +#endif } bool WKInspectorIsVisible(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isVisible(); +#else + return false; +#endif } bool WKInspectorIsFront(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isFront(); +#else + return false; +#endif } void WKInspectorShow(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->show(); +#endif } void WKInspectorClose(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->close(); +#endif } void WKInspectorShowConsole(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->showConsole(); +#endif } void WKInspectorShowResources(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->showResources(); +#endif } void WKInspectorShowMainResourceForFrame(WKInspectorRef inspectorRef, WKFrameRef frameRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->showMainResourceForFrame(toImpl(frameRef)); +#endif } bool WKInspectorIsAttached(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isAttached(); +#else + return false; +#endif } void WKInspectorAttach(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->attach(); +#endif } void WKInspectorDetach(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->detach(); +#endif } bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isDebuggingJavaScript(); +#else + return false; +#endif } void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->toggleJavaScriptDebugging(); +#endif } bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isProfilingJavaScript(); +#else + return false; +#endif } void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->toggleJavaScriptProfiling(); +#endif } bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) return toImpl(inspectorRef)->isProfilingPage(); +#else + return false; +#endif } void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef) { +#if ENABLE(INSPECTOR) toImpl(inspectorRef)->togglePageProfiling(); +#endif } - -#endif // ENABLE(INSPECTOR) diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.h b/Source/WebKit2/UIProcess/API/C/WKInspector.h index a00d103de..fd3438afa 100644 --- a/Source/WebKit2/UIProcess/API/C/WKInspector.h +++ b/Source/WebKit2/UIProcess/API/C/WKInspector.h @@ -28,8 +28,6 @@ #include <WebKit2/WKBase.h> -#if ENABLE(INSPECTOR) - #ifndef __cplusplus #include <stdbool.h> #endif @@ -68,6 +66,4 @@ WK_EXPORT void WKInspectorTogglePageProfiling(WKInspectorRef inspector); } #endif -#endif // ENABLE(INSPECTOR) - #endif // WKInspector_h diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp index 52e1cebf8..bdbcb554d 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -182,12 +182,14 @@ uint64_t WKPageGetRenderTreeSize(WKPageRef page) return toImpl(page)->renderTreeSize(); } -#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR WKInspectorRef WKPageGetInspector(WKPageRef pageRef) { +#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR return toAPI(toImpl(pageRef)->inspector()); -} +#else + return 0; #endif +} double WKPageGetEstimatedProgress(WKPageRef pageRef) { diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 9dfd52e3c..dadebbc91 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -387,9 +387,7 @@ WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page); WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled); -#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page); -#endif WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 532d82caf..068563d1f 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -943,3 +943,13 @@ bool WKPreferencesGetPDFPluginEnabled(WKPreferencesRef preferencesRef) { return toImpl(preferencesRef)->pdfPluginEnabled(); } + +void WKPreferencesSetEncodingDetectorEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setUsesEncodingDetector(enabled); +} + +bool WKPreferencesGetEncodingDetectorEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->usesEncodingDetector(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h index d91b82d83..ff2e0a006 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -220,6 +220,10 @@ WK_EXPORT WKStorageBlockingPolicy WKPreferencesGetStorageBlockingPolicy(WKPrefer WK_EXPORT void WKPreferencesSetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef, bool enabled); WK_EXPORT bool WKPreferencesGetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef); +// Defaults to false. +WK_EXPORT void WKPreferencesSetEncodingDetectorEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetEncodingDetectorEnabled(WKPreferencesRef preferencesRef); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp b/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp index 03f6930dd..a03d189df 100644 --- a/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp +++ b/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp @@ -20,6 +20,7 @@ #include "config.h" #include "WKView.h" +#include "EwkViewImpl.h" #include "WKAPICast.h" #include "ewk_view_private.h" @@ -32,5 +33,7 @@ WKViewRef WKViewCreate(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pag WKPageRef WKViewGetPage(WKViewRef viewRef) { - return toAPI(ewk_view_page_get(toImpl(viewRef))); + EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(toImpl(viewRef)); + + return viewImpl->wkPage(); } diff --git a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp b/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp deleted file mode 100644 index 810711597..000000000 --- a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "BatteryProvider.h" - -#if ENABLE(BATTERY_STATUS) - -#include "WKAPICast.h" -#include "WKBatteryManager.h" -#include "WKBatteryStatus.h" -#include "WKContext.h" - -using namespace WebCore; -using namespace WebKit; - -static inline BatteryProvider* toBatteryProvider(const void* clientInfo) -{ - return static_cast<BatteryProvider*>(const_cast<void*>(clientInfo)); -} - -static void startUpdatingCallback(WKBatteryManagerRef, const void* clientInfo) -{ - toBatteryProvider(clientInfo)->startUpdating(); -} - -static void stopUpdatingCallback(WKBatteryManagerRef, const void* clientInfo) -{ - toBatteryProvider(clientInfo)->stopUpdating(); -} - -BatteryProvider::~BatteryProvider() -{ - m_provider.stopUpdating(); - - WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(m_wkContext.get()); - ASSERT(wkBatteryManager); - - WKBatteryManagerSetProvider(wkBatteryManager, 0); -} - -PassRefPtr<BatteryProvider> BatteryProvider::create(WKContextRef wkContext) -{ - return adoptRef(new BatteryProvider(wkContext)); -} - -BatteryProvider::BatteryProvider(WKContextRef wkContext) - : m_wkContext(wkContext) - , m_provider(this) -{ - ASSERT(m_wkContext); - - WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(m_wkContext.get()); - ASSERT(wkBatteryManager); - - WKBatteryProvider wkBatteryProvider = { - kWKBatteryProviderCurrentVersion, - this, // clientInfo - startUpdatingCallback, - stopUpdatingCallback - }; - WKBatteryManagerSetProvider(wkBatteryManager, &wkBatteryProvider); -} - -void BatteryProvider::startUpdating() -{ - m_provider.startUpdating(); -} - -void BatteryProvider::stopUpdating() -{ - m_provider.stopUpdating(); -} - -void BatteryProvider::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> status) -{ - WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(m_wkContext.get()); - ASSERT(wkBatteryManager); - - WKRetainPtr<WKBatteryStatusRef> wkBatteryStatus(AdoptWK, WKBatteryStatusCreate(status->charging(), status->chargingTime(), status->dischargingTime(), status->level())); - WKBatteryManagerProviderDidChangeBatteryStatus(wkBatteryManager, toAPI(eventType.impl()), wkBatteryStatus.get()); -} - -#endif // ENABLE(BATTERY_STATUS) diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index 17afb115d..07ca12935 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -28,22 +28,30 @@ #ifndef EWebKit2_h #define EWebKit2_h +#include "ewk_auth_request.h" #include "ewk_back_forward_list.h" #include "ewk_back_forward_list_item.h" +#include "ewk_color_picker.h" #include "ewk_context.h" #include "ewk_cookie_manager.h" +#include "ewk_database_manager.h" #include "ewk_download_job.h" #include "ewk_error.h" #include "ewk_favicon_database.h" +#include "ewk_file_chooser_request.h" #include "ewk_form_submission_request.h" #include "ewk_intent.h" #include "ewk_intent_service.h" #include "ewk_main.h" #include "ewk_navigation_data.h" #include "ewk_navigation_policy_decision.h" +#include "ewk_object.h" +#include "ewk_popup_menu.h" #include "ewk_popup_menu_item.h" #include "ewk_resource.h" +#include "ewk_security_origin.h" #include "ewk_settings.h" +#include "ewk_storage_manager.h" #include "ewk_text_checker.h" #include "ewk_touch.h" #include "ewk_url_request.h" diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client_private.h b/Source/WebKit2/UIProcess/API/efl/EvasGLContext.cpp index e056aafe6..98a7e6a8e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client_private.h +++ b/Source/WebKit2/UIProcess/API/efl/EvasGLContext.cpp @@ -23,11 +23,26 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_context_download_client_private_h -#define ewk_context_download_client_private_h +#include "config.h" +#include "EvasGLContext.h" -typedef struct Ewk_Context Ewk_Context; +#if USE(ACCELERATED_COMPOSITING) -void ewk_context_download_client_attach(Ewk_Context*); +namespace WebKit { -#endif // ewk_context_download_client_private_h +EvasGLContext::EvasGLContext(Evas_GL* evasGL, Evas_GL_Context* passContext) + : m_evasGL(evasGL) + , m_context(passContext) +{ + ASSERT(evasGL); + ASSERT(passContext); +} + +EvasGLContext::~EvasGLContext() +{ + evas_gl_context_destroy(m_evasGL, m_context); +} + +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h b/Source/WebKit2/UIProcess/API/efl/EvasGLContext.h index fadd58a1b..9899a81f4 100644 --- a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/EvasGLContext.h @@ -23,34 +23,40 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef VibrationProvider_h -#define VibrationProvider_h +#ifndef EvasGLContext_h +#define EvasGLContext_h -#if ENABLE(VIBRATION) +#if USE(ACCELERATED_COMPOSITING) +#include <Evas_GL.h> +#include <wtf/PassOwnPtr.h> -#include "WKRetainPtr.h" -#include "ewk_context.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> +namespace WebKit { -typedef struct Ewk_Vibration_Client Ewk_Vibration_Client; - -class VibrationProvider : public RefCounted<VibrationProvider> { +class EvasGLContext { public: - static PassRefPtr<VibrationProvider> create(WKContextRef); - virtual ~VibrationProvider(); + static PassOwnPtr<EvasGLContext> create(Evas_GL* evasGL) + { + ASSERT(evasGL); + Evas_GL_Context* context = evas_gl_context_create(evasGL, 0); + if (!context) + return nullptr; + + // Ownership of context is passed to EvasGLContext. + return adoptPtr(new EvasGLContext(evasGL, context)); + } + ~EvasGLContext(); - void vibrate(uint64_t vibrationTime); - void cancelVibration(); - void setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb, Ewk_Vibration_Client_Vibration_Cancel_Cb, void*); + inline Evas_GL_Context* context() const { return m_context; } private: - explicit VibrationProvider(WKContextRef); + EvasGLContext(Evas_GL* evasGL, Evas_GL_Context* passContext); - WKRetainPtr<WKContextRef> m_wkContext; - OwnPtr<Ewk_Vibration_Client> m_vibrationClient; + Evas_GL* m_evasGL; + Evas_GL_Context* m_context; }; -#endif // ENABLE(VIBRATION) +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) -#endif // VibrationProvider_h +#endif // EvasGLContext_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client_private.h b/Source/WebKit2/UIProcess/API/efl/EvasGLSurface.cpp index 9feb4a138..d5d138390 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client_private.h +++ b/Source/WebKit2/UIProcess/API/efl/EvasGLSurface.cpp @@ -23,12 +23,26 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_view_form_client_private_h -#define ewk_view_form_client_private_h +#include "config.h" +#include "EvasGLSurface.h" -#include <Evas.h> -#include <WebKit2/WKBase.h> +#if USE(ACCELERATED_COMPOSITING) -void ewk_view_form_client_attach(WKPageRef pageRef, Evas_Object* ewkView); +namespace WebKit { -#endif // ewk_view_form_client_private_h +EvasGLSurface::EvasGLSurface(Evas_GL* evasGL, Evas_GL_Surface* passSurface) + : m_evasGL(evasGL) + , m_surface(passSurface) +{ + ASSERT(evasGL); + ASSERT(passSurface); +} + +EvasGLSurface::~EvasGLSurface() +{ + evas_gl_surface_destroy(m_evasGL, m_surface); +} + +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h b/Source/WebKit2/UIProcess/API/efl/EvasGLSurface.h index c54414e68..9ab3062c4 100644 --- a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/EvasGLSurface.h @@ -23,36 +23,42 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BatteryProvider_h -#define BatteryProvider_h +#ifndef EvasGLSurface_h +#define EvasGLSurface_h -#if ENABLE(BATTERY_STATUS) +#if USE(ACCELERATED_COMPOSITING) +#include <Evas_GL.h> +#include <WebCore/IntSize.h> +#include <wtf/PassOwnPtr.h> -#include "BatteryProviderEfl.h" -#include "BatteryProviderEflClient.h" -#include "BatteryStatus.h" -#include "WKRetainPtr.h" -#include <WebKit2/WKBase.h> -#include <wtf/PassRefPtr.h> +namespace WebKit { -class BatteryProvider : public RefCounted<BatteryProvider>, public WebCore::BatteryProviderEflClient { +class EvasGLSurface { public: - virtual ~BatteryProvider(); - static PassRefPtr<BatteryProvider> create(WKContextRef); + static PassOwnPtr<EvasGLSurface> create(Evas_GL* evasGL, Evas_GL_Config* cfg, const WebCore::IntSize& size) + { + ASSERT(evasGL); + ASSERT(cfg); + Evas_GL_Surface* surface = evas_gl_surface_create(evasGL, cfg, size.width(), size.height()); + if (!surface) + return nullptr; - void startUpdating(); - void stopUpdating(); + // Ownership of surface is passed to EvasGLSurface. + return adoptPtr(new EvasGLSurface(evasGL, surface)); + } + ~EvasGLSurface(); -private: - BatteryProvider(WKContextRef); + inline Evas_GL_Surface* surface() const { return m_surface; } - // BatteryProviderEflClient interface. - virtual void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<WebCore::BatteryStatus>); +private: + EvasGLSurface(Evas_GL* evasGL, Evas_GL_Surface* passSurface); - WKRetainPtr<WKContextRef> m_wkContext; - WebCore::BatteryProviderEfl m_provider; + Evas_GL* m_evasGL; + Evas_GL_Surface* m_surface; }; -#endif // ENABLE(BATTERY_STATUS) +} // namespace WebKit + +#endif // USE(ACCELERATED_COMPOSITING) -#endif // BatteryProvider_h +#endif // EvasGLSurface_h diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h b/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h new file mode 100644 index 000000000..7f5512753 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewCallbacks.h @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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 EwkViewCallbacks_h +#define EwkViewCallbacks_h + +#include "WKEinaSharedString.h" +#include "ewk_private.h" +#include <Evas.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +typedef struct Ewk_Object Ewk_Auth_Request; +typedef struct Ewk_Object Ewk_Download_Job; +struct Ewk_Download_Job_Error; +struct Ewk_File_Chooser_Request; +struct Ewk_Form_Submission_Request; +struct Ewk_Error; +struct Ewk_Resource_Request; +struct Ewk_Resource_Load_Response; +struct Ewk_Resource_Load_Error; +struct Ewk_Resource; +struct Ewk_Navigation_Policy_Decision; +#if ENABLE(WEB_INTENTS) +struct Ewk_Intent; +#endif +#if ENABLE(WEB_INTENTS_TAG) +struct Ewk_Intent_Service; +#endif + +namespace EwkViewCallbacks { + +enum CallbackType { + AuthenticationRequest, + BackForwardListChange, + CloseWindow, + CreateWindow, + DownloadJobCancelled, + DownloadJobFailed, + DownloadJobFinished, + DownloadJobRequested, + FileChooserRequest, + NewFormSubmissionRequest, + IconChanged, + LoadError, + LoadFinished, + LoadProgress, + ProvisionalLoadFailed, + ProvisionalLoadRedirect, + ProvisionalLoadStarted, + ResourceLoadStarted, + ResourceLoadResponse, + ResourceLoadFailed, + ResourceLoadFinished, + ResourceRequestSent, + NavigationPolicyDecision, + NewWindowPolicyDecision, + TextFound, + TitleChange, + TooltipTextUnset, + TooltipTextSet, + URLChanged, + WebProcessCrashed, +#if ENABLE(WEB_INTENTS) + IntentRequest, +#endif +#if ENABLE(WEB_INTENTS_TAG) + IntentServiceRegistration, +#endif +}; + +template<typename T> +inline bool callbackArgumentsExpected() +{ + return true; +} + +template<> +inline bool callbackArgumentsExpected<void>() +{ + return false; +} + +template <CallbackType> +struct CallBackInfo { + typedef void* Type; + + static inline const char* name() + { + ASSERT_NOT_REACHED(); + return ""; + } +}; + +template <CallbackType callbackType> +class CallBack { +public: + typedef typename CallBackInfo<callbackType>::Type ArgType; + + explicit CallBack(Evas_Object* view) + : m_view(view) + { + ASSERT(m_view); + } + + void call(ArgType* argument = 0) + { + if (argument && !callbackArgumentsExpected<ArgType>()) { + CRITICAL("should not pass arguments for this callback!"); + ASSERT_NOT_REACHED(); + return; + } + + evas_object_smart_callback_call(m_view, CallBackInfo<callbackType>::name(), static_cast<void*>(argument)); + } + + void call(const String& arg) + { + call(const_cast<char*>(arg.utf8().data())); + } + + void call(const WKEinaSharedString& arg) + { + call(const_cast<char*>(static_cast<const char*>(arg))); + } + +private: + Evas_Object* m_view; +}; + +#define DECLARE_EWK_VIEW_CALLBACK(callbackType, string, type) \ +template <> \ +struct CallBackInfo<callbackType> { \ + typedef type Type; \ + static inline const char* name() { return string; } \ +} + +// Note: type 'void' means that no arguments are expected. +DECLARE_EWK_VIEW_CALLBACK(AuthenticationRequest, "authentication,request", Ewk_Auth_Request); +DECLARE_EWK_VIEW_CALLBACK(BackForwardListChange, "back,forward,list,changed", void); +DECLARE_EWK_VIEW_CALLBACK(CloseWindow, "close,window", void); +DECLARE_EWK_VIEW_CALLBACK(CreateWindow, "create,window", Evas_Object*); +DECLARE_EWK_VIEW_CALLBACK(DownloadJobCancelled, "download,cancelled", Ewk_Download_Job); +DECLARE_EWK_VIEW_CALLBACK(DownloadJobFailed, "download,failed", Ewk_Download_Job_Error); +DECLARE_EWK_VIEW_CALLBACK(DownloadJobFinished, "download,finished", Ewk_Download_Job); +DECLARE_EWK_VIEW_CALLBACK(DownloadJobRequested, "download,request", Ewk_Download_Job); +DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request); +DECLARE_EWK_VIEW_CALLBACK(NewFormSubmissionRequest, "form,submission,request", Ewk_Form_Submission_Request); +DECLARE_EWK_VIEW_CALLBACK(IconChanged, "icon,changed", void); +DECLARE_EWK_VIEW_CALLBACK(LoadError, "load,error", Ewk_Error); +DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void); +DECLARE_EWK_VIEW_CALLBACK(LoadProgress, "load,progress", double); +DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadFailed, "load,provisional,failed", Ewk_Error); +DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadRedirect, "load,provisional,redirect", void); +DECLARE_EWK_VIEW_CALLBACK(ProvisionalLoadStarted, "load,provisional,started", void); +DECLARE_EWK_VIEW_CALLBACK(NavigationPolicyDecision, "policy,decision,navigation", Ewk_Navigation_Policy_Decision); +DECLARE_EWK_VIEW_CALLBACK(NewWindowPolicyDecision, "policy,decision,new,window", Ewk_Navigation_Policy_Decision); +DECLARE_EWK_VIEW_CALLBACK(ResourceLoadStarted, "resource,request,new", Ewk_Resource_Request); +DECLARE_EWK_VIEW_CALLBACK(ResourceLoadResponse, "resource,request,response", Ewk_Resource_Load_Response); +DECLARE_EWK_VIEW_CALLBACK(ResourceLoadFailed, "resource,request,failed", Ewk_Resource_Load_Error); +DECLARE_EWK_VIEW_CALLBACK(ResourceLoadFinished, "resource,request,finished", Ewk_Resource); +DECLARE_EWK_VIEW_CALLBACK(ResourceRequestSent, "resource,request,sent", Ewk_Resource_Request); +DECLARE_EWK_VIEW_CALLBACK(TextFound, "text,found", unsigned); +DECLARE_EWK_VIEW_CALLBACK(TitleChange, "title,changed", char); +DECLARE_EWK_VIEW_CALLBACK(TooltipTextUnset, "tooltip,text,unset", void); +DECLARE_EWK_VIEW_CALLBACK(TooltipTextSet, "tooltip,text,set", char); +DECLARE_EWK_VIEW_CALLBACK(URLChanged, "url,changed", char); +DECLARE_EWK_VIEW_CALLBACK(WebProcessCrashed, "webprocess,crashed", bool); +#if ENABLE(WEB_INTENTS) +DECLARE_EWK_VIEW_CALLBACK(IntentRequest, "intent,request,new", Ewk_Intent); +#endif +#if ENABLE(WEB_INTENTS_TAG) +DECLARE_EWK_VIEW_CALLBACK(IntentServiceRegistration, "intent,service,register", Ewk_Intent_Service); +#endif + +} + +#endif // #ifndef EwkViewCallbacks_h diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp new file mode 100644 index 000000000..42166c98c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp @@ -0,0 +1,834 @@ +/* + Copyright (C) 2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + 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 "config.h" +#include "EwkViewImpl.h" + +#include "EflScreenUtilities.h" +#include "FindClientEfl.h" +#include "FormClientEfl.h" +#include "InputMethodContextEfl.h" +#include "LayerTreeCoordinatorProxy.h" +#include "LayerTreeRenderer.h" +#include "PageClientBase.h" +#include "PageClientDefaultImpl.h" +#include "PageClientLegacyImpl.h" +#include "PageLoadClientEfl.h" +#include "PagePolicyClientEfl.h" +#include "PageUIClientEfl.h" +#include "ResourceLoadClientEfl.h" +#include "WKString.h" +#include "WebContext.h" +#include "WebPageGroup.h" +#include "WebPageProxy.h" +#include "WebPopupMenuProxyEfl.h" +#include "WebPreferences.h" +#include "ewk_back_forward_list_private.h" +#include "ewk_color_picker_private.h" +#include "ewk_context_private.h" +#include "ewk_favicon_database_private.h" +#include "ewk_popup_menu_item_private.h" +#include "ewk_popup_menu_private.h" +#include "ewk_private.h" +#include "ewk_settings_private.h" +#include "ewk_view.h" +#include "ewk_view_private.h" +#include <Ecore_Evas.h> +#include <Ecore_X.h> +#include <Edje.h> +#include <WebCore/Cursor.h> + + +#if ENABLE(FULLSCREEN_API) +#include "WebFullScreenManagerProxy.h" +#endif + +#if USE(ACCELERATED_COMPOSITING) +#include <Evas_GL.h> +#endif + +using namespace EwkViewCallbacks; +using namespace WebCore; +using namespace WebKit; + +static const int defaultCursorSize = 16; + +typedef HashMap<WKPageRef, Evas_Object*> PageViewMap; + +static inline PageViewMap& pageViewMap() +{ + DEFINE_STATIC_LOCAL(PageViewMap, map, ()); + return map; +} + +void EwkViewImpl::addToPageViewMap(EwkViewImpl* viewImpl) +{ + PageViewMap::AddResult result = pageViewMap().add(viewImpl->wkPage(), viewImpl->view()); + ASSERT_UNUSED(result, result.isNewEntry); +} + +void EwkViewImpl::removeFromPageViewMap(EwkViewImpl* viewImpl) +{ + ASSERT(pageViewMap().contains(viewImpl->wkPage())); + pageViewMap().remove(viewImpl->wkPage()); +} + +const Evas_Object* EwkViewImpl::viewFromPageViewMap(const WKPageRef page) +{ + ASSERT(page); + + return pageViewMap().get(page); +} + +EwkViewImpl::EwkViewImpl(Evas_Object* view, PassRefPtr<EwkContext> context, PassRefPtr<WebPageGroup> pageGroup, ViewBehavior behavior) + : m_view(view) + , m_context(context) + , m_pageClient(behavior == DefaultBehavior ? PageClientDefaultImpl::create(this) : PageClientLegacyImpl::create(this)) + , m_pageProxy(toImpl(m_context->wkContext())->createWebPage(m_pageClient.get(), pageGroup.get())) + , m_pageLoadClient(PageLoadClientEfl::create(this)) + , m_pagePolicyClient(PagePolicyClientEfl::create(this)) + , m_pageUIClient(PageUIClientEfl::create(this)) + , m_resourceLoadClient(ResourceLoadClientEfl::create(this)) + , m_findClient(FindClientEfl::create(this)) + , m_formClient(FormClientEfl::create(this)) + , m_backForwardList(Ewk_Back_Forward_List::create(toAPI(m_pageProxy->backForwardList()))) +#if USE(TILED_BACKING_STORE) + , m_scaleFactor(1) +#endif + , m_settings(Ewk_Settings::create(this)) + , m_cursorGroup(0) + , m_mouseEventsEnabled(false) +#if ENABLE(TOUCH_EVENTS) + , m_touchEventsEnabled(false) +#endif + , m_displayTimer(this, &EwkViewImpl::displayTimerFired) + , m_inputMethodContext(InputMethodContextEfl::create(this, smartData()->base.evas)) +{ + ASSERT(m_view); + ASSERT(m_context); + ASSERT(m_pageProxy); + +#if USE(COORDINATED_GRAPHICS) + m_pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); + m_pageProxy->pageGroup()->preferences()->setForceCompositingMode(true); +#if ENABLE(WEBGL) + m_pageProxy->pageGroup()->preferences()->setWebGLEnabled(true); +#endif + if (behavior == DefaultBehavior) + m_pageProxy->setUseFixedLayout(true); +#endif + + m_pageProxy->initializeWebPage(); + +#if ENABLE(FULLSCREEN_API) + m_pageProxy->fullScreenManager()->setWebView(m_view); + m_pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true); +#endif + + // Enable mouse events by default + setMouseEventsEnabled(true); + + // Listen for favicon changes. + Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase(); + ASSERT(iconDatabase); + + iconDatabase->watchChanges(IconChangeCallbackData(EwkViewImpl::onFaviconChanged, this)); + + EwkViewImpl::addToPageViewMap(this); +} + +EwkViewImpl::~EwkViewImpl() +{ + m_pageProxy->close(); + + // Unregister icon change callback. + Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase(); + ASSERT(iconDatabase); + + iconDatabase->unwatchChanges(EwkViewImpl::onFaviconChanged); + + EwkViewImpl::removeFromPageViewMap(this); +} + +Ewk_View_Smart_Data* EwkViewImpl::smartData() const +{ + return static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_view)); +} + +EwkViewImpl* EwkViewImpl::fromEvasObject(const Evas_Object* view) +{ + ASSERT(view); + Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(view)); + ASSERT(sd); + ASSERT(sd->priv); + return sd->priv; +} + +/** + * @internal + * Retrieves the internal WKPage for this view. + */ +WKPageRef EwkViewImpl::wkPage() +{ + return toAPI(m_pageProxy.get()); +} + +void EwkViewImpl::setCursor(const Cursor& cursor) +{ + const char* group = cursor.platformCursor(); + if (!group || group == m_cursorGroup) + return; + + m_cursorGroup = group; + Ewk_View_Smart_Data* sd = smartData(); + RefPtr<Evas_Object> cursorObject = adoptRef(edje_object_add(sd->base.evas)); + + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas); + if (!m_theme || !edje_object_file_set(cursorObject.get(), m_theme, group)) { + ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0); +#ifdef HAVE_ECORE_X + if (WebCore::isUsingEcoreX(sd->base.evas)) + WebCore::applyFallbackCursor(ecoreEvas, group); +#endif + return; + } + + // Set cursor size. + Evas_Coord width, height; + edje_object_size_min_get(cursorObject.get(), &width, &height); + if (width <= 0 || height <= 0) + edje_object_size_min_calc(cursorObject.get(), &width, &height); + if (width <= 0 || height <= 0) { + width = defaultCursorSize; + height = defaultCursorSize; + } + evas_object_resize(cursorObject.get(), width, height); + + // Get cursor hot spot. + const char* data; + int hotspotX = 0; + data = edje_object_data_get(cursorObject.get(), "hot.x"); + if (data) + hotspotX = atoi(data); + + int hotspotY = 0; + data = edje_object_data_get(cursorObject.get(), "hot.y"); + if (data) + hotspotY = atoi(data); + + // ecore_evas takes care of freeing the cursor object. + ecore_evas_object_cursor_set(ecoreEvas, cursorObject.release().leakRef(), EVAS_LAYER_MAX, hotspotX, hotspotY); +} + +AffineTransform EwkViewImpl::transformFromScene() const +{ + AffineTransform transform; + +#if USE(TILED_BACKING_STORE) + transform.translate(m_scrollPosition.x(), m_scrollPosition.y()); + transform.scale(1 / m_scaleFactor); +#endif + + Ewk_View_Smart_Data* sd = smartData(); + transform.translate(-sd->view.x, -sd->view.y); + + return transform; +} + +AffineTransform EwkViewImpl::transformToScene() const +{ + return transformFromScene().inverse(); +} + +AffineTransform EwkViewImpl::transformToScreen() const +{ + AffineTransform transform; + + int windowGlobalX = 0; + int windowGlobalY = 0; + + Ewk_View_Smart_Data* sd = smartData(); + +#ifdef HAVE_ECORE_X + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas); + Ecore_X_Window window = ecore_evas_software_x11_window_get(ecoreEvas); // Returns 0 if none. + + int x, y; // x, y are relative to parent (in a reparenting window manager). + while (window) { + ecore_x_window_geometry_get(window, &x, &y, 0, 0); + windowGlobalX += x; + windowGlobalY += y; + window = ecore_x_window_parent_get(window); + } +#endif + + transform.translate(-sd->view.x, -sd->view.y); + transform.translate(windowGlobalX, windowGlobalY); + + return transform; +} + +void EwkViewImpl::displayTimerFired(Timer<EwkViewImpl>*) +{ +#if USE(COORDINATED_GRAPHICS) + Ewk_View_Smart_Data* sd = smartData(); + + evas_gl_make_current(evasGL(), evasGLSurface(), evasGLContext()); + + // We are supposed to clip to the actual viewport, nothing less. + IntRect viewport(sd->view.x, sd->view.y, sd->view.w, sd->view.h); + + LayerTreeRenderer* renderer = page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer(); + renderer->setActive(true); + renderer->syncRemoteContent(); + + renderer->paintToCurrentGLContext(transformToScene().toTransformationMatrix(), /* opacity */ 1, viewport); + + evas_object_image_data_update_add(sd->image, viewport.x(), viewport.y(), viewport.width(), viewport.height()); +#endif +} + +void EwkViewImpl::update(const IntRect& rect) +{ +#if USE(COORDINATED_GRAPHICS) + // Coordinated graphices needs to schedule an full update, not + // repainting of a region. Update in the event loop. + UNUSED_PARAM(rect); + if (!m_displayTimer.isActive()) + m_displayTimer.startOneShot(0); +#else + Ewk_View_Smart_Data* sd = smartData(); + if (!sd->image) + return; + + evas_object_image_data_update_add(sd->image, rect.x(), rect.y(), rect.width(), rect.height()); +#endif +} + +#if ENABLE(FULLSCREEN_API) +/** + * @internal + * Calls fullscreen_enter callback or falls back to default behavior and enables fullscreen mode. + */ +void EwkViewImpl::enterFullScreen() +{ + Ewk_View_Smart_Data* sd = smartData(); + + if (!sd->api->fullscreen_enter || !sd->api->fullscreen_enter(sd)) { + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas); + ecore_evas_fullscreen_set(ecoreEvas, true); + } +} + +/** + * @internal + * Calls fullscreen_exit callback or falls back to default behavior and disables fullscreen mode. + */ +void EwkViewImpl::exitFullScreen() +{ + Ewk_View_Smart_Data* sd = smartData(); + + if (!sd->api->fullscreen_exit || !sd->api->fullscreen_exit(sd)) { + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas); + ecore_evas_fullscreen_set(ecoreEvas, false); + } +} +#endif + +void EwkViewImpl::setImageData(void* imageData, const IntSize& size) +{ + Ewk_View_Smart_Data* sd = smartData(); + if (!imageData || !sd->image) + return; + + evas_object_resize(sd->image, size.width(), size.height()); + evas_object_image_size_set(sd->image, size.width(), size.height()); + evas_object_image_data_copy_set(sd->image, imageData); +} + +#if USE(TILED_BACKING_STORE) +void EwkViewImpl::informLoadCommitted() +{ + m_pageClient->didCommitLoad(); +} +#endif + +IntSize EwkViewImpl::size() const +{ + int width, height; + evas_object_geometry_get(m_view, 0, 0, &width, &height); + return IntSize(width, height); +} + +bool EwkViewImpl::isFocused() const +{ + return evas_object_focus_get(m_view); +} + +bool EwkViewImpl::isVisible() const +{ + return evas_object_visible_get(m_view); +} + +const char* EwkViewImpl::title() const +{ + m_title = m_pageProxy->pageTitle().utf8().data(); + + return m_title; +} + +/** + * @internal + * This function may return @c NULL. + */ +InputMethodContextEfl* EwkViewImpl::inputMethodContext() +{ + return m_inputMethodContext.get(); +} + +const char* EwkViewImpl::themePath() const +{ + return m_theme; +} + +void EwkViewImpl::setThemePath(const char* theme) +{ + if (m_theme != theme) { + m_theme = theme; + m_pageProxy->setThemePath(theme); + } +} + +const char* EwkViewImpl::customTextEncodingName() const +{ + String customEncoding = m_pageProxy->customTextEncodingName(); + if (customEncoding.isEmpty()) + return 0; + + m_customEncoding = customEncoding.utf8().data(); + + return m_customEncoding; +} + +void EwkViewImpl::setCustomTextEncodingName(const String& encoding) +{ + m_pageProxy->setCustomTextEncodingName(encoding); +} + +void EwkViewImpl::setMouseEventsEnabled(bool enabled) +{ + if (m_mouseEventsEnabled == enabled) + return; + + m_mouseEventsEnabled = enabled; + if (enabled) { + Ewk_View_Smart_Data* sd = smartData(); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_DOWN, onMouseDown, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_UP, onMouseUp, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_MOVE, onMouseMove, sd); + } else { + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_DOWN, onMouseDown); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_UP, onMouseUp); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_MOVE, onMouseMove); + } +} + +#if ENABLE(TOUCH_EVENTS) +void EwkViewImpl::setTouchEventsEnabled(bool enabled) +{ + if (m_touchEventsEnabled == enabled) + return; + + m_touchEventsEnabled = enabled; + + if (enabled) { + // FIXME: We have to connect touch callbacks with mouse and multi events + // because the Evas creates mouse events for first touch and multi events + // for second and third touches. Below codes should be fixed when the Evas + // supports the touch events. + // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details. + Ewk_View_Smart_Data* sd = smartData(); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_DOWN, onTouchDown, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_UP, onTouchUp, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_MOVE, onTouchMove, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_DOWN, onTouchDown, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_UP, onTouchUp, sd); + evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_MOVE, onTouchMove, sd); + } else { + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_DOWN, onTouchDown); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_UP, onTouchUp); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_MOVE, onTouchMove); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_DOWN, onTouchDown); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_UP, onTouchUp); + evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_MOVE, onTouchMove); + } +} +#endif + +/** + * @internal + * Update the view's favicon and emits a "icon,changed" signal if it has + * changed. + * + * This function is called whenever the URL has changed or when the icon for + * the current page URL has changed. + */ +void EwkViewImpl::informIconChange() +{ + Ewk_Favicon_Database* iconDatabase = m_context->faviconDatabase(); + ASSERT(iconDatabase); + + m_faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, m_url); + smartCallback<IconChanged>().call(); +} + +#if USE(ACCELERATED_COMPOSITING) +bool EwkViewImpl::createGLSurface(const IntSize& viewSize) +{ + if (!m_evasGL) { + Evas* evas = evas_object_evas_get(m_view); + m_evasGL = adoptPtr(evas_gl_new(evas)); + if (!m_evasGL) + return false; + } + + if (!m_evasGLContext) { + m_evasGLContext = EvasGLContext::create(evasGL()); + if (!m_evasGLContext) { + WARN("Failed to create GLContext."); + return false; + } + } + + Ewk_View_Smart_Data* sd = smartData(); + + Evas_GL_Config evasGLConfig = { + EVAS_GL_RGBA_8888, + EVAS_GL_DEPTH_BIT_8, + EVAS_GL_STENCIL_NONE, + EVAS_GL_OPTIONS_NONE, + EVAS_GL_MULTISAMPLE_NONE + }; + + ASSERT(!m_evasGLSurface); + m_evasGLSurface = EvasGLSurface::create(evasGL(), &evasGLConfig, viewSize); + if (!m_evasGLSurface) + return false; + + Evas_Native_Surface nativeSurface; + evas_gl_native_surface_get(evasGL(), evasGLSurface(), &nativeSurface); + evas_object_image_native_surface_set(sd->image, &nativeSurface); + + evas_gl_make_current(evasGL(), evasGLSurface(), evasGLContext()); + + Evas_GL_API* gl = evas_gl_api_get(evasGL()); + gl->glViewport(0, 0, viewSize.width() + sd->view.x, viewSize.height() + sd->view.y); + + return true; +} + +bool EwkViewImpl::enterAcceleratedCompositingMode() +{ + if (!m_evasGLSurface) { + if (!createGLSurface(size())) { + WARN("Failed to create GLSurface."); + return false; + } + } + + page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setActive(true); + return true; +} + +bool EwkViewImpl::exitAcceleratedCompositingMode() +{ + return true; +} +#endif + +#if ENABLE(INPUT_TYPE_COLOR) +/** + * @internal + * Requests to show external color picker. + */ +void EwkViewImpl::requestColorPicker(WKColorPickerResultListenerRef listener, const WebCore::Color& color) +{ + Ewk_View_Smart_Data* sd = smartData(); + EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_request); + + if (!sd->api->input_picker_color_request) + return; + + if (m_colorPicker) + dismissColorPicker(); + + m_colorPicker = Ewk_Color_Picker::create(listener, color); + + sd->api->input_picker_color_request(sd, m_colorPicker.get()); +} + +/** + * @internal + * Requests to hide external color picker. + */ +void EwkViewImpl::dismissColorPicker() +{ + if (!m_colorPicker) + return; + + Ewk_View_Smart_Data* sd = smartData(); + EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_dismiss); + + if (sd->api->input_picker_color_dismiss) + sd->api->input_picker_color_dismiss(sd); + + m_colorPicker.clear(); +} +#endif + +void EwkViewImpl::informContentsSizeChange(const IntSize& size) +{ +#if USE(COORDINATED_GRAPHICS) + m_pageClient->didChangeContentsSize(size); +#else + UNUSED_PARAM(size); +#endif +} + +COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, RTL); +COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, LTR); + +void EwkViewImpl::requestPopupMenu(WebPopupMenuProxyEfl* popupMenuProxy, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex) +{ + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + ASSERT(popupMenuProxy); + + if (!sd->api->popup_menu_show) + return; + + if (m_popupMenu) + closePopupMenu(); + + m_popupMenu = Ewk_Popup_Menu::create(this, popupMenuProxy, items, selectedIndex); + + sd->api->popup_menu_show(sd, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, m_popupMenu.get()); +} + +void EwkViewImpl::closePopupMenu() +{ + if (!m_popupMenu) + return; + + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + if (sd->api->popup_menu_hide) + sd->api->popup_menu_hide(sd); + + m_popupMenu.clear(); +} + +/** + * @internal + * Calls a smart member function for javascript alert(). + */ +void EwkViewImpl::requestJSAlertPopup(const WKEinaSharedString& message) +{ + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + if (!sd->api->run_javascript_alert) + return; + + sd->api->run_javascript_alert(sd, message); +} + +/** + * @internal + * Calls a smart member function for javascript confirm() and returns a value from the function. Returns false by default. + */ +bool EwkViewImpl::requestJSConfirmPopup(const WKEinaSharedString& message) +{ + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + if (!sd->api->run_javascript_confirm) + return false; + + return sd->api->run_javascript_confirm(sd, message); +} + +/** + * @internal + * Calls a smart member function for javascript prompt() and returns a value from the function. Returns null string by default. + */ +WKEinaSharedString EwkViewImpl::requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue) +{ + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + if (!sd->api->run_javascript_prompt) + return WKEinaSharedString(); + + return WKEinaSharedString::adopt(sd->api->run_javascript_prompt(sd, message, defaultValue)); +} + +#if ENABLE(SQL_DATABASE) +/** + * @internal + * Calls exceeded_database_quota callback or falls back to default behavior returns default database quota. + */ +unsigned long long EwkViewImpl::informDatabaseQuotaReached(const String& databaseName, const String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) +{ + Ewk_View_Smart_Data* sd = smartData(); + ASSERT(sd->api); + + static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB + if (sd->api->exceeded_database_quota) + return sd->api->exceeded_database_quota(sd, databaseName.utf8().data(), displayName.utf8().data(), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); + + return defaultQuota; +} +#endif + +/** + * @internal + * The url of view was changed by the frame loader. + * + * Emits signal: "url,changed" with pointer to new url string. + */ +void EwkViewImpl::informURLChange() +{ + String activeURL = m_pageProxy->activeURL(); + if (activeURL.isEmpty()) + return; + + CString rawActiveURL = activeURL.utf8(); + if (m_url == rawActiveURL.data()) + return; + + m_url = rawActiveURL.data(); + smartCallback<URLChanged>().call(m_url); + + // Update the view's favicon. + informIconChange(); +} + +WKPageRef EwkViewImpl::createNewPage() +{ + Evas_Object* newEwkView = 0; + smartCallback<CreateWindow>().call(&newEwkView); + + if (!newEwkView) + return 0; + + EwkViewImpl* newViewImpl = EwkViewImpl::fromEvasObject(newEwkView); + ASSERT(newViewImpl); + + return static_cast<WKPageRef>(WKRetain(newViewImpl->page())); +} + +void EwkViewImpl::closePage() +{ + smartCallback<CloseWindow>().call(); +} + +void EwkViewImpl::onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo) +{ + Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo); + Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data); + EINA_SAFETY_ON_NULL_RETURN(sd->api); + EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_down); + sd->api->mouse_down(sd, downEvent); +} + +void EwkViewImpl::onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo) +{ + Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo); + Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data); + EINA_SAFETY_ON_NULL_RETURN(sd->api); + EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_up); + sd->api->mouse_up(sd, upEvent); +} + +void EwkViewImpl::onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo) +{ + Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo); + Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data); + EINA_SAFETY_ON_NULL_RETURN(sd->api); + EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_move); + sd->api->mouse_move(sd, moveEvent); +} + +#if ENABLE(TOUCH_EVENTS) +void EwkViewImpl::feedTouchEvents(Ewk_Touch_Event_Type type) +{ + Ewk_View_Smart_Data* sd = smartData(); + + unsigned count = evas_touch_point_list_count(sd->base.evas); + if (!count) + return; + + Eina_List* points = 0; + for (unsigned i = 0; i < count; ++i) { + Ewk_Touch_Point* point = new Ewk_Touch_Point; + point->id = evas_touch_point_list_nth_id_get(sd->base.evas, i); + evas_touch_point_list_nth_xy_get(sd->base.evas, i, &point->x, &point->y); + point->state = evas_touch_point_list_nth_state_get(sd->base.evas, i); + points = eina_list_append(points, point); + } + + ewk_view_feed_touch_event(m_view, type, points, evas_key_modifier_get(sd->base.evas)); + + void* data; + EINA_LIST_FREE(points, data) + delete static_cast<Ewk_Touch_Point*>(data); +} + +void EwkViewImpl::onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView); + viewImpl->feedTouchEvents(EWK_TOUCH_START); +} + +void EwkViewImpl::onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView); + viewImpl->feedTouchEvents(EWK_TOUCH_END); +} + +void EwkViewImpl::onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) +{ + EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView); + viewImpl->feedTouchEvents(EWK_TOUCH_MOVE); +} +#endif + +void EwkViewImpl::onFaviconChanged(const char* pageURL, void* eventInfo) +{ + EwkViewImpl* viewImpl = static_cast<EwkViewImpl*>(eventInfo); + + if (!viewImpl->url() || strcasecmp(viewImpl->url(), pageURL)) + return; + + viewImpl->informIconChange(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h new file mode 100644 index 000000000..918fe22f9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h @@ -0,0 +1,255 @@ +/* + Copyright (C) 2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + 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 EwkViewImpl_h +#define EwkViewImpl_h + +#include "EwkViewCallbacks.h" +#include "RefPtrEfl.h" +#include "WKEinaSharedString.h" +#include "WKRetainPtr.h" +#include <Evas.h> +#include <WebCore/IntRect.h> +#include <WebCore/TextDirection.h> +#include <WebCore/Timer.h> +#include <WebKit2/WKBase.h> +#include <wtf/HashMap.h> +#include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +#if ENABLE(TOUCH_EVENTS) +#include "ewk_touch.h" +#endif + +#if USE(ACCELERATED_COMPOSITING) +#include "EvasGLContext.h" +#include "EvasGLSurface.h" +#endif + +namespace WebKit { +class FindClientEfl; +class FormClientEfl; +class InputMethodContextEfl; +class PageClientBase; +class PageLoadClientEfl; +class PagePolicyClientEfl; +class PageUIClientEfl; +class ResourceLoadClientEfl; +class WebPageGroup; +class WebPageProxy; +class WebPopupItem; +class WebPopupMenuProxyEfl; +} + +namespace WebCore { +class AffineTransform; +class Color; +class Cursor; +class IntSize; +} + +class EwkContext; + +class Ewk_Back_Forward_List; +class Ewk_Color_Picker; +class Ewk_Error; +class Ewk_Form_Submission_Request; +class Ewk_Intent; +class Ewk_Intent_Service; +class Ewk_Resource; +class Ewk_Popup_Menu; +class Ewk_Settings; + +#if USE(ACCELERATED_COMPOSITING) +typedef struct _Evas_GL_Context Evas_GL_Context; +typedef struct _Evas_GL_Surface Evas_GL_Surface; +#endif + +typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data; + +class EwkViewImpl { +public: + + enum ViewBehavior { + LegacyBehavior, + DefaultBehavior + }; + EwkViewImpl(Evas_Object* view, PassRefPtr<EwkContext> context, PassRefPtr<WebKit::WebPageGroup> pageGroup, ViewBehavior); + ~EwkViewImpl(); + + static EwkViewImpl* fromEvasObject(const Evas_Object* view); + + Evas_Object* view() { return m_view; } + WKPageRef wkPage(); + WebKit::WebPageProxy* page() { return m_pageProxy.get(); } + EwkContext* ewkContext() { return m_context.get(); } + Ewk_Settings* settings() { return m_settings.get(); } + Ewk_Back_Forward_List* backForwardList() { return m_backForwardList.get(); } + + WebCore::IntSize size() const; + bool isFocused() const; + bool isVisible() const; + + WebCore::AffineTransform transformToScene() const; + WebCore::AffineTransform transformFromScene() const; + WebCore::AffineTransform transformToScreen() const; + + const char* url() const { return m_url; } + const char* faviconURL() const { return m_faviconURL; } + const char* title() const; + WebKit::InputMethodContextEfl* inputMethodContext(); + + const char* themePath() const; + void setThemePath(const char* theme); + const char* customTextEncodingName() const; + void setCustomTextEncodingName(const String& encoding); + + bool mouseEventsEnabled() const { return m_mouseEventsEnabled; } + void setMouseEventsEnabled(bool enabled); +#if ENABLE(TOUCH_EVENTS) + bool touchEventsEnabled() const { return m_touchEventsEnabled; } + void setTouchEventsEnabled(bool enabled); +#endif + + void setCursor(const WebCore::Cursor& cursor); + void setImageData(void* imageData, const WebCore::IntSize& size); + + void update(const WebCore::IntRect& rect = WebCore::IntRect()); + + static void addToPageViewMap(EwkViewImpl* viewImpl); + static void removeFromPageViewMap(EwkViewImpl* viewImpl); + static const Evas_Object* viewFromPageViewMap(const WKPageRef); + +#if ENABLE(FULLSCREEN_API) + void enterFullScreen(); + void exitFullScreen(); +#endif + +#if USE(ACCELERATED_COMPOSITING) + bool createGLSurface(const WebCore::IntSize& viewSize); + bool enterAcceleratedCompositingMode(); + bool exitAcceleratedCompositingMode(); +#endif + +#if ENABLE(INPUT_TYPE_COLOR) + void requestColorPicker(WKColorPickerResultListenerRef listener, const WebCore::Color&); + void dismissColorPicker(); +#endif + + WKPageRef createNewPage(); + void closePage(); + + void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex); + void closePopupMenu(); + + void updateTextInputState(); + + void requestJSAlertPopup(const WKEinaSharedString& message); + bool requestJSConfirmPopup(const WKEinaSharedString& message); + WKEinaSharedString requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue); + + template<EwkViewCallbacks::CallbackType callbackType> + EwkViewCallbacks::CallBack<callbackType> smartCallback() const + { + return EwkViewCallbacks::CallBack<callbackType>(m_view); + } + +#if USE(TILED_BACKING_STORE) + void informLoadCommitted(); +#endif + void informContentsSizeChange(const WebCore::IntSize& size); + unsigned long long informDatabaseQuotaReached(const String& databaseName, const String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); + +#if USE(TILED_BACKING_STORE) + WebKit::PageClientBase* pageClient() { return m_pageClient.get(); } + + void setScaleFactor(float scaleFactor) { m_scaleFactor = scaleFactor; } + float scaleFactor() const { return m_scaleFactor; } + + void setScrollPosition(WebCore::IntPoint position) { m_scrollPosition = position; } + const WebCore::IntPoint scrollPosition() const { return m_scrollPosition; } +#endif +#if USE(ACCELERATED_COMPOSITING) + Evas_GL* evasGL() { return m_evasGL.get(); } + Evas_GL_Context* evasGLContext() { return m_evasGLContext ? m_evasGLContext->context() : 0; } + Evas_GL_Surface* evasGLSurface() { return m_evasGLSurface ? m_evasGLSurface->surface() : 0; } + void clearEvasGLSurface() { m_evasGLSurface.clear(); } +#endif + + // FIXME: needs refactoring (split callback invoke) + void informURLChange(); + +private: + inline Ewk_View_Smart_Data* smartData() const; + void displayTimerFired(WebCore::Timer<EwkViewImpl>*); + + void informIconChange(); + + static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo); + static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo); + static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo); +#if ENABLE(TOUCH_EVENTS) + void feedTouchEvents(Ewk_Touch_Event_Type type); + static void onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */); + static void onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */); + static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */); +#endif + static void onFaviconChanged(const char* pageURL, void* eventInfo); + + // Note, initialization matters. + Evas_Object* m_view; + RefPtr<EwkContext> m_context; +#if USE(ACCELERATED_COMPOSITING) + OwnPtr<Evas_GL> m_evasGL; + OwnPtr<WebKit::EvasGLContext> m_evasGLContext; + OwnPtr<WebKit::EvasGLSurface> m_evasGLSurface; +#endif + OwnPtr<WebKit::PageClientBase> m_pageClient; + RefPtr<WebKit::WebPageProxy> m_pageProxy; + OwnPtr<WebKit::PageLoadClientEfl> m_pageLoadClient; + OwnPtr<WebKit::PagePolicyClientEfl> m_pagePolicyClient; + OwnPtr<WebKit::PageUIClientEfl> m_pageUIClient; + OwnPtr<WebKit::ResourceLoadClientEfl> m_resourceLoadClient; + OwnPtr<WebKit::FindClientEfl> m_findClient; + OwnPtr<WebKit::FormClientEfl> m_formClient; + OwnPtr<Ewk_Back_Forward_List> m_backForwardList; +#if USE(TILED_BACKING_STORE) + float m_scaleFactor; + WebCore::IntPoint m_scrollPosition; +#endif + OwnPtr<Ewk_Settings> m_settings; + const char* m_cursorGroup; // This is an address, do not free it or use WKEinaSharedString. + WKEinaSharedString m_faviconURL; + WKEinaSharedString m_url; + mutable WKEinaSharedString m_title; + WKEinaSharedString m_theme; + mutable WKEinaSharedString m_customEncoding; + bool m_mouseEventsEnabled; +#if ENABLE(TOUCH_EVENTS) + bool m_touchEventsEnabled; +#endif + WebCore::Timer<EwkViewImpl> m_displayTimer; + OwnPtr<Ewk_Popup_Menu> m_popupMenu; + OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext; + OwnPtr<Ewk_Color_Picker> m_colorPicker; +}; + +#endif // EwkViewImpl_h diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp deleted file mode 100644 index 1431c83a7..000000000 --- a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "NetworkInfoProvider.h" - -#if ENABLE(NETWORK_INFO) - -#include "WKContext.h" -#include "WKNetworkInfoManager.h" -#include <NotImplemented.h> - -static inline NetworkInfoProvider* toNetworkInfoProvider(const void* clientInfo) -{ - return static_cast<NetworkInfoProvider*>(const_cast<void*>(clientInfo)); -} - -static void startUpdatingCallback(WKNetworkInfoManagerRef, const void* clientInfo) -{ - toNetworkInfoProvider(clientInfo)->startUpdating(); -} - -static void stopUpdatingCallback(WKNetworkInfoManagerRef, const void* clientInfo) -{ - toNetworkInfoProvider(clientInfo)->stopUpdating(); -} - -static double getBandwidthCallback(WKNetworkInfoManagerRef, const void* clientInfo) -{ - return toNetworkInfoProvider(clientInfo)->bandwidth(); -} - -static bool isMeteredCallback(WKNetworkInfoManagerRef, const void* clientInfo) -{ - return toNetworkInfoProvider(clientInfo)->metered(); -} - -PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(WKContextRef wkContext) -{ - return adoptRef(new NetworkInfoProvider(wkContext)); -} - -NetworkInfoProvider::NetworkInfoProvider(WKContextRef wkContext) - : m_wkContext(wkContext) -{ - ASSERT(wkContext); - - WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_wkContext.get()); - ASSERT(wkNetworkInfoManager); - - WKNetworkInfoProvider wkNetworkInfoProvider = { - kWKNetworkInfoProviderCurrentVersion, - this, // clientInfo - startUpdatingCallback, - stopUpdatingCallback, - getBandwidthCallback, - isMeteredCallback - }; - WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, &wkNetworkInfoProvider); -} - -NetworkInfoProvider::~NetworkInfoProvider() -{ - WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_wkContext.get()); - ASSERT(wkNetworkInfoManager); - - WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, 0); -} - -double NetworkInfoProvider::bandwidth() const -{ - return m_provider.bandwidth(); -} - -bool NetworkInfoProvider::metered() const -{ - notImplemented(); - - return false; -} - -void NetworkInfoProvider::startUpdating() -{ - m_provider.startUpdating(); -} - -void NetworkInfoProvider::stopUpdating() -{ - m_provider.stopUpdating(); -} - -#endif // ENABLE(NETWORK_INFO) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp deleted file mode 100644 index 054bfcbf7..000000000 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2011 Samsung Electronics - * - * 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 "PageClientImpl.h" - -#include "DrawingAreaProxyImpl.h" -#include "NativeWebKeyboardEvent.h" -#include "NotImplemented.h" -#include "WebContext.h" -#include "WebContextMenuProxy.h" -#include "WebPageGroup.h" -#include "WebPageProxy.h" -#include "WebPopupMenuProxyEfl.h" -#include "WebPreferences.h" -#include "ewk_context.h" -#include "ewk_context_private.h" -#include "ewk_download_job.h" -#include "ewk_download_job_private.h" -#include "ewk_view.h" -#include "ewk_view_private.h" - -using namespace WebCore; - -namespace WebKit { - -PageClientImpl::PageClientImpl(Evas_Object* viewWidget) - : m_viewWidget(viewWidget) -{ -} - -PageClientImpl::~PageClientImpl() -{ -} - -// PageClient -PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() -{ - return DrawingAreaProxyImpl::create(ewk_view_page_get(m_viewWidget)); -} - -void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) -{ - ewk_view_display(m_viewWidget, rect); -} - -void PageClientImpl::displayView() -{ - notImplemented(); -} - -void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&) -{ - setViewNeedsDisplay(scrollRect); -} - -WebCore::IntSize PageClientImpl::viewSize() -{ - return ewk_view_size_get(m_viewWidget); -} - -bool PageClientImpl::isViewWindowActive() -{ - notImplemented(); - return true; -} - -bool PageClientImpl::isViewFocused() -{ - return evas_object_focus_get(m_viewWidget); -} - -bool PageClientImpl::isViewVisible() -{ - return evas_object_visible_get(m_viewWidget); -} - -bool PageClientImpl::isViewInWindow() -{ - notImplemented(); - return true; -} - -void PageClientImpl::processDidCrash() -{ - // Check if loading was ongoing, when web process crashed. - double loadProgress = ewk_view_load_progress_get(m_viewWidget); - if (loadProgress >= 0 && loadProgress < 1) - ewk_view_load_progress_changed(m_viewWidget, 1); - - ewk_view_webprocess_crashed(m_viewWidget); -} - -void PageClientImpl::didRelaunchProcess() -{ - notImplemented(); -} - -void PageClientImpl::pageClosed() -{ - notImplemented(); -} - -void PageClientImpl::toolTipChanged(const String&, const String& newToolTip) -{ - ewk_view_tooltip_text_set(m_viewWidget, newToolTip.utf8().data()); -} - -void PageClientImpl::setCursor(const Cursor& cursor) -{ - ewk_view_cursor_set(m_viewWidget, cursor); -} - -void PageClientImpl::setCursorHiddenUntilMouseMoves(bool) -{ - notImplemented(); -} - -void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&) -{ - notImplemented(); -} - -void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo) -{ - m_undoController.registerEditCommand(command, undoOrRedo); -} - -void PageClientImpl::clearAllEditCommands() -{ - m_undoController.clearAllEditCommands(); -} - -bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) -{ - return m_undoController.canUndoRedo(undoOrRedo); -} - -void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) -{ - m_undoController.executeUndoRedo(undoOrRedo); -} - -FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect) -{ - notImplemented(); - return viewRect; -} - -FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect) -{ - notImplemented(); - return viewRect; -} - -IntPoint PageClientImpl::screenToWindow(const IntPoint& point) -{ - notImplemented(); - return point; -} - -IntRect PageClientImpl::windowToScreen(const IntRect&) -{ - notImplemented(); - return IntRect(); -} - -void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool) -{ - notImplemented(); -} - -#if ENABLE(TOUCH_EVENTS) -void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent&, bool /*wasEventHandled*/) -{ - notImplemented(); -} -#endif - -PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) -{ - return WebPopupMenuProxyEfl::create(m_viewWidget, page); -} - -PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy*) -{ - notImplemented(); - return 0; -} - -#if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) -{ - notImplemented(); - return 0; -} -#endif - -void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool) -{ - notImplemented(); -} - -#if USE(ACCELERATED_COMPOSITING) -void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&) -{ - ewk_view_accelerated_compositing_mode_enter(m_viewWidget); -} - -void PageClientImpl::exitAcceleratedCompositingMode() -{ - ewk_view_accelerated_compositing_mode_exit(m_viewWidget); -} - -void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&) -{ - notImplemented(); -} -#endif // USE(ACCELERATED_COMPOSITING) - -void PageClientImpl::didChangeScrollbarsForMainFrame() const -{ - notImplemented(); -} - -void PageClientImpl::didCommitLoadForMainFrame(bool) -{ - notImplemented(); -} - -void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&) -{ - notImplemented(); -} - -double PageClientImpl::customRepresentationZoomFactor() -{ - notImplemented(); - return 0; -} - -void PageClientImpl::setCustomRepresentationZoomFactor(double) -{ - notImplemented(); -} - -void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&) -{ - notImplemented(); -} - -void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned) -{ - notImplemented(); -} - -void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned) -{ - notImplemented(); -} - -void PageClientImpl::handleDownloadRequest(DownloadProxy* download) -{ - RefPtr<Ewk_Download_Job> ewkDownload = Ewk_Download_Job::create(download, m_viewWidget); - ewk_view_context_get(m_viewWidget)->addDownloadJob(ewkDownload.get()); -} - -#if USE(TILED_BACKING_STORE) -void PageClientImpl::pageDidRequestScroll(const IntPoint&) -{ - notImplemented(); -} -#endif - -void PageClientImpl::didChangeContentsSize(const WebCore::IntSize& size) -{ - ewk_view_contents_size_changed(m_viewWidget, size); -} - -} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h deleted file mode 100644 index 8f03b09f4..000000000 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2011 Samsung Electronics - * - * 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 "DefaultUndoController.h" -#include "PageClient.h" -#include <Evas.h> - -namespace WebKit { - -class PageClientImpl : public PageClient { -public: - static PassOwnPtr<PageClientImpl> create(Evas_Object* viewWidget) - { - return adoptPtr(new PageClientImpl(viewWidget)); - } - ~PageClientImpl(); - - Evas_Object* viewWidget() const { return m_viewWidget; } - - -private: - explicit PageClientImpl(Evas_Object*); - - // PageClient - virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); - virtual void setViewNeedsDisplay(const WebCore::IntRect&); - virtual void displayView(); - virtual void scrollView(const WebCore::IntRect&, const WebCore::IntSize&); - virtual WebCore::IntSize viewSize(); - virtual bool isViewWindowActive(); - virtual bool isViewFocused(); - virtual bool isViewVisible(); - virtual bool isViewInWindow(); - - virtual void processDidCrash(); - virtual void didRelaunchProcess(); - virtual void pageClosed(); - - virtual void toolTipChanged(const String&, const String&); - - virtual void setCursor(const WebCore::Cursor&); - virtual void setCursorHiddenUntilMouseMoves(bool); - virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&); - - virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo); - virtual void clearAllEditCommands(); - virtual bool canUndoRedo(WebPageProxy::UndoOrRedo); - virtual void executeUndoRedo(WebPageProxy::UndoOrRedo); - virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); - virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); - virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&); - virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); - - virtual void handleDownloadRequest(DownloadProxy*); - - virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool); -#if ENABLE(TOUCH_EVENTS) - virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled); -#endif - - virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); - virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); - -#if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&); -#endif - - virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool); -#if USE(ACCELERATED_COMPOSITING) - virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); - virtual void exitAcceleratedCompositingMode(); - virtual void updateAcceleratedCompositingMode(const LayerTreeContext&); -#endif - - virtual void didChangeScrollbarsForMainFrame() const; - - virtual void didCommitLoadForMainFrame(bool); - virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&); - virtual double customRepresentationZoomFactor(); - virtual void setCustomRepresentationZoomFactor(double); - - virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&); - virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned); - virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned); - -#if USE(TILED_BACKING_STORE) - virtual void pageDidRequestScroll(const WebCore::IntPoint&); -#endif - - virtual void didChangeContentsSize(const WebCore::IntSize&); - -private: - Evas_Object* m_viewWidget; - DefaultUndoController m_undoController; -}; - -} // namespace WebKit - -#endif // PageClientImpl_h diff --git a/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.cpp b/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.cpp deleted file mode 100644 index 99160c4a3..000000000 --- a/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "PageViewportControllerClientEfl.h" - -#if USE(COORDINATED_GRAPHICS) - -#include "LayerTreeCoordinatorProxy.h" -#include "LayerTreeRenderer.h" -#include "TransformationMatrix.h" -#include "ewk_view_private.h" - -using namespace WebCore; - -namespace WebKit { - -PageViewportControllerClientEfl::PageViewportControllerClientEfl(Evas_Object* viewWidget) - : m_viewWidget(viewWidget) - , m_scaleFactor(1) -{ - ASSERT(m_viewWidget); -} - -PageViewportControllerClientEfl::~PageViewportControllerClientEfl() -{ -} - -DrawingAreaProxy* PageViewportControllerClientEfl::drawingArea() const -{ - return ewk_view_page_get(m_viewWidget)->drawingArea(); -} - -void PageViewportControllerClientEfl::setRendererActive(bool active) -{ - drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setActive(active); -} - -void PageViewportControllerClientEfl::display(const IntRect& rect, const IntPoint& viewPosition) -{ - WebCore::TransformationMatrix matrix; - matrix.setMatrix(m_scaleFactor, 0, 0, m_scaleFactor, -m_visibleContentRect.x() + viewPosition.x(), -m_visibleContentRect.y() + viewPosition.y()); - - LayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer(); - renderer->setActive(true); - renderer->syncRemoteContent(); - IntRect clipRect(rect); - clipRect.move(viewPosition.x(), viewPosition.y()); - renderer->paintToCurrentGLContext(matrix, 1, clipRect); -} - -void PageViewportControllerClientEfl::updateViewportSize(const IntSize& viewportSize) -{ - m_viewportSize = viewportSize; - ewk_view_page_get(m_viewWidget)->setViewportSize(viewportSize); - setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint()); -} - -void PageViewportControllerClientEfl::setVisibleContentsRect(const IntPoint& newScrollPosition, float newScale, const FloatPoint& trajectory) -{ - m_scaleFactor = newScale; - m_visibleContentRect = IntRect(newScrollPosition, m_viewportSize); - - // Move visibleContentRect inside contentsRect when visibleContentRect goes outside contentsRect. - IntSize contentsSize = m_contentsSize; - contentsSize.scale(m_scaleFactor); - if (m_visibleContentRect.x() > contentsSize.width() - m_visibleContentRect.width()) - m_visibleContentRect.setX(contentsSize.width() - m_visibleContentRect.width()); - if (m_visibleContentRect.x() < 0) - m_visibleContentRect.setX(0); - if (m_visibleContentRect.y() > contentsSize.height() - m_visibleContentRect.height()) - m_visibleContentRect.setY(contentsSize.height() - m_visibleContentRect.height()); - if (m_visibleContentRect.y() < 0) - m_visibleContentRect.setY(0); - - FloatRect mapRectToWebContent = m_visibleContentRect; - mapRectToWebContent.scale(1 / m_scaleFactor); - drawingArea()->setVisibleContentsRect(enclosingIntRect(mapRectToWebContent), m_scaleFactor, trajectory); -} - -void PageViewportControllerClientEfl::didChangeContentsSize(const WebCore::IntSize& size) -{ - m_contentsSize = size; - setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint()); - drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height())); -} - -void PageViewportControllerClientEfl::setViewportPosition(const WebCore::FloatPoint& /*contentsPoint*/) -{ -} - -void PageViewportControllerClientEfl::setContentsScale(float, bool /*treatAsInitialValue*/) -{ -} - -void PageViewportControllerClientEfl::didResumeContent() -{ -} - -void PageViewportControllerClientEfl::didChangeVisibleContents() -{ -} - -void PageViewportControllerClientEfl::didChangeViewportAttributes() -{ -} - -void PageViewportControllerClientEfl::setController(PageViewportController* pageViewportController) -{ -} - -} // namespace WebKit -#endif // USE(COORDINATED_GRAPHICS) - diff --git a/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.h b/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.h deleted file mode 100644 index 943452651..000000000 --- a/Source/WebKit2/UIProcess/API/efl/PageViewportControllerClientEfl.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. 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 PageViewportControllerClientEfl_h -#define PageViewportControllerClientEfl_h - -#if USE(COORDINATED_GRAPHICS) - -#include "PageClientImpl.h" -#include "PageViewportControllerClient.h" -#include <wtf/PassOwnPtr.h> - -namespace WebKit { - -class PageViewportControllerClientEfl : public PageViewportControllerClient { -public: - static PassOwnPtr<PageViewportControllerClientEfl> create(Evas_Object* viewWidget) - { - return adoptPtr(new PageViewportControllerClientEfl(viewWidget)); - } - ~PageViewportControllerClientEfl(); - - DrawingAreaProxy* drawingArea() const; - WebCore::IntSize viewSize() { return m_viewportSize; } - - void display(const WebCore::IntRect& rect, const WebCore::IntPoint& viewPosition); - void updateViewportSize(const WebCore::IntSize& viewportSize); - void setVisibleContentsRect(const WebCore::IntPoint&, float, const WebCore::FloatPoint&); - void setRendererActive(bool); - - virtual void setViewportPosition(const WebCore::FloatPoint& contentsPoint); - virtual void setContentsScale(float, bool treatAsInitialValue); - - virtual void didResumeContent(); - virtual void didChangeContentsSize(const WebCore::IntSize&); - virtual void didChangeVisibleContents(); - virtual void didChangeViewportAttributes(); - - virtual void setController(PageViewportController*); - -private: - explicit PageViewportControllerClientEfl(Evas_Object*); - - Evas_Object* m_viewWidget; - WebCore::IntRect m_visibleContentRect; - WebCore::IntSize m_contentsSize; - WebCore::IntSize m_viewportSize; - float m_scaleFactor; -}; - -} // namespace WebKit - -#endif - -#endif // PageViewportControllerClientEfl_h diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp deleted file mode 100644 index 9d8feb1fe..000000000 --- a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "VibrationProvider.h" - -#if ENABLE(VIBRATION) - -#include "WKAPICast.h" -#include "WKContext.h" -#include "WKVibration.h" -#include <Evas.h> - -using namespace WebCore; - -/** - * \struct Ewk_Vibration_Client - * @brief Contains the vibration client callbacks. - */ -struct Ewk_Vibration_Client { - Ewk_Vibration_Client_Vibrate_Cb vibrate; - Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration; - void* userData; - - Ewk_Vibration_Client(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* userData) - : vibrate(vibrate) - , cancelVibration(cancelVibration) - , userData(userData) - { } -}; - -static inline VibrationProvider* toVibrationProvider(const void* clientInfo) -{ - return static_cast<VibrationProvider*>(const_cast<void*>(clientInfo)); -} - -static void vibrateCallback(WKVibrationRef, uint64_t vibrationTime, const void* clientInfo) -{ - toVibrationProvider(clientInfo)->vibrate(vibrationTime); -} - -static void cancelVibrationCallback(WKVibrationRef, const void* clientInfo) -{ - toVibrationProvider(clientInfo)->cancelVibration(); -} - -PassRefPtr<VibrationProvider> VibrationProvider::create(WKContextRef wkContext) -{ - return adoptRef(new VibrationProvider(wkContext)); -} - -VibrationProvider::VibrationProvider(WKContextRef wkContext) - : m_wkContext(wkContext) -{ - ASSERT(m_wkContext.get()); - - WKVibrationRef wkVibration = WKContextGetVibration(m_wkContext.get()); - ASSERT(wkVibration); - - WKVibrationProvider wkVibrationProvider = { - kWKVibrationProviderCurrentVersion, - this, // clientInfo - vibrateCallback, - cancelVibrationCallback - }; - WKVibrationSetProvider(wkVibration, &wkVibrationProvider); -} - -VibrationProvider::~VibrationProvider() -{ - WKVibrationRef wkVibration = WKContextGetVibration(m_wkContext.get()); - ASSERT(wkVibration); - - WKVibrationSetProvider(wkVibration, 0); -} - -void VibrationProvider::vibrate(uint64_t vibrationTime) -{ - if (m_vibrationClient && m_vibrationClient->vibrate) - m_vibrationClient->vibrate(vibrationTime, m_vibrationClient->userData); -} - -void VibrationProvider::cancelVibration() -{ - if (m_vibrationClient && m_vibrationClient->cancelVibration) - m_vibrationClient->cancelVibration(m_vibrationClient->userData); -} - -void VibrationProvider::setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancelVibration, void* data) -{ - m_vibrationClient = adoptPtr(new Ewk_Vibration_Client(vibrate, cancelVibration, data)); -} - -#endif // ENABLE(VIBRATION) diff --git a/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp deleted file mode 100644 index 2ff39c4df..000000000 --- a/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics - * - * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. - */ - -#include "config.h" -#include "WebKitTextChecker.h" - -#if ENABLE(SPELLCHECK) - -#include "NotImplemented.h" -#include "WKAPICast.h" -#include "WKMutableArray.h" -#include "WKRetainPtr.h" -#include "WebPageProxy.h" -#include "WebString.h" -#include "ewk_settings.h" -#include "ewk_text_checker_private.h" -#include <Eina.h> -#include <wtf/OwnPtr.h> -#include <wtf/text/CString.h> - -namespace WebKit { - -static OwnPtr<WebCore::TextCheckerEnchant> textCheckerEnchant = WebCore::TextCheckerEnchant::create(); - -static Ewk_Text_Checker* ewkTextCheckerCallbacks = ewk_text_checker_callbacks_get(); - -bool isContinuousSpellCheckingEnabled(const void*) -{ - return ewk_settings_continuous_spell_checking_enabled_get(); -} - -void setContinuousSpellCheckingEnabled(bool enabled, const void*) -{ - ewk_settings_continuous_spell_checking_enabled_set(enabled); -} - -uint64_t uniqueSpellDocumentTag(WKPageRef page, const void*) -{ - if (ewkTextCheckerCallbacks->unique_spell_document_tag_get) - return ewkTextCheckerCallbacks->unique_spell_document_tag_get(toImpl(page)->viewWidget()); - - return 0; -} - -void closeSpellDocumentWithTag(uint64_t tag, const void*) -{ - if (ewkTextCheckerCallbacks->unique_spell_document_tag_close) - ewkTextCheckerCallbacks->unique_spell_document_tag_close(tag); -} - -void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void*) -{ - if (ewkTextCheckerCallbacks->string_spelling_check) - ewkTextCheckerCallbacks->string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength); - else - textCheckerEnchant->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength); -} - -WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void*) -{ - WKMutableArrayRef suggestionsForWord = WKMutableArrayCreate(); - - if (ewkTextCheckerCallbacks->word_guesses_get) { - Eina_List* list = ewkTextCheckerCallbacks->word_guesses_get(tag, toImpl(word)->string().utf8().data()); - void* item; - - EINA_LIST_FREE(list, item) { - WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(static_cast<char*>(item))); - WKArrayAppendItem(suggestionsForWord, suggestion.get()); - free(item); - } - } else { - Vector<String> guesses = textCheckerEnchant->getGuessesForWord(toImpl(word)->string()); - size_t numberOfGuesses = guesses.size(); - for (size_t i = 0; i < numberOfGuesses; ++i) { - WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(guesses[i].utf8().data())); - WKArrayAppendItem(suggestionsForWord, suggestion.get()); - } - } - - return suggestionsForWord; -} - -void learnWord(uint64_t tag, WKStringRef word, const void*) -{ - if (ewkTextCheckerCallbacks->word_learn) - ewkTextCheckerCallbacks->word_learn(tag, toImpl(word)->string().utf8().data()); - else - textCheckerEnchant->learnWord(toImpl(word)->string()); -} - -void ignoreWord(uint64_t tag, WKStringRef word, const void*) -{ - if (ewkTextCheckerCallbacks->word_ignore) - ewkTextCheckerCallbacks->word_ignore(tag, toImpl(word)->string().utf8().data()); - else - textCheckerEnchant->ignoreWord(toImpl(word)->string()); -} - -Vector<String> availableSpellCheckingLanguages() -{ - return textCheckerEnchant->availableSpellCheckingLanguages(); -} - -void updateSpellCheckingLanguages(const Vector<String>& languages) -{ - textCheckerEnchant->updateSpellCheckingLanguages(languages); -} - -Vector<String> loadedSpellCheckingLanguages() -{ - return textCheckerEnchant->loadedSpellCheckingLanguages(); -} - -} // namespace WebKit - -#endif // ENABLE(SPELLCHECK) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.cpp new file mode 100644 index 000000000..20279e3a6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_auth_request.h" + +#include "AuthenticationChallengeProxy.h" +#include "AuthenticationDecisionListener.h" +#include "WebCredential.h" +#include "WebProtectionSpace.h" +#include "WebString.h" +#include "ewk_auth_request_private.h" +#include <wtf/text/CString.h> + +using namespace WebKit; +using namespace WebCore; + +EwkAuthRequest::EwkAuthRequest(AuthenticationChallengeProxy* authenticationChallenge) + : m_authenticationChallenge(authenticationChallenge) + , m_wasHandled(false) +{ + ASSERT(m_authenticationChallenge); +} + +EwkAuthRequest::~EwkAuthRequest() +{ + if (!m_wasHandled) + continueWithoutCredential(); +} + +const char* EwkAuthRequest::suggestedUsername() const +{ + if (!m_suggestedUsername) { + WebCredential* credential = m_authenticationChallenge->proposedCredential(); + ASSERT(credential); + + const String& suggestedUsername = credential->user(); + if (suggestedUsername.isEmpty()) + return 0; + + m_suggestedUsername = suggestedUsername.utf8().data(); + } + + return m_suggestedUsername; +} + +const char* EwkAuthRequest::realm() const +{ + if (!m_realm) { + WebProtectionSpace* protectionSpace = m_authenticationChallenge->protectionSpace(); + ASSERT(protectionSpace); + + const String& realm = protectionSpace->realm(); + if (realm.isEmpty()) + return 0; + + m_realm = realm.utf8().data(); + } + + return m_realm; +} + +const char* EwkAuthRequest::host() const +{ + if (!m_host) { + WebProtectionSpace* protectionSpace = m_authenticationChallenge->protectionSpace(); + ASSERT(protectionSpace); + + const String& host = protectionSpace->host(); + if (host.isEmpty()) + return 0; + + m_host = host.utf8().data(); + } + + return m_host; +} + +bool EwkAuthRequest::continueWithoutCredential() +{ + if (m_wasHandled) + return false; + + m_wasHandled = true; + m_authenticationChallenge->useCredential(0); + + return true; +} + +bool EwkAuthRequest::authenticate(const String& username, const String& password) +{ + if (m_wasHandled) + return false; + + m_wasHandled = true; + RefPtr<WebCredential> credential = WebCredential::create(WebString::create(username).get(), WebString::create(password).get(), CredentialPersistenceForSession); + m_authenticationChallenge->useCredential(credential.get()); + + return true; +} + +bool EwkAuthRequest::isRetrying() const +{ + return m_authenticationChallenge->previousFailureCount() > 0; +} + +const char* ewk_auth_request_suggested_username_get(const Ewk_Auth_Request* request) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkAuthRequest, request, impl, 0); + + return impl->suggestedUsername(); +} + +Eina_Bool ewk_auth_request_cancel(Ewk_Auth_Request* request) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(EwkAuthRequest, request, impl, false); + + return impl->continueWithoutCredential(); +} + +Eina_Bool ewk_auth_request_authenticate(Ewk_Auth_Request* request, const char* username, const char* password) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(EwkAuthRequest, request, impl, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(username, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(password, false); + + return impl->authenticate(String::fromUTF8(username), String::fromUTF8(password)); +} + +Eina_Bool ewk_auth_request_retrying_get(const Ewk_Auth_Request* request) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkAuthRequest, request, impl, false); + + return impl->isRetrying(); +} + +const char* ewk_auth_request_realm_get(const Ewk_Auth_Request* request) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkAuthRequest, request, impl, 0); + + return impl->realm(); +} + +const char* ewk_auth_request_host_get(const Ewk_Auth_Request* request) +{ + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkAuthRequest, request, impl, 0); + + return impl->host(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.h new file mode 100644 index 000000000..78abb2b38 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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. + */ + +/** + * @file ewk_auth_request.h + * @brief Describes the Ewk Authentication Request API. + */ + +#ifndef ewk_auth_request_h +#define ewk_auth_request_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Declare Ewk_Auth_Request as Ewk_Object. + * + * @see Ewk_Object + */ +typedef struct Ewk_Object Ewk_Auth_Request; + +/** + * Queries the suggested username to be used for authenticating. + * + * @param request request object to query + * + * @return the username pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_auth_request_suggested_username_get(const Ewk_Auth_Request *request); + +/** + * Queries if this an authentication attempt retrying. + * + * @param request request object to query + * + * @return @c EINA_TRUE if this is not the first authentication attempt + * and we are trying, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_auth_request_retrying_get(const Ewk_Auth_Request *request); + +/** + * Queries the authentication realm. + * + * @param request request object to query + * + * @return the realm pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_auth_request_realm_get(const Ewk_Auth_Request *request); + +/** + * Queries the host requiring the authentication. + * + * @param request request object to query + * + * @return the host pointer, that may be @c NULL. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_auth_request_host_get(const Ewk_Auth_Request *request); + +/** + * Cancels the authentication request. + * + * @param request request object to cancel + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_auth_request_cancel(Ewk_Auth_Request *request); + +/** + * Set credential for the authentication request. + * + * @param request request object to update + * + * @return @c EINA_TRUE if the credential was successfuly sent, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_auth_request_authenticate(Ewk_Auth_Request *request, const char *username, const char *password); + +#ifdef __cplusplus +} +#endif + +#endif /* ewk_auth_request_h */ diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request_private.h index 0b470dcaf..ad1277cd0 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_auth_request_private.h @@ -23,20 +23,45 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_context_history_client_private_h -#define ewk_context_history_client_private_h - -#include "ewk_context.h" - -struct Ewk_Context_History_Client { - void* user_data; - Ewk_History_Navigation_Cb navigate_func; - Ewk_History_Client_Redirection_Cb client_redirect_func; - Ewk_History_Server_Redirection_Cb server_redirect_func; - Ewk_History_Title_Update_Cb title_update_func; - Ewk_History_Populate_Visited_Links_Cb populate_visited_links_func; -}; +#ifndef ewk_auth_request_private_h +#define ewk_auth_request_private_h + +#include "WKEinaSharedString.h" +#include "ewk_object_private.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/text/WTFString.h> + +namespace WebKit { +class AuthenticationChallengeProxy; +} + +class EwkAuthRequest : public Ewk_Object { +public: + EWK_OBJECT_DECLARE(EwkAuthRequest) + + static PassRefPtr<EwkAuthRequest> create(WebKit::AuthenticationChallengeProxy* authenticationChallenge) + { + return adoptRef(new EwkAuthRequest(authenticationChallenge)); + } + ~EwkAuthRequest(); -void ewk_context_history_client_attach(Ewk_Context*); + const char* suggestedUsername() const; + const char* realm() const; + const char* host() const; + bool isRetrying() const; + + bool continueWithoutCredential(); + bool authenticate(const String& username, const String& password); + +private: + explicit EwkAuthRequest(WebKit::AuthenticationChallengeProxy* authenticationChallenge); + + RefPtr<WebKit::AuthenticationChallengeProxy> m_authenticationChallenge; + bool m_wasHandled; + mutable WKEinaSharedString m_suggestedUsername; + mutable WKEinaSharedString m_realm; + mutable WKEinaSharedString m_host; +}; -#endif // ewk_context_history_client_private_h +#endif // ewk_auth_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp index 12dbb8f4b..dd3ae623b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp @@ -30,6 +30,7 @@ #include "WKArray.h" #include "WKBackForwardList.h" #include "ewk_back_forward_list_private.h" +#include "ewk_object.h" #include <wtf/text/CString.h> using namespace WebKit; @@ -90,7 +91,7 @@ Ewk_Back_Forward_List_Item* Ewk_Back_Forward_List::getFromCacheOrCreate(WKBackFo RefPtr<Ewk_Back_Forward_List_Item> item = m_wrapperCache.get(wkItem); if (!item) { - item = Ewk_Back_Forward_List_Item::create(wkItem); + item = EwkBackForwardListItem::create(wkItem); m_wrapperCache.set(wkItem, item); } @@ -108,7 +109,7 @@ Eina_List* Ewk_Back_Forward_List::createEinaList(WKArrayRef wkList) const for (size_t i = 0; i < count; ++i) { WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkList, i)); Ewk_Back_Forward_List_Item* item = getFromCacheOrCreate(wkItem); - result = eina_list_append(result, ewk_back_forward_list_item_ref(item)); + result = eina_list_append(result, ewk_object_ref(item)); } return result; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h index 09dbc5ab6..9a791ba2d 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h @@ -96,7 +96,7 @@ EAPI unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list); * @param limit the number of items to retrieve * * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, - * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * the Eina_List and its items should be freed after use. Use ewk_object_unref() * to free the items */ EAPI Eina_List *ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_List *list, int limit); @@ -111,7 +111,7 @@ EAPI Eina_List *ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_L * @param limit the number of items to retrieve * * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, - * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * the Eina_List and its items should be freed after use. Use ewk_object_unref() * to free the items */ EAPI Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forward_List *list, int limit); @@ -124,7 +124,7 @@ EAPI Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forwar * @param list the back-forward list instance * * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, - * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * the Eina_List and its items should be freed after use. Use ewk_object_unref() * to free the items * * @see ewk_back_forward_list_n_back_items_copy @@ -140,7 +140,7 @@ EAPI Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forwar * @param list the back-forward list instance * * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, - * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * the Eina_List and its items should be freed after use. Use ewk_object_unref() * to free the items * * @see ewk_back_forward_list_n_forward_items_copy diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp index 5ec236033..43f29c96c 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp @@ -32,63 +32,48 @@ using namespace WebKit; -Ewk_Back_Forward_List_Item::Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef) +EwkBackForwardListItem::EwkBackForwardListItem(WKBackForwardListItemRef itemRef) : m_wkItem(itemRef) { } -const char* Ewk_Back_Forward_List_Item::url() const +const char* EwkBackForwardListItem::url() const { m_url = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyURL(m_wkItem.get())); return m_url; } -const char* Ewk_Back_Forward_List_Item::title() const +const char* EwkBackForwardListItem::title() const { m_title = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyTitle(m_wkItem.get())); return m_title; } -const char* Ewk_Back_Forward_List_Item::originalURL() const +const char* EwkBackForwardListItem::originalURL() const { m_originalURL = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyOriginalURL(m_wkItem.get())); return m_originalURL; } -Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item* item) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); - item->ref(); - - return item; -} - -void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item* item) -{ - EINA_SAFETY_ON_NULL_RETURN(item); - - item->deref(); -} - const char* ewk_back_forward_list_item_url_get(const Ewk_Back_Forward_List_Item* item) { - EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkBackForwardListItem, item, impl, 0); - return item->url(); + return impl->url(); } const char* ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item* item) { - EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkBackForwardListItem, item, impl, 0); - return item->title(); + return impl->title(); } const char* ewk_back_forward_list_item_original_url_get(const Ewk_Back_Forward_List_Item* item) { - EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkBackForwardListItem, item, impl, 0); - return item->originalURL(); + return impl->originalURL(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h index 8d0724d4a..18bc61146 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h @@ -37,26 +37,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Back_Forward_List_Item */ -typedef struct Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item; - /** - * Increases the reference count of the given object. - * - * @param item the back-forward list item instance to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item *item); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count reaches 0, the item is freed. + * Declare Ewk_Back_Forward_List_Item as Ewk_Object. * - * @param item the back-forward list item instance to decrease the reference count + * @see Ewk_Object */ -EAPI void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item); +typedef struct Ewk_Object Ewk_Back_Forward_List_Item; /** * Returns URL of the item. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h index 50718bc26..87525169b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h @@ -27,19 +27,21 @@ #define ewk_back_forward_list_item_private_h #include "WKEinaSharedString.h" +#include "ewk_object_private.h" #include <WebKit2/WKBase.h> #include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> /** * \struct Ewk_Back_Forward_List * @brief Contains the Back Forward List data. */ -class Ewk_Back_Forward_List_Item : public RefCounted<Ewk_Back_Forward_List_Item> { +class EwkBackForwardListItem : public Ewk_Object { public: - static PassRefPtr<Ewk_Back_Forward_List_Item> create(WKBackForwardListItemRef itemRef) + EWK_OBJECT_DECLARE(EwkBackForwardListItem) + + static PassRefPtr<EwkBackForwardListItem> create(WKBackForwardListItemRef itemRef) { - return adoptRef(new Ewk_Back_Forward_List_Item(itemRef)); + return adoptRef(new EwkBackForwardListItem(itemRef)); } const char* url() const; @@ -47,7 +49,7 @@ public: const char* originalURL() const; private: - explicit Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef); + explicit EwkBackForwardListItem(WKBackForwardListItemRef itemRef); WKRetainPtr<WKBackForwardListItemRef> m_wkItem; mutable WKEinaSharedString m_url; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h index 7aad46700..fd0db1247 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h @@ -27,6 +27,7 @@ #define ewk_back_forward_list_private_h #include "WKRetainPtr.h" +#include "ewk_back_forward_list_item.h" #include "ewk_back_forward_list_item_private.h" #include <WebKit2/WKBase.h> #include <wtf/HashMap.h> diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp new file mode 100644 index 000000000..24bd0ed60 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp @@ -0,0 +1,84 @@ +/* + Copyright (C) 2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + 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 "config.h" +#include "ewk_color_picker.h" + +#include "WKColorPickerResultListener.h" +#include "WKString.h" +#include "ewk_color_picker_private.h" +#include <WebCore/Color.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +using namespace WebCore; + +#if ENABLE(INPUT_TYPE_COLOR) +Ewk_Color_Picker::Ewk_Color_Picker(WKColorPickerResultListenerRef colorPickerListener, const Color& initialColor) + : m_colorPickerListener(colorPickerListener) + , m_color(initialColor) +{ +} + +void Ewk_Color_Picker::setColor(const Color& color) +{ + WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data())); + WKColorPickerResultListenerSetColor(m_colorPickerListener.get(), colorString.get()); +} + +const Color& Ewk_Color_Picker::color() const +{ + return m_color; +} +#endif + +Eina_Bool ewk_color_picker_color_set(Ewk_Color_Picker* colorPicker, int r, int g, int b, int a) +{ +#if ENABLE(INPUT_TYPE_COLOR) + EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false); + + colorPicker->setColor(Color(r, g, b, a)); + + return true; +#else + return false; +#endif +} + +Eina_Bool ewk_color_picker_color_get(const Ewk_Color_Picker* colorPicker, int* r, int* g, int* b, int* a) +{ +#if ENABLE(INPUT_TYPE_COLOR) + EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(r, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(g, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(b, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(a, false); + + const Color& color = colorPicker->color(); + *r = color.red(); + *g = color.green(); + *b = color.blue(); + *a = color.alpha(); + + return true; +#else + return false; +#endif +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h new file mode 100644 index 000000000..e13c37e3e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + 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 ewk_color_picker_h +#define ewk_color_picker_h + +#include <Evas.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for @a Ewk_Color_Picker. */ +typedef struct Ewk_Color_Picker Ewk_Color_Picker; + +/** + * Sets the selected color. + * + * The function should only be called when a color has been requested by the document. + * If called when this is not the case or when the input picker has been dismissed, this + * function will fail and return EINA_FALSE. + * + * @param color_picker color picker object + * @param r red channel value to be set + * @param g green channel value to be set + * @param b blue channel value to be set + * @param a alpha channel value to be set + * + * @return @c EINA_TRUE on success @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_color_picker_color_set(Ewk_Color_Picker *color_picker, int r, int g, int b, int a); + +/** + * Gets the currently selected color. + * + * @param color_picker color picker object + * @param r red channel value to be get + * @param g green channel value to be get + * @param b blue channel value to be get + * @param a alpha channel value to be get + * + * @return @c EINA_TRUE on success @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_color_picker_color_get(const Ewk_Color_Picker *color_picker, int *r, int *g, int *b, int *a); + +#ifdef __cplusplus +} +#endif + +#endif /* ewk_color_picker_h */ diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h new file mode 100644 index 000000000..273140bd4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2011 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + 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 ewk_color_picker_private_h +#define ewk_color_picker_private_h + +#if ENABLE(INPUT_TYPE_COLOR) + +#include "WKRetainPtr.h" +#include <WebCore/Color.h> +#include <wtf/PassOwnPtr.h> + +class Ewk_Color_Picker { +public: + static PassOwnPtr<Ewk_Color_Picker> create(WKColorPickerResultListenerRef colorPickerListener, const WebCore::Color& initialColor) + { + return adoptPtr(new Ewk_Color_Picker(colorPickerListener, initialColor)); + } + + const WebCore::Color& color() const; + void setColor(const WebCore::Color&); + +private: + Ewk_Color_Picker(WKColorPickerResultListenerRef colorPickerListener, const WebCore::Color& initialColor); + + WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerListener; + WebCore::Color m_color; +}; + +#endif // ENABLE(INPUT_TYPE_COLOR) + +#endif // ewk_color_picker_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index 32991c5c8..2dbf37857 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -22,7 +22,9 @@ #include "ewk_context.h" #include "BatteryProvider.h" +#include "ContextHistoryClientEfl.h" #include "NetworkInfoProvider.h" +#include "RequestManagerClientEfl.h" #include "VibrationProvider.h" #include "WKAPICast.h" #include "WKContextSoup.h" @@ -32,15 +34,12 @@ #include "WebContext.h" #include "WebIconDatabase.h" #include "WebSoupRequestManagerProxy.h" -#include "ewk_context_download_client_private.h" -#include "ewk_context_history_client_private.h" #include "ewk_context_private.h" -#include "ewk_context_request_manager_client_private.h" #include "ewk_cookie_manager_private.h" -#include "ewk_download_job.h" -#include "ewk_download_job_private.h" +#include "ewk_database_manager_private.h" #include "ewk_favicon_database_private.h" #include "ewk_private.h" +#include "ewk_storage_manager_private.h" #include "ewk_url_scheme_request_private.h" #include <WebCore/FileSystem.h> #include <WebCore/IconDatabase.h> @@ -55,22 +54,7 @@ using namespace WebCore; using namespace WebKit; -struct Ewk_Url_Scheme_Handler { - Ewk_Url_Scheme_Request_Cb callback; - void* userData; - - Ewk_Url_Scheme_Handler() - : callback(0) - , userData(0) - { } - - Ewk_Url_Scheme_Handler(Ewk_Url_Scheme_Request_Cb callback, void* userData) - : callback(callback) - , userData(userData) - { } -}; - -typedef HashMap<WKContextRef, Ewk_Context*> ContextMap; +typedef HashMap<WKContextRef, EwkContext*> ContextMap; static inline ContextMap& contextMap() { @@ -78,25 +62,25 @@ static inline ContextMap& contextMap() return map; } -Ewk_Context::Ewk_Context(WKContextRef context) +EwkContext::EwkContext(WKContextRef context) : m_context(context) - , m_requestManager(WKContextGetSoupRequestManager(context)) - , m_historyClient() -{ - ContextMap::AddResult result = contextMap().add(context, this); - ASSERT_UNUSED(result, result.isNewEntry); - + , m_databaseManager(Ewk_Database_Manager::create(WKContextGetDatabaseManager(m_context.get()))) + , m_storageManager(Ewk_Storage_Manager::create(WKContextGetKeyValueStorageManager(m_context.get()))) #if ENABLE(BATTERY_STATUS) - m_batteryProvider = BatteryProvider::create(context); + , m_batteryProvider(BatteryProvider::create(context)) #endif - #if ENABLE(NETWORK_INFO) - m_networkInfoProvider = NetworkInfoProvider::create(context); + , m_networkInfoProvider(NetworkInfoProvider::create(context)) #endif - #if ENABLE(VIBRATION) - m_vibrationProvider = VibrationProvider::create(context); + , m_vibrationProvider(VibrationProvider::create(context)) #endif + , m_downloadManager(DownloadManagerEfl::create(this)) + , m_requestManagerClient(RequestManagerClientEfl::create(this)) + , m_historyClient(ContextHistoryClientEfl::create(context)) +{ + ContextMap::AddResult result = contextMap().add(context, this); + ASSERT_UNUSED(result, result.isNewEntry); #if ENABLE(MEMORY_SAMPLER) static bool initializeMemorySampler = false; @@ -110,38 +94,34 @@ Ewk_Context::Ewk_Context(WKContextRef context) #endif #if ENABLE(SPELLCHECK) - ewk_text_checker_client_attach(); + Ewk_Text_Checker::initialize(); if (ewk_settings_continuous_spell_checking_enabled_get()) { // Load the default language. ewk_settings_spell_checking_languages_set(0); } #endif - - ewk_context_request_manager_client_attach(this); - ewk_context_download_client_attach(this); - ewk_context_history_client_attach(this); } -Ewk_Context::~Ewk_Context() +EwkContext::~EwkContext() { ASSERT(contextMap().get(m_context.get()) == this); contextMap().remove(m_context.get()); } -PassRefPtr<Ewk_Context> Ewk_Context::create(WKContextRef context) +PassRefPtr<EwkContext> EwkContext::create(WKContextRef context) { if (contextMap().contains(context)) return contextMap().get(context); // Will be ref-ed automatically. - return adoptRef(new Ewk_Context(context)); + return adoptRef(new EwkContext(context)); } -PassRefPtr<Ewk_Context> Ewk_Context::create() +PassRefPtr<EwkContext> EwkContext::create() { return create(adoptWK(WKContextCreate()).get()); } -PassRefPtr<Ewk_Context> Ewk_Context::create(const String& injectedBundlePath) +PassRefPtr<EwkContext> EwkContext::create(const String& injectedBundlePath) { if (!fileExists(injectedBundlePath)) return 0; @@ -152,14 +132,14 @@ PassRefPtr<Ewk_Context> Ewk_Context::create(const String& injectedBundlePath) return create(contextWK.get()); } -PassRefPtr<Ewk_Context> Ewk_Context::defaultContext() +PassRefPtr<EwkContext> EwkContext::defaultContext() { - static RefPtr<Ewk_Context> defaultInstance = create(adoptWK(WKContextCreate()).get()); + static RefPtr<EwkContext> defaultInstance = create(adoptWK(WKContextCreate()).get()); return defaultInstance; } -Ewk_Cookie_Manager* Ewk_Context::cookieManager() +Ewk_Cookie_Manager* EwkContext::cookieManager() { if (!m_cookieManager) m_cookieManager = Ewk_Cookie_Manager::create(WKContextGetCookieManager(m_context.get())); @@ -167,206 +147,177 @@ Ewk_Cookie_Manager* Ewk_Context::cookieManager() return m_cookieManager.get(); } -Ewk_Favicon_Database* Ewk_Context::faviconDatabase() +Ewk_Database_Manager* EwkContext::databaseManager() { - if (!m_faviconDatabase) { - WKRetainPtr<WKIconDatabaseRef> iconDatabase = WKContextGetIconDatabase(m_context.get()); - // Set the database path if it is not open yet. - if (!toImpl(iconDatabase.get())->isOpen()) { - WebContext* webContext = toImpl(m_context.get()); - String databasePath = webContext->iconDatabasePath() + "/" + WebCore::IconDatabase::defaultDatabaseFilename(); - webContext->setIconDatabasePath(databasePath); - } - m_faviconDatabase = Ewk_Favicon_Database::create(iconDatabase.get()); - } + return m_databaseManager.get(); +} - return m_faviconDatabase.get(); +void EwkContext::ensureFaviconDatabase() +{ + if (m_faviconDatabase) + return; + + m_faviconDatabase = Ewk_Favicon_Database::create(toImpl(m_context.get())->iconDatabase()); } -bool Ewk_Context::registerURLScheme(const String& scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) +bool EwkContext::setFaviconDatabaseDirectoryPath(const String& databaseDirectory) { - EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); + ensureFaviconDatabase(); + + WebContext* webContext = toImpl(m_context.get()); - m_urlSchemeHandlers.set(scheme, Ewk_Url_Scheme_Handler(callback, userData)); - toImpl(m_requestManager.get())->registerURIScheme(scheme); + // The database path is already open so its path was + // already set. + if (webContext->iconDatabase()->isOpen()) + return false; + + // If databaseDirectory is empty, we use the default database path for the platform. + String databasePath = databaseDirectory.isEmpty() ? webContext->iconDatabasePath() : pathByAppendingComponent(databaseDirectory, WebCore::IconDatabase::defaultDatabaseFilename()); + webContext->setIconDatabasePath(databasePath); return true; } +Ewk_Favicon_Database* EwkContext::faviconDatabase() +{ + ensureFaviconDatabase(); + ASSERT(m_faviconDatabase); + + return m_faviconDatabase.get(); +} + +Ewk_Storage_Manager* EwkContext::storageManager() const +{ + return m_storageManager.get(); +} + +RequestManagerClientEfl* EwkContext::requestManager() +{ + return m_requestManagerClient.get(); +} + #if ENABLE(VIBRATION) -PassRefPtr<VibrationProvider> Ewk_Context::vibrationProvider() +PassRefPtr<VibrationProvider> EwkContext::vibrationProvider() { return m_vibrationProvider; } #endif -void Ewk_Context::addVisitedLink(const String& visitedURL) +void EwkContext::addVisitedLink(const String& visitedURL) { toImpl(m_context.get())->addVisitedLink(visitedURL); } -void Ewk_Context::setCacheModel(Ewk_Cache_Model cacheModel) +void EwkContext::setCacheModel(Ewk_Cache_Model cacheModel) { WKContextSetCacheModel(m_context.get(), static_cast<Ewk_Cache_Model>(cacheModel)); } -Ewk_Cache_Model Ewk_Context::cacheModel() const +Ewk_Cache_Model EwkContext::cacheModel() const { return static_cast<Ewk_Cache_Model>(WKContextGetCacheModel(m_context.get())); } -Ewk_Context* ewk_context_ref(Ewk_Context* ewkContext) +Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, 0); - ewkContext->ref(); - - return ewkContext; + return const_cast<EwkContext*>(impl)->cookieManager(); } -void ewk_context_unref(Ewk_Context* ewkContext) +Ewk_Database_Manager* ewk_context_database_manager_get(const Ewk_Context* ewkContext) { - EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, 0); - ewkContext->deref(); + return const_cast<EwkContext*>(impl)->databaseManager(); } -Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext) +Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context* ewkContext, const char* directoryPath) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl, false); - return const_cast<Ewk_Context*>(ewkContext)->cookieManager(); + return impl->setFaviconDatabaseDirectoryPath(String::fromUTF8(directoryPath)); } Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, 0); - return const_cast<Ewk_Context*>(ewkContext)->faviconDatabase(); + return const_cast<EwkContext*>(impl)->faviconDatabase(); } -WKContextRef Ewk_Context::wkContext() +Ewk_Storage_Manager* ewk_context_storage_manager_get(const Ewk_Context* ewkContext) { - return m_context.get(); -} - -/** - * @internal - * Registers that a new download has been requested. - */ -void Ewk_Context::addDownloadJob(Ewk_Download_Job* ewkDownload) -{ - EINA_SAFETY_ON_NULL_RETURN(ewkDownload); - - uint64_t downloadId = ewkDownload->id(); - if (m_downloadJobs.contains(downloadId)) - return; - - m_downloadJobs.add(downloadId, ewkDownload); -} + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, 0); -/** - * @internal - * Returns the #Ewk_Download_Job with the given @a downloadId, or - * @c 0 in case of failure. - */ -Ewk_Download_Job* Ewk_Context::downloadJob(uint64_t downloadId) -{ - return m_downloadJobs.get(downloadId).get(); + return impl->storageManager(); } -/** - * @internal - * Removes the #Ewk_Download_Job with the given @a downloadId from the internal - * HashMap. - */ -void Ewk_Context::removeDownloadJob(uint64_t downloadId) +WKContextRef EwkContext::wkContext() { - m_downloadJobs.remove(downloadId); + return m_context.get(); } -/** - * Retrieve the request manager for @a ewkContext. - * - * @param ewkContext a #Ewk_Context object. - */ -WKSoupRequestManagerRef Ewk_Context::requestManager() +DownloadManagerEfl* EwkContext::downloadManager() const { - return m_requestManager.get(); + return m_downloadManager.get(); } -/** - * @internal - * A new URL request was received. - * - * @param ewkContext a #Ewk_Context object. - * @param schemeRequest a #Ewk_Url_Scheme_Request object. - */ -void Ewk_Context::urlSchemeRequestReceived(Ewk_Url_Scheme_Request* schemeRequest) +ContextHistoryClientEfl* EwkContext::historyClient() { - EINA_SAFETY_ON_NULL_RETURN(schemeRequest); - - Ewk_Url_Scheme_Handler handler = m_urlSchemeHandlers.get(schemeRequest->scheme()); - if (!handler.callback) - return; - - handler.callback(schemeRequest, handler.userData); + return m_historyClient.get(); } Ewk_Context* ewk_context_default_get() { - return Ewk_Context::defaultContext().get(); + return EwkContext::defaultContext().get(); } Ewk_Context* ewk_context_new() { - return Ewk_Context::create().leakRef(); + return EwkContext::create().leakRef(); } Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path) { EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0); - return Ewk_Context::create(String::fromUTF8(path)).leakRef(); + return EwkContext::create(String::fromUTF8(path)).leakRef(); } Eina_Bool ewk_context_url_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); - return ewkContext->registerURLScheme(String::fromUTF8(scheme), callback, userData); + impl->requestManager()->registerURLSchemeHandler(String::fromUTF8(scheme), callback, userData); + + return true; } void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void* data) { - EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl); #if ENABLE(VIBRATION) - ewkContext->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data); + impl->vibrationProvider()->setVibrationClientCallbacks(vibrate, cancel, data); #endif } void ewk_context_history_callbacks_set(Ewk_Context* ewkContext, Ewk_History_Navigation_Cb navigate, Ewk_History_Client_Redirection_Cb clientRedirect, Ewk_History_Server_Redirection_Cb serverRedirect, Ewk_History_Title_Update_Cb titleUpdate, Ewk_History_Populate_Visited_Links_Cb populateVisitedLinks, void* data) { - EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl); - Ewk_Context_History_Client& historyClient = ewkContext->historyClient(); - historyClient.navigate_func = navigate; - historyClient.client_redirect_func = clientRedirect; - historyClient.server_redirect_func = serverRedirect; - historyClient.title_update_func = titleUpdate; - historyClient.populate_visited_links_func = populateVisitedLinks; - historyClient.user_data = data; + impl->historyClient()->setCallbacks(navigate, clientRedirect, serverRedirect, titleUpdate, populateVisitedLinks, data); } - void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL) { - EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl); EINA_SAFETY_ON_NULL_RETURN(visitedURL); - ewkContext->addVisitedLink(visitedURL); + impl->addVisitedLink(visitedURL); } // Ewk_Cache_Model enum validation @@ -376,17 +327,17 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPr Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkContext, ewkContext, impl, false); - ewkContext->setCacheModel(cacheModel); + impl->setCacheModel(cacheModel); return true; } Ewk_Cache_Model ewk_context_cache_model_get(const Ewk_Context* ewkContext) { - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, EWK_CACHE_MODEL_DOCUMENT_VIEWER); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkContext, ewkContext, impl, EWK_CACHE_MODEL_DOCUMENT_VIEWER); - return ewkContext->cacheModel(); + return impl->cacheModel(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h index f6b8bb67d..4a8e95655 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h @@ -38,8 +38,10 @@ #define ewk_context_h #include "ewk_cookie_manager.h" +#include "ewk_database_manager.h" #include "ewk_favicon_database.h" #include "ewk_navigation_data.h" +#include "ewk_storage_manager.h" #include "ewk_url_scheme_request.h" #include <Evas.h> @@ -47,8 +49,12 @@ extern "C" { #endif -/** Creates a type name for @a Ewk_Context. */ -typedef struct Ewk_Context Ewk_Context; +/** + * Declare Ewk_Context as Ewk_Object. + * + * @see Ewk_Object + */ +typedef struct Ewk_Object Ewk_Context; /** * \enum Ewk_Cache_Model @@ -120,24 +126,6 @@ typedef void (*Ewk_History_Title_Update_Cb)(const Evas_Object *view, const char typedef void (*Ewk_History_Populate_Visited_Links_Cb)(void *user_data); /** - * Increases the reference count of the given object. - * - * @param context context object to increase the reference count - * - * @return Ewk_Context object on success or @c NULL on failure - */ -EAPI Ewk_Context *ewk_context_ref(Ewk_Context *context); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count it's reached 0, the Ewk_Context is freed. - * - * @param context context object to decrease the reference count - */ -EAPI void ewk_context_unref(Ewk_Context *context); - -/** * Gets default Ewk_Context instance. * * The returned Ewk_Context object @b should not be unref'ed if application @@ -183,6 +171,34 @@ EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path); EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context); /** + * Gets the database manager instance for this @a context. + * + * @param context context object to query + * + * @return Ewk_Database_Manager object instance or @c NULL in case of failure + */ +EAPI Ewk_Database_Manager *ewk_context_database_manager_get(const Ewk_Context *context); + +/** + * Sets the favicon database directory for this @a context. + * + * Sets the directory path to be used to store the favicons database + * for @a context on disk. Passing @c NULL as @a directory_path will + * result in using the default directory for the platform. + * + * Calling this method also means enabling the favicons database for + * its use from the applications, it is therefore expected to be + * called only once. Further calls for the same instance of + * @a context will not have any effect. + * + * @param context context object to update + * @param directory_path database directory path to set + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context *context, const char *directory_path); + +/** * Gets the favicon database instance for this @a context. * * @param context context object to query. @@ -192,6 +208,15 @@ EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *conte EAPI Ewk_Favicon_Database *ewk_context_favicon_database_get(const Ewk_Context *context); /** + * Gets the storage manager instance for this @a context. + * + * @param context context object to query. + * + * @return Ewk_Storage_Manager object instance or @c NULL in case of failure. + */ +EAPI Ewk_Storage_Manager *ewk_context_storage_manager_get(const Ewk_Context *context); + +/** * Register @a scheme in @a context. * * When an URL request with @a scheme is made in the #Ewk_Context, the callback diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp deleted file mode 100644 index 2fa86e9a7..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "DownloadProxy.h" -#include "WKAPICast.h" -#include "WKContext.h" -#include "WKString.h" -#include "ewk_context_download_client_private.h" -#include "ewk_context_private.h" -#include "ewk_download_job.h" -#include "ewk_download_job_private.h" -#include "ewk_error_private.h" -#include "ewk_url_response.h" -#include "ewk_url_response_private.h" -#include "ewk_view_private.h" -#include <string.h> -#include <wtf/OwnPtr.h> -#include <wtf/text/CString.h> - -using namespace WebKit; - -static inline Ewk_Context* toEwkContext(const void* clientInfo) -{ - return static_cast<Ewk_Context*>(const_cast<void*>(clientInfo)); -} - -static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* /*allowOverwrite*/, const void* clientInfo) -{ - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(toImpl(wkDownload)->downloadID()); - ASSERT(download); - - download->setSuggestedFileName(toImpl(filename)->string().utf8().data()); - - // We send the new download signal on the Ewk_View only once we have received the response - // and the suggested file name. - ewk_view_download_job_requested(download->view(), download); - - // DownloadSoup expects the destination to be a URL. - String destination = ASCIILiteral("file://") + String::fromUTF8(download->destination()); - - return WKStringCreateWithUTF8CString(destination.utf8().data()); -} - -static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo) -{ - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(toImpl(wkDownload)->downloadID()); - ASSERT(download); - download->setResponse(Ewk_Url_Response::create(wkResponse)); -} - -static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef /*path*/, const void* clientInfo) -{ - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(toImpl(wkDownload)->downloadID()); - ASSERT(download); - - download->setState(EWK_DOWNLOAD_JOB_STATE_DOWNLOADING); -} - -static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo) -{ - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(toImpl(wkDownload)->downloadID()); - ASSERT(download); - download->incrementReceivedData(length); -} - -static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void* clientInfo) -{ - uint64_t downloadId = toImpl(wkDownload)->downloadID(); - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(downloadId); - ASSERT(download); - - OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); - download->setState(EWK_DOWNLOAD_JOB_STATE_FAILED); - ewk_view_download_job_failed(download->view(), download, ewkError.get()); - toEwkContext(clientInfo)->removeDownloadJob(downloadId); -} - -static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo) -{ - uint64_t downloadId = toImpl(wkDownload)->downloadID(); - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(downloadId); - ASSERT(download); - - download->setState(EWK_DOWNLOAD_JOB_STATE_CANCELLED); - ewk_view_download_job_cancelled(download->view(), download); - toEwkContext(clientInfo)->removeDownloadJob(downloadId); -} - -static void didFinish(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo) -{ - uint64_t downloadId = toImpl(wkDownload)->downloadID(); - Ewk_Download_Job* download = toEwkContext(clientInfo)->downloadJob(downloadId); - ASSERT(download); - - download->setState(EWK_DOWNLOAD_JOB_STATE_FINISHED); - ewk_view_download_job_finished(download->view(), download); - toEwkContext(clientInfo)->removeDownloadJob(downloadId); -} - -void ewk_context_download_client_attach(Ewk_Context* ewkContext) -{ - WKContextDownloadClient wkDownloadClient; - memset(&wkDownloadClient, 0, sizeof(WKContextDownloadClient)); - - wkDownloadClient.version = kWKContextDownloadClientCurrentVersion; - wkDownloadClient.clientInfo = ewkContext; - wkDownloadClient.didCancel = didCancel; - wkDownloadClient.decideDestinationWithSuggestedFilename = decideDestinationWithSuggestedFilename; - wkDownloadClient.didCreateDestination = didCreateDestination; - wkDownloadClient.didReceiveResponse = didReceiveResponse; - wkDownloadClient.didReceiveData = didReceiveData; - wkDownloadClient.didFail = didFail; - wkDownloadClient.didFinish = didFinish; - - WKContextSetDownloadClient(ewkContext->wkContext(), &wkDownloadClient); -} - - diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp deleted file mode 100644 index 4f793b9d0..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "ewk_context.h" - -#include "DownloadProxy.h" -#include "WKAPICast.h" -#include "WKContext.h" -#include "WKEinaSharedString.h" -#include "WKString.h" -#include "ewk_context_history_client_private.h" -#include "ewk_context_private.h" -#include "ewk_navigation_data.h" -#include "ewk_navigation_data_private.h" -#include "ewk_url_response.h" -#include "ewk_url_response_private.h" -#include "ewk_view_private.h" - -using namespace WebKit; - -static inline const Ewk_Context_History_Client& getEwkHistoryClient(const void* clientInfo) -{ - ASSERT(clientInfo); - return static_cast<const Ewk_Context*>(clientInfo)->historyClient(); -} - -static void didNavigateWithNavigationData(WKContextRef, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef, const void* clientInfo) -{ - const Ewk_Context_History_Client& historyClient = getEwkHistoryClient(clientInfo); - - if (!historyClient.navigate_func) - return; - - RefPtr<Ewk_Navigation_Data> navigationDataEwk = Ewk_Navigation_Data::create(navigationData); - historyClient.navigate_func(ewk_view_from_page_get(toImpl(page)), navigationDataEwk.get(), historyClient.user_data); -} - -static void didPerformClientRedirect(WKContextRef, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void* clientInfo) -{ - const Ewk_Context_History_Client& historyClient = getEwkHistoryClient(clientInfo); - - if (!historyClient.client_redirect_func) - return; - - WKEinaSharedString sourceURLString(sourceURL); - WKEinaSharedString destinationURLString(destinationURL); - - historyClient.client_redirect_func(ewk_view_from_page_get(toImpl(page)), sourceURLString, destinationURLString, historyClient.user_data); -} - -static void didPerformServerRedirect(WKContextRef, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void* clientInfo) -{ - const Ewk_Context_History_Client& historyClient = getEwkHistoryClient(clientInfo); - - if (!historyClient.server_redirect_func) - return; - - WKEinaSharedString sourceURLString(sourceURL); - WKEinaSharedString destinationURLString(destinationURL); - - historyClient.server_redirect_func(ewk_view_from_page_get(toImpl(page)), sourceURLString, destinationURLString, historyClient.user_data); -} - -static void didUpdateHistoryTitle(WKContextRef, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef, const void* clientInfo) -{ - const Ewk_Context_History_Client& historyClient = getEwkHistoryClient(clientInfo); - - if (!historyClient.title_update_func) - return; - - WKEinaSharedString titleString(title); - WKEinaSharedString stringURL(URL); - - historyClient.title_update_func(ewk_view_from_page_get(toImpl(page)), titleString, stringURL, historyClient.user_data); -} - -static void populateVisitedLinks(WKContextRef, const void* clientInfo) -{ - const Ewk_Context_History_Client& historyClient = getEwkHistoryClient(clientInfo); - - if (!historyClient.populate_visited_links_func) - return; - - historyClient.populate_visited_links_func(historyClient.user_data); -} - -void ewk_context_history_client_attach(Ewk_Context* ewkContext) -{ - WKContextHistoryClient wkHistoryClient; - memset(&wkHistoryClient, 0, sizeof(WKContextHistoryClient)); - - wkHistoryClient.version = kWKContextHistoryClientCurrentVersion; - wkHistoryClient.clientInfo = ewkContext; - - wkHistoryClient.didNavigateWithNavigationData = didNavigateWithNavigationData; - wkHistoryClient.didPerformClientRedirect = didPerformClientRedirect; - wkHistoryClient.didPerformServerRedirect = didPerformServerRedirect; - wkHistoryClient.didUpdateHistoryTitle = didUpdateHistoryTitle; - wkHistoryClient.populateVisitedLinks = populateVisitedLinks; - - WKContextSetHistoryClient(ewkContext->wkContext(), &wkHistoryClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h index 489f05189..4ddb65324 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h @@ -20,14 +20,18 @@ #ifndef ewk_context_private_h #define ewk_context_private_h +#include "DownloadManagerEfl.h" #include "WKAPICast.h" #include "WKRetainPtr.h" -#include "ewk_context_history_client_private.h" +#include "ewk_context.h" +#include "ewk_object_private.h" -class Ewk_Download_Job; -class Ewk_Url_Scheme_Request; class Ewk_Cookie_Manager; class Ewk_Favicon_Database; + +namespace WebKit { +class ContextHistoryClientEfl; +class RequestManagerClientEfl; #if ENABLE(BATTERY_STATUS) class BatteryProvider; #endif @@ -37,25 +41,33 @@ class NetworkInfoProvider; #if ENABLE(VIBRATION) class VibrationProvider; #endif +} -class Ewk_Context : public RefCounted<Ewk_Context> { +class EwkContext : public Ewk_Object { public: - static PassRefPtr<Ewk_Context> create(WKContextRef context); - static PassRefPtr<Ewk_Context> create(); - static PassRefPtr<Ewk_Context> create(const String& injectedBundlePath); + EWK_OBJECT_DECLARE(EwkContext) + + static PassRefPtr<EwkContext> create(WKContextRef context); + static PassRefPtr<EwkContext> create(); + static PassRefPtr<EwkContext> create(const String& injectedBundlePath); - static PassRefPtr<Ewk_Context> defaultContext(); + static PassRefPtr<EwkContext> defaultContext(); - ~Ewk_Context(); + ~EwkContext(); Ewk_Cookie_Manager* cookieManager(); + Ewk_Database_Manager* databaseManager(); + + bool setFaviconDatabaseDirectoryPath(const String& databaseDirectory); Ewk_Favicon_Database* faviconDatabase(); - bool registerURLScheme(const String& scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData); + Ewk_Storage_Manager* storageManager() const; + + WebKit::RequestManagerClientEfl* requestManager(); #if ENABLE(VIBRATION) - PassRefPtr<VibrationProvider> vibrationProvider(); + PassRefPtr<WebKit::VibrationProvider> vibrationProvider(); #endif void addVisitedLink(const String& visitedURL); @@ -66,41 +78,34 @@ public: WKContextRef wkContext(); - WKSoupRequestManagerRef requestManager(); - - void urlSchemeRequestReceived(Ewk_Url_Scheme_Request*); + WebKit::DownloadManagerEfl* downloadManager() const; - void addDownloadJob(Ewk_Download_Job*); - Ewk_Download_Job* downloadJob(uint64_t downloadId); - void removeDownloadJob(uint64_t downloadId); - - const Ewk_Context_History_Client& historyClient() const { return m_historyClient; } - Ewk_Context_History_Client& historyClient() { return m_historyClient; } + WebKit::ContextHistoryClientEfl* historyClient(); private: - explicit Ewk_Context(WKContextRef); + explicit EwkContext(WKContextRef); + + void ensureFaviconDatabase(); WKRetainPtr<WKContextRef> m_context; OwnPtr<Ewk_Cookie_Manager> m_cookieManager; + OwnPtr<Ewk_Database_Manager> m_databaseManager; OwnPtr<Ewk_Favicon_Database> m_faviconDatabase; + OwnPtr<Ewk_Storage_Manager> m_storageManager; #if ENABLE(BATTERY_STATUS) - RefPtr<BatteryProvider> m_batteryProvider; + RefPtr<WebKit::BatteryProvider> m_batteryProvider; #endif #if ENABLE(NETWORK_INFO) - RefPtr<NetworkInfoProvider> m_networkInfoProvider; + RefPtr<WebKit::NetworkInfoProvider> m_networkInfoProvider; #endif #if ENABLE(VIBRATION) - RefPtr<VibrationProvider> m_vibrationProvider; + RefPtr<WebKit::VibrationProvider> m_vibrationProvider; #endif - HashMap<uint64_t, RefPtr<Ewk_Download_Job> > m_downloadJobs; - - WKRetainPtr<WKSoupRequestManagerRef> m_requestManager; - - typedef HashMap<String, class Ewk_Url_Scheme_Handler> URLSchemeHandlerMap; - URLSchemeHandlerMap m_urlSchemeHandlers; + OwnPtr<WebKit::DownloadManagerEfl> m_downloadManager; + OwnPtr<WebKit::RequestManagerClientEfl> m_requestManagerClient; - Ewk_Context_History_Client m_historyClient; + OwnPtr<WebKit::ContextHistoryClientEfl> m_historyClient; }; #endif // ewk_context_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client_private.h deleted file mode 100644 index 311343890..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client_private.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. 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 ewk_context_request_manager_client_private_h -#define ewk_context_request_manager_client_private_h - -typedef struct Ewk_Context Ewk_Context; - -void ewk_context_request_manager_client_attach(Ewk_Context* context); - -#endif // ewk_context_request_manager_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.cpp new file mode 100644 index 000000000..ddc13b494 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +#include "config.h" +#include "ewk_database_manager.h" + +#include "WKAPICast.h" +#include "WKArray.h" +#include "WKDatabaseManager.h" +#include "ewk_database_manager_private.h" +#include "ewk_error_private.h" +#include "ewk_security_origin.h" +#include "ewk_security_origin_private.h" +#include <wtf/RefCounted.h> + +using namespace WebKit; + +Ewk_Database_Manager::Ewk_Database_Manager(WKDatabaseManagerRef databaseManagerRef) + : m_databaseManager(databaseManagerRef) +{ } + +void Ewk_Database_Manager::getDatabaseOrigins(WKDatabaseManagerGetDatabaseOriginsFunction callback, void* context) const +{ + WKDatabaseManagerGetDatabaseOrigins(m_databaseManager.get(), context, callback); +} + +Eina_List* Ewk_Database_Manager::createOriginList(WKArrayRef origins) const +{ + Eina_List* originList = 0; + const size_t length = WKArrayGetSize(origins); + + for (size_t i = 0; i < length; ++i) { + WKSecurityOriginRef wkOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i)); + RefPtr<Ewk_Security_Origin> origin = m_wrapperCache.get(wkOriginRef); + if (!origin) { + origin = Ewk_Security_Origin::create(wkOriginRef); + m_wrapperCache.set(wkOriginRef, origin); + } + originList = eina_list_append(originList, origin.release().leakRef()); + } + + return originList; +} + +struct Ewk_Database_Origins_Async_Get_Context { + const Ewk_Database_Manager* manager; + Ewk_Database_Origins_Get_Cb callback; + void* userData; + + Ewk_Database_Origins_Async_Get_Context(const Ewk_Database_Manager* manager, Ewk_Database_Origins_Get_Cb callback, void* userData) + : manager(manager) + , callback(callback) + , userData(userData) + { } +}; + +static void getDatabaseOriginsCallback(WKArrayRef origins, WKErrorRef wkError, void* context) +{ + OwnPtr<Ewk_Database_Origins_Async_Get_Context*> webDatabaseContext = adoptPtr(static_cast<Ewk_Database_Origins_Async_Get_Context*>(context)); + Eina_List* originList = webDatabaseContext->manager->createOriginList(origins); + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); + webDatabaseContext->callback(originList, ewkError.get(), webDatabaseContext->userData); +} + +Eina_Bool ewk_database_manager_origins_get(const Ewk_Database_Manager* ewkDatabaseManager, Ewk_Database_Origins_Get_Cb callback, void* userData) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkDatabaseManager, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); + + Ewk_Database_Origins_Async_Get_Context* context = new Ewk_Database_Origins_Async_Get_Context(ewkDatabaseManager, callback, userData); + ewkDatabaseManager->getDatabaseOrigins(getDatabaseOriginsCallback, context); + + return true; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.h new file mode 100644 index 000000000..dc8236c5b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +/** + * @file ewk_database_manager.h + * @brief Describes the Ewk Database Manager API. + * + * Ewk Database Manager manages web database. + */ + +#ifndef ewk_database_manager_h +#define ewk_database_manager_h + +#include "ewk_error.h" +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_Database_Manager. */ +typedef struct Ewk_Database_Manager Ewk_Database_Manager; + +/** + * @typedef Ewk_Database_Origins_Get_Cb Ewk_Database_Origins_Get_Cb + * @brief Callback type for use with ewk_database_manager_origins_get() + * + * @param origins @c Eina_List containing @c Ewk_Security_Origin elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_security_origin_unref() + * to free the items + */ +typedef void (*Ewk_Database_Origins_Get_Cb)(Eina_List *origins, Ewk_Error *error, void *user_data); + +/** + * Gets list of origins using web database asynchronously. + * + * This function allocates memory for context structure made from callback and user_data. + * + * @param manager Ewk_Database_Manager object + * @param callback callback to get database origins + * @param user_data user_data will be passed when result_callback is called, + * -i.e., user data will be kept until callback is called + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_database_manager_origins_get(const Ewk_Database_Manager *manager, Ewk_Database_Origins_Get_Cb callback, void *user_data); + +#ifdef __cplusplus +} +#endif +#endif // ewk_database_manager_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_database_manager_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager_private.h new file mode 100644 index 000000000..1b4a66164 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_database_manager_private.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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 ewk_database_manager_private_h +#define ewk_database_manager_private_h + +#include "WKDatabaseManager.h" +#include "WKRetainPtr.h" +#include "ewk_security_origin_private.h" +#include <WebKit2/WKBase.h> +#include <wtf/PassOwnPtr.h> + +class Ewk_Database_Manager { +public: + static PassOwnPtr<Ewk_Database_Manager> create(WKDatabaseManagerRef databaseManagerRef) + { + return adoptPtr(new Ewk_Database_Manager(databaseManagerRef)); + } + + Eina_List* createOriginList(WKArrayRef wkList) const; + void getDatabaseOrigins(WKDatabaseManagerGetDatabaseOriginsFunction callback, void* context) const; + +private: + explicit Ewk_Database_Manager(WKDatabaseManagerRef); + + WKRetainPtr<WKDatabaseManagerRef> m_databaseManager; + mutable HashMap<WKSecurityOriginRef, RefPtr<Ewk_Security_Origin> > m_wrapperCache; +}; +#endif // ewk_database_manager_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp index 7dc3a1784..3ad7d4dbc 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp @@ -36,36 +36,20 @@ using namespace WebKit; -Ewk_Download_Job::Ewk_Download_Job(WebKit::DownloadProxy* download, Evas_Object* ewkView) +EwkDownloadJob::EwkDownloadJob(WebKit::DownloadProxy* download, EwkViewImpl* viewImpl) : m_downloadProxy(download) - , m_view(ewkView) + , m_viewImpl(viewImpl) , m_state(EWK_DOWNLOAD_JOB_STATE_NOT_STARTED) , m_startTime(-1) , m_endTime(-1) , m_downloaded(0) { } -Ewk_Download_Job* ewk_download_job_ref(Ewk_Download_Job* download) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); - - download->ref(); - - return download; -} - -void ewk_download_job_unref(Ewk_Download_Job* download) -{ - EINA_SAFETY_ON_NULL_RETURN(download); - - download->deref(); -} - /** * @internal * Queries the identifier for this download */ -uint64_t Ewk_Download_Job::id() const +uint64_t EwkDownloadJob::id() const { return m_downloadProxy->downloadID(); } @@ -75,35 +59,35 @@ uint64_t Ewk_Download_Job::id() const * Returns the view this download is attached to. * The view is needed to send notification signals. */ -Evas_Object* Ewk_Download_Job::view() const +EwkViewImpl* EwkDownloadJob::viewImpl() const { - return m_view; + return m_viewImpl; } Ewk_Download_Job_State ewk_download_job_state_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, EWK_DOWNLOAD_JOB_STATE_UNKNOWN); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, EWK_DOWNLOAD_JOB_STATE_UNKNOWN); - return download->state(); + return impl->state(); } -Ewk_Download_Job_State Ewk_Download_Job::state() const +Ewk_Download_Job_State EwkDownloadJob::state() const { return m_state; } Ewk_Url_Request* ewk_download_job_request_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->request(); + return impl->request(); } -Ewk_Url_Request* Ewk_Download_Job::request() const +EwkUrlRequest* EwkDownloadJob::request() const { if (!m_request) { WKRetainPtr<WKURLRequestRef> wkURLRequest(AdoptWK, toAPI(WebURLRequest::create(m_downloadProxy->request()).leakRef())); - m_request = Ewk_Url_Request::create(wkURLRequest.get()); + m_request = EwkUrlRequest::create(wkURLRequest.get()); } return m_request.get(); @@ -111,63 +95,63 @@ Ewk_Url_Request* Ewk_Download_Job::request() const Ewk_Url_Response* ewk_download_job_response_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->response(); + return impl->response(); } -Ewk_Url_Response* Ewk_Download_Job::response() const +EwkUrlResponse* EwkDownloadJob::response() const { return m_response.get(); } const char* ewk_download_job_destination_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->destination(); + return impl->destination(); } -const char* Ewk_Download_Job::destination() const +const char* EwkDownloadJob::destination() const { return m_destination; } Eina_Bool ewk_download_job_destination_set(Ewk_Download_Job* download, const char* destination) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, false); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkDownloadJob, download, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(destination, false); - download->setDestination(destination); + impl->setDestination(destination); return true; } -void Ewk_Download_Job::setDestination(const char* destination) +void EwkDownloadJob::setDestination(const char* destination) { m_destination = destination; } const char* ewk_download_job_suggested_filename_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->suggestedFileName(); + return impl->suggestedFileName(); } -const char* Ewk_Download_Job::suggestedFileName() const +const char* EwkDownloadJob::suggestedFileName() const { return m_suggestedFilename; } Eina_Bool ewk_download_job_cancel(Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, false); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkDownloadJob, download, impl, false); - return download->cancel(); + return impl->cancel(); } -bool Ewk_Download_Job::cancel() +bool EwkDownloadJob::cancel() { if (m_state != EWK_DOWNLOAD_JOB_STATE_DOWNLOADING) return false; @@ -179,12 +163,12 @@ bool Ewk_Download_Job::cancel() double ewk_download_job_estimated_progress_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->estimatedProgress(); + return impl->estimatedProgress(); } -double Ewk_Download_Job::estimatedProgress() const +double EwkDownloadJob::estimatedProgress() const { if (!m_response) return 0; @@ -198,12 +182,12 @@ double Ewk_Download_Job::estimatedProgress() const double ewk_download_job_elapsed_time_get(const Ewk_Download_Job* download) { - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkDownloadJob, download, impl, 0); - return download->elapsedTime(); + return impl->elapsedTime(); } -double Ewk_Download_Job::elapsedTime() const +double EwkDownloadJob::elapsedTime() const { // Download has not started yet. if (m_startTime < 0) @@ -222,7 +206,7 @@ double Ewk_Download_Job::elapsedTime() const * @internal * Sets the URL @a response for this @a download. */ -void Ewk_Download_Job::setResponse(PassRefPtr<Ewk_Url_Response> response) +void EwkDownloadJob::setResponse(PassRefPtr<EwkUrlResponse> response) { ASSERT(response); @@ -233,7 +217,7 @@ void Ewk_Download_Job::setResponse(PassRefPtr<Ewk_Url_Response> response) * @internal * Sets the suggested file name for this @a download. */ -void Ewk_Download_Job::setSuggestedFileName(const char* suggestedFilename) +void EwkDownloadJob::setSuggestedFileName(const char* suggestedFilename) { m_suggestedFilename = suggestedFilename; } @@ -242,7 +226,7 @@ void Ewk_Download_Job::setSuggestedFileName(const char* suggestedFilename) * @internal * Report a given amount of data was received. */ -void Ewk_Download_Job::incrementReceivedData(uint64_t length) +void EwkDownloadJob::incrementReceivedData(uint64_t length) { m_downloaded += length; } @@ -251,7 +235,7 @@ void Ewk_Download_Job::incrementReceivedData(uint64_t length) * @internal * Sets the state of the download. */ -void Ewk_Download_Job::setState(Ewk_Download_Job_State state) +void EwkDownloadJob::setState(Ewk_Download_Job_State state) { m_state = state; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h index 156f29a26..4784fc598 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h @@ -43,8 +43,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Download_Job */ -typedef struct Ewk_Download_Job Ewk_Download_Job; +/** + * Declare Ewk_Download_Job as Ewk_Object. + * + * @see Ewk_Object + */ +typedef struct Ewk_Object Ewk_Download_Job; /// Defines the possible states of a download. enum Ewk_Download_Job_State { @@ -67,24 +71,6 @@ enum Ewk_Download_Job_State { typedef enum Ewk_Download_Job_State Ewk_Download_Job_State; /** - * Increases the reference count of the given object. - * - * @param download the download object to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Download_Job *ewk_download_job_ref(Ewk_Download_Job *download); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count reaches 0, the download is freed. - * - * @param download the download object to decrease the reference count - */ -EAPI void ewk_download_job_unref(Ewk_Download_Job *download); - -/** * Query the state for this download. * * @param download a #Ewk_Download_Job to query. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h index e2501d125..d903874e6 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h @@ -28,6 +28,7 @@ #include "WKBase.h" #include "WKEinaSharedString.h" +#include "ewk_download_job.h" #include "ewk_url_request_private.h" #include "ewk_url_response_private.h" #include <Evas.h> @@ -37,22 +38,26 @@ namespace WebKit { class DownloadProxy; } -class Ewk_Download_Job : public RefCounted<Ewk_Download_Job> { +class EwkViewImpl; + +class EwkDownloadJob : public Ewk_Object { public: - static PassRefPtr<Ewk_Download_Job> create(WebKit::DownloadProxy* download, Evas_Object* ewkView) + EWK_OBJECT_DECLARE(EwkDownloadJob) + + static PassRefPtr<EwkDownloadJob> create(WebKit::DownloadProxy* download, EwkViewImpl* viewImpl) { - return adoptRef(new Ewk_Download_Job(download, ewkView)); + return adoptRef(new EwkDownloadJob(download, viewImpl)); } uint64_t id() const; - Evas_Object* view() const; + EwkViewImpl* viewImpl() const; Ewk_Download_Job_State state() const; void setState(Ewk_Download_Job_State); - Ewk_Url_Request* request() const; - Ewk_Url_Response* response() const; - void setResponse(PassRefPtr<Ewk_Url_Response>); + EwkUrlRequest* request() const; + EwkUrlResponse* response() const; + void setResponse(PassRefPtr<EwkUrlResponse>); const char* destination() const; void setDestination(const char* destination); @@ -67,13 +72,13 @@ public: void incrementReceivedData(uint64_t length); private: - Ewk_Download_Job(WebKit::DownloadProxy* download, Evas_Object* ewkView); + EwkDownloadJob(WebKit::DownloadProxy* download, EwkViewImpl* viewImpl); WebKit::DownloadProxy* m_downloadProxy; - Evas_Object* m_view; + EwkViewImpl* m_viewImpl; Ewk_Download_Job_State m_state; - mutable RefPtr<Ewk_Url_Request> m_request; - RefPtr<Ewk_Url_Response> m_response; + mutable RefPtr<EwkUrlRequest> m_request; + RefPtr<EwkUrlResponse> m_response; double m_startTime; double m_endTime; uint64_t m_downloaded; // length already downloaded diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp index 17c99c442..b22afc89d 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp @@ -27,6 +27,7 @@ #include "ewk_favicon_database.h" #include "WKAPICast.h" +#include "WKIconDatabase.h" #include "WKURL.h" #include "WebIconDatabase.h" #include "WebURL.h" @@ -38,8 +39,8 @@ using namespace WebKit; -Ewk_Favicon_Database::Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef) - : m_wkIconDatabase(iconDatabaseRef) +Ewk_Favicon_Database::Ewk_Favicon_Database(WebIconDatabase* iconDatabase) + : m_iconDatabase(iconDatabase) { WKIconDatabaseClient iconDatabaseClient; memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient)); @@ -47,13 +48,17 @@ Ewk_Favicon_Database::Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef) iconDatabaseClient.clientInfo = this; iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL; iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL; - WKIconDatabaseSetIconDatabaseClient(m_wkIconDatabase.get(), &iconDatabaseClient); + WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), &iconDatabaseClient); +} + +Ewk_Favicon_Database::~Ewk_Favicon_Database() +{ } String Ewk_Favicon_Database::iconURLForPageURL(const String& pageURL) const { String iconURL; - toImpl(m_wkIconDatabase.get())->synchronousIconURLForPageURL(pageURL, iconURL); + m_iconDatabase->synchronousIconURLForPageURL(pageURL, iconURL); return iconURL; } @@ -99,8 +104,6 @@ static Eina_Bool respond_icon_request_idle(void* data) void Ewk_Favicon_Database::iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData) { - WebIconDatabase* webIconDatabase = toImpl(m_wkIconDatabase.get()); - // We ask for the icon directly. If we don't get the icon data now, // we'll be notified later (even if the database is still importing icons). RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(pageURL); @@ -110,7 +113,7 @@ void Ewk_Favicon_Database::iconForPageURL(const String& pageURL, const IconReque // finished yet, we need to wait for iconDataReadyForPageURL to be // called before making and informed decision. String iconURL = iconURLForPageURL(pageURL); - if (!surface && (!iconURL.isEmpty() || !webIconDatabase->isUrlImportCompleted())) { + if (!surface && (!iconURL.isEmpty() || !m_iconDatabase->isUrlImportCompleted())) { PendingIconRequestVector requests = m_iconRequests.get(pageURL); requests.append(callbackData); m_iconRequests.set(pageURL, requests); @@ -139,13 +142,11 @@ void Ewk_Favicon_Database::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef p PassRefPtr<cairo_surface_t> Ewk_Favicon_Database::getIconSurfaceSynchronously(const String& pageURL) const { - WebIconDatabase* webIconDatabase = toImpl(m_wkIconDatabase.get()); - - webIconDatabase->retainIconForPageURL(pageURL); + m_iconDatabase->retainIconForPageURL(pageURL); - WebCore::NativeImagePtr icon = webIconDatabase->nativeImageForPageURL(pageURL); + WebCore::NativeImagePtr icon = m_iconDatabase->nativeImageForPageURL(pageURL); if (!icon) { - webIconDatabase->releaseIconForPageURL(pageURL); + m_iconDatabase->releaseIconForPageURL(pageURL); return 0; } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h index b8ba4f666..34da50375 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h @@ -26,12 +26,14 @@ #ifndef ewk_favicon_database_private_h #define ewk_favicon_database_private_h -#include "WKIconDatabase.h" -#include "WKRetainPtr.h" #include "ewk_favicon_database.h" #include <WebKit2/WKBase.h> #include <wtf/HashMap.h> +namespace WebKit { +class WebIconDatabase; +} + struct IconChangeCallbackData { Ewk_Favicon_Database_Icon_Change_Cb callback; void* userData; @@ -71,10 +73,11 @@ typedef HashMap<String /* pageURL */, PendingIconRequestVector> PendingIconReque class Ewk_Favicon_Database { public: - static PassOwnPtr<Ewk_Favicon_Database> create(WKIconDatabaseRef iconDatabaseRef) + static PassOwnPtr<Ewk_Favicon_Database> create(WebKit::WebIconDatabase* iconDatabase) { - return adoptPtr(new Ewk_Favicon_Database(iconDatabaseRef)); + return adoptPtr(new Ewk_Favicon_Database(iconDatabase)); } + ~Ewk_Favicon_Database(); String iconURLForPageURL(const String& pageURL) const; void iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData); @@ -83,14 +86,14 @@ public: void unwatchChanges(Ewk_Favicon_Database_Icon_Change_Cb callback); private: - explicit Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef); + explicit Ewk_Favicon_Database(WebKit::WebIconDatabase* iconDatabase); PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(const String& pageURL) const; static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); - WKRetainPtr<WKIconDatabaseRef> m_wkIconDatabase; + RefPtr<WebKit::WebIconDatabase> m_iconDatabase; ChangeListenerMap m_changeListeners; PendingIconRequestMap m_iconRequests; }; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp new file mode 100644 index 000000000..a990b1b05 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_file_chooser_request.h" + +#include "ImmutableArray.h" +#include "MutableArray.h" +#include "WebOpenPanelParameters.h" +#include "WebOpenPanelResultListenerProxy.h" +#include "WebString.h" +#include "WebURL.h" +#include "ewk_file_chooser_request_private.h" +#include <wtf/text/CString.h> + +using namespace WebKit; + +Ewk_File_Chooser_Request::Ewk_File_Chooser_Request(WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) + : m_parameters(parameters) + , m_listener(listener) + , m_wasRequestHandled(false) +{ + ASSERT(parameters); + ASSERT(listener); +} + +Ewk_File_Chooser_Request::~Ewk_File_Chooser_Request() +{ + if (!m_wasRequestHandled) + m_listener->cancel(); +} + +bool Ewk_File_Chooser_Request::allowMultipleFiles() const +{ + return m_parameters->allowMultipleFiles(); +} + +PassRefPtr<ImmutableArray> Ewk_File_Chooser_Request::acceptedMIMETypes() const +{ + return m_parameters->acceptMIMETypes(); +} + +void Ewk_File_Chooser_Request::cancel() +{ + m_wasRequestHandled = true; + + return m_listener->cancel(); +} + +void Ewk_File_Chooser_Request::chooseFiles(Vector< RefPtr<APIObject> >& fileURLs) +{ + ASSERT(!fileURLs.isEmpty()); + ASSERT(fileURLs.size() == 1 || m_parameters->allowMultipleFiles()); + + m_wasRequestHandled = true; + m_listener->chooseFiles(ImmutableArray::adopt(fileURLs).get()); +} + +Ewk_File_Chooser_Request* ewk_file_chooser_request_ref(Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + request->ref(); + + return request; +} + +void ewk_file_chooser_request_unref(Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN(request); + + request->deref(); +} + +Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + + return request->allowMultipleFiles(); +} + +Eina_List* ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + + Eina_List* mimeTypeList = 0; + RefPtr<ImmutableArray> mimeTypes = request->acceptedMIMETypes(); + + const size_t size = mimeTypes->size(); + for (size_t i = 0; i < size; ++i) { + String mimeTypeString = static_cast<WebString*>(mimeTypes->at(i))->string(); + if (mimeTypeString.isEmpty()) + continue; + mimeTypeList = eina_list_append(mimeTypeList, eina_stringshare_add(mimeTypeString.utf8().data())); + } + + return mimeTypeList; +} + +Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false); + + request->cancel(); + + return true; +} + +Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request* request, const Eina_List* chosenFiles) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(chosenFiles, false); + EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_list_count(chosenFiles) == 1 || request->allowMultipleFiles(), false); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false); + + Vector< RefPtr<APIObject> > fileURLs; + + const Eina_List* l; + void* data; + EINA_LIST_FOREACH(chosenFiles, l, data) { + EINA_SAFETY_ON_NULL_RETURN_VAL(data, false); + String fileURL = "file://" + String::fromUTF8(static_cast<char*>(data)); + fileURLs.append(WebURL::create(fileURL)); + } + + request->chooseFiles(fileURLs); + + return true; +} + +Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request* request, const char* chosenFile) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(chosenFile, false); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->wasHandled(), false); + + Vector< RefPtr<APIObject> > fileURLs; + String fileURL = "file://" + String::fromUTF8(chosenFile); + fileURLs.append(WebURL::create(fileURL)); + + request->chooseFiles(fileURLs); + + return true; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h new file mode 100644 index 000000000..9c23a6bf6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request.h @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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. + */ + +/** + * @file ewk_file_chooser_request.h + * @brief Describes the Ewk File Chooser API. + */ + +#ifndef ewk_file_chooser_request_h +#define ewk_file_chooser_request_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_File_Chooser_Request */ +typedef struct Ewk_File_Chooser_Request Ewk_File_Chooser_Request; + +/** + * Increases the reference count of the given object. + * + * @param request the request object to increase the reference count + * + * @return a pointer to the object on success, @c NULL otherwise + */ +EAPI Ewk_File_Chooser_Request *ewk_file_chooser_request_ref(Ewk_File_Chooser_Request *request); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count reaches 0, the file chooser request is freed. The request + * will be cancelled by default if the client did not act on it. + * + * @param request the request object to decrease the reference count + */ +EAPI void ewk_file_chooser_request_unref(Ewk_File_Chooser_Request *request); + +/** + * Queries if it is allowed to select multiple files or not. + * + * @param request request object to query + * + * @return @c EINA_TRUE if it is allowed to select multiple files, + * @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request *request); + +/** + * Queries the list of accepted MIME types. + * + * Possible MIME types are: + * - "audio\/\*": All sound files are accepted + * - "video\/\*": All video files are accepted + * - "image\/\*": All image files are accepted + * - standard IANA MIME type (see http://www.iana.org/assignments/media-types/ for a complete list) + * + * @param request request object to query + * + * @return The list of accepted MIME types. The list items are guaranteed to be stringshared. + * The caller needs to free the list and its items after use + */ +EAPI Eina_List *ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request *request); + +/** + * Cancels the file chooser request. + * + * @param request request object to cancel + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request *request); + +/** + * Sets the files chosen by the user. + * + * @param request request object to update + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + * + * @see ewk_file_chooser_request_file_choose() + */ +EAPI Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request *request, const Eina_List *chosen_files); + +/** + * Sets the file chosen by the user. + * + * This is a convenience function in case only one file needs to be set. + * + * @param request request object to update + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + * + * @see ewk_file_chooser_request_files_choose() + */ +EAPI Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request *request, const char *chosen_file); + +#ifdef __cplusplus +} +#endif + +#endif /* ewk_file_chooser_request_h */ diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request_private.h index fe801ce6b..6afb7c945 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_file_chooser_request_private.h @@ -23,35 +23,42 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" - -#include "WKBase.h" -#include "WKSoupRequestManager.h" -#include "WKURL.h" -#include "ewk_context_private.h" -#include "ewk_context_request_manager_client_private.h" -#include "ewk_url_scheme_request.h" -#include "ewk_url_scheme_request_private.h" - -static inline Ewk_Context* toEwkContext(const void* clientInfo) -{ - return static_cast<Ewk_Context*>(const_cast<void*>(clientInfo)); -} +#ifndef ewk_file_chooser_request_private_h +#define ewk_file_chooser_request_private_h + +#include "APIObject.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> -static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef, uint64_t requestID, const void* clientInfo) -{ - RefPtr<Ewk_Url_Scheme_Request> schemeRequest = Ewk_Url_Scheme_Request::create(soupRequestManagerRef, urlRef, requestID); - toEwkContext(clientInfo)->urlSchemeRequestReceived(schemeRequest.get()); +namespace WebKit { +class ImmutableArray; +class WebOpenPanelParameters; +class WebOpenPanelResultListenerProxy; } -void ewk_context_request_manager_client_attach(Ewk_Context* context) -{ - WKSoupRequestManagerClient wkRequestManagerClient; - memset(&wkRequestManagerClient, 0, sizeof(WKSoupRequestManagerClient)); +class Ewk_File_Chooser_Request : public RefCounted<Ewk_File_Chooser_Request> { +public: + static PassRefPtr<Ewk_File_Chooser_Request> create(WebKit::WebOpenPanelParameters* parameters, WebKit::WebOpenPanelResultListenerProxy* listener) + { + return adoptRef(new Ewk_File_Chooser_Request(parameters, listener)); + } - wkRequestManagerClient.version = kWKSoupRequestManagerClientCurrentVersion; - wkRequestManagerClient.clientInfo = context; - wkRequestManagerClient.didReceiveURIRequest = didReceiveURIRequest; + ~Ewk_File_Chooser_Request(); - WKSoupRequestManagerSetClient(context->requestManager(), &wkRequestManagerClient); -} + bool allowMultipleFiles() const; + PassRefPtr<WebKit::ImmutableArray> acceptedMIMETypes() const; + inline bool wasHandled() const { return m_wasRequestHandled; } + void cancel(); + void chooseFiles(Vector< RefPtr<WebKit::APIObject> >& fileURLs); + +private: + Ewk_File_Chooser_Request(WebKit::WebOpenPanelParameters* parameters, WebKit::WebOpenPanelResultListenerProxy* listener); + + RefPtr<WebKit::WebOpenPanelParameters> m_parameters; + RefPtr<WebKit::WebOpenPanelResultListenerProxy> m_listener; + bool m_wasRequestHandled; +}; + +#endif // ewk_file_chooser_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp index 17e2b1eea..890bc699a 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp @@ -25,6 +25,7 @@ #include "ewk_private.h" #include <Ecore.h> #include <Ecore_Evas.h> +#include <Ecore_IMF.h> #include <Edje.h> #include <Eina.h> #include <Evas.h> @@ -72,6 +73,11 @@ int ewk_init(void) goto error_ecore_evas; } + if (!ecore_imf_init()) { + CRITICAL("could not init ecore_imf."); + goto error_ecore_imf; + } + #ifdef HAVE_ECORE_X if (!ecore_x_init(0)) { CRITICAL("could not init ecore_x."); @@ -90,8 +96,10 @@ int ewk_init(void) #ifdef HAVE_ECORE_X error_ecore_x: - ecore_evas_shutdown(); + ecore_imf_shutdown(); #endif +error_ecore_imf: + ecore_evas_shutdown(); error_ecore_evas: ecore_shutdown(); error_ecore: @@ -113,6 +121,7 @@ int ewk_shutdown(void) #ifdef HAVE_ECORE_X ecore_x_shutdown(); #endif + ecore_imf_shutdown(); ecore_evas_shutdown(); ecore_shutdown(); evas_shutdown(); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.cpp index 3d1f05f8f..a2ae9a4ef 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.cpp @@ -30,60 +30,44 @@ using namespace WebKit; -Ewk_Navigation_Data::Ewk_Navigation_Data(WKNavigationDataRef dataRef) - : m_request(Ewk_Url_Request::create(adoptWK(WKNavigationDataCopyOriginalRequest(dataRef)).get())) +EwkNavigationData::EwkNavigationData(WKNavigationDataRef dataRef) + : m_request(EwkUrlRequest::create(adoptWK(WKNavigationDataCopyOriginalRequest(dataRef)).get())) , m_title(AdoptWK, WKNavigationDataCopyTitle(dataRef)) , m_url(AdoptWK, WKNavigationDataCopyURL(dataRef)) { } -Ewk_Url_Request* Ewk_Navigation_Data::originalRequest() const +EwkUrlRequest* EwkNavigationData::originalRequest() const { return m_request.get(); } -const char* Ewk_Navigation_Data::title() const +const char* EwkNavigationData::title() const { return m_title; } -const char* Ewk_Navigation_Data::url() const +const char* EwkNavigationData::url() const { return m_url; } -Ewk_Navigation_Data* ewk_navigation_data_ref(Ewk_Navigation_Data* data) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); - - data->ref(); - - return data; -} - -void ewk_navigation_data_unref(Ewk_Navigation_Data* data) -{ - EINA_SAFETY_ON_NULL_RETURN(data); - - data->deref(); -} - const char* ewk_navigation_data_title_get(const Ewk_Navigation_Data* data) { - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkNavigationData, data, impl, 0); - return data->title(); + return impl->title(); } Ewk_Url_Request* ewk_navigation_data_original_request_get(const Ewk_Navigation_Data* data) { - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkNavigationData, data, impl, 0); - return data->originalRequest(); + return impl->originalRequest(); } const char* ewk_navigation_data_url_get(const Ewk_Navigation_Data* data) { - EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkNavigationData, data, impl, 0); - return data->url(); + return impl->url(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h index b3b5c26fc..16f7bc5b8 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h @@ -38,26 +38,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Navigation_Data */ -typedef struct Ewk_Navigation_Data Ewk_Navigation_Data; - /** - * Increases the reference count of the given object. - * - * @param data the navigation data object to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Navigation_Data *ewk_navigation_data_ref(Ewk_Navigation_Data *data); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count reaches 0, the object is freed. + * Declare Ewk_Navigation_Data as Ewk_Object. * - * @param data the navigation data object to decrease the reference count + * @see Ewk_Object */ -EAPI void ewk_navigation_data_unref(Ewk_Navigation_Data *data); +typedef struct Ewk_Object Ewk_Navigation_Data; /** * Returns title for this navigation data. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h index 0d0ecb043..59e0c6976 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h @@ -36,25 +36,27 @@ #include <wtf/RefCounted.h> /** - * \struct Ewk_Navigation_Data + * \struct EwkNavigationData * @brief Contains the navigation data details. */ -class Ewk_Navigation_Data : public RefCounted<Ewk_Navigation_Data> { +class EwkNavigationData : public Ewk_Object { public: - static PassRefPtr<Ewk_Navigation_Data> create(WKNavigationDataRef dataRef) + EWK_OBJECT_DECLARE(EwkNavigationData) + + static PassRefPtr<EwkNavigationData> create(WKNavigationDataRef dataRef) { - return adoptRef(new Ewk_Navigation_Data(dataRef)); + return adoptRef(new EwkNavigationData(dataRef)); } - Ewk_Url_Request* originalRequest() const; + EwkUrlRequest* originalRequest() const; const char* title() const; const char* url() const; private: - explicit Ewk_Navigation_Data(WKNavigationDataRef dataRef); + explicit EwkNavigationData(WKNavigationDataRef dataRef); - RefPtr<Ewk_Url_Request> m_request; + RefPtr<EwkUrlRequest> m_request; WKEinaSharedString m_title; WKEinaSharedString m_url; }; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp index 5c4f24c5b..ad2deefbd 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp @@ -32,7 +32,7 @@ using namespace WebKit; -Ewk_Navigation_Policy_Decision::Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<Ewk_Url_Request> request, const char* frameName) +Ewk_Navigation_Policy_Decision::Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName) : m_listener(listener) , m_actedUponByClient(false) , m_navigationType(navigationType) @@ -69,7 +69,7 @@ const char* Ewk_Navigation_Policy_Decision::frameName() const return m_frameName; } -Ewk_Url_Request* Ewk_Navigation_Policy_Decision::request() const +EwkUrlRequest* Ewk_Navigation_Policy_Decision::request() const { return m_request.get(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision_private.h index 95a18b7c2..66feb3151 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision_private.h @@ -46,8 +46,7 @@ public: static PassRefPtr<Ewk_Navigation_Policy_Decision> create(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef requestRef, const char* frameName, WKFramePolicyListenerRef listener) { - RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(requestRef); - return adoptRef(new Ewk_Navigation_Policy_Decision(listener, static_cast<Ewk_Navigation_Type>(navigationType), static_cast<Event_Mouse_Button>(mouseButton), static_cast<Event_Modifier_Keys>(modifiers), request.release(), frameName)); + return adoptRef(new Ewk_Navigation_Policy_Decision(listener, static_cast<Ewk_Navigation_Type>(navigationType), static_cast<Event_Mouse_Button>(mouseButton), static_cast<Event_Modifier_Keys>(modifiers), EwkUrlRequest::create(requestRef), frameName)); } void accept(); @@ -58,17 +57,17 @@ public: Event_Mouse_Button mouseButton() const; Event_Modifier_Keys modifiers() const; const char* frameName() const; - Ewk_Url_Request* request() const; + EwkUrlRequest* request() const; private: - Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<Ewk_Url_Request> request, const char* frameName); + Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef listener, Ewk_Navigation_Type navigationType, Event_Mouse_Button mouseButton, Event_Modifier_Keys modifiers, PassRefPtr<EwkUrlRequest> request, const char* frameName); WKRetainPtr<WKFramePolicyListenerRef> m_listener; bool m_actedUponByClient; Ewk_Navigation_Type m_navigationType; Event_Mouse_Button m_mouseButton; Event_Modifier_Keys m_modifiers; - RefPtr<Ewk_Url_Request> m_request; + RefPtr<EwkUrlRequest> m_request; WKEinaSharedString m_frameName; }; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_object.cpp index c67248d96..f25d668d2 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_object.cpp @@ -5,9 +5,9 @@ * 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. + * notice, this item 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 + * notice, this item 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'' @@ -23,12 +23,22 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_view_policy_client_private_h -#define ewk_view_policy_client_private_h +#include "config.h" +#include "ewk_object.h" -#include <Evas.h> -#include <WebKit2/WKBase.h> +#include "ewk_object_private.h" -void ewk_view_policy_client_attach(WKPageRef pageRef, Evas_Object* ewkView); +Ewk_Object* ewk_object_ref(Ewk_Object* object) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(object, 0); + object->ref(); -#endif // ewk_view_policy_client_private_h + return object; +} + +void ewk_object_unref(Ewk_Object* object) +{ + EINA_SAFETY_ON_NULL_RETURN(object); + + object->deref(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h b/Source/WebKit2/UIProcess/API/efl/ewk_object.h index 0a5d60e4f..0349493c8 100644 --- a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_object.h @@ -23,36 +23,43 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef NetworkInfoProvider_h -#define NetworkInfoProvider_h - -#if ENABLE(NETWORK_INFO) +/** + * @file ewk_object.h + * @brief Describes the Ewk Ref Counted API. + */ -#include <NetworkInfoClient.h> -#include <NetworkInfoProviderEfl.h> -#include <WebKit2/WKBase.h> -#include <WebKit2/WKRetainPtr.h> -#include <wtf/PassRefPtr.h> +#ifndef ewk_object_h +#define ewk_object_h -class NetworkInfoProvider : public RefCounted<NetworkInfoProvider>, public WebCore::NetworkInfoClient { -public: - virtual ~NetworkInfoProvider(); - static PassRefPtr<NetworkInfoProvider> create(WKContextRef); +#include <Eina.h> - // NetworkInfoClient interface. - virtual double bandwidth() const; - virtual bool metered() const; +#ifdef __cplusplus +extern "C" { +#endif - virtual void startUpdating(); - virtual void stopUpdating(); +/** Creates a type name for Ewk_Object */ +typedef struct Ewk_Object Ewk_Object; -private: - NetworkInfoProvider(WKContextRef); +/** + * Increases the reference count of the given Ewk_Object. + * + * @param object the Ewk_Object instance to increase the reference count + * + * @return a pointer to the object on success, @c NULL otherwise. + */ +EAPI Ewk_Object *ewk_object_ref(Ewk_Object *object); - WKRetainPtr<WKContextRef> m_wkContext; - WebCore::NetworkInfoProviderEfl m_provider; -}; +/** + * Decreases the reference count of the given Ewk_Object, possibly freeing it. + * + * When the reference count reaches 0, the item is freed. + * + * @param object the Ewk_Object instance to decrease the reference count + */ +EAPI void ewk_object_unref(Ewk_Object *object); -#endif // ENABLE(NETWORK_INFO) -#endif // NetworkInfoProvider_h +#ifdef __cplusplus +} +#endif +#endif // ewk_object_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_object_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_object_private.h new file mode 100644 index 000000000..4d4ccfabc --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_object_private.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2012 Intel Corporation. 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 ewk_object_private_h +#define ewk_object_private_h + +#include <wtf/RefCounted.h> + +class Ewk_Object : public RefCounted<Ewk_Object> { +public: + virtual ~Ewk_Object() { } + virtual const char* instanceClassName() const = 0; +}; + +template <class T> +inline bool ewk_object_is_of_type(const Ewk_Object* object) +{ + return (reinterpret_cast<T>(0)->className() == object->instanceClassName()); +} + +template <class T> +inline bool ewk_object_cast_check(const Ewk_Object* object) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(object, false); + + if (!ewk_object_is_of_type<T>(object)) { + EINA_LOG_CRIT("attempt to convert object of type %s to type %s", + object->instanceClassName(), reinterpret_cast<T>(0)->className()); + ASSERT_NOT_REACHED(); + return false; + } + + return true; +} + +template <class T> +inline const T ewk_object_cast(const Ewk_Object* object) +{ + return ewk_object_cast_check<T>(object) ? static_cast<T>(object) : 0; +} + +template <class T> +inline T ewk_object_cast(Ewk_Object* object) +{ + return ewk_object_cast_check<T>(object) ? static_cast<T>(object) : 0; +} + +#define EWK_OBJ_GET_IMPL_OR_RETURN(ImplClass, object, impl, ...) \ + ImplClass* impl = ewk_object_cast<ImplClass*>(object); \ + if (!impl) \ + return __VA_ARGS__ + + +#define EWK_OBJECT_DECLARE(_className) \ +static const char* className() \ +{ \ + static const char* name = #_className; \ + return name; \ +} \ +virtual const char* instanceClassName() const \ +{ \ + return className(); \ +} + +#endif // ewk_object_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.cpp new file mode 100644 index 000000000..765114e6d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2012 Intel Corporation + * Copyright (C) 2012 Samsung Electronics + * + * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +#include "config.h" +#include "ewk_popup_menu.h" + +#include "EwkViewImpl.h" +#include "WebPopupMenuProxyEfl.h" +#include "ewk_popup_menu_item_private.h" +#include "ewk_popup_menu_private.h" + +using namespace WebKit; + +Ewk_Popup_Menu::Ewk_Popup_Menu(EwkViewImpl* viewImpl, WebPopupMenuProxyEfl* popupMenuProxy, const Vector<WebKit::WebPopupItem>& items, unsigned selectedIndex) + : m_viewImpl(viewImpl) + , m_popupMenuProxy(popupMenuProxy) + , m_popupMenuItems(0) + , m_selectedIndex(selectedIndex) +{ + const size_t size = items.size(); + for (size_t i = 0; i < size; ++i) + m_popupMenuItems = eina_list_append(m_popupMenuItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr()); +} + +Ewk_Popup_Menu::~Ewk_Popup_Menu() +{ + void* item; + EINA_LIST_FREE(m_popupMenuItems, item) + delete static_cast<Ewk_Popup_Menu_Item*>(item); +} + +void Ewk_Popup_Menu::close() +{ + m_viewImpl->closePopupMenu(); +} + +const Eina_List* Ewk_Popup_Menu::items() const +{ + return m_popupMenuItems; +} + +unsigned Ewk_Popup_Menu::selectedIndex() const +{ + return m_selectedIndex; +} + +bool Ewk_Popup_Menu::setSelectedIndex(unsigned selectedIndex) +{ + if (!m_popupMenuProxy) + return false; + + if (selectedIndex >= eina_list_count(m_popupMenuItems)) + return false; + + if (m_selectedIndex == selectedIndex) + return true; + + m_selectedIndex = selectedIndex; + m_popupMenuProxy->valueChanged(selectedIndex); + + return true; +} + +Eina_Bool ewk_popup_menu_close(Ewk_Popup_Menu* popupMenu) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(popupMenu, false); + + popupMenu->close(); + + return true; +} + +Eina_Bool ewk_popup_menu_selected_index_set(Ewk_Popup_Menu* popupMenu, unsigned selectedIndex) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(popupMenu, false); + + return popupMenu->setSelectedIndex(selectedIndex); +} + +unsigned ewk_popup_menu_selected_index_get(const Ewk_Popup_Menu* popupMenu) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(popupMenu, 0); + + return popupMenu->selectedIndex(); +} + +const Eina_List* ewk_popup_menu_items_get(const Ewk_Popup_Menu* popupMenu) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(popupMenu, 0); + + return popupMenu->items(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.h b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.h new file mode 100644 index 000000000..04e17688c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2012 Intel Corporation + * Copyright (C) 2012 Samsung Electronics + * + * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +/** + * @file ewk_popup_menu.h + * @brief Describes the Ewk Popup Menu API. + */ + +#ifndef ewk_popup_menu_h +#define ewk_popup_menu_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_Popup_Menu */ +typedef struct Ewk_Popup_Menu Ewk_Popup_Menu; + +/** + * Selects index of current popup menu. + * + * @param popup_menu popup menu object + * @param index index of item to select + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (e.g. the index is out of range) + */ +EAPI Eina_Bool ewk_popup_menu_selected_index_set(Ewk_Popup_Menu *popup_menu, unsigned index); + +/** + * Returns the index of the currently selected item in the popup menu. + * + * @param popup_menu popup menu object + * + * @return index of the currently selected popup item on success, @c 0 otherwise + */ +EAPI unsigned ewk_popup_menu_selected_index_get(const Ewk_Popup_Menu *popup_menu); + +/** + * Closes current popup menu. + * + * The Ewk_Popup_Menu object becomes invalid after calling this function. + * + * @param popup_menu popup menu object + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_popup_menu_close(Ewk_Popup_Menu *popup_menu); + +/** + * Retrieve the popup menu items + * + * @param popup_menu popup menu object + * + * @return @c list of popup menu items on success, @c NULL otherwise + */ +EAPI const Eina_List *ewk_popup_menu_items_get(const Ewk_Popup_Menu *popup_menu); + +#ifdef __cplusplus +} +#endif + +#endif /* ewk_popup_menu_h */ diff --git a/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_private.h index 4123244c3..bdadc5ec3 100644 --- a/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_private.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2012 Intel Corporation * Copyright (C) 2012 Samsung Electronics * * Redistribution and use in source and binary forms, with or without @@ -23,38 +24,42 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WebKitTextChecker_h -#define WebKitTextChecker_h +#ifndef ewk_popup_menu_private_h +#define ewk_popup_menu_private_h -#if ENABLE(SPELLCHECK) - -#include "TextCheckerEnchant.h" -#include "WKArray.h" -#include "WKPage.h" -#include "WKString.h" +#include <Eina.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> namespace WebKit { +class WebPopupItem; +class WebPopupMenuProxyEfl; +} + +class EwkViewImpl; -// The functions mainly choose between client's implementation of spelling and the WebKit one. +class Ewk_Popup_Menu { +public: + static PassOwnPtr<Ewk_Popup_Menu> create(EwkViewImpl* viewImpl, WebKit::WebPopupMenuProxyEfl* popupMenuProxy, const Vector<WebKit::WebPopupItem>& items, unsigned selectedIndex) + { + return adoptPtr(new Ewk_Popup_Menu(viewImpl, popupMenuProxy, items, selectedIndex)); + } + ~Ewk_Popup_Menu(); -// Callbacks required by WKTextChecker. -bool isContinuousSpellCheckingEnabled(const void* clientInfo); -void setContinuousSpellCheckingEnabled(bool enabled, const void* clientInfo); + void close(); -uint64_t uniqueSpellDocumentTag(WKPageRef page, const void* clientInfo); -void closeSpellDocumentWithTag(uint64_t tag, const void* clientInfo); + const Eina_List* items() const; -void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo); -WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void* clientInfo); -void learnWord(uint64_t tag, WKStringRef word, const void* clientInfo); -void ignoreWord(uint64_t tag, WKStringRef word, const void* clientInfo); + bool setSelectedIndex(unsigned selectedIndex); + unsigned selectedIndex() const; -// Enchant's helper. -Vector<String> availableSpellCheckingLanguages(); -void updateSpellCheckingLanguages(const Vector<String>& languages); -Vector<String> loadedSpellCheckingLanguages(); +private: + Ewk_Popup_Menu(EwkViewImpl* viewImpl, WebKit::WebPopupMenuProxyEfl*, const Vector<WebKit::WebPopupItem>& items, unsigned selectedIndex); -} // namespace WebKit + EwkViewImpl* m_viewImpl; + WebKit::WebPopupMenuProxyEfl* m_popupMenuProxy; + Eina_List* m_popupMenuItems; + unsigned m_selectedIndex; +}; -#endif // ENABLE(SPELLCHECK) -#endif // WebKitTextChecker_h +#endif // ewk_popup_menu_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.cpp new file mode 100644 index 000000000..bc0f8c7ae --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +#include "config.h" +#include "ewk_security_origin.h" + +#include "WKAPICast.h" +#include "WKSecurityOrigin.h" +#include "ewk_security_origin_private.h" + +using namespace WebKit; + +Ewk_Security_Origin::Ewk_Security_Origin(WKSecurityOriginRef originRef) + : m_wkOrigin(originRef) + , m_host(AdoptWK, WKSecurityOriginCopyHost(originRef)) + , m_protocol(AdoptWK, WKSecurityOriginCopyProtocol(originRef)) +{ } + +const char* Ewk_Security_Origin::host() const +{ + return m_host; +} + +const char* Ewk_Security_Origin::protocol() const +{ + return m_protocol; +} + +uint32_t Ewk_Security_Origin::port() const +{ + return WKSecurityOriginGetPort(m_wkOrigin.get()); +} + +Ewk_Security_Origin* ewk_security_origin_ref(Ewk_Security_Origin* origin) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + + origin->ref(); + return origin; +} + +void ewk_security_origin_unref(Ewk_Security_Origin* origin) +{ + EINA_SAFETY_ON_NULL_RETURN(origin); + + origin->deref(); +} + +const char* ewk_security_origin_host_get(const Ewk_Security_Origin* origin) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + + return origin->host(); +} + +const char* ewk_security_origin_protocol_get(const Ewk_Security_Origin* origin) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + + return origin->protocol(); +} + +uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin* origin) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0); + + return origin->port(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.h b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.h new file mode 100644 index 000000000..5be84165b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +/** + * @file ewk_security_origin.h + * @brief Security Origin API. + * + * Security Origin is the mechanism that defines the access limits of a website. + * Based on information such as domain, protocol and port, you can or cannot grant + * authorization for accessing data and performing certain tasks. + */ + +#ifndef ewk_security_origin_h +#define ewk_security_origin_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_Security_Origin. */ +typedef struct Ewk_Security_Origin Ewk_Security_Origin; + +/** + * Increases the reference count of the given object. + * + * @param origin the origin object to increase the reference count + * + * @return a pointer to the object on success, @c NULL otherwise + */ +EAPI Ewk_Security_Origin *ewk_security_origin_ref(Ewk_Security_Origin *o); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count reaches 0, the origin is freed. + * + * @param origin the origin object to decrease the reference count + */ +EAPI void ewk_security_origin_unref(Ewk_Security_Origin *o); + +/** + * Returns the host of the security origin. + * + * @param o security origin object + * + * @return the host domain pointer or @c NULL if there is not a host scheme. + * This pointer is guaranteed to be eina_stringshare, so whenever possible + * save yourself from cpu cycles and use eina_stringshare_ref() + * instead of eina_stringshare_add() or strdup(). + */ +EAPI const char *ewk_security_origin_host_get(const Ewk_Security_Origin *o); + +/** + * Returns the port of the security origin. + * + * @param o security origin object + * + * @return the port number or @c 0 if there is not a proper security origin scheme + */ +EAPI uint32_t ewk_security_origin_port_get(const Ewk_Security_Origin *o); + +/** + * Returns the protocol of the security origin. + * + * @param o security origin object + * + * @return the protocol scheme pointer or @c NULL if there is not a protocol scheme. + * This pointer is guaranteed to be eina_stringshare, so whenever possible + * save yourself from cpu cycles and use eina_stringshare_ref() + * instead of eina_stringshare_add() or strdup(). + */ +EAPI const char *ewk_security_origin_protocol_get(const Ewk_Security_Origin *o); + +#ifdef __cplusplus +} +#endif +#endif // ewk_security_origin_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_security_origin_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin_private.h new file mode 100644 index 000000000..04012410e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_security_origin_private.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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 ewk_security_origin_private_h +#define ewk_security_origin_private_h + +#include "WKEinaSharedString.h" +#include "WKSecurityOrigin.h" +#include <WebKit2/WKBase.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +class Ewk_Security_Origin : public RefCounted<Ewk_Security_Origin> { +public: + static PassRefPtr<Ewk_Security_Origin> create(WKSecurityOriginRef originRef) + { + return adoptRef(new Ewk_Security_Origin(originRef)); + } + + const char* host() const; + const char* protocol() const; + uint32_t port() const; + +private: + explicit Ewk_Security_Origin(WKSecurityOriginRef originRef); + + WKRetainPtr<WKSecurityOriginRef> m_wkOrigin; + WKEinaSharedString m_host; + WKEinaSharedString m_protocol; +}; + +#endif // ewk_security_origin_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp index 803761168..0b5083f8a 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Samsung Electronics + * Copyright (C) 2012 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,13 +27,15 @@ #include "config.h" #include "ewk_settings.h" +#include "EwkViewImpl.h" #include "ewk_settings_private.h" -#include <WebKit2/WKPreferences.h> -#include <WebKit2/WKPreferencesPrivate.h> +#include <WebKit2/WebPageGroup.h> +#include <WebKit2/WebPageProxy.h> +#include <WebKit2/WebPreferences.h> #if ENABLE(SPELLCHECK) #include "WKTextChecker.h" -#include "WebKitTextChecker.h" +#include "ewk_text_checker_private.h" #include <Ecore.h> #include <wtf/Vector.h> #include <wtf/text/CString.h> @@ -40,6 +43,16 @@ using namespace WebKit; +const WebKit::WebPreferences* Ewk_Settings::preferences() const +{ + return m_viewImpl->page()->pageGroup()->preferences(); +} + +WebKit::WebPreferences* Ewk_Settings::preferences() +{ + return m_viewImpl->page()->pageGroup()->preferences(); +} + #if ENABLE(SPELLCHECK) static struct { bool isContinuousSpellCheckingEnabled : 1; @@ -58,7 +71,7 @@ static Eina_Bool onContinuousSpellCheckingIdler(void*) static Eina_Bool spellCheckingLanguagesSetUpdate(void*) { // FIXME: Consider to delegate calling of this method in WebProcess to do not delay/block UIProcess. - updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages); + Ewk_Text_Checker::updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages); return ECORE_CALLBACK_CANCEL; } @@ -73,7 +86,7 @@ Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool { #if ENABLE(FULLSCREEN_API) EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetFullScreenEnabled(settings->preferences.get(), enable); + settings->preferences()->setFullScreenEnabled(enable); return true; #else return false; @@ -84,7 +97,7 @@ Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings* settings) { #if ENABLE(FULLSCREEN_API) EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetFullScreenEnabled(settings->preferences.get()); + return settings->preferences()->fullScreenEnabled(); #else return false; #endif @@ -94,7 +107,7 @@ Eina_Bool ewk_settings_javascript_enabled_set(Ewk_Settings* settings, Eina_Bool { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetJavaScriptEnabled(settings->preferences.get(), enable); + settings->preferences()->setJavaScriptEnabled(enable); return true; } @@ -103,14 +116,14 @@ Eina_Bool ewk_settings_javascript_enabled_get(const Ewk_Settings* settings) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetJavaScriptEnabled(settings->preferences.get()); + return settings->preferences()->javaScriptEnabled(); } Eina_Bool ewk_settings_loads_images_automatically_set(Ewk_Settings* settings, Eina_Bool automatic) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetLoadsImagesAutomatically(settings->preferences.get(), automatic); + settings->preferences()->setLoadsImagesAutomatically(automatic); return true; } @@ -119,14 +132,14 @@ Eina_Bool ewk_settings_loads_images_automatically_get(const Ewk_Settings* settin { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetLoadsImagesAutomatically(settings->preferences.get()); + return settings->preferences()->loadsImagesAutomatically(); } Eina_Bool ewk_settings_developer_extras_enabled_set(Ewk_Settings* settings, Eina_Bool enable) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetDeveloperExtrasEnabled(settings->preferences.get(), enable); + settings->preferences()->setDeveloperExtrasEnabled(enable); return true; } @@ -135,14 +148,14 @@ Eina_Bool ewk_settings_developer_extras_enabled_get(const Ewk_Settings* settings { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetDeveloperExtrasEnabled(settings->preferences.get()); + return settings->preferences()->developerExtrasEnabled(); } Eina_Bool ewk_settings_file_access_from_file_urls_allowed_set(Ewk_Settings* settings, Eina_Bool enable) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetFileAccessFromFileURLsAllowed(settings->preferences.get(), enable); + settings->preferences()->setAllowFileAccessFromFileURLs(enable); return true; } @@ -151,14 +164,14 @@ Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetFileAccessFromFileURLsAllowed(settings->preferences.get()); + return settings->preferences()->allowFileAccessFromFileURLs(); } Eina_Bool ewk_settings_frame_flattening_enabled_set(Ewk_Settings* settings, Eina_Bool enable) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetFrameFlatteningEnabled(settings->preferences.get(), enable); + settings->preferences()->setFrameFlatteningEnabled(enable); return true; } @@ -167,14 +180,14 @@ Eina_Bool ewk_settings_frame_flattening_enabled_get(const Ewk_Settings* settings { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetFrameFlatteningEnabled(settings->preferences.get()); + return settings->preferences()->frameFlatteningEnabled(); } Eina_Bool ewk_settings_dns_prefetching_enabled_set(Ewk_Settings* settings, Eina_Bool enable) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - WKPreferencesSetDNSPrefetchingEnabled(settings->preferences.get(), enable); + settings->preferences()->setDNSPrefetchingEnabled(enable); return true; } @@ -183,7 +196,7 @@ Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings* settings) { EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); - return WKPreferencesGetDNSPrefetchingEnabled(settings->preferences.get()); + return settings->preferences()->dnsPrefetchingEnabled(); } void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb callback) @@ -212,7 +225,7 @@ void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable) WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enable); // Sets the default language if user didn't specify any. - if (enable && loadedSpellCheckingLanguages().isEmpty()) + if (enable && Ewk_Text_Checker::loadedSpellCheckingLanguages().isEmpty()) spellCheckingLanguagesSet(Vector<String>()); if (ewkTextCheckerSettings.onContinuousSpellChecking) @@ -225,7 +238,7 @@ Eina_List* ewk_settings_spell_checking_available_languages_get() { Eina_List* listOflanguages = 0; #if ENABLE(SPELLCHECK) - Vector<String> languages = availableSpellCheckingLanguages(); + const Vector<String>& languages = Ewk_Text_Checker::availableSpellCheckingLanguages(); size_t numberOfLanuages = languages.size(); for (size_t i = 0; i < numberOfLanuages; ++i) @@ -248,7 +261,7 @@ Eina_List* ewk_settings_spell_checking_languages_get() { Eina_List* listOflanguages = 0; #if ENABLE(SPELLCHECK) - Vector<String> languages = loadedSpellCheckingLanguages(); + Vector<String> languages = Ewk_Text_Checker::loadedSpellCheckingLanguages(); size_t numberOfLanuages = languages.size(); for (size_t i = 0; i < numberOfLanuages; ++i) @@ -257,3 +270,19 @@ Eina_List* ewk_settings_spell_checking_languages_get() #endif return listOflanguages; } + +Eina_Bool ewk_setting_encoding_detector_enabled_set(Ewk_Settings* settings, Eina_Bool enable) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + settings->preferences()->setUsesEncodingDetector(enable); + + return true; +} + +Eina_Bool ewk_setting_encoding_detector_enabled_get(const Ewk_Settings* settings) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + return settings->preferences()->usesEncodingDetector(); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.h b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h index 861b9917f..5eea469b2 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h @@ -298,6 +298,29 @@ EAPI void ewk_settings_spell_checking_languages_set(const char *languages); */ EAPI Eina_List *ewk_settings_spell_checking_languages_get(void); +/** + * Enables/disables the encoding detector. + * + * By default, the encoding detector is disabled. + * + * @param settings settings object to set the encoding detector + * @param enable @c EINA_TRUE to enable the encoding detector, + * @c EINA_FALSE to disable + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_setting_encoding_detector_enabled_set(Ewk_Settings *settings, Eina_Bool enable); + +/** +* Returns whether the encoding detector is enabled or not. + * + * @param settings settings object to query whether encoding detector is enabled + * + * @return @c EINA_TRUE if the encoding detector is enabled + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_setting_encoding_detector_enabled_get(const Ewk_Settings *settings); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h index 40ae3b781..ea29a8575 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Samsung Electronics + * Copyright (C) 2012 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,21 +27,34 @@ #ifndef ewk_settings_private_h #define ewk_settings_private_h -#include "ewk_settings.h" -#include <WebKit2/WKPreferences.h> -#include <WebKit2/WKRetainPtr.h> #include <wtf/PassOwnPtr.h> +namespace WebKit { +class WebPreferences; +} +class EwkViewImpl; /** * \struct Ewk_Settings * @brief Contains the settings data. */ -struct Ewk_Settings { - WKRetainPtr<WKPreferencesRef> preferences; +class Ewk_Settings { +public: + static PassOwnPtr<Ewk_Settings> create(EwkViewImpl* viewImpl) + { + return adoptPtr(new Ewk_Settings(viewImpl)); + } - explicit Ewk_Settings(WKPreferencesRef wkPreferences) - : preferences(wkPreferences) - { } + const WebKit::WebPreferences* preferences() const; + WebKit::WebPreferences* preferences(); + +private: + explicit Ewk_Settings(EwkViewImpl* viewImpl) + : m_viewImpl(viewImpl) + { + ASSERT(m_viewImpl); + } + + EwkViewImpl* m_viewImpl; }; #endif // ewk_settings_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.cpp new file mode 100644 index 000000000..1632b2e6b --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +#include "config.h" +#include "ewk_storage_manager.h" + +#include "WKAPICast.h" +#include "WKArray.h" +#include "WKKeyValueStorageManager.h" +#include "ewk_error_private.h" +#include "ewk_security_origin.h" +#include "ewk_security_origin_private.h" +#include "ewk_storage_manager_private.h" +#include <wtf/RefCounted.h> + +using namespace WebKit; + +Ewk_Storage_Manager::Ewk_Storage_Manager(WKKeyValueStorageManagerRef wkStorageManagerRef) + : m_wkStorageManager(wkStorageManagerRef) +{ } + +void Ewk_Storage_Manager::getStorageOrigins(void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback) const +{ + WKKeyValueStorageManagerGetKeyValueStorageOrigins(m_wkStorageManager.get(), context, callback); +} + +Eina_List* Ewk_Storage_Manager::createOriginList(WKArrayRef origins) const +{ + Eina_List* originList = 0; + const size_t length = WKArrayGetSize(origins); + + for (size_t i = 0; i < length; ++i) { + WKSecurityOriginRef wkOriginRef = static_cast<WKSecurityOriginRef>(WKArrayGetItemAtIndex(origins, i)); + RefPtr<Ewk_Security_Origin> origin = m_wrapperCache.get(wkOriginRef); + if (!origin) { + origin = Ewk_Security_Origin::create(wkOriginRef); + m_wrapperCache.set(wkOriginRef, origin); + } + originList = eina_list_append(originList, origin.release().leakRef()); + } + + return originList; +} + +struct Ewk_Storage_Origins_Async_Get_Context { + const Ewk_Storage_Manager* manager; + Ewk_Storage_Origins_Get_Cb callback; + void* userData; + + Ewk_Storage_Origins_Async_Get_Context(const Ewk_Storage_Manager* manager, Ewk_Storage_Origins_Get_Cb callback, void* userData) + : manager(manager) + , callback(callback) + , userData(userData) + { } +}; + +static void getStorageOriginsCallback(WKArrayRef origins, WKErrorRef wkError, void* context) +{ + Eina_List* originList = 0; + OwnPtr<Ewk_Storage_Origins_Async_Get_Context*> webStorageContext = adoptPtr(static_cast<Ewk_Storage_Origins_Async_Get_Context*>(context)); + + originList = webStorageContext->manager->createOriginList(origins); + + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); + webStorageContext->callback(originList, ewkError.get(), webStorageContext->userData); +} + +Eina_Bool ewk_storage_manager_origins_get(const Ewk_Storage_Manager* ewkStorageManager, Ewk_Storage_Origins_Get_Cb callback, void* userData) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkStorageManager, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); + + Ewk_Storage_Origins_Async_Get_Context* context = new Ewk_Storage_Origins_Async_Get_Context(ewkStorageManager, callback, userData); + ewkStorageManager->getStorageOrigins(context, getStorageOriginsCallback); + + return true; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.h new file mode 100644 index 000000000..d94a556b6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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. + */ + +/** + * @file ewk_storage_manager.h + * @brief Describes the Ewk Storage Manager API. + * + * Ewk Storage Manager manages web storage. + */ + +#ifndef ewk_storage_manager_h +#define ewk_storage_manager_h + +#include "ewk_error.h" +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_Storage_Manager. */ +typedef struct Ewk_Storage_Manager Ewk_Storage_Manager; + +/** + * @typedef Ewk_Storage_Origins_Get_Cb Ewk_Storage_Origins_Get_Cb + * @brief Callback type for use with ewk_storage_manager_origins_get(). + * + * @param origins @c Eina_List containing @c Ewk_Security_Origin elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_security_origin_unref() + * to free the items + */ +typedef void (*Ewk_Storage_Origins_Get_Cb)(Eina_List *origins, Ewk_Error *error, void *user_data); + +/** + * Gets list of origins that are stored in storage db asynchronously. + * + * This function allocates memory for context structure made from callback and user_data. + * + * @param manager Ewk_Storage_Manager object + * @param callback callback to get storage origins + * @param user_data user_data will be passed when result_callback is called, + * -i.e., user data will be kept until callback is called + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_storage_manager_origins_get(const Ewk_Storage_Manager *manager, Ewk_Storage_Origins_Get_Cb callback, void *user_data); + +#ifdef __cplusplus +} +#endif +#endif // ewk_storage_manager_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager_private.h new file mode 100644 index 000000000..5eeea4913 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_storage_manager_private.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2012 Samsung Electronics. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT HOLDER 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 ewk_storage_manager_private_h +#define ewk_storage_manager_private_h + +#include "WKKeyValueStorageManager.h" +#include "WKRetainPtr.h" +#include "ewk_security_origin_private.h" +#include <WebKit2/WKBase.h> +#include <wtf/PassOwnPtr.h> + +class Ewk_Storage_Manager { +public: + static PassOwnPtr<Ewk_Storage_Manager> create(WKKeyValueStorageManagerRef wkStorageManagerRef) + { + return adoptPtr(new Ewk_Storage_Manager(wkStorageManagerRef)); + } + + Eina_List* createOriginList(WKArrayRef wkList) const; + void getStorageOrigins(void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback) const; + +private: + explicit Ewk_Storage_Manager(WKKeyValueStorageManagerRef wkStorageManagerRef); + + WKRetainPtr<WKKeyValueStorageManagerRef> m_wkStorageManager; + mutable HashMap<WKSecurityOriginRef, RefPtr<Ewk_Security_Origin> > m_wrapperCache; +}; + +#endif // ewk_storage_manager_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp index 525d6d4db..e15b8fc1a 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Samsung Electronics + * Copyright (C) 2012 Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,38 +29,149 @@ #if ENABLE(SPELLCHECK) +#include "TextCheckerEnchant.h" +#include "WKAPICast.h" +#include "WKMutableArray.h" +#include "WKRetainPtr.h" +#include "WKString.h" #include "WKTextChecker.h" -#include "WebKitTextChecker.h" +#include "WebPageProxy.h" +#include "WebString.h" +#include "ewk_settings.h" #include "ewk_text_checker_private.h" +#include <Eina.h> +#include <wtf/OwnPtr.h> +#include <wtf/text/CString.h> +using namespace WebCore; using namespace WebKit; -// Initializes the client's functions to @c 0 to be sure that they are not defined. -static Ewk_Text_Checker ewkTextCheckerCallbacks = { - 0, // unique_spell_document_tag_get - 0, // unique_spell_document_tag_close - 0, // string_spelling_check - 0, // word_guesses_get - 0, // word_learn - 0 // word_ignore +/** + * @brief Structure to store client callback functions. + * + * @internal + */ +struct ClientCallbacks { + Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get; + Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close; + Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check; + Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get; + Ewk_Text_Checker_Word_Learn_Cb word_learn; + Ewk_Text_Checker_Word_Ignore_Cb word_ignore; }; -#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ -void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \ -{ \ - ewkTextCheckerCallbacks.NAME = cb; \ +static inline TextCheckerEnchant* textCheckerEnchant() +{ + static OwnPtr<TextCheckerEnchant> textCheckerEnchant = TextCheckerEnchant::create(); + return textCheckerEnchant.get(); +} + +static inline ClientCallbacks& clientCallbacks() +{ + DEFINE_STATIC_LOCAL(ClientCallbacks, clientCallbacks, ()); + return clientCallbacks; +} + +static bool isContinuousSpellCheckingEnabled(const void*) +{ + return ewk_settings_continuous_spell_checking_enabled_get(); +} + +static void setContinuousSpellCheckingEnabled(bool enabled, const void*) +{ + ewk_settings_continuous_spell_checking_enabled_set(enabled); +} + +static uint64_t uniqueSpellDocumentTag(WKPageRef page, const void*) +{ + if (clientCallbacks().unique_spell_document_tag_get) + return clientCallbacks().unique_spell_document_tag_get(toImpl(page)->viewWidget()); + + return 0; +} + +static void closeSpellDocumentWithTag(uint64_t tag, const void*) +{ + if (clientCallbacks().unique_spell_document_tag_close) + clientCallbacks().unique_spell_document_tag_close(tag); +} + +static void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void*) +{ + if (clientCallbacks().string_spelling_check) + clientCallbacks().string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength); + else + textCheckerEnchant()->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength); +} + +static WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void*) +{ + WKMutableArrayRef suggestionsForWord = WKMutableArrayCreate(); + + if (clientCallbacks().word_guesses_get) { + Eina_List* list = clientCallbacks().word_guesses_get(tag, toImpl(word)->string().utf8().data()); + void* item; + + EINA_LIST_FREE(list, item) { + WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(static_cast<const char*>(item))); + WKArrayAppendItem(suggestionsForWord, suggestion.get()); + free(item); + } + } else { + const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toImpl(word)->string()); + size_t numberOfGuesses = guesses.size(); + for (size_t i = 0; i < numberOfGuesses; ++i) { + WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(guesses[i].utf8().data())); + WKArrayAppendItem(suggestionsForWord, suggestion.get()); + } + } + + return suggestionsForWord; +} + +static void learnWord(uint64_t tag, WKStringRef word, const void*) +{ + if (clientCallbacks().word_learn) + clientCallbacks().word_learn(tag, toImpl(word)->string().utf8().data()); + else + textCheckerEnchant()->learnWord(toImpl(word)->string()); +} + +static void ignoreWord(uint64_t tag, WKStringRef word, const void*) +{ + if (clientCallbacks().word_ignore) + clientCallbacks().word_ignore(tag, toImpl(word)->string().utf8().data()); + else + textCheckerEnchant()->ignoreWord(toImpl(word)->string()); +} + +namespace Ewk_Text_Checker { + +Vector<String> availableSpellCheckingLanguages() +{ + return textCheckerEnchant()->availableSpellCheckingLanguages(); +} + +void updateSpellCheckingLanguages(const Vector<String>& languages) +{ + textCheckerEnchant()->updateSpellCheckingLanguages(languages); +} + +Vector<String> loadedSpellCheckingLanguages() +{ + return textCheckerEnchant()->loadedSpellCheckingLanguages(); } /** - * Attaches spellchecker feature. + * Initializes spellcheck feature. * * @internal * - * The default spellchecker feature is based on Enchant library. - * Client may use own implementation of spellchecker previously set + * The default spellcheck feature is based on Enchant library. + * Client may use own spellcheck implementation previously set * through the callback functions. */ -void ewk_text_checker_client_attach() +void initialize() { static bool didInitializeTextCheckerClient = false; if (didInitializeTextCheckerClient) @@ -90,21 +202,12 @@ void ewk_text_checker_client_attach() didInitializeTextCheckerClient = true; } -/* - * Gets the client's callbacks. - * - * @internal - * - * The client't callbacks are not defined by default. - * If the client hasn't set the callback, the corresponding callback will - * return @c 0 and the default WebKit implementation will be used for this - * functionality. - * - * @return the struct with the client's callbacks. - */ -Ewk_Text_Checker* ewk_text_checker_callbacks_get() -{ - return &ewkTextCheckerCallbacks; +} // namespace Ewk_Text_Checker + +#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ +void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \ +{ \ + clientCallbacks().NAME = cb; \ } #else diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h index e74810613..462d314f4 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 Samsung Electronics + * Copyright (C) 2012 Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,24 +31,16 @@ #include "ewk_text_checker.h" -/** - * @brief Structure keeps client's callback functions. - * - * @internal - */ -struct Ewk_Text_Checker { - Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get; - Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close; - Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check; - Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get; - Ewk_Text_Checker_Word_Learn_Cb word_learn; - Ewk_Text_Checker_Word_Ignore_Cb word_ignore; -}; - -Ewk_Text_Checker* ewk_text_checker_callbacks_get(); - -// Makes it visible for WTR. -EAPI void ewk_text_checker_client_attach(); +namespace Ewk_Text_Checker { + +void initialize(); + +// Enchant helpers. +Vector<String> availableSpellCheckingLanguages(); +void updateSpellCheckingLanguages(const Vector<String>& languages); +Vector<String> loadedSpellCheckingLanguages(); + +} #endif // ENABLE(SPELLCHECK) #endif // ewk_text_checker_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp index 55a6801ab..879791a59 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp @@ -30,59 +30,44 @@ using namespace WebKit; -Ewk_Url_Request::Ewk_Url_Request(WKURLRequestRef requestRef) +EwkUrlRequest::EwkUrlRequest(WKURLRequestRef requestRef) : m_url(AdoptWK, WKURLRequestCopyURL(requestRef)) , m_firstParty(AdoptWK, WKURLRequestCopyFirstPartyForCookies(requestRef)) , m_httpMethod(AdoptWK, WKURLRequestCopyHTTPMethod(requestRef)) { } -const char* Ewk_Url_Request::url() const +const char* EwkUrlRequest::url() const { return m_url; } -const char* Ewk_Url_Request::firstParty() const +const char* EwkUrlRequest::firstParty() const { return m_firstParty; } -const char* Ewk_Url_Request::httpMethod() const +const char* EwkUrlRequest::httpMethod() const { return m_httpMethod; } -Ewk_Url_Request* ewk_url_request_ref(Ewk_Url_Request* request) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - request->ref(); - - return request; -} - -void ewk_url_request_unref(Ewk_Url_Request* request) -{ - EINA_SAFETY_ON_NULL_RETURN(request); - - request->deref(); -} - const char* ewk_url_request_url_get(const Ewk_Url_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlRequest, request, impl, 0); - return request->url(); + return impl->url(); } const char* ewk_request_cookies_first_party_get(const Ewk_Url_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlRequest, request, impl, 0); - return request->firstParty(); + return impl->firstParty(); } const char* ewk_url_request_http_method_get(const Ewk_Url_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlRequest, request, impl, 0); - return request->httpMethod(); + return impl->httpMethod(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.h index 987bd8f05..e696dc83d 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.h @@ -37,26 +37,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Url_Request */ -typedef struct Ewk_Url_Request Ewk_Url_Request; - /** - * Increases the reference count of the given object. - * - * @param request the URL request object to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Url_Request *ewk_url_request_ref(Ewk_Url_Request *request); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count reaches 0, the URL request is freed. + * Declare Ewk_Url_Request as Ewk_Object. * - * @param request the URL request object to decrease the reference count + * @see Ewk_Object */ -EAPI void ewk_url_request_unref(Ewk_Url_Request *request); +typedef struct Ewk_Object Ewk_Url_Request; /** * Query URL for this request. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h index 31a1bea4e..e9911054b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h @@ -30,17 +30,20 @@ #include "WKURL.h" #include "WKURLRequest.h" #include "WebURLRequest.h" +#include "ewk_object_private.h" #include <wtf/PassRefPtr.h> /** - * \struct Ewk_Url_Request + * \struct EwkUrlRequest * @brief Contains the URL request data. */ -class Ewk_Url_Request : public RefCounted<Ewk_Url_Request> { +class EwkUrlRequest : public Ewk_Object { public: - static PassRefPtr<Ewk_Url_Request> create(WKURLRequestRef requestRef) + EWK_OBJECT_DECLARE(EwkUrlRequest) + + static PassRefPtr<EwkUrlRequest> create(WKURLRequestRef requestRef) { - return adoptRef(new Ewk_Url_Request(requestRef)); + return adoptRef(new EwkUrlRequest(requestRef)); } const char* url() const; @@ -48,7 +51,7 @@ public: const char* httpMethod() const; private: - explicit Ewk_Url_Request(WKURLRequestRef requestRef); + explicit EwkUrlRequest(WKURLRequestRef requestRef); WKEinaSharedString m_url; WKEinaSharedString m_firstParty; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp index 04e176b84..6d5b87652 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp @@ -31,71 +31,56 @@ using namespace WebKit; -Ewk_Url_Response::Ewk_Url_Response(const WebCore::ResourceResponse& coreResponse) +EwkUrlResponse::EwkUrlResponse(const WebCore::ResourceResponse& coreResponse) : m_coreResponse(coreResponse) , m_url(AdoptWK, WKURLResponseCopyURL(WebKit::toAPI(coreResponse))) , m_mimeType(AdoptWK, WKURLResponseCopyMIMEType(WebKit::toAPI(coreResponse))) { } -int Ewk_Url_Response::httpStatusCode() const +int EwkUrlResponse::httpStatusCode() const { return m_coreResponse.httpStatusCode(); } -const char* Ewk_Url_Response::url() const +const char* EwkUrlResponse::url() const { return m_url; } -const char* Ewk_Url_Response::mimeType() const +const char* EwkUrlResponse::mimeType() const { return m_mimeType; } -unsigned long Ewk_Url_Response::contentLength() const +unsigned long EwkUrlResponse::contentLength() const { return m_coreResponse.expectedContentLength(); } -Ewk_Url_Response* ewk_url_response_ref(Ewk_Url_Response* response) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); - response->ref(); - - return response; -} - -void ewk_url_response_unref(Ewk_Url_Response* response) -{ - EINA_SAFETY_ON_NULL_RETURN(response); - - response->deref(); -} - const char* ewk_url_response_url_get(const Ewk_Url_Response* response) { - EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlResponse, response, impl, 0); - return response->url(); + return impl->url(); } int ewk_url_response_status_code_get(const Ewk_Url_Response* response) { - EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlResponse, response, impl, 0); - return response->httpStatusCode(); + return impl->httpStatusCode(); } const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response) { - EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlResponse, response, impl, 0); - return response->mimeType(); + return impl->mimeType(); } unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* response) { - EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlResponse, response, impl, 0); - return response->contentLength(); + return impl->contentLength(); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h index cad8e0f76..2f34171ee 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.h @@ -37,26 +37,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Url_Response */ -typedef struct Ewk_Url_Response Ewk_Url_Response; - /** - * Increases the reference count of the given object. - * - * @param response the URL response object to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Url_Response *ewk_url_response_ref(Ewk_Url_Response *response); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count reaches 0, the URL response is freed. + * Declare Ewk_Url_Response as Ewk_Object. * - * @param response the URL response object to decrease the reference count + * @see Ewk_Object */ -EAPI void ewk_url_response_unref(Ewk_Url_Response *response); +typedef struct Ewk_Object Ewk_Url_Response; /** * Query URL for this response. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h index 2d918a8fb..fc512d127 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h @@ -29,21 +29,24 @@ #include "WKAPICast.h" #include "WKEinaSharedString.h" #include "WKURLResponse.h" +#include "ewk_object_private.h" #include <WebCore/ResourceResponse.h> #include <wtf/PassRefPtr.h> /** - * \struct Ewk_Url_Response + * \struct EwkUrlResponse * @brief Contains the URL response data. */ -class Ewk_Url_Response : public RefCounted<Ewk_Url_Response> { +class EwkUrlResponse : public Ewk_Object { public: - static PassRefPtr<Ewk_Url_Response> create(WKURLResponseRef wkResponse) + EWK_OBJECT_DECLARE(EwkUrlResponse) + + static PassRefPtr<EwkUrlResponse> create(WKURLResponseRef wkResponse) { if (!wkResponse) return 0; - return adoptRef(new Ewk_Url_Response(WebKit::toImpl(wkResponse)->resourceResponse())); + return adoptRef(new EwkUrlResponse(WebKit::toImpl(wkResponse)->resourceResponse())); } int httpStatusCode() const; @@ -52,7 +55,7 @@ public: unsigned long contentLength() const; private: - explicit Ewk_Url_Response(const WebCore::ResourceResponse& coreResponse); + explicit EwkUrlResponse(const WebCore::ResourceResponse& coreResponse); WebCore::ResourceResponse m_coreResponse; WKEinaSharedString m_url; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp index 04d9118d6..889173088 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp @@ -33,7 +33,7 @@ using namespace WebKit; -Ewk_Url_Scheme_Request::Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID) +EwkUrlSchemeRequest::EwkUrlSchemeRequest(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID) : m_wkRequestManager(manager) , m_url(url) , m_requestID(requestID) @@ -43,27 +43,27 @@ Ewk_Url_Scheme_Request::Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, m_path = soupURI->path; } -uint64_t Ewk_Url_Scheme_Request::id() const +uint64_t EwkUrlSchemeRequest::id() const { return m_requestID; } -const char* Ewk_Url_Scheme_Request::url() const +const char* EwkUrlSchemeRequest::url() const { return m_url; } -const char* Ewk_Url_Scheme_Request::scheme() const +const char* EwkUrlSchemeRequest::scheme() const { return m_scheme; } -const char* Ewk_Url_Scheme_Request::path() const +const char* EwkUrlSchemeRequest::path() const { return m_path; } -void Ewk_Url_Scheme_Request::finish(const void* contentData, uint64_t contentLength, const char* mimeType) +void EwkUrlSchemeRequest::finish(const void* contentData, uint64_t contentLength, const char* mimeType) { WKRetainPtr<WKDataRef> wkData(AdoptWK, WKDataCreate(contentLength ? reinterpret_cast<const unsigned char*>(contentData) : 0, contentLength)); WKRetainPtr<WKStringRef> wkMimeType = mimeType ? adoptWK(WKStringCreateWithUTF8CString(mimeType)) : 0; @@ -72,47 +72,32 @@ void Ewk_Url_Scheme_Request::finish(const void* contentData, uint64_t contentLen WKSoupRequestManagerDidHandleURIRequest(m_wkRequestManager.get(), wkData.get(), contentLength, wkMimeType.get(), m_requestID); } -Ewk_Url_Scheme_Request* ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request* request) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - request->ref(); - - return request; -} - -void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request* request) -{ - EINA_SAFETY_ON_NULL_RETURN(request); - - request->deref(); -} - const char* ewk_url_scheme_request_scheme_get(const Ewk_Url_Scheme_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlSchemeRequest, request, impl, 0); - return request->scheme(); + return impl->scheme(); } const char* ewk_url_scheme_request_url_get(const Ewk_Url_Scheme_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlSchemeRequest, request, impl, 0); - return request->url(); + return impl->url(); } const char* ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request* request) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); + EWK_OBJ_GET_IMPL_OR_RETURN(const EwkUrlSchemeRequest, request, impl, 0); - return request->path(); + return impl->path(); } Eina_Bool ewk_url_scheme_request_finish(Ewk_Url_Scheme_Request* request, const void* contentData, uint64_t contentLength, const char* mimeType) { - EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); + EWK_OBJ_GET_IMPL_OR_RETURN(EwkUrlSchemeRequest, request, impl, false); - request->finish(contentData, contentLength, mimeType); + impl->finish(contentData, contentLength, mimeType); return true; } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h index ce01afc31..62b72158b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h @@ -37,26 +37,12 @@ extern "C" { #endif -/** Creates a type name for Ewk_Url_Scheme_Request */ -typedef struct Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; - /** - * Increases the reference count of the given object. - * - * @param request the URL scheme request object to increase the reference count - * - * @return a pointer to the object on success, @c NULL otherwise. - */ -EAPI Ewk_Url_Scheme_Request *ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request *request); - -/** - * Decreases the reference count of the given object, possibly freeing it. - * - * When the reference count it's reached 0, the URL scheme request is freed. + * Declare Ewk_Url_Scheme_Request as Ewk_Object. * - * @param request the URL request object to decrease the reference count + * @see Ewk_Object */ -EAPI void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request *request); +typedef struct Ewk_Object Ewk_Url_Scheme_Request; /** * Query the URL scheme for this request. diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h index 30fd6f514..65fc9f94a 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request_private.h @@ -31,18 +31,21 @@ #include "WKEinaSharedString.h" #include "WKRetainPtr.h" #include "WKSoupRequestManager.h" +#include "ewk_object_private.h" /** - * \struct Ewk_Url_Scheme_Request + * \struct EwkUrlSchemeRequest * @brief Contains the URL scheme request data. */ -struct Ewk_Url_Scheme_Request : public RefCounted<Ewk_Url_Scheme_Request> { - static PassRefPtr<Ewk_Url_Scheme_Request> create(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID) +class EwkUrlSchemeRequest : public Ewk_Object { +public: + EWK_OBJECT_DECLARE(EwkUrlSchemeRequest) + static PassRefPtr<EwkUrlSchemeRequest> create(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID) { if (!manager || !url) return 0; - return adoptRef(new Ewk_Url_Scheme_Request(manager, url, requestID)); + return adoptRef(new EwkUrlSchemeRequest(manager, url, requestID)); } uint64_t id() const; @@ -53,7 +56,7 @@ struct Ewk_Url_Scheme_Request : public RefCounted<Ewk_Url_Scheme_Request> { void finish(const void* contentData, uint64_t contentLength, const char* mimeType); private: - Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, WKURLRef urlRef, uint64_t requestID); + EwkUrlSchemeRequest(WKSoupRequestManagerRef manager, WKURLRef urlRef, uint64_t requestID); WKRetainPtr<WKSoupRequestManagerRef> m_wkRequestManager; WKEinaSharedString m_url; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index e77751934..429185cef 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -21,61 +21,44 @@ #include "config.h" #include "ewk_view.h" +#include "EwkViewImpl.h" +#include "FindClientEfl.h" +#include "FormClientEfl.h" +#include "InputMethodContextEfl.h" #include "NativeWebKeyboardEvent.h" #include "NativeWebMouseEvent.h" #include "NativeWebWheelEvent.h" -#include "PageClientImpl.h" +#include "PageClientBase.h" #include "PageLoadClientEfl.h" -#include "RefPtrEfl.h" +#include "PagePolicyClientEfl.h" +#include "PageUIClientEfl.h" #include "ResourceLoadClientEfl.h" #include "WKAPICast.h" -#include "WKColorPickerResultListener.h" #include "WKEinaSharedString.h" #include "WKFindOptions.h" #include "WKRetainPtr.h" #include "WKString.h" -#include "WKURL.h" #include "WebContext.h" #include "WebPageGroup.h" -#include "WebPopupItem.h" -#include "WebPopupMenuProxyEfl.h" #include "WebPreferences.h" #include "ewk_back_forward_list_private.h" #include "ewk_context.h" #include "ewk_context_private.h" #include "ewk_favicon_database_private.h" #include "ewk_intent_private.h" -#include "ewk_popup_menu_item.h" -#include "ewk_popup_menu_item_private.h" #include "ewk_private.h" -#include "ewk_resource.h" -#include "ewk_resource_private.h" #include "ewk_settings_private.h" -#include "ewk_view_find_client_private.h" -#include "ewk_view_form_client_private.h" -#include "ewk_view_policy_client_private.h" #include "ewk_view_private.h" -#include "ewk_view_ui_client_private.h" #include <Ecore_Evas.h> -#include <Edje.h> -#include <WebCore/Cursor.h> -#include <WebCore/EflScreenUtilities.h> #include <WebKit2/WKPageGroup.h> #include <wtf/text/CString.h> -#if ENABLE(FULLSCREEN_API) -#include "WebFullScreenManagerProxy.h" -#endif - #if ENABLE(INSPECTOR) #include "WebInspectorProxy.h" #endif -#if USE(ACCELERATED_COMPOSITING) -#include <Evas_GL.h> -#endif - -#if USE(COORDINATED_GRAPHICS) +#if USE(TILED_BACKING_STORE) +#include "PageViewportController.h" #include "PageViewportControllerClientEfl.h" #endif @@ -84,104 +67,14 @@ using namespace WebCore; static const char EWK_VIEW_TYPE_STR[] = "EWK2_View"; -static const int defaultCursorSize = 16; - -static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo); - -typedef HashMap<const WebPageProxy*, const Evas_Object*> PageViewMap; - -static inline PageViewMap& pageViewMap() -{ - DEFINE_STATIC_LOCAL(PageViewMap, map, ()); - return map; -} - -static inline void addToPageViewMap(const Evas_Object* ewkView) -{ - ASSERT(ewkView); - ASSERT(ewk_view_page_get(ewkView)); - PageViewMap::AddResult result = pageViewMap().add(ewk_view_page_get(ewkView), ewkView); - ASSERT_UNUSED(result, result.isNewEntry); -} - -static inline void removeFromPageViewMap(const Evas_Object* ewkView) -{ - ASSERT(ewkView); - ASSERT(ewk_view_page_get(ewkView)); - ASSERT(pageViewMap().contains(ewk_view_page_get(ewkView))); - pageViewMap().remove(ewk_view_page_get(ewkView)); -} - -struct Ewk_View_Private_Data { - OwnPtr<PageClientImpl> pageClient; -#if USE(COORDINATED_GRAPHICS) - OwnPtr<PageViewportControllerClientEfl> pageViewportControllerClient; -#endif - RefPtr<WebPageProxy> pageProxy; - OwnPtr<PageLoadClientEfl> pageLoadClient; - OwnPtr<ResourceLoadClientEfl> resourceLoadClient; - - WKEinaSharedString url; - WKEinaSharedString title; - WKEinaSharedString theme; - WKEinaSharedString customEncoding; - WKEinaSharedString cursorGroup; - WKEinaSharedString faviconURL; - RefPtr<Evas_Object> cursorObject; - OwnPtr<Ewk_Back_Forward_List> backForwardList; - OwnPtr<Ewk_Settings> settings; - bool areMouseEventsEnabled; - WKRetainPtr<WKColorPickerResultListenerRef> colorPickerResultListener; - RefPtr<Ewk_Context> context; -#if ENABLE(TOUCH_EVENTS) - bool areTouchEventsEnabled; -#endif - - WebPopupMenuProxyEfl* popupMenuProxy; - Eina_List* popupMenuItems; - -#ifdef HAVE_ECORE_X - bool isUsingEcoreX; -#endif - -#if USE(ACCELERATED_COMPOSITING) - Evas_GL* evasGl; - Evas_GL_Context* evasGlContext; - Evas_GL_Surface* evasGlSurface; -#endif - - Ewk_View_Private_Data() - : areMouseEventsEnabled(false) -#if ENABLE(TOUCH_EVENTS) - , areTouchEventsEnabled(false) -#endif - , popupMenuProxy(0) - , popupMenuItems(0) -#ifdef HAVE_ECORE_X - , isUsingEcoreX(false) -#endif -#if USE(ACCELERATED_COMPOSITING) - , evasGl(0) - , evasGlContext(0) - , evasGlSurface(0) -#endif - { } - - ~Ewk_View_Private_Data() - { - /* Unregister icon change callback */ - Ewk_Favicon_Database* iconDatabase = context->faviconDatabase(); - iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed); - - void* item; - EINA_LIST_FREE(popupMenuItems, item) - delete static_cast<Ewk_Popup_Menu_Item*>(item); - } -}; - #define EWK_VIEW_TYPE_CHECK(ewkView, result) \ bool result = true; \ do { \ + if (!ewkView) { \ + EINA_LOG_CRIT("null is not a ewk_view"); \ + result = false; \ + break; \ + } \ const char* _tmp_otype = evas_object_type_get(ewkView); \ const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \ if (EINA_UNLIKELY(!_tmp_s)) { \ @@ -189,6 +82,7 @@ struct Ewk_View_Private_Data { ("%p (%s) is not a smart object!", \ ewkView, _tmp_otype ? _tmp_otype : "(null)"); \ result = false; \ + break; \ } \ const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \ if (EINA_UNLIKELY(!_tmp_sc)) { \ @@ -196,6 +90,7 @@ struct Ewk_View_Private_Data { ("%p (%s) is not a smart object!", \ ewkView, _tmp_otype ? _tmp_otype : "(null)"); \ result = false; \ + break; \ } \ if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \ EINA_LOG_CRIT \ @@ -222,19 +117,28 @@ struct Ewk_View_Private_Data { } \ } while (0) -#define EWK_VIEW_PRIV_GET(smartData, priv) \ - Ewk_View_Private_Data* priv = smartData->priv - -#define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \ +#define EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, ...) \ if (!smartData) { \ EINA_LOG_CRIT("smart data is null"); \ return __VA_ARGS__; \ } \ - EWK_VIEW_PRIV_GET(smartData, priv); \ + EwkViewImpl* impl = smartData->priv; \ do { \ - if (!priv) { \ + if (!impl) { \ EINA_LOG_CRIT("no private data for object %p (%s)", \ - smartData->self, evas_object_type_get(smartData->self)); \ + smartData->self, evas_object_type_get(smartData->self)); \ + return __VA_ARGS__; \ + } \ + } while (0) + +#define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \ + EwkViewImpl* impl = 0; \ + do { \ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, __VA_ARGS__); \ + impl = smartData->priv; \ + if (!impl) { \ + EINA_LOG_CRIT("no private data for object %p (%s)", \ + smartData->self, evas_object_type_get(smartData->self)); \ return __VA_ARGS__; \ } \ } while (0) @@ -247,83 +151,78 @@ static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData) evas_object_smart_changed(smartData->self); } -static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo) -{ - Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo); - - const char* view_url = ewk_view_url_get(ewkView); - if (!view_url || strcasecmp(view_url, pageURL)) - return; - - ewk_view_update_icon(ewkView); -} - // Default Event Handling. static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); + impl->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); return true; } static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); + impl->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); return true; } static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position)); + impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen())); return true; } static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(downEvent, &position)); + impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen())); return true; } static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); + + impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen())); + + InputMethodContextEfl* inputMethodContext = impl->inputMethodContext(); + if (inputMethodContext) + inputMethodContext->handleMouseUpEvent(upEvent); - Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(upEvent, &position)); return true; } static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position)); + impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen())); return true; } static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); + + bool isFiltered = false; + InputMethodContextEfl* inputMethodContext = impl->inputMethodContext(); + if (inputMethodContext) + inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered); - priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent)); + impl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered)); return true; } static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent)); + impl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent)); return true; } @@ -353,33 +252,6 @@ static void _ewk_view_on_mouse_wheel(void* data, Evas*, Evas_Object*, void* even smartData->api->mouse_wheel(smartData, wheelEvent); } -static void _ewk_view_on_mouse_down(void* data, Evas*, Evas_Object*, void* eventInfo) -{ - Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo); - Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - EINA_SAFETY_ON_NULL_RETURN(smartData->api); - EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down); - smartData->api->mouse_down(smartData, downEvent); -} - -static void _ewk_view_on_mouse_up(void* data, Evas*, Evas_Object*, void* eventInfo) -{ - Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo); - Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - EINA_SAFETY_ON_NULL_RETURN(smartData->api); - EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up); - smartData->api->mouse_up(smartData, upEvent); -} - -static void _ewk_view_on_mouse_move(void* data, Evas*, Evas_Object*, void* eventInfo) -{ - Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo); - Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - EINA_SAFETY_ON_NULL_RETURN(smartData->api); - EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move); - smartData->api->mouse_move(smartData, moveEvent); -} - static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo) { Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo); @@ -401,84 +273,23 @@ static void _ewk_view_on_key_up(void* data, Evas*, Evas_Object*, void* eventInfo static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/) { Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl); + impl->page()->viewStateDidChange(WebPageProxy::ViewIsVisible); } static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/) { Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl); // This call may look wrong, but we really need to pass ViewIsVisible here. // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process. - priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible); + impl->page()->viewStateDidChange(WebPageProxy::ViewIsVisible); } -#if ENABLE(TOUCH_EVENTS) -static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - - unsigned count = evas_touch_point_list_count(smartData->base.evas); - if (!count) - return; - - Eina_List* points = 0; - for (unsigned i = 0; i < count; ++i) { - Ewk_Touch_Point* point = new Ewk_Touch_Point; - point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i); - evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y); - point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i); - points = eina_list_append(points, point); - } - - ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas)); - - void* data; - EINA_LIST_FREE(points, data) - delete static_cast<Ewk_Touch_Point*>(data); -} - -static void _ewk_view_on_touch_down(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) -{ - _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START); -} - -static void _ewk_view_on_touch_up(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) -{ - _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END); -} - -static void _ewk_view_on_touch_move(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */) -{ - _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE); -} -#endif - static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL; -static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) -{ - Ewk_View_Private_Data* priv = new Ewk_View_Private_Data; - if (!priv) { - EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data"); - return 0; - } - -#ifdef HAVE_ECORE_X - priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas); -#endif - - return priv; -} - -static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) -{ - delete priv; -} - static void _ewk_view_smart_add(Evas_Object* ewkView) { const Evas_Smart* smart = evas_object_smart_smart_get(ewkView); @@ -500,13 +311,7 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) g_parentSmartClass.add(ewkView); - smartData->priv = _ewk_view_priv_new(smartData); - if (!smartData->priv) { - EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data"); - evas_object_smart_data_set(ewkView, 0); - free(smartData); - return; - } + smartData->priv = 0; // Create evas_object_image to draw web contents. smartData->image = evas_object_image_add(smartData->base.evas); @@ -515,8 +320,6 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) evas_object_smart_member_add(smartData->image, ewkView); evas_object_show(smartData->image); - ewk_view_mouse_events_enabled_set(ewkView, true); - #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData) CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in); CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out); @@ -530,10 +333,9 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) static void _ewk_view_smart_del(Evas_Object* ewkView) { - removeFromPageViewMap(ewkView); EWK_VIEW_SD_GET(ewkView, smartData); - if (smartData && smartData->priv) - _ewk_view_priv_del(smartData->priv); + if (smartData) + delete smartData->priv; g_parentSmartClass.del(ewkView); } @@ -558,143 +360,42 @@ static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord /*x*/, Evas_Co _ewk_view_smart_changed(smartData); } -IntSize ewk_view_size_get(const Evas_Object* ewkView) -{ - int width, height; - evas_object_geometry_get(ewkView, 0, 0, &width, &height); - return IntSize(width, height); -} - -#if USE(ACCELERATED_COMPOSITING) -static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - - Evas_GL_Config evasGlConfig = { - EVAS_GL_RGBA_8888, - EVAS_GL_DEPTH_BIT_8, - EVAS_GL_STENCIL_NONE, - EVAS_GL_OPTIONS_NONE, - EVAS_GL_MULTISAMPLE_NONE - }; - - ASSERT(!priv->evasGlSurface); - priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height()); - if (!priv->evasGlSurface) - return false; - - Evas_Native_Surface nativeSurface; - evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface); - evas_object_image_native_surface_set(smartData->image, &nativeSurface); - - return true; -} - -bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - - if (priv->evasGl) { - EINA_LOG_DOM_WARN(_ewk_log_dom, "Accelerated compositing mode already entered."); - return false; - } - - Evas* evas = evas_object_evas_get(ewkView); - priv->evasGl = evas_gl_new(evas); - if (!priv->evasGl) - return false; - - priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0); - if (!priv->evasGlContext) { - evas_gl_free(priv->evasGl); - priv->evasGl = 0; - return false; - } - - if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) { - evas_gl_context_destroy(priv->evasGl, priv->evasGlContext); - priv->evasGlContext = 0; - - evas_gl_free(priv->evasGl); - priv->evasGl = 0; - return false; - } - - priv->pageViewportControllerClient->setRendererActive(true); - return true; -} - -bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - - EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false); - - if (priv->evasGlSurface) { - evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); - priv->evasGlSurface = 0; - } - - if (priv->evasGlContext) { - evas_gl_context_destroy(priv->evasGl, priv->evasGlContext); - priv->evasGlContext = 0; - } - - evas_gl_free(priv->evasGl); - priv->evasGl = 0; - - return true; -} -#endif - static void _ewk_view_smart_calculate(Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - -#if USE(ACCELERATED_COMPOSITING) - bool needsNewSurface = false; -#endif + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl); smartData->changed.any = false; Evas_Coord x, y, width, height; evas_object_geometry_get(ewkView, &x, &y, &width, &height); - if (smartData->changed.size) { -#if USE(COORDINATED_GRAPHICS) - priv->pageViewportControllerClient->updateViewportSize(IntSize(width, height)); -#endif -#if USE(ACCELERATED_COMPOSITING) - needsNewSurface = priv->evasGlSurface; -#endif - - if (priv->pageProxy->drawingArea()) - priv->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize()); - - smartData->view.w = width; - smartData->view.h = height; - smartData->changed.size = false; - } - if (smartData->changed.position) { - evas_object_move(smartData->image, x, y); + smartData->changed.position = false; smartData->view.x = x; smartData->view.y = y; - smartData->changed.position = false; + evas_object_move(smartData->image, x, y); } + if (smartData->changed.size) { + smartData->changed.size = false; + smartData->view.w = width; + smartData->view.h = height; + + if (impl->page()->drawingArea()) + impl->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); + #if USE(ACCELERATED_COMPOSITING) - if (needsNewSurface) { - evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface); - priv->evasGlSurface = 0; - ewk_view_create_gl_surface(ewkView, IntSize(width, height)); - ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height))); - } + // Recreate surface if needed. + if (impl->evasGLSurface()) + impl->clearEvasGLSurface(); + + impl->createGLSurface(IntSize(width, height)); #endif +#if USE(TILED_BACKING_STORE) + impl->pageClient()->updateViewportSize(IntSize(width, height)); +#endif + } } static void _ewk_view_smart_show(Evas_Object* ewkView) @@ -717,7 +418,7 @@ static void _ewk_view_smart_hide(Evas_Object* ewkView) static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl); if (alpha < 0) alpha = 0; @@ -735,8 +436,8 @@ static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, #undef CHECK_COLOR evas_object_image_alpha_set(smartData->image, alpha < 255); - priv->pageProxy->setDrawsBackground(red || green || blue); - priv->pageProxy->setDrawsTransparentBackground(alpha < 255); + impl->page()->setDrawsBackground(red || green || blue); + impl->page()->setDrawsTransparentBackground(alpha < 255); g_parentSmartClass.color_set(ewkView, red, green, blue, alpha); } @@ -780,7 +481,7 @@ Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api) return true; } -static inline Evas_Smart* _ewk_view_smart_class_new(void) +static inline Evas_Smart* createEwkViewSmartClass(void) { static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View"); static Evas_Smart* smart = 0; @@ -793,65 +494,14 @@ static inline Evas_Smart* _ewk_view_smart_class_new(void) return smart; } -static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - EINA_SAFETY_ON_NULL_RETURN(context); - - if (priv->pageClient) - return; - - priv->pageClient = PageClientImpl::create(ewkView); - - if (pageGroupRef) - priv->pageProxy = toImpl(context->wkContext())->createWebPage(priv->pageClient.get(), toImpl(pageGroupRef)); - else - priv->pageProxy = toImpl(context->wkContext())->createWebPage(priv->pageClient.get(), WebPageGroup::create().get()); - - addToPageViewMap(ewkView); - -#if USE(COORDINATED_GRAPHICS) - priv->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); - priv->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true); - priv->pageProxy->setUseFixedLayout(true); -#endif - priv->pageProxy->initializeWebPage(); - - priv->backForwardList = Ewk_Back_Forward_List::create(toAPI(priv->pageProxy->backForwardList())); - priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get()))))); - priv->context = context; - -#if USE(COORDINATED_GRAPHICS) - priv->pageViewportControllerClient = PageViewportControllerClientEfl::create(ewkView); -#endif - - // Initialize page clients. - WKPageRef wkPage = toAPI(priv->pageProxy.get()); - ewk_view_find_client_attach(wkPage, ewkView); - ewk_view_form_client_attach(wkPage, ewkView); - ewk_view_policy_client_attach(wkPage, ewkView); - ewk_view_ui_client_attach(wkPage, ewkView); -#if ENABLE(FULLSCREEN_API) - priv->pageProxy->fullScreenManager()->setWebView(ewkView); - ewk_settings_fullscreen_enabled_set(priv->settings.get(), true); -#endif - priv->pageLoadClient = PageLoadClientEfl::create(ewkView); - priv->resourceLoadClient = ResourceLoadClientEfl::create(ewkView); - - /* Listen for favicon changes */ - Ewk_Favicon_Database* iconDatabase = priv->context->faviconDatabase(); - iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView)); -} - -static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) +static inline Evas_Object* createEwkView(Evas* canvas, Evas_Smart* smart, PassRefPtr<EwkContext> context, WKPageGroupRef pageGroupRef = 0, EwkViewImpl::ViewBehavior behavior = EwkViewImpl::DefaultBehavior) { EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0); Evas_Object* ewkView = evas_object_smart_add(canvas, smart); - if (!ewkView) - return 0; + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0); EWK_VIEW_SD_GET(ewkView, smartData); if (!smartData) { @@ -859,12 +509,9 @@ static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) return 0; } - EWK_VIEW_PRIV_GET(smartData, priv); - if (!priv) { - evas_object_del(ewkView); - return 0; - } - + ASSERT(!smartData->priv); + RefPtr<WebPageGroup> pageGroup = pageGroupRef ? toImpl(pageGroupRef) : WebPageGroup::create(); + smartData->priv = new EwkViewImpl(ewkView, context, pageGroup, behavior); return ewkView; } @@ -874,36 +521,17 @@ static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) */ Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef) { - EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0); - Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new()); - if (!ewkView) - return 0; - - _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef); - - return ewkView; + return createEwkView(canvas, createEwkViewSmartClass(), EwkContext::create(contextRef), pageGroupRef, EwkViewImpl::LegacyBehavior); } Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context) { - EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0); - - Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart); - if (!ewkView) - return 0; - - _ewk_view_initialize(ewkView, context, 0); - - return ewkView; + return createEwkView(canvas, smart, ewk_object_cast<EwkContext*>(context)); } Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context) { - EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0); - return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context); + return ewk_view_smart_add(canvas, createEwkViewSmartClass(), ewk_object_cast<EwkContext*>(context)); } Evas_Object* ewk_view_add(Evas* canvas) @@ -913,470 +541,136 @@ Evas_Object* ewk_view_add(Evas* canvas) Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - return priv->context.get(); -} - -/** - * @internal - * The url of view was changed by the frame loader. - * - * Emits signal: "url,changed" with pointer to new url string. - */ -void ewk_view_url_update(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - String activeURL = priv->pageProxy->activeURL(); - if (activeURL.isEmpty()) - return; - - if (priv->url == activeURL.utf8().data()) - return; - - priv->url = activeURL.utf8().data(); - const char* callbackArgument = static_cast<const char*>(priv->url); - evas_object_smart_callback_call(ewkView, "url,changed", const_cast<char*>(callbackArgument)); - - // Update the view's favicon. - ewk_view_update_icon(ewkView); + return impl->ewkContext(); } Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(url, false); - priv->pageProxy->loadURL(url); - ewk_view_url_update(ewkView); + impl->page()->loadURL(url); + impl->informURLChange(); return true; } const char* ewk_view_url_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - return priv->url; + return impl->url(); } const char *ewk_view_icon_url_get(const Evas_Object *ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - return priv->faviconURL; + return impl->faviconURL(); } Eina_Bool ewk_view_reload(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->reload(/*reloadFromOrigin*/ false); - ewk_view_url_update(ewkView); + impl->page()->reload(/*reloadFromOrigin*/ false); + impl->informURLChange(); return true; } Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->reload(/*reloadFromOrigin*/ true); - ewk_view_url_update(ewkView); + impl->page()->reload(/*reloadFromOrigin*/ true); + impl->informURLChange(); return true; } Eina_Bool ewk_view_stop(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->stopLoading(); + impl->page()->stopLoading(); return true; } Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - return priv->settings.get(); -} - -/** - * @internal - * Retrieves the internal WKPage for this view. - */ -WKPageRef ewk_view_wkpage_get(const Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - - return toAPI(priv->pageProxy.get()); -} - -/** - * @internal - * Load was initiated for a resource in the view. - * - * Emits signal: "resource,request,new" with pointer to resource request. - */ -void ewk_view_resource_load_initiated(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request) -{ - Ewk_Resource_Request resourceRequest = {resource, request, 0}; - - evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest); -} - -/** - * @internal - * Received a response to a resource load request in the view. - * - * Emits signal: "resource,request,response" with pointer to resource response. - */ -void ewk_view_resource_load_response(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Response* response) -{ - Ewk_Resource_Load_Response resourceLoadResponse = {resource, response}; - evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse); -} - -/** - * @internal - * Failed loading a resource in the view. - * - * Emits signal: "resource,request,finished" with pointer to the resource load error. - */ -void ewk_view_resource_load_failed(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Error* error) -{ - Ewk_Resource_Load_Error resourceLoadError = {resource, error}; - evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError); -} - -/** - * @internal - * Finished loading a resource in the view. - * - * Emits signal: "resource,request,finished" with pointer to the resource. - */ -void ewk_view_resource_load_finished(Evas_Object* ewkView, Ewk_Resource* resource) -{ - evas_object_smart_callback_call(ewkView, "resource,request,finished", resource); -} - -/** - * @internal - * Request was sent for a resource in the view. - * - * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response. - */ -void ewk_view_resource_request_sent(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse) -{ - Ewk_Resource_Request resourceRequest = {resource, request, redirectResponse}; - evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest); + return impl->settings(); } const char* ewk_view_title_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - CString title = priv->pageProxy->pageTitle().utf8(); - priv->title = title.data(); - - return priv->title; -} - -/** - * @internal - * Reports that the requested text was found. - * - * Emits signal: "text,found" with the number of matches. - */ -void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount) -{ - evas_object_smart_callback_call(ewkView, "text,found", &matchCount); -} - -/** - * @internal - * The view title was changed by the frame loader. - * - * Emits signal: "title,changed" with pointer to new title string. - */ -void ewk_view_title_changed(Evas_Object* ewkView, const char* title) -{ - evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title)); -} - -/** - * @internal - */ -void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text) -{ - if (text && *text) - evas_object_smart_callback_call(ewkView, "tooltip,text,set", const_cast<char*>(text)); - else - evas_object_smart_callback_call(ewkView, "tooltip,text,unset", 0); + return impl->title(); } double ewk_view_load_progress_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0); - return priv->pageProxy->estimatedProgress(); + return impl->page()->estimatedProgress(); } Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->scalePage(scaleFactor, IntPoint(x, y)); + impl->page()->scalePage(scaleFactor, IntPoint(x, y)); return true; } double ewk_view_scale_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1); - return priv->pageProxy->pageScaleFactor(); + return impl->page()->pageScaleFactor(); } Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->setCustomDeviceScaleFactor(ratio); + impl->page()->setCustomDeviceScaleFactor(ratio); return true; } float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); - - return priv->pageProxy->deviceScaleFactor(); -} - -/** - * @internal - * Reports load progress changed. - * - * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0. - */ -void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress) -{ - evas_object_smart_callback_call(ewkView, "load,progress", &progress); -} + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, -1.0); -/** - * @internal - * The view received a new intent request. - * - * Emits signal: "intent,request,new" with pointer to a Ewk_Intent. - */ -void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent) -{ -#if ENABLE(WEB_INTENTS) - evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent)); -#endif + return impl->page()->deviceScaleFactor(); } void ewk_view_theme_set(Evas_Object* ewkView, const char* path) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl); - if (priv->theme != path) { - priv->theme = path; - priv->pageProxy->setThemePath(path); - } + impl->setThemePath(path); } const char* ewk_view_theme_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - - return priv->theme; -} - -void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - const char* group = cursor.platformCursor(); - if (!group || group == priv->cursorGroup) - return; - - priv->cursorGroup = group; - priv->cursorObject = adoptRef(edje_object_add(smartData->base.evas)); - - Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); - if (!priv->theme || !edje_object_file_set(priv->cursorObject.get(), priv->theme, group)) { - priv->cursorObject.clear(); - - ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0); -#ifdef HAVE_ECORE_X - if (priv->isUsingEcoreX) - WebCore::applyFallbackCursor(ecoreEvas, group); -#endif - return; - } - - Evas_Coord width, height; - edje_object_size_min_get(priv->cursorObject.get(), &width, &height); - if (width <= 0 || height <= 0) - edje_object_size_min_calc(priv->cursorObject.get(), &width, &height); - if (width <= 0 || height <= 0) { - width = defaultCursorSize; - height = defaultCursorSize; - } - evas_object_resize(priv->cursorObject.get(), width, height); - - const char* data; - int hotspotX = 0; - data = edje_object_data_get(priv->cursorObject.get(), "hot.x"); - if (data) - hotspotX = atoi(data); - - int hotspotY = 0; - data = edje_object_data_get(priv->cursorObject.get(), "hot.y"); - if (data) - hotspotY = atoi(data); - - ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject.get(), EVAS_LAYER_MAX, hotspotX, hotspotY); -} - -void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - if (!smartData->image) - return; - -#if USE(COORDINATED_GRAPHICS) - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - evas_gl_make_current(priv->evasGl, priv->evasGlSurface, priv->evasGlContext); - priv->pageViewportControllerClient->display(rect, IntPoint(smartData->view.x, smartData->view.y)); -#endif - - evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height()); -} - -#if ENABLE(FULLSCREEN_API) -/** - * @internal - * Calls fullscreen_enter callback or falls back to default behavior and enables fullscreen mode. - */ -void ewk_view_full_screen_enter(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - - if (!smartData->api->fullscreen_enter || !smartData->api->fullscreen_enter(smartData)) { - Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); - ecore_evas_fullscreen_set(ecoreEvas, true); - } -} - -/** - * @internal - * Calls fullscreen_exit callback or falls back to default behavior and disables fullscreen mode. - */ -void ewk_view_full_screen_exit(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - if (!smartData->api->fullscreen_exit || !smartData->api->fullscreen_exit(smartData)) { - Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); - ecore_evas_fullscreen_set(ecoreEvas, false); - } -} -#endif - -#if ENABLE(SQL_DATABASE) -/** - * @internal - * Calls exceeded_database_quota callback or falls back to default behavior returns default database quota. - */ -unsigned long long ewk_view_database_quota_exceeded(Evas_Object* ewkView, const char* databaseName, const char* displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - - static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB - if (smartData->api->exceeded_database_quota) - return smartData->api->exceeded_database_quota(smartData, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); - - return defaultQuota; -} -#endif - -/** - * @internal - * A download for that view was cancelled. - * - * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job. - */ -void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download) -{ - evas_object_smart_callback_call(ewkView, "download,cancelled", download); -} - -/** - * @internal - * A new download has been requested for that view. - * - * Emits signal: "download,request" with pointer to a Ewk_Download_Job. - */ -void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download) -{ - evas_object_smart_callback_call(ewkView, "download,request", download); -} - -/** - * @internal - * A download for that view has failed. - * - * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error. - */ -void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Error* error) -{ - Ewk_Download_Job_Error downloadError = { download, error }; - evas_object_smart_callback_call(ewkView, "download,failed", &downloadError); -} - -/** - * @internal - * A download for that view finished successfully. - * - * Emits signal: "download,finished" with pointer to a Ewk_Download_Job. - */ -void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download) -{ - evas_object_smart_callback_call(ewkView, "download,finished", download); + return impl->themePath(); } Eina_Bool ewk_view_back(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - WebPageProxy* page = priv->pageProxy.get(); + WebPageProxy* page = impl->page(); if (page->canGoBack()) { page->goBack(); return true; @@ -1387,10 +681,9 @@ Eina_Bool ewk_view_back(Evas_Object* ewkView) Eina_Bool ewk_view_forward(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - WebPageProxy* page = priv->pageProxy.get(); + WebPageProxy* page = impl->page(); if (page->canGoForward()) { page->goForward(); return true; @@ -1402,11 +695,10 @@ Eina_Bool ewk_view_forward(Evas_Object* ewkView) Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) { #if ENABLE(WEB_INTENTS) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false); - WebPageProxy* page = priv->pageProxy.get(); + WebPageProxy* page = impl->page(); page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData()); return true; @@ -1417,245 +709,56 @@ Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) Eina_Bool ewk_view_back_possible(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - return priv->pageProxy->canGoBack(); + return impl->page()->canGoBack(); } Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - return priv->pageProxy->canGoForward(); + return impl->page()->canGoForward(); } Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - - return priv->backForwardList.get(); -} - -void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - if (!imageData || !smartData->image) - return; - - evas_object_resize(smartData->image, size.width(), size.height()); - evas_object_image_size_set(smartData->image, size.width(), size.height()); - evas_object_image_data_copy_set(smartData->image, imageData); -} - -/** - * @internal - * Reports that a form request is about to be submitted. - * - * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request. - */ -void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request) -{ - evas_object_smart_callback_call(ewkView, "form,submission,request", request); -} + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); -/** - * @internal - * Reports load failed with error information. - * - * Emits signal: "load,error" with pointer to Ewk_Error. - */ -void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Error* error) -{ - evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Error*>(error)); -} - -/** - * @internal - * Reports load finished. - * - * Emits signal: "load,finished". - */ -void ewk_view_load_finished(Evas_Object* ewkView) -{ - ewk_view_url_update(ewkView); - evas_object_smart_callback_call(ewkView, "load,finished", 0); -} - -/** - * @internal - * Reports view provisional load failed with error information. - * - * Emits signal: "load,provisional,failed" with pointer to Ewk_Error. - */ -void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Error* error) -{ - evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Error*>(error)); -} - -/** - * @internal - * Reports view received redirect for provisional load. - * - * Emits signal: "load,provisional,redirect". - */ -void ewk_view_load_provisional_redirect(Evas_Object* ewkView) -{ - ewk_view_url_update(ewkView); - evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0); -} - -/** - * @internal - * Reports view provisional load started. - * - * Emits signal: "load,provisional,started". - */ -void ewk_view_load_provisional_started(Evas_Object* ewkView) -{ - ewk_view_url_update(ewkView); - evas_object_smart_callback_call(ewkView, "load,provisional,started", 0); -} - -/** - * @internal - * Reports that the view's back / forward list has changed. - * - * Emits signal: "back,forward,list,changed". - */ -void ewk_view_back_forward_list_changed(Evas_Object* ewkView) -{ - evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0); -} - -/** - * @internal - * Update the view's favicon and emits a "icon,changed" signal if it has - * changed. - * - * This function is called whenever the URL has changed or when the icon for - * the current page URL has changed. - */ -void ewk_view_update_icon(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - Ewk_Favicon_Database* iconDatabase = priv->context->faviconDatabase(); - ASSERT(iconDatabase); - - priv->faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, priv->url); - evas_object_smart_callback_call(ewkView, "icon,changed", 0); -} - -/** - * @internal - * Reports that a navigation policy decision should be taken. - * - * Emits signal: "policy,decision,navigation". - */ -void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision) -{ - evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision); -} - -/** - * @internal - * Reports that a new window policy decision should be taken. - * - * Emits signal: "policy,decision,new,window". - */ -void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision) -{ - evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision); + return impl->backForwardList(); } Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(html, false); if (unreachableUrl && *unreachableUrl) - priv->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); + impl->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); else - priv->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); - ewk_view_url_update(ewkView); - - return true; -} - -#if ENABLE(WEB_INTENTS_TAG) -/** - * @internal - * The view received a new intent service registration. - * - * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service. - */ -void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService) -{ - evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService)); -} -#endif // ENABLE(WEB_INTENTS_TAG) - -const Evas_Object* ewk_view_from_page_get(const WebKit::WebPageProxy* page) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0); + impl->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); - return pageViewMap().get(page); -} - -WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + impl->informURLChange(); - return priv->pageProxy.get(); + return true; } const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - - String customEncoding = priv->pageProxy->customTextEncodingName(); - if (customEncoding.isEmpty()) - return 0; - - priv->customEncoding = customEncoding.utf8().data(); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, 0); - return priv->customEncoding; + return impl->customTextEncodingName(); } Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* encoding) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->customEncoding = encoding; - priv->pageProxy->setCustomTextEncodingName(encoding ? encoding : String()); + impl->setCustomTextEncodingName(encoding ? encoding : String()); return true; } -void ewk_view_page_close(Evas_Object* ewkView) -{ - evas_object_smart_callback_call(ewkView, "close,window", 0); -} - -WKPageRef ewk_view_page_create(Evas_Object* ewkView) -{ - Evas_Object* newEwkView = 0; - evas_object_smart_callback_call(ewkView, "create,window", &newEwkView); - - if (!newEwkView) - return 0; - - return static_cast<WKPageRef>(WKRetain(ewk_view_page_get(newEwkView))); -} - // EwkFindOptions should be matched up orders with WkFindOptions. COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive); COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts); @@ -1668,258 +771,47 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShow Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); - priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); + impl->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->pageProxy->hideFindUI(); + impl->page()->hideFindUI(); return true; } Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); - priv->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); - - return true; -} - -void ewk_view_contents_size_changed(const Evas_Object* ewkView, const IntSize& size) -{ -#if USE(COORDINATED_GRAPHICS) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - priv->pageViewportControllerClient->didChangeContentsSize(size); -#else - UNUSED_PARAM(ewkView); - UNUSED_PARAM(size); -#endif -} - -COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, RTL); -COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, LTR); - -void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - EINA_SAFETY_ON_NULL_RETURN(smartData->api); - - ASSERT(popupMenu); - - if (!smartData->api->popup_menu_show) - return; - - if (priv->popupMenuProxy) - ewk_view_popup_menu_close(ewkView); - priv->popupMenuProxy = popupMenu; - - Eina_List* popupItems = 0; - size_t size = items.size(); - for (size_t i = 0; i < size; ++i) - popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr()); - priv->popupMenuItems = popupItems; - - smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex); -} - -Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false); - - if (!priv->popupMenuProxy) - return false; - - priv->popupMenuProxy = 0; - - if (smartData->api->popup_menu_hide) - smartData->api->popup_menu_hide(smartData); - - void* item; - EINA_LIST_FREE(priv->popupMenuItems, item) - delete static_cast<Ewk_Popup_Menu_Item*>(item); - - return true; -} - -Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false); - - if (selectedIndex >= eina_list_count(priv->popupMenuItems)) - return false; - - priv->popupMenuProxy->valueChanged(selectedIndex); + impl->page()->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - enabled = !!enabled; - if (priv->areMouseEventsEnabled == enabled) - return true; - - priv->areMouseEventsEnabled = enabled; - if (enabled) { - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData); - } else { - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move); - } + impl->setMouseEventsEnabled(!!enabled); return true; } Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - return priv->areMouseEventsEnabled; -} - -/** - * @internal - * Web process has crashed. - * - * Emits signal: "webprocess,crashed" with pointer to crash handling boolean. - */ -void ewk_view_webprocess_crashed(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - - bool handled = false; - evas_object_smart_callback_call(ewkView, "webprocess,crashed", &handled); - - if (!handled) { - CString url = priv->pageProxy->urlAtProcessExit().utf8(); - WARN("WARNING: The web process experienced a crash on '%s'.\n", url.data()); - - // Display an error page - ewk_view_html_string_load(ewkView, "The web process has crashed.", 0, url.data()); - } -} - -/** - * @internal - * Calls a smart member function for javascript alert(). - */ -void ewk_view_run_javascript_alert(Evas_Object* ewkView, const WKEinaSharedString& message) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EINA_SAFETY_ON_NULL_RETURN(smartData->api); - - if (!smartData->api->run_javascript_alert) - return; - - smartData->api->run_javascript_alert(smartData, message); -} - -/** - * @internal - * Calls a smart member function for javascript confirm() and returns a value from the function. Returns false by default. - */ -bool ewk_view_run_javascript_confirm(Evas_Object* ewkView, const WKEinaSharedString& message) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false); - - if (!smartData->api->run_javascript_confirm) - return false; - - return smartData->api->run_javascript_confirm(smartData, message); -} - -/** - * @internal - * Calls a smart member function for javascript prompt() and returns a value from the function. Returns null string by default. - */ -WKEinaSharedString ewk_view_run_javascript_prompt(Evas_Object* ewkView, const WKEinaSharedString& message, const WKEinaSharedString& defaultValue) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, WKEinaSharedString()); - EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, WKEinaSharedString()); - - if (!smartData->api->run_javascript_prompt) - return WKEinaSharedString(); - - return WKEinaSharedString::adopt(smartData->api->run_javascript_prompt(smartData, message, defaultValue)); -} - -#if ENABLE(INPUT_TYPE_COLOR) -/** - * @internal - * Requests to show external color picker. - */ -void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request); - - priv->colorPickerResultListener = listener; - - smartData->api->input_picker_color_request(smartData, r, g, b, a); -} - -/** - * @internal - * Requests to hide external color picker. - */ -void ewk_view_color_picker_dismiss(Evas_Object* ewkView) -{ - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss); - - priv->colorPickerResultListener.clear(); - - smartData->api->input_picker_color_dismiss(smartData); -} -#endif - -Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a) -{ -#if ENABLE(INPUT_TYPE_COLOR) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false); - - WebCore::Color color = WebCore::Color(r, g, b, a); - WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data())); - WKColorPickerResultListenerSetColor(priv->colorPickerResultListener.get(), colorString.get()); - priv->colorPickerResultListener.clear(); - - return true; -#else - return false; -#endif + return impl->mouseEventsEnabled(); } Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers) @@ -1927,10 +819,9 @@ Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type t #if ENABLE(TOUCH_EVENTS) EINA_SAFETY_ON_NULL_RETURN_VAL(points, false); EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false); - Evas_Point position = { smartData->view.x, smartData->view.y }; - priv->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, &position, ecore_time_get())); + impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get())); return true; #else @@ -1941,34 +832,9 @@ Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type t Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled) { #if ENABLE(TOUCH_EVENTS) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - - enabled = !!enabled; - if (priv->areTouchEventsEnabled == enabled) - return true; + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - priv->areTouchEventsEnabled = enabled; - if (enabled) { - // FIXME: We have to connect touch callbacks with mouse and multi events - // because the Evas creates mouse events for first touch and multi events - // for second and third touches. Below codes should be fixed when the Evas - // supports the touch events. - // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details. - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData); - evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData); - } else { - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up); - evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move); - } + impl->setTouchEventsEnabled(!!enabled); return true; #else @@ -1979,10 +845,9 @@ Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enab Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView) { #if ENABLE(TOUCH_EVENTS) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - return priv->areTouchEventsEnabled; + return impl->touchEventsEnabled(); #else return false; #endif @@ -1991,10 +856,9 @@ Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView) Eina_Bool ewk_view_inspector_show(Evas_Object* ewkView) { #if ENABLE(INSPECTOR) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - WebInspectorProxy* inspector = priv->pageProxy->inspector(); + WebInspectorProxy* inspector = impl->page()->inspector(); if (inspector) inspector->show(); @@ -2007,10 +871,9 @@ Eina_Bool ewk_view_inspector_show(Evas_Object* ewkView) Eina_Bool ewk_view_inspector_close(Evas_Object* ewkView) { #if ENABLE(INSPECTOR) - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); - WebInspectorProxy* inspector = priv->pageProxy->inspector(); + WebInspectorProxy* inspector = impl->page()->inspector(); if (inspector) inspector->close(); @@ -2019,3 +882,26 @@ Eina_Bool ewk_view_inspector_close(Evas_Object* ewkView) return false; #endif } + +// Ewk_Pagination_Mode should be matched up orders with WebCore::Pagination::Mode. +COMPILE_ASSERT_MATCHING_ENUM(EWK_PAGINATION_MODE_UNPAGINATED, WebCore::Pagination::Unpaginated); +COMPILE_ASSERT_MATCHING_ENUM(EWK_PAGINATION_MODE_LEFT_TO_RIGHT, WebCore::Pagination::LeftToRightPaginated); +COMPILE_ASSERT_MATCHING_ENUM(EWK_PAGINATION_MODE_RIGHT_TO_LEFT, WebCore::Pagination::RightToLeftPaginated); +COMPILE_ASSERT_MATCHING_ENUM(EWK_PAGINATION_MODE_TOP_TO_BOTTOM, WebCore::Pagination::TopToBottomPaginated); +COMPILE_ASSERT_MATCHING_ENUM(EWK_PAGINATION_MODE_BOTTOM_TO_TOP, WebCore::Pagination::BottomToTopPaginated); + +Eina_Bool ewk_view_pagination_mode_set(Evas_Object* ewkView, Ewk_Pagination_Mode mode) +{ + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false); + + impl->page()->setPaginationMode(static_cast<WebCore::Pagination::Mode>(mode)); + + return true; +} + +Ewk_Pagination_Mode ewk_view_pagination_mode_get(const Evas_Object* ewkView) +{ + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, EWK_PAGINATION_MODE_INVALID); + + return static_cast<Ewk_Pagination_Mode>(impl->page()->paginationMode()); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 59809fab6..175c28cf2 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -26,6 +26,8 @@ * * The following signals (see evas_object_smart_callback_add()) are emitted: * + * - "authentication,request", Ewk_Auth_Request*: reports that user authentication was requested. Call + * ewk_auth_request_ref() on the request object to process the authentication asynchronously. * - "back,forward,list,changed", void: reports that the view's back / forward list had changed. * - "close,window", void: window is closed. * - "create,window", Evas_Object**: a new window is created. @@ -34,6 +36,9 @@ * - "download,finished", Ewk_Download_Job*: reports that a download completed successfully. * - "download,request", Ewk_Download_Job*: reports that a new download has been requested. The client should set the * destination path by calling ewk_download_job_destination_set() or the download will fail. + * - "file,chooser,request", Ewk_File_Chooser_Request*: reports that a request has been made for the user to choose + * a file (or several) on the file system. Call ewk_file_chooser_request_ref() on the request object to process it + * asynchronously. * - "form,submission,request", Ewk_Form_Submission_Request*: Reports that a form request is about to be submitted. * The Ewk_Form_Submission_Request passed contains information about the text fields of the form. This * is typically used to store login information that can be used later to pre-fill the form. @@ -75,10 +80,12 @@ #define ewk_view_h #include "ewk_back_forward_list.h" +#include "ewk_color_picker.h" #include "ewk_context.h" #include "ewk_download_job.h" #include "ewk_error.h" #include "ewk_intent.h" +#include "ewk_popup_menu.h" #include "ewk_resource.h" #include "ewk_settings.h" #include "ewk_touch.h" @@ -104,7 +111,7 @@ struct Ewk_View_Smart_Class { Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */ unsigned long version; - Eina_Bool (*popup_menu_show)(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List *items, int selected_index); + Eina_Bool (*popup_menu_show)(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Ewk_Popup_Menu *menu); Eina_Bool (*popup_menu_hide)(Ewk_View_Smart_Data *sd); // event handling: @@ -129,7 +136,7 @@ struct Ewk_View_Smart_Class { // color picker: // - Shows and hides color picker. - Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, int r, int g, int b, int a); + Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, Ewk_Color_Picker *color_picker); Eina_Bool (*input_picker_color_dismiss)(Ewk_View_Smart_Data *sd); // storage: @@ -182,7 +189,7 @@ struct Ewk_View_Smart_Class { */ #define EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(name) EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name)) -typedef struct Ewk_View_Private_Data Ewk_View_Private_Data; +typedef struct EwkViewImpl EwkViewImpl; /** * @brief Contains an internal View data. * @@ -194,7 +201,7 @@ struct Ewk_View_Smart_Data { const Ewk_View_Smart_Class* api; /**< reference to casted class instance */ Evas_Object* self; /**< reference to owner object */ Evas_Object* image; /**< reference to evas_object_image for drawing web contents */ - Ewk_View_Private_Data* priv; /**< should never be accessed, c++ stuff */ + EwkViewImpl* priv; /**< should never be accessed, c++ stuff */ struct { Evas_Coord x, y, w, h; /**< last used viewport */ } view; @@ -271,6 +278,18 @@ enum Ewk_Find_Options { typedef enum Ewk_Find_Options Ewk_Find_Options; /** + * Enum values used to set pagination mode. + */ +typedef enum { + EWK_PAGINATION_MODE_INVALID = -1, /**< invalid pagination mode that will be returned when error occured. */ + EWK_PAGINATION_MODE_UNPAGINATED, /**< default mode for pagination. not paginated */ + EWK_PAGINATION_MODE_LEFT_TO_RIGHT, /**< go to the next page with scrolling left to right horizontally. */ + EWK_PAGINATION_MODE_RIGHT_TO_LEFT, /**< go to the next page with scrolling right to left horizontally. */ + EWK_PAGINATION_MODE_TOP_TO_BOTTOM, /**< go to the next page with scrolling top to bottom vertically. */ + EWK_PAGINATION_MODE_BOTTOM_TO_TOP /**< go to the next page with scrolling bottom to top vertically. */ +} Ewk_Pagination_Mode; + +/** * Sets the smart class APIs, enabling view to be inherited. * * @param api class definition to set, all members with the @@ -677,27 +696,6 @@ EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o); EAPI Eina_Bool ewk_view_text_matches_count(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned max_match_count); /** - * Selects index of current popup menu. - * - * @param o view object contains popup menu. - * @param index index of item to select - * - * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (probably - * popup menu is not selected or index is out of range) - */ -EAPI Eina_Bool ewk_view_popup_menu_select(Evas_Object *o, unsigned int index); - -/** - * Closes current popup menu. - * - * @param o view object contains popup menu. - * - * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (probably - * popup menu is not selected) - */ -EAPI Eina_Bool ewk_view_popup_menu_close(Evas_Object *o); - -/** * Sets whether the ewk_view supports the mouse events or not. * * The ewk_view will support the mouse events if EINA_TRUE or not support the @@ -719,23 +717,6 @@ EAPI Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *o, Eina_Bool enabl */ EAPI Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *o); -/* - * Sets the user chosen color. To be used when implementing a color picker. - * - * The function should only be called when a color has been requested by the document. - * If called when this is not the case or when the input picker has been dismissed, this - * function will fail and return EINA_FALSE. - * - * @param o view object contains color picker - * @param r red channel value to be set - * @param g green channel value to be set - * @param b blue channel value to be set - * @param a alpha channel value to be set - * - * @return @c EINA_TRUE on success @c EINA_FALSE otherwise - */ -EAPI Eina_Bool ewk_view_color_picker_color_set(Evas_Object *o, int r, int g, int b, int a); - /** * Feeds the touch event to the view. * @@ -793,6 +774,28 @@ EAPI Eina_Bool ewk_view_inspector_show(Evas_Object *o); */ EAPI Eina_Bool ewk_view_inspector_close(Evas_Object *o); +/** + * Set pagination mode to the current web page. + * + * @param o view object to set the pagenation mode + * @param mode The Ewk_Pagination_Mode to set + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_view_pagination_mode_set(Evas_Object *o, Ewk_Pagination_Mode mode); + +/** + * Get pagination mode of the current web page. + * + * The default value is EWK_PAGINATION_MODE_UNPAGINATED. + * When error occured, EWK_PAGINATION_MODE_INVALID is returned. + * + * @param o view object to get the pagination mode + * + * @return The pagination mode of the current web page + */ +EAPI Ewk_Pagination_Mode ewk_view_pagination_mode_get(const Evas_Object *o); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp deleted file mode 100644 index 1edc3cbfd..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "WKPage.h" -#include "ewk_view_find_client_private.h" -#include "ewk_view_private.h" - -static inline Evas_Object* toEwkView(const void* clientInfo) -{ - return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); -} - -static void didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo) -{ - ewk_view_text_found(toEwkView(clientInfo), matchCount); -} - -static void didFailToFindString(WKPageRef, WKStringRef, const void* clientInfo) -{ - ewk_view_text_found(toEwkView(clientInfo), 0); -} - -static void didCountStringMatches(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo) -{ - ewk_view_text_found(toEwkView(clientInfo), matchCount); -} - -void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView) -{ - WKPageFindClient findClient; - memset(&findClient, 0, sizeof(WKPageFindClient)); - findClient.version = kWKPageFindClientCurrentVersion; - findClient.clientInfo = ewkView; - findClient.didFindString = didFindString; - findClient.didFailToFindString = didFailToFindString; - findClient.didCountStringMatches = didCountStringMatches; - WKPageSetPageFindClient(pageRef, &findClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h deleted file mode 100644 index c17143360..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. 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 ewk_view_find_client_private_h -#define ewk_view_find_client_private_h - -#include <Evas.h> -#include <WebKit2/WKBase.h> - -void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView); - -#endif // ewk_view_find_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp deleted file mode 100644 index 7509ed96d..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "WKPage.h" -#include "ewk_form_submission_request.h" -#include "ewk_form_submission_request_private.h" -#include "ewk_view_form_client_private.h" -#include "ewk_view_private.h" - -static void willSubmitForm(WKPageRef, WKFrameRef /*frame*/, WKFrameRef /*sourceFrame*/, WKDictionaryRef values, WKTypeRef /*userData*/, WKFormSubmissionListenerRef listener, const void* clientInfo) -{ - Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - - RefPtr<Ewk_Form_Submission_Request> request = Ewk_Form_Submission_Request::create(values, listener); - ewk_view_form_submission_request_new(ewkView, request.get()); -} - -void ewk_view_form_client_attach(WKPageRef pageRef, Evas_Object* ewkView) -{ - WKPageFormClient formClient; - memset(&formClient, 0, sizeof(WKPageFormClient)); - formClient.version = kWKPageFormClientCurrentVersion; - formClient.clientInfo = ewkView; - formClient.willSubmitForm = willSubmitForm; - WKPageSetPageFormClient(pageRef, &formClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp deleted file mode 100644 index bdec9f625..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2012 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "WKFrame.h" -#include "WKFramePolicyListener.h" -#include "ewk_navigation_policy_decision.h" -#include "ewk_navigation_policy_decision_private.h" -#include "ewk_view_policy_client_private.h" -#include "ewk_view_private.h" -#include <WebCore/HTTPStatusCodes.h> -#include <wtf/text/CString.h> - -using namespace WebCore; -using namespace WebKit; - -static inline Evas_Object* toEwkView(const void* clientInfo) -{ - return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); -} - -static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef /*userData*/, const void* clientInfo) -{ - RefPtr<Ewk_Navigation_Policy_Decision> decision = Ewk_Navigation_Policy_Decision::create(navigationType, mouseButton, modifiers, request, 0, listener); - ewk_view_navigation_policy_decision(toEwkView(clientInfo), decision.get()); -} - -static void decidePolicyForNewWindowAction(WKPageRef, WKFrameRef, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef /*userData*/, const void* clientInfo) -{ - RefPtr<Ewk_Navigation_Policy_Decision> decision = Ewk_Navigation_Policy_Decision::create(navigationType, mouseButton, modifiers, request, toImpl(frameName)->string().utf8().data(), listener); - ewk_view_new_window_policy_decision(toEwkView(clientInfo), decision.get()); -} - -static void decidePolicyForResponseCallback(WKPageRef, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef /*userData*/, const void* /*clientInfo*/) -{ - const ResourceResponse resourceResponse = toImpl(response)->resourceResponse(); - - // Ignore responses with an HTTP status code of 204 (No Content) - if (resourceResponse.httpStatusCode() == HTTPNoContent) { - WKFramePolicyListenerIgnore(listener); - return; - } - - // If the URL Response has "Content-Disposition: attachment;" header, then - // we should download it. - if (resourceResponse.isAttachment()) { - WKFramePolicyListenerDownload(listener); - return; - } - - String mimeType = toImpl(response)->resourceResponse().mimeType().lower(); - bool canShowMIMEType = toImpl(frame)->canShowMIMEType(mimeType); - if (WKFrameIsMainFrame(frame)) { - if (canShowMIMEType) { - WKFramePolicyListenerUse(listener); - return; - } - - // If we can't use (show) it then we should download it. - WKFramePolicyListenerDownload(listener); - return; - } - - // We should ignore downloadable top-level content for subframes, with an exception for text/xml and application/xml so we can still support Acid3 test. - // It makes the browser intentionally behave differently when it comes to text(application)/xml content in subframes vs. mainframe. - if (!canShowMIMEType && !(mimeType == "text/xml" || mimeType == "application/xml")) { - WKFramePolicyListenerIgnore(listener); - return; - } - - WKFramePolicyListenerUse(listener); -} - -void ewk_view_policy_client_attach(WKPageRef pageRef, Evas_Object* ewkView) -{ - WKPagePolicyClient policyClient; - memset(&policyClient, 0, sizeof(WKPagePolicyClient)); - policyClient.version = kWKPagePolicyClientCurrentVersion; - policyClient.clientInfo = ewkView; - policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction; - policyClient.decidePolicyForNewWindowAction = decidePolicyForNewWindowAction; - policyClient.decidePolicyForResponse = decidePolicyForResponseCallback; - - WKPageSetPagePolicyClient(pageRef, &policyClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index 2066f9eff..28038857f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -21,107 +21,9 @@ #ifndef ewk_view_private_h #define ewk_view_private_h -#include "WebPageProxy.h" #include <Evas.h> -#include <WKEinaSharedString.h> -#include <WebCore/TextDirection.h> #include <WebKit2/WKBase.h> -#include <wtf/Vector.h> - -namespace WebCore { -class Cursor; -class IntRect; -class IntSize; -} - -namespace WebKit { -class WebPopupItem; -class WebPopupMenuProxyEfl; -} - -typedef struct Ewk_Download_Job Ewk_Download_Job; -typedef struct Ewk_Form_Submission_Request Ewk_Form_Submission_Request; -typedef struct Ewk_Url_Request Ewk_Url_Request; -typedef struct Ewk_Url_Response Ewk_Url_Response; -typedef struct Ewk_Error Ewk_Error; -typedef struct Ewk_Resource Ewk_Resource; -typedef struct Ewk_Navigation_Policy_Decision Ewk_Navigation_Policy_Decision; -#if ENABLE(WEB_INTENTS) -typedef struct Ewk_Intent Ewk_Intent; -#endif -#if ENABLE(WEB_INTENTS_TAG) -typedef struct Ewk_Intent_Service Ewk_Intent_Service; -#endif - -void ewk_view_cursor_set(Evas_Object* ewkView, const WebCore::Cursor& cursor); -void ewk_view_display(Evas_Object* ewkView, const WebCore::IntRect& rect); -void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job*); -void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job*, Ewk_Error*); -void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job*); -void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job*); -void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request*); -#if ENABLE(FULLSCREEN_API) -void ewk_view_full_screen_enter(Evas_Object* ewkView); -void ewk_view_full_screen_exit(Evas_Object* ewkView); -#endif -void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size); -void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Error* error); -void ewk_view_load_finished(Evas_Object* ewkView); -void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress); -void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Error* error); -void ewk_view_load_provisional_redirect(Evas_Object* ewkView); -void ewk_view_load_provisional_started(Evas_Object* ewkView); -void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision); -void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision); -void ewk_view_page_close(Evas_Object* ewkView); -WKPageRef ewk_view_page_create(Evas_Object* ewkView); -void ewk_view_title_changed(Evas_Object* ewkView, const char* title); -void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text); -void ewk_view_resource_load_failed(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Error* error); -void ewk_view_resource_load_finished(Evas_Object* ewkView, Ewk_Resource* resource); -void ewk_view_resource_load_initiated(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request); -void ewk_view_resource_load_response(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Response* response); -void ewk_view_resource_request_sent(Evas_Object* ewkView, Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse); -void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount); -void ewk_view_url_update(Evas_Object* ewkView); -void ewk_view_contents_size_changed(const Evas_Object* ewkView, const WebCore::IntSize&); -void ewk_view_back_forward_list_changed(Evas_Object* ewkView); -void ewk_view_update_icon(Evas_Object* ewkView); - -WKPageRef ewk_view_wkpage_get(const Evas_Object* ewkView); Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef); -#if ENABLE(WEB_INTENTS) -void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent); -#endif -#if ENABLE(WEB_INTENTS_TAG) -void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService); -#endif - -const Evas_Object* ewk_view_from_page_get(const WebKit::WebPageProxy*); -WebKit::WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView); -WebCore::IntSize ewk_view_size_get(const Evas_Object* ewkView); - -#if USE(ACCELERATED_COMPOSITING) -bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView); -bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView); -#endif - -void ewk_view_popup_menu_request(Evas_Object* ewkView, WebKit::WebPopupMenuProxyEfl* popupMenu, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex); -void ewk_view_webprocess_crashed(Evas_Object* ewkView); - -void ewk_view_run_javascript_alert(Evas_Object* ewkView, const WKEinaSharedString& message); -bool ewk_view_run_javascript_confirm(Evas_Object* ewkView, const WKEinaSharedString& message); -WKEinaSharedString ewk_view_run_javascript_prompt(Evas_Object* ewkView, const WKEinaSharedString& message, const WKEinaSharedString& defaultValue); - -#if ENABLE(INPUT_TYPE_COLOR) -void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener); -void ewk_view_color_picker_dismiss(Evas_Object* ewkView); -#endif - -#if ENABLE(SQL_DATABASE) -unsigned long long ewk_view_database_quota_exceeded(Evas_Object* ewkView, const char* databaseName, const char* displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); -#endif - #endif // ewk_view_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp deleted file mode 100644 index 0f7bd9277..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "WKString.h" -#include "ewk_view_private.h" -#include "ewk_view_ui_client_private.h" -#include <Ecore_Evas.h> - -static inline Evas_Object* toEwkView(const void* clientInfo) -{ - return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); -} - -static void closePage(WKPageRef, const void* clientInfo) -{ - ewk_view_page_close(toEwkView(clientInfo)); -} - -static WKPageRef createNewPage(WKPageRef, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void* clientInfo) -{ - return ewk_view_page_create(toEwkView(clientInfo)); -} - -static void runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo) -{ - ewk_view_run_javascript_alert(toEwkView(clientInfo), WKEinaSharedString(alertText)); -} - -static bool runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo) -{ - return ewk_view_run_javascript_confirm(toEwkView(clientInfo), WKEinaSharedString(message)); -} - -static WKStringRef runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo) -{ - WKEinaSharedString value = ewk_view_run_javascript_prompt(toEwkView(clientInfo), WKEinaSharedString(message), WKEinaSharedString(defaultValue)); - return value ? WKStringCreateWithUTF8CString(value) : 0; -} - -#if ENABLE(INPUT_TYPE_COLOR) -static void showColorPicker(WKPageRef, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo) -{ - WebCore::Color color = WebCore::Color(WebKit::toWTFString(initialColor)); - ewk_view_color_picker_request(toEwkView(clientInfo), color.red(), color.green(), color.blue(), color.alpha(), listener); -} - -static void hideColorPicker(WKPageRef, const void* clientInfo) -{ - ewk_view_color_picker_dismiss(toEwkView(clientInfo)); -} -#endif - -#if ENABLE(SQL_DATABASE) -static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void* clientInfo) -{ - return ewk_view_database_quota_exceeded(toEwkView(clientInfo), WKEinaSharedString(databaseName), WKEinaSharedString(displayName), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); -} -#endif - -static void focus(WKPageRef, const void* clientInfo) -{ - evas_object_focus_set(toEwkView(clientInfo), true); -} - -static void unfocus(WKPageRef, const void* clientInfo) -{ - evas_object_focus_set(toEwkView(clientInfo), false); -} - -static void takeFocus(WKPageRef, WKFocusDirection, const void* clientInfo) -{ - // FIXME: this is only a partial implementation. - evas_object_focus_set(toEwkView(clientInfo), false); -} - -static WKRect getWindowFrame(WKPageRef, const void* clientInfo) -{ - int x, y, width, height; - - Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(toEwkView(clientInfo))); - ecore_evas_request_geometry_get(ee, &x, &y, &width, &height); - - return WKRectMake(x, y, width, height); -} - -static void setWindowFrame(WKPageRef, WKRect frame, const void* clientInfo) -{ - Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(toEwkView(clientInfo))); - ecore_evas_move_resize(ee, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); -} - -void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView) -{ - WKPageUIClient uiClient; - memset(&uiClient, 0, sizeof(WKPageUIClient)); - uiClient.version = kWKPageUIClientCurrentVersion; - uiClient.clientInfo = ewkView; - uiClient.close = closePage; - uiClient.createNewPage = createNewPage; - uiClient.runJavaScriptAlert = runJavaScriptAlert; - uiClient.runJavaScriptConfirm = runJavaScriptConfirm; - uiClient.runJavaScriptPrompt = runJavaScriptPrompt; - uiClient.takeFocus = takeFocus; - uiClient.focus = focus; - uiClient.unfocus = unfocus; - uiClient.getWindowFrame = getWindowFrame; - uiClient.setWindowFrame = setWindowFrame; -#if ENABLE(SQL_DATABASE) - uiClient.exceededDatabaseQuota = exceededDatabaseQuota; -#endif - -#if ENABLE(INPUT_TYPE_COLOR) - uiClient.showColorPicker = showColorPicker; - uiClient.hideColorPicker = hideColorPicker; -#endif - - WKPageSetPageUIClient(pageRef, &uiClient); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h deleted file mode 100644 index 4c9c492a5..000000000 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2012 Samsung Electronics. 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 ewk_view_ui_client_private_h -#define ewk_view_ui_client_private_h - -#include <Evas.h> -#include <WebKit2/WKBase.h> - -void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView); - -#endif // ewk_view_ui_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp index 63d315050..82280fcd4 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp @@ -48,7 +48,12 @@ void EWK2UnitTestBase::SetUp() unsigned int width = environment->defaultWidth(); unsigned int height = environment->defaultHeight(); +#if defined(WTF_USE_ACCELERATED_COMPOSITING) && defined(HAVE_ECORE_X) + const char* engine = "opengl_x11"; + m_ecoreEvas = ecore_evas_new(engine, 0, 0, width, height, 0); +#else m_ecoreEvas = ecore_evas_new(0, 0, 0, width, height, 0); +#endif ecore_evas_show(m_ecoreEvas); Evas* evas = ecore_evas_get(m_ecoreEvas); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html new file mode 100644 index 000000000..4418c6477 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/file_chooser.html @@ -0,0 +1,21 @@ +<html> +<head> +<title>File chooser test</title> +<script> +function updateTitle() +{ + var myinput = document.getElementById('myInput'); + var title = "" + for (var i = 0; i < myinput.files.length; i++) { + title += myinput.files[i].name; + if (i < (myinput.files.length - 1)) + title += "|"; + } + document.title = title; +} +</script> +</head> +<body> +<input type="file" id="myInput" name="Upload media" accept="image/*,video/*" multiple="multiple" onchange="updateTitle()" style="top: 10; left: 10;"/> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp new file mode 100644 index 000000000..093b507e6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" +#include <EWebKit2.h> +#include <Ecore.h> +#include <wtf/PassOwnPtr.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static const char TEST_USERNAME[] = "username"; +static const char TEST_PASSWORD[] = "password"; +static const char EXPECTED_AUTHORIZATION[] = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="; // Base64 encoding of "username:password". +static const char INDEX_HTML_STRING[] = + "<html>" + "<head><title>EFLWebKit2 Authentication test</title></head>" + "<body></body></html>"; + +static void serverCallback(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, void*) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + if (!strcmp(path, "/index.html")) { + const char* authorization = soup_message_headers_get_one(message->request_headers, "Authorization"); + // Require authentication + if (authorization && !strcmp(authorization, EXPECTED_AUTHORIZATION)) { + // Successful authentication. + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, INDEX_HTML_STRING, strlen(INDEX_HTML_STRING)); + } else { + // No (valid) authorization header provided by the client, request authentication. + soup_message_set_status(message, SOUP_STATUS_UNAUTHORIZED); + soup_message_headers_append(message->response_headers, "WWW-Authenticate", "Basic realm=\"my realm\""); + } + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + + soup_message_body_complete(message->response_body); +} + +static void onAuthenticationRequest(void* userData, Evas_Object*, void* eventInfo) +{ + Ewk_Auth_Request** returnRequest = static_cast<Ewk_Auth_Request**>(userData); + ASSERT_TRUE(returnRequest); + + Ewk_Auth_Request* request = static_cast<Ewk_Auth_Request*>(eventInfo); + ASSERT_TRUE(request); + + *returnRequest = ewk_object_ref(request); +} + +TEST_F(EWK2UnitTestBase, ewk_auth_request_success) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Auth_Request* authenticationRequest = 0; + evas_object_smart_callback_add(webView(), "authentication,request", onAuthenticationRequest, &authenticationRequest); + + ewk_view_url_set(webView(), httpServer->getURLForPath("/index.html").data()); + + while (!authenticationRequest) + ecore_main_loop_iterate(); + + ASSERT_TRUE(authenticationRequest); + evas_object_smart_callback_del(webView(), "authentication,request", onAuthenticationRequest); + + EXPECT_STREQ("my realm", ewk_auth_request_realm_get(authenticationRequest)); + EXPECT_STREQ("127.0.0.1", ewk_auth_request_host_get(authenticationRequest)); + EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest)); + + ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, TEST_PASSWORD)); + + ewk_object_unref(authenticationRequest); + + ASSERT_TRUE(waitUntilTitleChangedTo("EFLWebKit2 Authentication test")); +} + +TEST_F(EWK2UnitTestBase, ewk_auth_request_failure_then_success) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Auth_Request* authenticationRequest = 0; + evas_object_smart_callback_add(webView(), "authentication,request", onAuthenticationRequest, &authenticationRequest); + + ewk_view_url_set(webView(), httpServer->getURLForPath("/index.html").data()); + + while (!authenticationRequest) + ecore_main_loop_iterate(); + + ASSERT_TRUE(authenticationRequest); + + EXPECT_STREQ("my realm", ewk_auth_request_realm_get(authenticationRequest)); + EXPECT_STREQ("127.0.0.1", ewk_auth_request_host_get(authenticationRequest)); + EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest)); + + ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, "wrongpassword")); + + ewk_object_unref(authenticationRequest); + authenticationRequest = 0; + + // We expect a second authentication request since the first one failed. + while (!authenticationRequest) + ecore_main_loop_iterate(); + evas_object_smart_callback_del(webView(), "authentication,request", onAuthenticationRequest); + + EXPECT_STREQ("my realm", ewk_auth_request_realm_get(authenticationRequest)); + EXPECT_STREQ("127.0.0.1", ewk_auth_request_host_get(authenticationRequest)); + EXPECT_TRUE(ewk_auth_request_retrying_get(authenticationRequest)); + + // Now provide the right password. + ASSERT_TRUE(ewk_auth_request_authenticate(authenticationRequest, TEST_USERNAME, TEST_PASSWORD)); + + ewk_object_unref(authenticationRequest); + + ASSERT_TRUE(waitUntilTitleChangedTo("EFLWebKit2 Authentication test")); +} + +static void onResourceLoadResponse(void* userData, Evas_Object*, void* eventInfo) +{ + int* statusCode = static_cast<int*>(userData); + ASSERT_TRUE(statusCode); + + Ewk_Resource_Load_Response* response = static_cast<Ewk_Resource_Load_Response*>(eventInfo); + ASSERT_TRUE(response); + + if (!ewk_resource_main_resource_get(response->resource)) + return; + + *statusCode = ewk_url_response_status_code_get(response->response); +} + +TEST_F(EWK2UnitTestBase, ewk_auth_request_cancel) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + Ewk_Auth_Request* authenticationRequest = 0; + evas_object_smart_callback_add(webView(), "authentication,request", onAuthenticationRequest, &authenticationRequest); + + ewk_view_url_set(webView(), httpServer->getURLForPath("/index.html").data()); + + while (!authenticationRequest) + ecore_main_loop_iterate(); + + ASSERT_TRUE(authenticationRequest); + evas_object_smart_callback_del(webView(), "authentication,request", onAuthenticationRequest); + + EXPECT_STREQ("my realm", ewk_auth_request_realm_get(authenticationRequest)); + EXPECT_STREQ("127.0.0.1", ewk_auth_request_host_get(authenticationRequest)); + EXPECT_FALSE(ewk_auth_request_retrying_get(authenticationRequest)); + + int statusCode = 0; + evas_object_smart_callback_add(webView(), "resource,request,response", onResourceLoadResponse, &statusCode); + + // Will attempt to continue without authentication by default. + ewk_object_unref(authenticationRequest); + + while (!statusCode) + ecore_main_loop_iterate(); + + // We should get a "402 Unauthorized" error. + EXPECT_EQ(SOUP_STATUS_UNAUTHORIZED, statusCode); + + evas_object_smart_callback_del(webView(), "resource,request,response", onResourceLoadResponse); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_back_forward_list.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_back_forward_list.cpp index 80d7755ec..ec4a4d90a 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_back_forward_list.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_back_forward_list.cpp @@ -83,7 +83,7 @@ static inline void freeEinaList(Eina_List* list) { void* data = 0; EINA_LIST_FREE(list, data) - ewk_back_forward_list_item_unref(static_cast<Ewk_Back_Forward_List_Item*>(data)); + ewk_object_unref(static_cast<Ewk_Object*>(data)); } TEST_F(EWK2UnitTestBase, ewk_back_forward_list_current_item_get) diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp new file mode 100644 index 000000000..7f59c33f6 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp @@ -0,0 +1,164 @@ +/* + Copyright (C) 2012 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include <EWebKit2.h> +#include <Ecore.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +#if ENABLE(INPUT_TYPE_COLOR) +static const int initialRed = 0x12; +static const int initialGreen = 0x34; +static const int initialBlue = 0x56; +static const int initialAlpha = 0xff; +static const int changedRed = 0x98; +static const int changedGreen = 0x76; +static const int changedBlue = 0x54; +static const int changedAlpha = 0xff; + +static bool s_isColorPickerShown = false; +static Ewk_Color_Picker* s_colorPicker = 0; + + +static void onColorPickerDone(void* userData, Evas_Object*, void*) +{ + bool* handled = static_cast<bool*>(userData); + + *handled = true; +} + +static unsigned char setColorPickerColor(void* data) +{ + Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); + + // 4. Change color to changed color. + EXPECT_TRUE(ewk_color_picker_color_set(s_colorPicker, changedRed, changedGreen, changedBlue, changedAlpha)); + + evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); + + return 0; +} + +static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, Ewk_Color_Picker* colorPicker) +{ + static bool isFirstRun = true; + + s_colorPicker = colorPicker; + s_isColorPickerShown = true; + + int r, g, b, a; + EXPECT_TRUE(ewk_color_picker_color_get(colorPicker, &r, &g, &b, &a)); + + if (isFirstRun) { + // 2. Check initial value from html file. + EXPECT_EQ(initialRed, r); + EXPECT_EQ(initialGreen, g); + EXPECT_EQ(initialBlue, b); + EXPECT_EQ(initialAlpha, a); + + isFirstRun = false; + } else { + // 7. Input values should be same as changed color. + EXPECT_EQ(changedRed, r); + EXPECT_EQ(changedGreen, g); + EXPECT_EQ(changedBlue, b); + EXPECT_EQ(changedAlpha, a); + + evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); + return true; + } + + // 3. Return after making a color picker. + ecore_timer_add(0.0, setColorPickerColor, smartData); + return true; +} + +static Eina_Bool hideColorPicker(Ewk_View_Smart_Data*) +{ + // 5. Test color picker is shown. + EXPECT_TRUE(s_isColorPickerShown); + s_isColorPickerShown = false; +} + +static Eina_Bool hideColorPickerByRemovingElement(Ewk_View_Smart_Data* smartData) +{ + // 9. input_picker_color_dismiss() is called if the element is removed. + EXPECT_TRUE(s_isColorPickerShown); + s_isColorPickerShown = false; + evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); +} + +TEST_F(EWK2UnitTestBase, ewk_color_picker_color_set) +{ + Ewk_View_Smart_Class* api = ewkViewClass(); + api->input_picker_color_request = showColorPicker; + api->input_picker_color_dismiss = hideColorPicker; + + const char colorPickerHTML[] = + "<!DOCTYPE html>" + "<html>" + "<head>" + "<script>function removeInputElement(){" + "var parentElement = document.getElementById('parent');" + "var inputElement = document.getElementById('color');" + "parentElement.removeChild(inputElement);" + "}</script>" + "</head>" + "<body>" + "<div id='parent'>" + "<input type='color' value='#123456' id='color'>" + "<button onclick='removeInputElement();'>Remove Element</button>" + "</div>" + "</body>" + "</html>"; + + ewk_view_html_string_load(webView(), colorPickerHTML, 0, 0); + waitUntilLoadFinished(); + + // 1. Click input element to show color picker. + mouseClick(30, 20); + + bool handled = false; + evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled); + while (!handled) + ecore_main_loop_iterate(); + + // 6. Click input element to show color picker again. + mouseClick(30, 20); + + handled = false; + while (!handled) + ecore_main_loop_iterate(); + + // 8. Click button to remove input element durlng color picker is shown. + api->input_picker_color_dismiss = hideColorPickerByRemovingElement; + mouseClick(80, 20); + + handled = false; + while (!handled) + ecore_main_loop_iterate(); + evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone); +} +#endif // ENABLE(INPUT_TYPE_COLOR) diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp index 27e46dc1e..b02a8d26e 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp @@ -53,6 +53,14 @@ TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get) ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(context)); } +TEST_F(EWK2UnitTestBase, ewk_context_database_manager_get) +{ + Ewk_Context* context = ewk_view_context_get(webView()); + Ewk_Database_Manager* databaseManager = ewk_context_database_manager_get(context); + ASSERT_TRUE(databaseManager); + ASSERT_EQ(databaseManager, ewk_context_database_manager_get(context)); +} + TEST_F(EWK2UnitTestBase, ewk_context_favicon_database_get) { Ewk_Context* context = ewk_view_context_get(webView()); @@ -61,6 +69,14 @@ TEST_F(EWK2UnitTestBase, ewk_context_favicon_database_get) ASSERT_EQ(faviconDatabase, ewk_context_favicon_database_get(context)); } +TEST_F(EWK2UnitTestBase, ewk_context_storage_manager_get) +{ + Ewk_Context* context = ewk_view_context_get(webView()); + Ewk_Storage_Manager* storageManager = ewk_context_storage_manager_get(context); + ASSERT_TRUE(storageManager); + ASSERT_EQ(storageManager, ewk_context_storage_manager_get(context)); +} + static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData) { const char* scheme = ewk_url_scheme_request_scheme_get(request); @@ -121,7 +137,7 @@ static void loadVibrationHTMLString(Evas_Object* webView, const char* vibrationP ecore_main_loop_iterate(); } -TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) +TEST_F(EWK2UnitTestBase, DISABLED_ewk_context_vibration_client_callbacks_set) { VibrationCbData data = { false, false, 0, 5000 }; ewk_context_vibration_client_callbacks_set(ewk_view_context_get(webView()), vibrateCallback, cancelVibrationCallback, &data); @@ -179,21 +195,12 @@ TEST_F(EWK2UnitTestBase, ewk_context_new) { Ewk_Context* context = ewk_context_new(); ASSERT_TRUE(context); - ewk_context_unref(context); + ewk_object_unref(context); } TEST_F(EWK2UnitTestBase, ewk_context_new_with_injected_bundle_path) { Ewk_Context* context = ewk_context_new_with_injected_bundle_path(environment->injectedBundleSample()); ASSERT_TRUE(context); - ewk_context_unref(context); -} - -TEST_F(EWK2UnitTestBase, ewk_context_ref) -{ - Ewk_Context* context = ewk_context_new(); - ASSERT_EQ(context, ewk_context_ref(context)); - ewk_context_unref(context); - ewk_context_unref(context); + ewk_object_unref(context); } - diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_database_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_database_manager.cpp new file mode 100644 index 000000000..dd9b4b079 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_database_manager.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * 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 "UnitTestUtils/EWK2UnitTestBase.h" +#include <EWebKit2.h> +#include <Ecore.h> + +using namespace EWK2UnitTest; + +struct OriginData { + Eina_List* originList; + Ewk_Database_Manager* manager; + bool didReceiveOriginsCallback; + bool isSynchronized; + unsigned timeoutSeconds; + + OriginData() + : originList(0) + , manager(0) + , didReceiveOriginsCallback(false) + , isSynchronized(false) + , timeoutSeconds(10) + { } +}; + +static void getDatabaseOriginsCallback(Eina_List* origins, Ewk_Error* error, void* userData) +{ + ASSERT_FALSE(error); + + OriginData* originData = static_cast<OriginData*>(userData); + originData->didReceiveOriginsCallback = true; + + Eina_List* l; + void* data; + EINA_LIST_FOREACH(origins, l, data) { + originData->originList = eina_list_append(originData->originList, data); + Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(data); + if (!strcmp(ewk_security_origin_protocol_get(origin), "http") + && !strcmp(ewk_security_origin_host_get(origin), "www.databasetest.com") + && !ewk_security_origin_port_get(origin)) { + originData->isSynchronized = true; + ecore_main_loop_quit(); + } + } +} + +static bool timerCallback(void* userData) +{ + OriginData* originData = static_cast<OriginData*>(userData); + + if (originData->isSynchronized || !--(originData->timeoutSeconds)) { + ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; + } + + if (originData->didReceiveOriginsCallback) { + originData->didReceiveOriginsCallback = false; + ewk_database_manager_origins_get(originData->manager, getDatabaseOriginsCallback, originData); + } + + return ECORE_CALLBACK_RENEW; +} + +TEST_F(EWK2UnitTestBase, ewk_database_manager_origins_get) +{ + Evas_Object* view = webView(); + const char* databaseHTML = + "<html><head><title>original title</title></head>" + "<body>" + "<script type='text/javascript'>" + " var db = openDatabase(\"DBTest\", \"1.0\", \"HTML5 Database example\", 200000);" + "</script>" + "</body></html>"; + + ASSERT_TRUE(ewk_view_html_string_load(view, databaseHTML, "http://www.databasetest.com", 0)); + ASSERT_TRUE(waitUntilLoadFinished()); + + OriginData originData; + originData.manager = ewk_context_database_manager_get(ewk_view_context_get(view)); + ASSERT_TRUE(ewk_database_manager_origins_get(originData.manager, getDatabaseOriginsCallback, &originData)); + Ecore_Timer* database_timer = ecore_timer_add(1, reinterpret_cast<Ecore_Task_Cb>(timerCallback), &originData); + + ecore_main_loop_begin(); + if (database_timer) + ecore_timer_del(database_timer); + + ASSERT_TRUE(originData.isSynchronized); + ASSERT_LE(1, eina_list_count(originData.originList)); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp index 7a57b9122..cda6efa06 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp @@ -89,6 +89,10 @@ TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); + // Set favicon database path and enable functionality. + Ewk_Context* context = ewk_view_context_get(webView()); + ewk_context_favicon_database_directory_set(context, 0); + bool iconChanged = false; evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged); @@ -103,7 +107,6 @@ TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get) evas_object_smart_callback_del(webView(), "icon,changed", onIconChanged); // Check the API retrieving a favicon URL. - Ewk_Context* context = ewk_view_context_get(webView()); Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context); ASSERT_TRUE(faviconDatabase); @@ -146,6 +149,10 @@ TEST_F(EWK2UnitTestBase, ewk_favicon_database_async_icon_get) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); + // Set favicon database path and enable functionality. + Ewk_Context* context = ewk_view_context_get(webView()); + ewk_context_favicon_database_directory_set(context, 0); + IconRequestData data = { webView(), 0 }; evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp new file mode 100644 index 000000000..a562d74c2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_file_chooser_request.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" +#include <EWebKit2.h> +#include <Ecore.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static void onFileChooserRequest(void* userData, Evas_Object*, void* eventInfo) +{ + Ewk_File_Chooser_Request** returnRequest = static_cast<Ewk_File_Chooser_Request**>(userData); + ASSERT_TRUE(returnRequest); + Ewk_File_Chooser_Request* request = static_cast<Ewk_File_Chooser_Request*>(eventInfo); + ASSERT_TRUE(request); + + // Ref the request to process asynchronously. + *returnRequest = ewk_file_chooser_request_ref(request); +} + +static int compareStrings(const void* string1, const void* string2) +{ + ASSERT(string1); + ASSERT(string2); + + return strcmp(static_cast<const char*>(string1), static_cast<const char*>(string2)); +} + +static void freeStringList(Eina_List** list) +{ + void* data; + EINA_LIST_FREE(*list, data) { + eina_stringshare_del(static_cast<char*>(data)); + } +} + +TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_files_choose) +{ + Ewk_File_Chooser_Request* request = 0; + evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request); + ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data())); + + // Click on the file input. + mouseClick(15, 15); + + // Wait for the file chooser request. + while (!request) + ecore_main_loop_iterate(); + + evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest); + ASSERT_TRUE(request); + // Validate file chooser request. + EXPECT_TRUE(ewk_file_chooser_request_allow_multiple_files_get(request)); + Eina_List* mimeTypes = ewk_file_chooser_request_accepted_mimetypes_get(request); + mimeTypes = eina_list_sort(mimeTypes, eina_list_count(mimeTypes), compareStrings); + + ASSERT_EQ(2, eina_list_count(mimeTypes)); + EXPECT_STREQ("image/*", static_cast<char*>(eina_list_nth(mimeTypes, 0))); + EXPECT_STREQ("video/*", static_cast<char*>(eina_list_nth(mimeTypes, 1))); + freeStringList(&mimeTypes); + + ASSERT_FALSE(ewk_file_chooser_request_files_choose(request, 0)); + Eina_List* files = 0; + files = eina_list_append(files, eina_stringshare_add("/tmp/file1.png")); + files = eina_list_append(files, eina_stringshare_add("/tmp/file2.png")); + ASSERT_TRUE(ewk_file_chooser_request_files_choose(request, files)); + ASSERT_FALSE(ewk_file_chooser_request_files_choose(request, files)); + freeStringList(&files); + + ewk_file_chooser_request_unref(request); + + // Check that the JS side received the files. + EXPECT_TRUE(waitUntilTitleChangedTo("file1.png|file2.png")); +} + +TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_file_choose) +{ + Ewk_File_Chooser_Request* request = 0; + evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request); + ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data())); + + // Click on the file input. + mouseClick(15, 15); + + // Wait for the file chooser request. + while (!request) + ecore_main_loop_iterate(); + + evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest); + ASSERT_TRUE(request); + + ASSERT_FALSE(ewk_file_chooser_request_file_choose(request, 0)); + ASSERT_TRUE(ewk_file_chooser_request_file_choose(request, "/tmp/file3.png")); + ASSERT_FALSE(ewk_file_chooser_request_file_choose(request, "/tmp/file3.png")); + + ewk_file_chooser_request_unref(request); + + // Check that the JS side received the file. + EXPECT_TRUE(waitUntilTitleChangedTo("file3.png")); +} + +TEST_F(EWK2UnitTestBase, ewk_file_chooser_request_file_cancel) +{ + Ewk_File_Chooser_Request* request = 0; + evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request); + ASSERT_TRUE(loadUrlSync(environment->urlForResource("file_chooser.html").data())); + + // Click on the file input. + mouseClick(15, 15); + + // Wait for the file chooser request. + while (!request) + ecore_main_loop_iterate(); + + evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest); + ASSERT_TRUE(request); + + ASSERT_TRUE(ewk_file_chooser_request_cancel(request)); + ASSERT_FALSE(ewk_file_chooser_request_cancel(request)); + + ewk_file_chooser_request_unref(request); + + ecore_main_loop_iterate(); + EXPECT_STREQ("File chooser test", ewk_view_title_get(webView())); + + // Default behavior is to cancel if the client does not act on the request. + request = 0; + evas_object_smart_callback_add(webView(), "file,chooser,request", onFileChooserRequest, &request); + // Click on the file input. + mouseClick(15, 15); + + // Wait for the file chooser request. + while (!request) + ecore_main_loop_iterate(); + + evas_object_smart_callback_del(webView(), "file,chooser,request", onFileChooserRequest); + ASSERT_TRUE(request); + + ewk_file_chooser_request_unref(request); + + ecore_main_loop_iterate(); + EXPECT_STREQ("File chooser test", ewk_view_title_get(webView())); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_object.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_object.cpp new file mode 100644 index 000000000..1c96f2e80 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_object.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include "UnitTestUtils/EWK2UnitTestServer.h" +#include "WKEinaSharedString.h" +#include "ewk_object_private.h" +#include <EWebKit2.h> +#include <gtest/gtest.h> +#include <wtf/PassRefPtr.h> + +using namespace EWK2UnitTest; +using namespace WTF; + +extern EWK2UnitTestEnvironment* environment; + +class TestEwkObject1 : public Ewk_Object { +public: + EWK_OBJECT_DECLARE(TestEwkObject) + + static PassRefPtr<TestEwkObject1> create() + { + wasDeleted = false; + return adoptRef(new TestEwkObject1()); + } + + static bool wasDeleted; // We always test only one instance of TestEwkObject. + + ~TestEwkObject1() + { + wasDeleted = true; + } +}; + +bool TestEwkObject1::wasDeleted = false; + +class TestEwkObject2 : public Ewk_Object { +public: + EWK_OBJECT_DECLARE(TestEwkObject2) + + static PassRefPtr<TestEwkObject2> create() + { + return adoptRef(new TestEwkObject2()); + } +}; + +TEST_F(EWK2UnitTestBase, ewk_object_ref) +{ + Ewk_Object* objectRef = 0; + + { + RefPtr<Ewk_Object> object = TestEwkObject1::create(); + ASSERT_FALSE(TestEwkObject1::wasDeleted); + ASSERT_EQ(1, object->refCount()); + + objectRef = object.get(); + ewk_object_ref(objectRef); + ASSERT_EQ(2, objectRef->refCount()); + } + + ASSERT_FALSE(TestEwkObject1::wasDeleted); + ASSERT_EQ(1, objectRef->refCount()); + + ewk_object_unref(objectRef); + ASSERT_TRUE(TestEwkObject1::wasDeleted); +} + +TEST_F(EWK2UnitTestBase, ewk_object_is_of_type) +{ + RefPtr<Ewk_Object> object1 = TestEwkObject1::create(); + RefPtr<Ewk_Object> object2 = TestEwkObject2::create(); + + ASSERT_TRUE(ewk_object_is_of_type<TestEwkObject1*>(object1.get())); + ASSERT_TRUE(ewk_object_is_of_type<TestEwkObject2*>(object2.get())); + + ASSERT_FALSE(ewk_object_is_of_type<TestEwkObject1*>(object2.get())); + ASSERT_FALSE(ewk_object_is_of_type<TestEwkObject2*>(object1.get())); +} + +TEST_F(EWK2UnitTestBase, ewk_object_cast) +{ + RefPtr<Ewk_Object> object1 = TestEwkObject1::create(); + RefPtr<Ewk_Object> object2 = TestEwkObject2::create(); + + TestEwkObject1* objectRef1 = ewk_object_cast<TestEwkObject1*>(object1.get()); + ASSERT_TRUE(objectRef1); + + TestEwkObject2* objectRef2 = ewk_object_cast<TestEwkObject2*>(object2.get()); + ASSERT_TRUE(objectRef2); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_popup_menu.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_popup_menu.cpp new file mode 100644 index 000000000..7a033519a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_popup_menu.cpp @@ -0,0 +1,105 @@ +/* + Copyright (C) 2012 Samsung Electronics + Copyright (C) 2012 Intel Corporation. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include <EWebKit2.h> +#include <Ecore.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static Ewk_Popup_Menu* s_popupMenu = 0; + +static inline void checkBasicPopupMenuItem(Ewk_Popup_Menu_Item* item, const char* title, bool enabled) +{ + EXPECT_EQ(EWK_POPUP_MENU_ITEM, ewk_popup_menu_item_type_get(item)); + EXPECT_STREQ(title, ewk_popup_menu_item_text_get(item)); + EXPECT_EQ(enabled, ewk_popup_menu_item_enabled_get(item)); +} + +static Eina_Bool selectItemAfterDelayed(void* data) +{ + EXPECT_TRUE(ewk_popup_menu_selected_index_set(static_cast<Ewk_Popup_Menu*>(data), 0)); + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool showPopupMenu(Ewk_View_Smart_Data* smartData, Eina_Rectangle, Ewk_Text_Direction, double, Ewk_Popup_Menu* popupMenu) +{ + s_popupMenu = popupMenu; + + EXPECT_EQ(2, ewk_popup_menu_selected_index_get(popupMenu)); + + const Eina_List* list = ewk_popup_menu_items_get(popupMenu); + + Ewk_Popup_Menu_Item* item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 0)); + checkBasicPopupMenuItem(item, "first", true); + EXPECT_EQ(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, ewk_popup_menu_item_text_direction_get(item)); + EXPECT_STREQ("", ewk_popup_menu_item_tooltip_get(item)); + EXPECT_STREQ("", ewk_popup_menu_item_accessibility_text_get(item)); + EXPECT_FALSE(ewk_popup_menu_item_is_label_get(item)); + EXPECT_FALSE(ewk_popup_menu_item_selected_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 1)); + checkBasicPopupMenuItem(item, "second", false); + EXPECT_FALSE(ewk_popup_menu_item_enabled_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 2)); + checkBasicPopupMenuItem(item, "third", true); + EXPECT_EQ(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, ewk_popup_menu_item_text_direction_get(item)); + EXPECT_STREQ("tooltip", ewk_popup_menu_item_tooltip_get(item)); + EXPECT_STREQ("aria", ewk_popup_menu_item_accessibility_text_get(item)); + EXPECT_TRUE(ewk_popup_menu_item_selected_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 3)); + checkBasicPopupMenuItem(item, "label", false); + EXPECT_TRUE(ewk_popup_menu_item_is_label_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 4)); + checkBasicPopupMenuItem(item, " forth", true); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 5)); + EXPECT_EQ(EWK_POPUP_MENU_UNKNOWN, ewk_popup_menu_item_type_get(item)); + EXPECT_STREQ(0, ewk_popup_menu_item_text_get(item)); + + ecore_timer_add(0, selectItemAfterDelayed, popupMenu); + return true; +} + +TEST_F(EWK2UnitTestBase, ewk_popup_menu_select_item) +{ + const char* selectHTML = + "<!doctype html><body><select onchange=\"document.title=this.value;\">" + "<option>first</option><option disabled>second</option><option selected dir=\"rtl\" title=\"tooltip\" aria-label=\"aria\">third</option>" + "<optgroup label=\"label\"><option>forth</option></optgroup>" + "</select></body>"; + + ewkViewClass()->popup_menu_show = showPopupMenu; + + ewk_view_html_string_load(webView(), selectHTML, "file:///", 0); + ASSERT_TRUE(waitUntilLoadFinished()); + mouseClick(30, 20); + ASSERT_TRUE(waitUntilTitleChangedTo("first")); + + ASSERT_TRUE(s_popupMenu); + EXPECT_TRUE(ewk_popup_menu_close(s_popupMenu)); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp index 32f981788..d3312f8fe 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp @@ -157,3 +157,17 @@ TEST_F(EWK2UnitTestBase, ewk_settings_dns_prefetching_enabled) ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_set(settings, false)); ASSERT_FALSE(ewk_settings_dns_prefetching_enabled_get(settings)); } + +TEST_F(EWK2UnitTestBase, ewk_setting_encoding_detector_enabled) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + + // The encoding detector is disabled by default. + ASSERT_FALSE(ewk_setting_encoding_detector_enabled_get(settings)); + + ASSERT_TRUE(ewk_setting_encoding_detector_enabled_set(settings, true)); + ASSERT_TRUE(ewk_setting_encoding_detector_enabled_get(settings)); + + ASSERT_TRUE(ewk_setting_encoding_detector_enabled_set(settings, false)); + ASSERT_FALSE(ewk_setting_encoding_detector_enabled_get(settings)); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_storage_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_storage_manager.cpp new file mode 100644 index 000000000..b5d962a9a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_storage_manager.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * 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 "UnitTestUtils/EWK2UnitTestBase.h" +#include <EWebKit2.h> +#include <Ecore.h> +#include <gtest/gtest.h> + +using namespace EWK2UnitTest; + +struct OriginData { + Eina_List* originList; + Ewk_Storage_Manager* manager; + bool didReceiveOriginsCallback; + bool isSynchronized; + unsigned timeToCheck; + + OriginData() + : originList(0) + , manager(0) + , didReceiveOriginsCallback(false) + , isSynchronized(false) + , timeToCheck(10) + { } +}; + +static void getStorageOriginsCallback(Eina_List* origins, Ewk_Error* error, void* userData) +{ + ASSERT_FALSE(error); + + OriginData* originData = static_cast<OriginData*>(userData); + originData->didReceiveOriginsCallback = true; + + Eina_List* l; + void* data; + EINA_LIST_FOREACH(origins, l, data) { + originData->originList = eina_list_append(originData->originList, data); + Ewk_Security_Origin* origin = static_cast<Ewk_Security_Origin*>(data); + if (!strcmp(ewk_security_origin_protocol_get(origin), "http") + && !strcmp(ewk_security_origin_host_get(origin), "www.storagetest.com") + && !ewk_security_origin_port_get(origin)) { + originData->isSynchronized = true; + ecore_main_loop_quit(); + } + } +} + +static bool timerCallback(void* userData) +{ + OriginData* originData = static_cast<OriginData*>(userData); + + if (originData->isSynchronized || !--(originData->timeToCheck)) { + ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; + } + + if (originData->didReceiveOriginsCallback) { + originData->didReceiveOriginsCallback = false; + ewk_storage_manager_origins_get(originData->manager, getStorageOriginsCallback, originData); + } + + return ECORE_CALLBACK_RENEW; +} + +static bool checkOrigin(Eina_List* origins, Ewk_Security_Origin** origin) +{ + Eina_List* l; + void* data; + EINA_LIST_FOREACH(origins, l, data) { + *origin = static_cast<Ewk_Security_Origin*>(data); + if (!strcmp(ewk_security_origin_protocol_get(*origin), "http") + && !strcmp(ewk_security_origin_host_get(*origin), "www.storagetest.com") + && !ewk_security_origin_port_get(*origin)) + return true; + } + + return false; +} + +TEST_F(EWK2UnitTestBase, ewk_storage_manager_origins_get) +{ + Evas_Object* view = webView(); + const char* storageHTML = + "<html><head><title>original title</title></head>" + "<body>" + "<script type='text/javascript'>" + " localStorage.setItem('item', 'storage');" + "</script>" + "</body></html>"; + + ewk_view_html_string_load(view, storageHTML, "http://www.storagetest.com", 0); + + OriginData originData; + originData.manager = ewk_context_storage_manager_get(ewk_view_context_get(view)); + ASSERT_TRUE(ewk_storage_manager_origins_get(originData.manager, getStorageOriginsCallback, &originData)); + Ecore_Timer* storage_timer = ecore_timer_add(1, reinterpret_cast<Ecore_Task_Cb>(timerCallback), &originData); + + ecore_main_loop_begin(); + if (storage_timer) + ecore_timer_del(storage_timer); + + ASSERT_TRUE(originData.isSynchronized); + ASSERT_LE(1, eina_list_count(originData.originList)); + + Ewk_Security_Origin* origin = 0; + EXPECT_TRUE(checkOrigin(originData.originList, &origin)); + + EXPECT_EQ(origin, ewk_security_origin_ref(origin)); + ewk_security_origin_unref(origin); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp index d4bb70fbf..80240d2ae 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -38,6 +38,14 @@ using namespace EWK2UnitTest; extern EWK2UnitTestEnvironment* environment; bool fullScreenCallbackCalled; +TEST_F(EWK2UnitTestBase, ewk_view_type_check) +{ + ASSERT_FALSE(ewk_view_context_get(0)); + + Evas_Object* rectangle = evas_object_rectangle_add(canvas()); + ASSERT_FALSE(ewk_view_url_set(rectangle, 0)); +} + static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*) { int* countLoadFinished = static_cast<int*>(userData); @@ -193,76 +201,6 @@ TEST_F(EWK2UnitTestBase, ewk_view_form_submission_request) evas_object_smart_callback_del(webView(), "form,submission,request", onFormAboutToBeSubmitted); } -static inline void checkBasicPopupMenuItem(Ewk_Popup_Menu_Item* item, const char* title, bool enabled) -{ - EXPECT_EQ(EWK_POPUP_MENU_ITEM, ewk_popup_menu_item_type_get(item)); - EXPECT_STREQ(title, ewk_popup_menu_item_text_get(item)); - EXPECT_EQ(enabled, ewk_popup_menu_item_enabled_get(item)); -} - -static Eina_Bool selectItemAfterDelayed(void* data) -{ - EXPECT_TRUE(ewk_view_popup_menu_select(static_cast<Evas_Object*>(data), 0)); - return ECORE_CALLBACK_CANCEL; -} - -static Eina_Bool showPopupMenu(Ewk_View_Smart_Data* smartData, Eina_Rectangle, Ewk_Text_Direction, double, Eina_List* list, int selectedIndex) -{ - EXPECT_EQ(2, selectedIndex); - - Ewk_Popup_Menu_Item* item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 0)); - checkBasicPopupMenuItem(item, "first", true); - EXPECT_EQ(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, ewk_popup_menu_item_text_direction_get(item)); - EXPECT_STREQ("", ewk_popup_menu_item_tooltip_get(item)); - EXPECT_STREQ("", ewk_popup_menu_item_accessibility_text_get(item)); - EXPECT_FALSE(ewk_popup_menu_item_is_label_get(item)); - EXPECT_FALSE(ewk_popup_menu_item_selected_get(item)); - - item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 1)); - checkBasicPopupMenuItem(item, "second", false); - EXPECT_FALSE(ewk_popup_menu_item_enabled_get(item)); - - item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 2)); - checkBasicPopupMenuItem(item, "third", true); - EXPECT_EQ(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, ewk_popup_menu_item_text_direction_get(item)); - EXPECT_STREQ("tooltip", ewk_popup_menu_item_tooltip_get(item)); - EXPECT_STREQ("aria", ewk_popup_menu_item_accessibility_text_get(item)); - EXPECT_TRUE(ewk_popup_menu_item_selected_get(item)); - - item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 3)); - checkBasicPopupMenuItem(item, "label", false); - EXPECT_TRUE(ewk_popup_menu_item_is_label_get(item)); - - item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 4)); - checkBasicPopupMenuItem(item, " forth", true); - - item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 5)); - EXPECT_EQ(EWK_POPUP_MENU_UNKNOWN, ewk_popup_menu_item_type_get(item)); - EXPECT_STREQ(0, ewk_popup_menu_item_text_get(item)); - - ecore_timer_add(0, selectItemAfterDelayed, smartData->self); - return true; -} - -TEST_F(EWK2UnitTestBase, ewk_view_popup_menu_select) -{ - const char* selectHTML = - "<!doctype html><body><select onchange=\"document.title=this.value;\">" - "<option>first</option><option disabled>second</option><option selected dir=\"rtl\" title=\"tooltip\" aria-label=\"aria\">third</option>" - "<optgroup label=\"label\"><option>forth</option></optgroup>" - "</select></body>"; - - ewkViewClass()->popup_menu_show = showPopupMenu; - - ewk_view_html_string_load(webView(), selectHTML, "file:///", 0); - ASSERT_TRUE(waitUntilLoadFinished()); - mouseClick(30, 20); - ASSERT_TRUE(waitUntilTitleChangedTo("first")); - - EXPECT_TRUE(ewk_view_popup_menu_close(webView())); - EXPECT_FALSE(ewk_view_popup_menu_select(webView(), 0)); -} - TEST_F(EWK2UnitTestBase, ewk_view_settings_get) { Ewk_Settings* settings = ewk_view_settings_get(webView()); @@ -612,135 +550,6 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) EXPECT_FALSE(promptCallbackData.called); } -#if ENABLE(INPUT_TYPE_COLOR) -static const int initialRed = 0x12; -static const int initialGreen = 0x34; -static const int initialBlue = 0x56; -static const int initialAlpha = 0xff; -static const int changedRed = 0x98; -static const int changedGreen = 0x76; -static const int changedBlue = 0x54; -static const int changedAlpha = 0xff; - -static bool isColorPickerShown = false; - -static void onColorPickerDone(void* userData, Evas_Object*, void*) -{ - bool* handled = static_cast<bool*>(userData); - - *handled = true; -} - -static unsigned char setColorPickerColor(void* data) -{ - Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); - - // 4. Change color to changed color. - EXPECT_TRUE(ewk_view_color_picker_color_set(smartData->self, changedRed, changedGreen, changedBlue, changedAlpha)); - - evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); - - return 0; -} - -static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a) -{ - static bool isFirstRun = true; - - isColorPickerShown = true; - - if (isFirstRun) { - // 2. Check initial value from html file. - EXPECT_EQ(initialRed, r); - EXPECT_EQ(initialGreen, g); - EXPECT_EQ(initialBlue, b); - EXPECT_EQ(initialAlpha, a); - - isFirstRun = false; - } else { - // 7. Input values should be same as changed color. - EXPECT_EQ(changedRed, r); - EXPECT_EQ(changedGreen, g); - EXPECT_EQ(changedBlue, b); - EXPECT_EQ(changedAlpha, a); - - evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); - return true; - } - - // 3. Return after making a color picker. - ecore_timer_add(0.0, setColorPickerColor, smartData); - return true; -} - -static Eina_Bool hideColorPicker(Ewk_View_Smart_Data*) -{ - // 5. Test color picker is shown. - EXPECT_TRUE(isColorPickerShown); - isColorPickerShown = false; -} - -static Eina_Bool hideColorPickerByRemovingElement(Ewk_View_Smart_Data* smartData) -{ - // 9. input_picker_color_dismiss() is called if the element is removed. - EXPECT_TRUE(isColorPickerShown); - isColorPickerShown = false; - evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); -} - -TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set) -{ - Ewk_View_Smart_Class* api = ewkViewClass(); - api->input_picker_color_request = showColorPicker; - api->input_picker_color_dismiss = hideColorPicker; - - const char colorPickerHTML[] = - "<!DOCTYPE html>" - "<html>" - "<head>" - "<script>function removeInputElement(){" - "var parentElement = document.getElementById('parent');" - "var inputElement = document.getElementById('color');" - "parentElement.removeChild(inputElement);" - "}</script>" - "</head>" - "<body>" - "<div id='parent'>" - "<input type='color' value='#123456' id='color'>" - "<button onclick='removeInputElement();'>Remove Element</button>" - "</div>" - "</body>" - "</html>"; - - ewk_view_html_string_load(webView(), colorPickerHTML, 0, 0); - waitUntilLoadFinished(); - - // 1. Click input element to show color picker. - mouseClick(30, 20); - - bool handled = false; - evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled); - while (!handled) - ecore_main_loop_iterate(); - - // 6. Click input element to show color picker again. - mouseClick(30, 20); - - handled = false; - while (!handled) - ecore_main_loop_iterate(); - - // 8. Click button to remove input element durlng color picker is shown. - api->input_picker_color_dismiss = hideColorPickerByRemovingElement; - mouseClick(80, 20); - - handled = false; - while (!handled) - ecore_main_loop_iterate(); - evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone); -} -#endif // ENABLE(INPUT_TYPE_COLOR) - TEST_F(EWK2UnitTestBase, ewk_view_context_get) { Ewk_Context* context = ewk_view_context_get(webView()); @@ -959,3 +768,32 @@ TEST_F(EWK2UnitTestBase, ewk_view_scale) ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); ASSERT_FLOAT_EQ(1, ewk_view_scale_get(webView())); } + +TEST_F(EWK2UnitTestBase, ewk_view_pagination) +{ + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + + // Default pagination value is EWK_PAGINATION_MODE_UNPAGINATED + ASSERT_EQ(EWK_PAGINATION_MODE_UNPAGINATED, ewk_view_pagination_mode_get(webView())); + + ASSERT_TRUE(ewk_view_pagination_mode_set(webView(), EWK_PAGINATION_MODE_LEFT_TO_RIGHT)); + // Reload page to check the pagination mode. + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + ASSERT_EQ(EWK_PAGINATION_MODE_LEFT_TO_RIGHT, ewk_view_pagination_mode_get(webView())); + + ASSERT_TRUE(ewk_view_pagination_mode_set(webView(), EWK_PAGINATION_MODE_RIGHT_TO_LEFT)); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + ASSERT_EQ(EWK_PAGINATION_MODE_RIGHT_TO_LEFT, ewk_view_pagination_mode_get(webView())); + + ASSERT_TRUE(ewk_view_pagination_mode_set(webView(), EWK_PAGINATION_MODE_TOP_TO_BOTTOM)); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + ASSERT_EQ(EWK_PAGINATION_MODE_TOP_TO_BOTTOM, ewk_view_pagination_mode_get(webView())); + + ASSERT_TRUE(ewk_view_pagination_mode_set(webView(), EWK_PAGINATION_MODE_BOTTOM_TO_TOP)); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + ASSERT_EQ(EWK_PAGINATION_MODE_BOTTOM_TO_TOP, ewk_view_pagination_mode_get(webView())); + + ASSERT_TRUE(ewk_view_pagination_mode_set(webView(), EWK_PAGINATION_MODE_UNPAGINATED)); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + ASSERT_EQ(EWK_PAGINATION_MODE_UNPAGINATED, ewk_view_pagination_mode_get(webView())); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp index d42b8b703..248d07284 100644 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp @@ -306,4 +306,9 @@ void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<Sha webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage); } +void PageClientImpl::handleDownloadRequest(DownloadProxy* download) +{ + webkitWebViewBaseHandleDownloadRequest(WEBKIT_WEB_VIEW_BASE(m_viewWidget), download); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h index f4afd06d9..d9b34c52b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h @@ -103,6 +103,8 @@ private: virtual double customRepresentationZoomFactor(); virtual void setCustomRepresentationZoomFactor(double); + virtual void handleDownloadRequest(DownloadProxy*); + // Members of PageClientImpl class GtkWidget* m_viewWidget; WebCore::KeyBindingTranslator m_keyBindingTranslator; diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp index 602d37999..56eae4437 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp @@ -248,7 +248,7 @@ guint webkit_back_forward_list_get_length(WebKitBackForwardList* backForwardList * webkit_back_forward_list_get_back_list: * @back_forward_list: a #WebKitBackForwardList * - * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of + * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of * items preceding the current item. */ GList* webkit_back_forward_list_get_back_list(WebKitBackForwardList* backForwardList) @@ -263,7 +263,7 @@ GList* webkit_back_forward_list_get_back_list(WebKitBackForwardList* backForward * @back_forward_list: a #WebKitBackForwardList * @limit: the number of items to retrieve * - * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of + * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of * items preceding the current item limited by @limit. */ GList* webkit_back_forward_list_get_back_list_with_limit(WebKitBackForwardList* backForwardList, guint limit) @@ -278,7 +278,7 @@ GList* webkit_back_forward_list_get_back_list_with_limit(WebKitBackForwardList* * webkit_back_forward_list_get_forward_list: * @back_forward_list: a #WebKitBackForwardList * - * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of + * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of * items following the current item. */ GList* webkit_back_forward_list_get_forward_list(WebKitBackForwardList* backForwardList) @@ -293,7 +293,7 @@ GList* webkit_back_forward_list_get_forward_list(WebKitBackForwardList* backForw * @back_forward_list: a #WebKitBackForwardList * @limit: the number of items to retrieve * - * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of + * Returns: (element-type WebKit2.BackForwardListItem) (transfer container): a #GList of * items following the current item limited by @limit. */ GList* webkit_back_forward_list_get_forward_list_with_limit(WebKitBackForwardList* backForwardList, guint limit) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp index cc3b51f52..a6754de06 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp @@ -57,6 +57,7 @@ struct _WebKitDownloadPrivate { GRefPtr<WebKitURIRequest> request; GRefPtr<WebKitURIResponse> response; + WebKitWebView* webView; CString destinationURI; guint64 currentSize; bool isCancelled; @@ -71,7 +72,10 @@ G_DEFINE_TYPE(WebKitDownload, webkit_download, G_TYPE_OBJECT) static void webkitDownloadFinalize(GObject* object) { - WEBKIT_DOWNLOAD(object)->priv->~WebKitDownloadPrivate(); + WebKitDownloadPrivate* priv = WEBKIT_DOWNLOAD(object)->priv; + if (priv->webView) + g_object_remove_weak_pointer(G_OBJECT(priv->webView), reinterpret_cast<void**>(&priv->webView)); + priv->~WebKitDownloadPrivate(); G_OBJECT_CLASS(webkit_download_parent_class)->finalize(object); } @@ -278,6 +282,12 @@ void webkitDownloadSetResponse(WebKitDownload* download, WebKitURIResponse* resp g_object_notify(G_OBJECT(download), "response"); } +void webkitDownloadSetWebView(WebKitDownload* download, WebKitWebView* webView) +{ + download->priv->webView = webView; + g_object_add_weak_pointer(G_OBJECT(webView), reinterpret_cast<void**>(&download->priv->webView)); +} + bool webkitDownloadIsCancelled(WebKitDownload* download) { return download->priv->isCancelled; @@ -530,3 +540,19 @@ guint64 webkit_download_get_received_data_length(WebKitDownload* download) return download->priv->currentSize; } + +/** + * webkit_download_get_web_view: + * @download: a #WebKitDownload + * + * Get the #WebKitWebView that initiated the download. + * + * Returns: (transfer none): the #WebKitWebView that initiated @download, + * or %NULL if @download was not initiated by a #WebKitWebView. + */ +WebKitWebView* webkit_download_get_web_view(WebKitDownload* download) +{ + g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0); + + return download->priv->webView; +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h index a02aa57fd..448bebf6b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h @@ -81,7 +81,10 @@ WEBKIT_API gdouble webkit_download_get_elapsed_time (WebKitDownload *download); WEBKIT_API guint64 -webkit_download_get_received_data_length (WebKitDownload* download); +webkit_download_get_received_data_length (WebKitDownload *download); + +WEBKIT_API WebKitWebView * +webkit_download_get_web_view (WebKitDownload *download); G_END_DECLS diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h index 215f565d5..d7b43050c 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadPrivate.h @@ -28,6 +28,7 @@ WebKitDownload* webkitDownloadCreate(WebKit::DownloadProxy*); bool webkitDownloadIsCancelled(WebKitDownload*); void webkitDownloadSetResponse(WebKitDownload*, WebKitURIResponse*); +void webkitDownloadSetWebView(WebKitDownload*, WebKitWebView*); void webkitDownloadNotifyProgress(WebKitDownload*, guint64 bytesReceived); void webkitDownloadFailed(WebKitDownload*, const WebCore::ResourceError&); void webkitDownloadCancelled(WebKitDownload*); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp index ca60a5dc2..7707c70ab 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp @@ -179,7 +179,7 @@ static gpointer createDefaultWebContext(gpointer) * * Gets the default web context * - * Returns: (transfer none) a #WebKitWebContext + * Returns: (transfer none): a #WebKitWebContext */ WebKitWebContext* webkit_web_context_get_default(void) { @@ -290,7 +290,10 @@ static DownloadsMap& downloadsMap() * @context: a #WebKitWebContext * @uri: the URI to download * - * Requests downloading of the specified URI string. + * Requests downloading of the specified URI string. The download operation + * will not be associated to any #WebKitWebView, if you are interested in + * starting a download from a particular #WebKitWebView use + * webkit_web_view_download_uri() instead. * * Returns: (transfer full): a new #WebKitDownload representing the * the download operation. @@ -300,10 +303,7 @@ WebKitDownload* webkit_web_context_download_uri(WebKitWebContext* context, const g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); g_return_val_if_fail(uri, 0); - DownloadProxy* downloadProxy = context->priv->context->download(0, WebCore::ResourceRequest(String::fromUTF8(uri))); - WebKitDownload* download = webkitDownloadCreate(downloadProxy); - downloadsMap().set(downloadProxy, download); - return download; + return webkitWebContextStartDownload(context, uri, 0); } /** @@ -695,6 +695,14 @@ WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy return download.get(); } +WebKitDownload* webkitWebContextStartDownload(WebKitWebContext* context, const char* uri, WebPageProxy* initiatingPage) +{ + DownloadProxy* downloadProxy = context->priv->context->download(initiatingPage, WebCore::ResourceRequest(String::fromUTF8(uri))); + WebKitDownload* download = webkitDownloadCreate(downloadProxy); + downloadsMap().set(downloadProxy, download); + return download; +} + void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy) { downloadsMap().remove(downloadProxy); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h index ace23df4f..f97e167ed 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h @@ -35,6 +35,7 @@ WebKit::WebContext* webkitWebContextGetContext(WebKitWebContext*); WebKitDownload* webkitWebContextGetOrCreateDownload(WebKit::DownloadProxy*); +WebKitDownload* webkitWebContextStartDownload(WebKitWebContext*, const char* uri, WebKit::WebPageProxy*); void webkitWebContextRemoveDownload(WebKit::DownloadProxy*); void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*); WebKit::WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index de0f28dce..506f11a55 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -28,6 +28,7 @@ #include "WebKitContextMenuClient.h" #include "WebKitContextMenuItemPrivate.h" #include "WebKitContextMenuPrivate.h" +#include "WebKitDownloadPrivate.h" #include "WebKitEnumTypes.h" #include "WebKitError.h" #include "WebKitFaviconDatabasePrivate.h" @@ -390,6 +391,12 @@ static gboolean webkitWebViewRunFileChooser(WebKitWebView* webView, WebKitFileCh return TRUE; } +static void webkitWebViewHandleDownloadRequest(WebKitWebViewBase* webViewBase, DownloadProxy* downloadProxy) +{ + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy); + webkitDownloadSetWebView(download.get(), WEBKIT_WEB_VIEW(webViewBase)); +} + static void webkitWebViewConstructed(GObject* object) { if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed) @@ -400,6 +407,7 @@ static void webkitWebViewConstructed(GObject* object) WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView); webkitWebViewBaseCreateWebPage(webViewBase, webkitWebContextGetContext(priv->context), 0); + webkitWebViewBaseSetDownloadRequestHandler(webViewBase, webkitWebViewHandleDownloadRequest); attachLoaderClientToView(webView); attachUIClientToView(webView); @@ -2758,3 +2766,24 @@ gboolean webkit_web_view_save_to_file_finish(WebKitWebView* webView, GAsyncResul return TRUE; } + +/** + * webkit_web_view_download_uri: + * @web_view: a #WebKitWebView + * @uri: the URI to download + * + * Requests downloading of the specified URI string for @web_view. + * + * Returns: (transfer full): a new #WebKitDownload representing the + * the download operation. + */ +WebKitDownload* webkit_web_view_download_uri(WebKitWebView* webView, const char* uri) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + g_return_val_if_fail(uri, 0); + + WebKitDownload* download = webkitWebContextStartDownload(webView->priv->context, uri, getPage(webView)); + webkitDownloadSetWebView(download, webView); + + return download; +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h index ac2e2813f..7c8381329 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h @@ -371,6 +371,10 @@ webkit_web_view_save_to_file_finish (WebKitWebView GAsyncResult *result, GError **error); +WEBKIT_API WebKitDownload * +webkit_web_view_download_uri (WebKitWebView *web_view, + const char *uri); + G_END_DECLS #endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp index e5bac671e..015f668cd 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -108,6 +108,8 @@ struct _WebKitWebViewBasePrivate { bool isFocused : 1; bool isVisible : 1; + WebKitWebViewBaseDownloadRequestHandler downloadHandler; + #if ENABLE(FULLSCREEN_API) bool fullScreenModeActive; WebFullScreenClientGtk fullScreenClient; @@ -978,3 +980,14 @@ bool webkitWebViewBaseIsInWindow(WebKitWebViewBase* webViewBase) { return webViewBase->priv->toplevelOnScreenWindow; } + +void webkitWebViewBaseSetDownloadRequestHandler(WebKitWebViewBase* webViewBase, WebKitWebViewBaseDownloadRequestHandler downloadHandler) +{ + webViewBase->priv->downloadHandler = downloadHandler; +} + +void webkitWebViewBaseHandleDownloadRequest(WebKitWebViewBase* webViewBase, DownloadProxy* download) +{ + if (webViewBase->priv->downloadHandler) + webViewBase->priv->downloadHandler(webViewBase, download); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h index ddb3e1451..ef05f2289 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h @@ -60,4 +60,8 @@ bool webkitWebViewBaseIsFocused(WebKitWebViewBase*); bool webkitWebViewBaseIsVisible(WebKitWebViewBase*); bool webkitWebViewBaseIsInWindow(WebKitWebViewBase*); +typedef void (*WebKitWebViewBaseDownloadRequestHandler) (WebKitWebViewBase*, WebKit::DownloadProxy*); +void webkitWebViewBaseSetDownloadRequestHandler(WebKitWebViewBase*, WebKitWebViewBaseDownloadRequestHandler); +void webkitWebViewBaseHandleDownloadRequest(WebKitWebViewBase*, WebKit::DownloadProxy*); + #endif // WebKitWebViewBasePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt index f56267b9a..2f6f54b0d 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt @@ -122,6 +122,7 @@ webkit_web_view_save webkit_web_view_save_finish webkit_web_view_save_to_file webkit_web_view_save_to_file_finish +webkit_web_view_download_uri <SUBSECTION WebKitJavascriptResult> WebKitJavascriptResult @@ -395,6 +396,7 @@ webkit_download_cancel webkit_download_get_estimated_progress webkit_download_get_elapsed_time webkit_download_get_received_data_length +webkit_download_get_web_view <SUBSECTION Standard> WebKitDownloadClass diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am index 734024250..1db90a628 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am +++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am @@ -58,11 +58,11 @@ webkit2_tests_ldflags = \ -no-install \ -no-fast-install -DerivedSources/WebKit2/webkit2gtk-tests-resources.gresource: Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml) +Programs/resources/webkit2gtk-tests-resources.gresource: Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml) $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $< -DISTCLEANFILES += DerivedSources/WebKit2/webkit2gtk-tests-resources.gresource -noinst_DATA += DerivedSources/WebKit2/webkit2gtk-tests-resources.gresource +DISTCLEANFILES += Programs/resources/webkit2gtk-tests-resources.gresource +noinst_DATA += Programs/resources/webkit2gtk-tests-resources.gresource noinst_LTLIBRARIES += Libraries/libWebKit2APITestCore.la Libraries_libWebKit2APITestCore_la_SOURCES = \ diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp index 9c3262b53..56a62cd09 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp @@ -19,8 +19,8 @@ #include "config.h" -#include "TestMain.h" #include "WebKitTestServer.h" +#include "WebViewTest.h" #include <glib/gstdio.h> #include <gtk/gtk.h> #include <libsoup/soup.h> @@ -184,6 +184,7 @@ static void testDownloadLocalFile(DownloadTest* test, gconstpointer) GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, sourceURI.get())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 5); @@ -248,6 +249,7 @@ static void testDownloadLocalFileError(DownloadErrorTest* test, gconstpointer) GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, "file:///foo/bar")); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 3); @@ -264,6 +266,7 @@ static void testDownloadLocalFileError(DownloadErrorTest* test, gconstpointer) download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, uri.get())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 4); @@ -279,6 +282,7 @@ static void testDownloadLocalFileError(DownloadErrorTest* test, gconstpointer) download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, uri.get())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 4); @@ -324,6 +328,7 @@ static void testDownloadRemoteFile(DownloadTest* test, gconstpointer) GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, kServer->getURIForPath("/test.pdf").data())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 5); @@ -351,6 +356,7 @@ static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer) kServer->getURIForPath("/foo").data())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); Vector<DownloadTest::DownloadEvent>& events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 4); @@ -367,6 +373,7 @@ static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer) download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, kServer->getURIForPath("/test.pdf").data())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 4); @@ -382,6 +389,7 @@ static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer) download = adoptGRef(webkit_web_context_download_uri(test->m_webContext, kServer->getURIForPath("/test.pdf").data())); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download.get())); test->waitUntilDownloadFinishes(); + g_assert(!webkit_download_get_web_view(download.get())); events = test->m_downloadEvents; g_assert_cmpint(events.size(), ==, 4); @@ -394,6 +402,110 @@ static void testDownloadRemoteFileError(DownloadErrorTest* test, gconstpointer) test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename); } +class WebViewDownloadTest: public WebViewTest { +public: + MAKE_GLIB_TEST_FIXTURE(WebViewDownloadTest); + + static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, WebViewDownloadTest* test) + { + test->m_download = download; + test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download)); + test->quitMainLoop(); + } + + WebViewDownloadTest() + { + g_signal_connect(webkit_web_view_get_context(m_webView), "download-started", G_CALLBACK(downloadStartedCallback), this); + } + + ~WebViewDownloadTest() + { + g_signal_handlers_disconnect_matched(webkit_web_view_get_context(m_webView), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); + } + + void waitUntilDownloadStarted() + { + m_download = 0; + g_main_loop_run(m_mainLoop); + g_assert(m_download.get()); + } + + static gboolean downloadDecideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, WebViewDownloadTest* test) + { + GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL)); + GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); + webkit_download_set_destination(download, destinationURI.get()); + return TRUE; + } + + static void downloadFinishedCallback(WebKitDownload* download, WebViewDownloadTest* test) + { + test->quitMainLoop(); + } + + void waitUntilDownloadFinished() + { + g_signal_connect(m_download.get(), "decide-destination", G_CALLBACK(downloadDecideDestinationCallback), this); + g_signal_connect(m_download.get(), "finished", G_CALLBACK(downloadFinishedCallback), this); + g_main_loop_run(m_mainLoop); + } + + GRefPtr<WebKitDownload> m_download; +}; + +static void testWebViewDownloadURI(WebViewDownloadTest* test, gconstpointer) +{ + GRefPtr<WebKitDownload> download = adoptGRef(webkit_web_view_download_uri(test->m_webView, kServer->getURIForPath("/test.pdf").data())); + test->waitUntilDownloadStarted(); + g_assert(test->m_webView == webkit_download_get_web_view(download.get())); + test->waitUntilDownloadFinished(); + + GRefPtr<GFile> downloadFile = adoptGRef(g_file_new_for_uri(webkit_download_get_destination(download.get()))); + GRefPtr<GFileInfo> downloadFileInfo = adoptGRef(g_file_query_info(downloadFile.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, static_cast<GFileQueryInfoFlags>(0), 0, 0)); + g_assert_cmpint(g_file_info_get_size(downloadFileInfo.get()), >, 0); + g_file_delete(downloadFile.get(), 0, 0); +} + +class PolicyResponseDownloadTest: public WebViewDownloadTest { +public: + MAKE_GLIB_TEST_FIXTURE(PolicyResponseDownloadTest); + + static gboolean decidePolicyCallback(WebKitWebView* webView, WebKitPolicyDecision* decision, WebKitPolicyDecisionType type, PolicyResponseDownloadTest* test) + { + if (type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) + return FALSE; + + webkit_policy_decision_download(decision); + return TRUE; + } + + PolicyResponseDownloadTest() + { + g_signal_connect(m_webView, "decide-policy", G_CALLBACK(decidePolicyCallback), this); + } + + ~PolicyResponseDownloadTest() + { + g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); + } + + void cancelDownloadAndWaitUntilFinished() + { + webkit_download_cancel(m_download.get()); + waitUntilDownloadFinished(); + m_download = 0; + } +}; + +static void testPolicyResponseDownload(PolicyResponseDownloadTest* test, gconstpointer) +{ + // Test that a download started by the the policy checker contains the web view. + test->loadURI(kServer->getURIForPath("/test.pdf").data()); + test->waitUntilDownloadStarted(); + g_assert(test->m_webView == webkit_download_get_web_view(test->m_download.get())); + test->cancelDownloadAndWaitUntilFinished(); +} + void beforeAll() { kServer = new WebKitTestServer(); @@ -406,6 +518,8 @@ void beforeAll() DownloadErrorTest::add("Downloads", "local-file-error", testDownloadLocalFileError); DownloadTest::add("Downloads", "remote-file", testDownloadRemoteFile); DownloadErrorTest::add("Downloads", "remote-file-error", testDownloadRemoteFileError); + WebViewDownloadTest::add("WebKitWebView", "download-uri", testWebViewDownloadURI); + PolicyResponseDownloadTest::add("Downloads", "policy-decision-download", testPolicyResponseDownload); } void afterAll() diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp index 9db47f82b..2044ab52e 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp @@ -27,7 +27,7 @@ void afterAll(); static void registerGResource(void) { - GOwnPtr<char> resourcesPath(g_build_filename(WEBKIT_DERIVED_SRC_DIR, "WebKit2", "webkit2gtk-tests-resources.gresource", NULL)); + GOwnPtr<char> resourcesPath(g_build_filename(WEBKIT_EXEC_PATH, "resources", "webkit2gtk-tests-resources.gresource", NULL)); GResource* resource = g_resource_load(resourcesPath.get(), 0); g_assert(resource); diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index ba88107e1..7b54b4bd7 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -139,7 +139,7 @@ PageClientImpl::~PageClientImpl() PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() { - return [m_wkView _wk_createDrawingAreaProxy]; + return [m_wkView _createDrawingAreaProxy]; } void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) @@ -156,7 +156,7 @@ void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scroll { NSRect clippedScrollRect = NSIntersectionRect(scrollRect, NSOffsetRect(scrollRect, -scrollOffset.width(), -scrollOffset.height())); - [m_wkView _wk_cacheWindowBottomCornerRect]; + [m_wkView _cacheWindowBottomCornerRect]; [m_wkView translateRectsNeedingDisplayInRect:clippedScrollRect by:scrollOffset]; [m_wkView scrollRect:clippedScrollRect by:scrollOffset]; @@ -174,7 +174,7 @@ bool PageClientImpl::isViewWindowActive() bool PageClientImpl::isViewFocused() { - return [m_wkView _wk_isFocused]; + return [m_wkView _isFocused]; } void PageClientImpl::makeFirstResponder() @@ -220,17 +220,17 @@ LayerHostingMode PageClientImpl::viewLayerHostingMode() ColorSpaceData PageClientImpl::colorSpace() { - return [m_wkView _wk_colorSpace]; + return [m_wkView _colorSpace]; } void PageClientImpl::processDidCrash() { - [m_wkView _wk_processDidCrash]; + [m_wkView _processDidCrash]; } void PageClientImpl::pageClosed() { - [m_wkView _wk_pageClosed]; + [m_wkView _pageClosed]; #if USE(DICTATION_ALTERNATIVES) m_alternativeTextUIController->clear(); #endif @@ -238,18 +238,18 @@ void PageClientImpl::pageClosed() void PageClientImpl::didRelaunchProcess() { - [m_wkView _wk_didRelaunchProcess]; + [m_wkView _didRelaunchProcess]; } void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip) { - [m_wkView _wk_toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)]; + [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)]; } void PageClientImpl::setCursor(const WebCore::Cursor& cursor) { if (![NSApp _cursorRectCursor]) - [m_wkView _wk_setCursor:cursor.platformCursor()]; + [m_wkView _setCursor:cursor.platformCursor()]; } void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves) @@ -291,7 +291,7 @@ void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo) bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands) { - return [m_wkView _wk_interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands]; + return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands]; } void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) @@ -299,34 +299,34 @@ void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<Sha RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage(); RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]); - [m_wkView _wk_setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag]; + [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag]; } void PageClientImpl::setPromisedData(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer) { RefPtr<Image> image = BitmapImage::create(); image->setData(imageBuffer.get(), true); - [m_wkView _wk_setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName]; + [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName]; } void PageClientImpl::updateTextInputState(bool updateSecureInputState) { - [m_wkView _wk_updateTextInputStateIncludingSecureInputState:updateSecureInputState]; + [m_wkView _updateTextInputStateIncludingSecureInputState:updateSecureInputState]; } void PageClientImpl::resetTextInputState() { - [m_wkView _wk_resetTextInputState]; + [m_wkView _resetTextInputState]; } FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect) { - return [m_wkView _wk_convertToDeviceSpace:rect]; + return [m_wkView _convertToDeviceSpace:rect]; } FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect) { - return [m_wkView _wk_convertToUserSpace:rect]; + return [m_wkView _convertToUserSpace:rect]; } IntPoint PageClientImpl::screenToWindow(const IntPoint& point) @@ -352,7 +352,7 @@ void PageClientImpl::doneWithGestureEvent(const WebGestureEvent&, bool wasEventH void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled) { - [m_wkView _wk_doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled]; + [m_wkView _doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled]; } PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) @@ -375,40 +375,40 @@ PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPage void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate) { - [m_wkView _wk_setFindIndicator:findIndicator fadeOut:fadeOut animate:animate]; + [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate]; } void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data) { - NSData *remoteToken = [NSData dataWithBytes:data.data() length:data.size()]; - [m_wkView _wk_setAccessibilityWebProcessToken:remoteToken]; + NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()]; + [m_wkView _setAccessibilityWebProcessToken:remoteToken]; } #if USE(ACCELERATED_COMPOSITING) void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext) { - [m_wkView _wk_enterAcceleratedCompositingMode:layerTreeContext]; + [m_wkView _enterAcceleratedCompositingMode:layerTreeContext]; } void PageClientImpl::exitAcceleratedCompositingMode() { - [m_wkView _wk_exitAcceleratedCompositingMode]; + [m_wkView _exitAcceleratedCompositingMode]; } void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext) { - [m_wkView _wk_updateAcceleratedCompositingMode:layerTreeContext]; + [m_wkView _updateAcceleratedCompositingMode:layerTreeContext]; } #endif // USE(ACCELERATED_COMPOSITING) void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) { - [m_wkView _wk_pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; + [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; } void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState) { - [m_wkView _wk_setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; + [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier]; } CGContextRef PageClientImpl::containingWindowGraphicsContext() @@ -424,37 +424,37 @@ CGContextRef PageClientImpl::containingWindowGraphicsContext() void PageClientImpl::didChangeScrollbarsForMainFrame() const { - [m_wkView _wk_didChangeScrollbarsForMainFrame]; + [m_wkView _didChangeScrollbarsForMainFrame]; } void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation) { - [m_wkView _wk_setPageHasCustomRepresentation:useCustomRepresentation]; + [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation]; } void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference) { - [m_wkView _wk_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference]; + [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference]; } double PageClientImpl::customRepresentationZoomFactor() { - return [m_wkView _wk_customRepresentationZoomFactor]; + return [m_wkView _customRepresentationZoomFactor]; } void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor) { - [m_wkView _wk_setCustomRepresentationZoomFactor:zoomFactor]; + [m_wkView _setCustomRepresentationZoomFactor:zoomFactor]; } void PageClientImpl::findStringInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount) { - [m_wkView _wk_findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; + [m_wkView _findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; } void PageClientImpl::countStringMatchesInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount) { - [m_wkView _wk_countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; + [m_wkView _countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount]; } void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&) @@ -555,11 +555,10 @@ void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle) bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString) { - return [m_wkView _wk_executeSavedCommandBySelector:NSSelectorFromString(selectorString)]; + return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)]; } #if USE(DICTATION_ALTERNATIVES) - uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives) { return m_alternativeTextUIController->addAlternatives(alternatives); @@ -575,7 +574,7 @@ void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundi if (!isViewVisible() || !isViewInWindow()) return; m_alternativeTextUIController->showAlternatives(m_wkView, boundingBoxOfDictatedText, dictationContext, ^(NSString* acceptedAlternative){ - [m_wkView _wk_handleAcceptedAlternativeText:acceptedAlternative]; + [m_wkView handleAcceptedAlternativeText:acceptedAlternative]; }); } @@ -588,7 +587,6 @@ void PageClientImpl::dismissDictationAlternativeUI() { m_alternativeTextUIController->dismissAlternatives(); } - #endif } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/mac/WKConnection.h b/Source/WebKit2/UIProcess/API/mac/WKConnection.h index bf582b303..52bd85c66 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKConnection.h +++ b/Source/WebKit2/UIProcess/API/mac/WKConnection.h @@ -41,6 +41,8 @@ WK_EXPORT WKConnectionData *_data; } +- (void)sendMessageWithName:(NSString *)messageName body:(id)messageBody; + #pragma mark Delegates @property(assign) id<WKConnectionDelegate> delegate; diff --git a/Source/WebKit2/UIProcess/API/mac/WKConnection.mm b/Source/WebKit2/UIProcess/API/mac/WKConnection.mm index 626ec85e6..8040a6781 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKConnection.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKConnection.mm @@ -27,11 +27,18 @@ #import "WKConnection.h" #import "WKConnectionInternal.h" +#import "ArgumentCodersMac.h" +#import "ArgumentDecoder.h" +#import "ArgumentEncoder.h" #import "WKConnectionRef.h" +#import "WKData.h" #import "WKRetainPtr.h" +#import "WKString.h" #import "WKStringCF.h" #import <wtf/RetainPtr.h> +using namespace WebKit; + @interface WKConnectionData : NSObject { @public // Underlying connection object. @@ -55,6 +62,17 @@ [super dealloc]; } +- (void)sendMessageWithName:(NSString *)messageName body:(id)messageBody +{ + OwnPtr<CoreIPC::ArgumentEncoder> messageData = CoreIPC::ArgumentEncoder::create(); + encode(*messageData, messageBody); + + WKRetainPtr<WKStringRef> wkMessageName = adoptWK(WKStringCreateWithCFString((CFStringRef)messageName)); + WKRetainPtr<WKDataRef> wkMessageBody = adoptWK(WKDataCreate(messageData->buffer(), messageData->bufferSize())); + + WKConnectionPostMessage(_data->_connectionRef.get(), wkMessageName.get(), wkMessageBody.get()); +} + #pragma mark Delegates - (id<WKConnectionDelegate>)delegate @@ -75,9 +93,17 @@ static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRe { WKConnection *connection = (WKConnection *)clientInfo; if ([connection.delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) { - // FIXME: Add messageBody conversion. RetainPtr<CFStringRef> cfMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName)); - [connection.delegate connection:connection didReceiveMessageWithName:(NSString *)cfMessageName.get() body:nil]; + + WKDataRef messageData = (WKDataRef)messageBody; + OwnPtr<CoreIPC::ArgumentDecoder> decoder = CoreIPC::ArgumentDecoder::create(WKDataGetBytes(messageData), WKDataGetSize(messageData)); + + RetainPtr<id> messageDictionary; + // FIXME: Don't just silently drop decoding failures on the ground. + if (!decode(decoder.get(), messageDictionary)) + return; + + [connection.delegate connection:connection didReceiveMessageWithName:(NSString *)cfMessageName.get() body:messageDictionary.get()]; } } diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index ac037fb30..5fd169c84 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. + * 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 @@ -26,6 +26,11 @@ #import "config.h" #import "WKView.h" +#if USE(DICTATION_ALTERNATIVES) +#import <AppKit/NSTextAlternatives.h> +#import <AppKit/NSAttributedString.h> +#endif + #import "AttributedString.h" #import "ColorSpaceData.h" #import "DataReference.h" @@ -41,16 +46,14 @@ #import "PDFViewController.h" #import "PageClientImpl.h" #import "PasteboardTypes.h" +#import "RemoteLayerTreeDrawingAreaProxy.h" #import "StringUtilities.h" #import "TextChecker.h" #import "TextCheckerState.h" #import "TiledCoreAnimationDrawingAreaProxy.h" #import "WKAPICast.h" -#import "WKBrowsingContextControllerInternal.h" -#import "WKBrowsingContextGroupInternal.h" #import "WKFullScreenWindowController.h" #import "WKPrintingView.h" -#import "WKProcessGroupInternal.h" #import "WKStringCF.h" #import "WKTextInputWindowController.h" #import "WKViewInternal.h" @@ -67,7 +70,6 @@ #import <WebCore/DragController.h> #import <WebCore/DragData.h> #import <WebCore/DragSession.h> -#import <WebCore/FileSystem.h> #import <WebCore/FloatRect.h> #import <WebCore/Image.h> #import <WebCore/IntRect.h> @@ -80,14 +82,17 @@ #import <WebCore/SharedBuffer.h> #import <WebCore/TextAlternativeWithRange.h> #import <WebCore/WebCoreNSStringExtras.h> +#import <WebCore/FileSystem.h> #import <WebKitSystemInterface.h> #import <sys/stat.h> #import <wtf/RefPtr.h> #import <wtf/RetainPtr.h> -#if USE(DICTATION_ALTERNATIVES) -#import <AppKit/NSTextAlternatives.h> -#endif +/* API internals. */ +#import "WKBrowsingContextControllerInternal.h" +#import "WKBrowsingContextGroupInternal.h" +#import "WKProcessGroupInternal.h" + @interface NSApplication (WKNSApplicationDetails) - (void)speakString:(NSString *)string; @@ -130,12 +135,13 @@ struct WKViewInterpretKeyEventsParameters { }; @interface WKView () -- (void)_wk_accessibilityRegisterUIProcessTokens; -- (void)_wk_disableComplexTextInputIfNecessary; -- (float)_wk_intrinsicDeviceScaleFactor; -- (void)_wk_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent; -- (void)_wk_setDrawingAreaSize:(NSSize)size; -- (void)_wk_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState; +- (void)_accessibilityRegisterUIProcessTokens; +- (void)_disableComplexTextInputIfNecessary; +- (float)_intrinsicDeviceScaleFactor; +- (void)_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent; +- (void)_setDrawingAreaSize:(NSSize)size; +- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState; +- (BOOL)_shouldUseTiledDrawingArea; @end @interface WKViewData : NSObject { @@ -209,8 +215,6 @@ struct WKViewInterpretKeyEventsParameters { RefPtr<WebCore::Image> _promisedImage; String _promisedFilename; String _promisedURL; - - RetainPtr<NSMutableArray> _observers; } @end @@ -218,6 +222,7 @@ struct WKViewInterpretKeyEventsParameters { @implementation WKViewData @end + @interface WKResponderChainSink : NSResponder { NSResponder *_lastResponderInChain; bool _didReceiveUnhandledCommand; @@ -303,7 +308,7 @@ struct WKViewInterpretKeyEventsParameters { _data->_inBecomeFirstResponder = true; - [self _wk_updateSecureInputState]; + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused); _data->_inBecomeFirstResponder = false; @@ -324,7 +329,7 @@ struct WKViewInterpretKeyEventsParameters { if (_data->_page->editorState().hasComposition && !_data->_page->editorState().shouldIgnoreCompositionSelectionChange) _data->_page->cancelComposition(); - [self _wk_resetTextInputState]; + [self _resetTextInputState]; if (!_data->_page->maintainsInactiveSelection()) _data->_page->clearSelection(); @@ -359,10 +364,10 @@ struct WKViewInterpretKeyEventsParameters { [super setFrameSize:size]; if (![self frameSizeUpdatesDisabled]) - [self _wk_setDrawingAreaSize:size]; + [self _setDrawingAreaSize:size]; } -- (void)_wk_updateWindowAndViewFrames +- (void)_updateWindowAndViewFrames { NSWindow *window = [self window]; ASSERT(window); @@ -381,12 +386,12 @@ struct WKViewInterpretKeyEventsParameters { // Update the view frame. if ([self window]) - [self _wk_updateWindowAndViewFrames]; + [self _updateWindowAndViewFrames]; [super renewGState]; } -- (void)_wk_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState +- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState { _data->_pluginComplexTextInputState = pluginComplexTextInputState; @@ -649,7 +654,7 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int WKView* wkView = static_cast<WKView*>(context); ASSERT(wkView); - [wkView _wk_setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state]; + [wkView _setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state]; } - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item @@ -960,7 +965,7 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) { #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 // FIXME: We should remove this code when <rdar://problem/9362085> is resolved. In the meantime, - // it is necessary to disable screen updates so we get a chance to redraw the corners before this + // it is necessary to disable scren updates so we get a chance to redraw the corners before this // display is visible. NSWindow *window = [self window]; BOOL shouldMaskWindow = window && !NSIsEmptyRect(_data->_windowBottomCornerIntersectionRect); @@ -988,7 +993,7 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) return YES; } -- (void)_wk_setMouseDownEvent:(NSEvent *)event +- (void)_setMouseDownEvent:(NSEvent *)event { ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown); @@ -1012,10 +1017,10 @@ static void speakString(WKStringRef string, WKErrorRef error, void*) NATIVE_MOUSE_EVENT_HANDLER(mouseEntered) NATIVE_MOUSE_EVENT_HANDLER(mouseExited) -NATIVE_MOUSE_EVENT_HANDLER(_wk_mouseMovedInternal) -NATIVE_MOUSE_EVENT_HANDLER(_wk_mouseDownInternal) -NATIVE_MOUSE_EVENT_HANDLER(_wk_mouseUpInternal) -NATIVE_MOUSE_EVENT_HANDLER(_wk_mouseDraggedInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseMovedInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseDownInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseUpInternal) +NATIVE_MOUSE_EVENT_HANDLER(mouseDraggedInternal) NATIVE_MOUSE_EVENT_HANDLER(otherMouseDown) NATIVE_MOUSE_EVENT_HANDLER(otherMouseDragged) NATIVE_MOUSE_EVENT_HANDLER(otherMouseMoved) @@ -1043,27 +1048,27 @@ NATIVE_EVENT_HANDLER(scrollWheel, Wheel) if (self == [[self window] firstResponder] && !NSPointInRect([self convertPoint:[event locationInWindow] fromView:nil], [self visibleRect])) return; - [self _wk_mouseMovedInternal:event]; + [self mouseMovedInternal:event]; } - (void)mouseDown:(NSEvent *)event { - [self _wk_setMouseDownEvent:event]; + [self _setMouseDownEvent:event]; _data->_ignoringMouseDraggedEvents = NO; - [self _wk_mouseDownInternal:event]; + [self mouseDownInternal:event]; } - (void)mouseUp:(NSEvent *)event { - [self _wk_setMouseDownEvent:nil]; - [self _wk_mouseUpInternal:event]; + [self _setMouseDownEvent:nil]; + [self mouseUpInternal:event]; } - (void)mouseDragged:(NSEvent *)event { if (_data->_ignoringMouseDraggedEvents) return; - [self _wk_mouseDraggedInternal:event]; + [self mouseDraggedInternal:event]; } - (BOOL)acceptsFirstMouse:(NSEvent *)event @@ -1076,9 +1081,9 @@ NATIVE_EVENT_HANDLER(scrollWheel, Wheel) if (![self hitTest:[event locationInWindow]]) return NO; - [self _wk_setMouseDownEvent:event]; + [self _setMouseDownEvent:event]; bool result = _data->_page->acceptsFirstMouse([event eventNumber], WebEventFactory::createWebMouseEvent(event, self)); - [self _wk_setMouseDownEvent:nil]; + [self _setMouseDownEvent:nil]; return result; } @@ -1097,9 +1102,9 @@ NATIVE_EVENT_HANDLER(scrollWheel, Wheel) if (![self hitTest:[event locationInWindow]]) return NO; - [self _wk_setMouseDownEvent:event]; + [self _setMouseDownEvent:event]; bool result = _data->_page->shouldDelayWindowOrderingForEvent(WebEventFactory::createWebMouseEvent(event, self)); - [self _wk_setMouseDownEvent:nil]; + [self _setMouseDownEvent:nil]; return result; } @@ -1136,7 +1141,6 @@ static const short kIOHIDEventTypeScroll = 6; }]; } } - #endif - (void)doCommandBySelector:(SEL)selector @@ -1223,7 +1227,7 @@ static const short kIOHIDEventTypeScroll = 6; parameters->eventInterpretationHadSideEffects |= eventHandled; } -- (BOOL)_wk_handleStyleKeyEquivalent:(NSEvent *)event +- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event { if (!_data->_page->editorState().isContentEditable) return NO; @@ -1259,7 +1263,7 @@ static const short kIOHIDEventTypeScroll = 6; BOOL eventWasSentToWebCore = (_data->_keyDownEventBeingResent == event); if (!eventWasSentToWebCore) - [self _wk_disableComplexTextInputIfNecessary]; + [self _disableComplexTextInputIfNecessary]; // 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. @@ -1270,7 +1274,7 @@ static const short kIOHIDEventTypeScroll = 6; return YES; } - return [self _wk_handleStyleKeyEquivalent:event] || [super performKeyEquivalent:event]; + return [self _handleStyleKeyEquivalent:event] || [super performKeyEquivalent:event]; } - (void)keyUp:(NSEvent *)theEvent @@ -1279,7 +1283,7 @@ static const short kIOHIDEventTypeScroll = 6; _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); } -- (void)_wk_disableComplexTextInputIfNecessary +- (void)_disableComplexTextInputIfNecessary { if (!_data->_pluginComplexTextInputIdentifier) return; @@ -1289,10 +1293,10 @@ static const short kIOHIDEventTypeScroll = 6; // Check if the text input window has been dismissed. if (![[WKTextInputWindowController sharedTextInputWindowController] hasMarkedText]) - [self _wk_setPluginComplexTextInputState:PluginComplexTextInputDisabled]; + [self _setPluginComplexTextInputState:PluginComplexTextInputDisabled]; } -- (BOOL)_wk_handlePluginComplexTextInputKeyDown:(NSEvent *)event +- (BOOL)_handlePluginComplexTextInputKeyDown:(NSEvent *)event { ASSERT(_data->_pluginComplexTextInputIdentifier); ASSERT(_data->_pluginComplexTextInputState != PluginComplexTextInputDisabled); @@ -1312,18 +1316,18 @@ static const short kIOHIDEventTypeScroll = 6; return didHandleEvent; } -- (BOOL)_wk_tryHandlePluginComplexTextInputKeyDown:(NSEvent *)event +- (BOOL)_tryHandlePluginComplexTextInputKeyDown:(NSEvent *)event { if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled) return NO; // Check if the text input window has been dismissed and let the plug-in process know. // This is only valid with the updated Cocoa text input spec. - [self _wk_disableComplexTextInputIfNecessary]; + [self _disableComplexTextInputIfNecessary]; // Try feeding the keyboard event directly to the plug-in. if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy) - return [self _wk_handlePluginComplexTextInputKeyDown:event]; + return [self _handlePluginComplexTextInputKeyDown:event]; return NO; } @@ -1337,7 +1341,7 @@ static const short kIOHIDEventTypeScroll = 6; // the current event prevents that from causing a problem inside WebKit or AppKit code. [[theEvent retain] autorelease]; - if ([self _wk_tryHandlePluginComplexTextInputKeyDown:theEvent]) { + if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent]) { LOG(TextInput, "...handled by plug-in"); return; } @@ -1371,7 +1375,7 @@ static const short kIOHIDEventTypeScroll = 6; _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self)); } -- (void)_wk_executeSavedKeypressCommands +- (void)_executeSavedKeypressCommands { WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters; if (!parameters || parameters->commands->isEmpty()) @@ -1392,7 +1396,7 @@ static const short kIOHIDEventTypeScroll = 6; LOG(TextInput, "...done executing saved keypress commands."); } -- (void)_wk_notifyInputContextAboutDiscardedComposition +- (void)_notifyInputContextAboutDiscardedComposition { // <rdar://problem/9359055>: -discardMarkedText can only be called for active contexts. // FIXME: We fail to ever notify the input context if something (e.g. a navigation) happens while the window is not key. @@ -1420,7 +1424,7 @@ static const short kIOHIDEventTypeScroll = 6; - (NSRange)selectedRange { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; uint64_t selectionStart; uint64_t selectionLength; @@ -1444,7 +1448,7 @@ static const short kIOHIDEventTypeScroll = 6; result = _data->_page->editorState().hasComposition; if (result) { // A saved command can confirm a composition, but it cannot start a new one. - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; result = _data->_page->editorState().hasComposition; } } else { @@ -1460,7 +1464,7 @@ static const short kIOHIDEventTypeScroll = 6; - (void)unmarkText { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; LOG(TextInput, "unmarkText"); @@ -1519,7 +1523,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange replacementRange:(NSRange)replacementRange { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]); @@ -1548,7 +1552,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde // In password fields, we only allow ASCII dead keys, and don't allow inline input, matching NSSecureTextInputField. // Allowing ASCII dead keys is necessary to enable full Roman input when using a Vietnamese keyboard. ASSERT(!_data->_page->editorState().hasComposition); - [self _wk_notifyInputContextAboutDiscardedComposition]; + [self _notifyInputContextAboutDiscardedComposition]; if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) { _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange)); } else @@ -1561,7 +1565,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (NSRange)markedRange { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; uint64_t location; uint64_t length; @@ -1573,7 +1577,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)nsRange actualRange:(NSRangePointer)actualRange { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; if (!_data->_page->editorState().isContentEditable) { LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length); @@ -1597,7 +1601,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; NSWindow *window = [self window]; @@ -1612,7 +1616,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (NSRect)firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange { - [self _wk_executeSavedKeypressCommands]; + [self _executeSavedKeypressCommands]; // 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 @@ -1637,7 +1641,6 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde } #if ENABLE(DRAG_SUPPORT) - - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation { NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint]; @@ -1779,7 +1782,6 @@ static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, Sandb return self; return nil; } - #endif // ENABLE(DRAG_SUPPORT) - (BOOL)_windowResizeMouseLocationIsInVisibleScrollerThumb:(NSPoint)loc @@ -1789,14 +1791,13 @@ static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, Sandb return NSMouseInRect(localPoint, visibleThumbRect, [self isFlipped]); } -- (void)_wk_updateWindowVisibility +- (void)_updateWindowVisibility { _data->_page->updateWindowIsVisible([[self window] isVisible]); } #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 - - (BOOL)_ownsWindowGrowBox { NSWindow* window = [self window]; @@ -1845,45 +1846,54 @@ static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, Sandb return ownsGrowBox; } - #endif // FIXME: Use AppKit constants for these when they are available. -static NSString * const windowDidBecomeVisibleNotification = @"_NSWindowDidBecomeVisible"; -static NSString * const windowDidOrderOffScreenNotification = @"NSWindowDidOrderOffScreenNotification"; static NSString * const windowDidChangeBackingPropertiesNotification = @"NSWindowDidChangeBackingPropertiesNotification"; static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOldScaleFactorKey"; -- (void)_wk_updateWindowObserversForWindow:(NSWindow *)window +- (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(_windowDidMove:) + name:NSWindowDidMoveNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResize:) + name:NSWindowDidResizeNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:) + name:@"NSWindowDidOrderOffScreenNotification" object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:) + name:@"_NSWindowDidBecomeVisible" object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeBackingProperties:) + name:windowDidChangeBackingPropertiesNotification object:window]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeScreen:) + name:NSWindowDidChangeScreenNotification object:window]; + } +} + +- (void)removeWindowObservers { - for (id observer in _data->_observers.get()) - [[NSNotificationCenter defaultCenter] removeObserver:observer]; - [_data->_observers.get() removeAllObjects]; - + NSWindow *window = [self window]; if (!window) return; - if (!_data->_observers) - _data->_observers = adoptNS([[NSMutableArray alloc] init]); - - #define ADD_OBSERVER(selectorName, notificationName, notificationObject) \ - [_data->_observers.get() addObject:[[NSNotificationCenter defaultCenter] \ - addObserverForName:notificationName object:notificationObject queue:[NSOperationQueue mainQueue] \ - usingBlock:^(NSNotification *notification){ [self selectorName:notification]; }] \ - ]; - - ADD_OBSERVER(_wk_windowDidBecomeKey, NSWindowDidBecomeKeyNotification, nil); - ADD_OBSERVER(_wk_windowDidChangeBackingProperties, windowDidChangeBackingPropertiesNotification, window); - ADD_OBSERVER(_wk_windowDidChangeScreen, NSWindowDidChangeScreenNotification, window); - ADD_OBSERVER(_wk_windowDidDeminiaturize, NSWindowDidDeminiaturizeNotification, window); - ADD_OBSERVER(_wk_windowDidMiniaturize, NSWindowDidMiniaturizeNotification, window); - ADD_OBSERVER(_wk_windowDidMove, NSWindowDidMoveNotification, window); - ADD_OBSERVER(_wk_windowDidOrderOffScreen, windowDidOrderOffScreenNotification, window); - ADD_OBSERVER(_wk_windowDidOrderOnScreen, windowDidBecomeVisibleNotification, window); - ADD_OBSERVER(_wk_windowDidResignKey, NSWindowDidResignKeyNotification, nil); - ADD_OBSERVER(_wk_windowDidResize, NSWindowDidResizeNotification, window); - - #undef ADD_OBSERVER + [[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]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:windowDidChangeBackingPropertiesNotification object:window]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeScreenNotification object:window]; } - (void)viewWillMoveToWindow:(NSWindow *)window @@ -1903,7 +1913,8 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl #endif _data->_pageClient->viewWillMoveToAnotherWindow(); - [self _wk_updateWindowObserversForWindow:window]; + [self removeWindowObservers]; + [self addWindowObserversForWindow:window]; #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 if ([currentWindow _growBoxOwner] == self) @@ -1913,28 +1924,26 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl - (void)viewDidMoveToWindow { - [self removeAllToolTips]; - // 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->_windowHasValidBackingStore = NO; - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible | WebPageProxy::ViewIsInWindow); - [self _wk_updateWindowAndViewFrames]; + [self _updateWindowAndViewFrames]; if (!_data->_flagsChangedEventMonitor) { _data->_flagsChangedEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSFlagsChangedMask handler:^(NSEvent *flagsChangedEvent) { - [self _wk_postFakeMouseMovedEventForFlagsChangedEvent:flagsChangedEvent]; + [self _postFakeMouseMovedEventForFlagsChangedEvent:flagsChangedEvent]; return flagsChangedEvent; }]; } - [self _wk_accessibilityRegisterUIProcessTokens]; + [self _accessibilityRegisterUIProcessTokens]; } else { - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow); @@ -1952,67 +1961,67 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl #endif } - _data->_page->setIntrinsicDeviceScaleFactor([self _wk_intrinsicDeviceScaleFactor]); + _data->_page->setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]); } -- (void)_wk_windowScreenDidChange +- (void)doWindowDidChangeScreen { _data->_page->windowScreenDidChange((PlatformDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]); } -- (void)_wk_windowDidBecomeKey:(NSNotification *)notification +- (void)_windowDidBecomeKey:(NSNotification *)notification { NSWindow *keyWindow = [notification object]; if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) { - [self _wk_updateSecureInputState]; + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); } // Send a change screen to make sure the initial displayID is set - [self _wk_windowScreenDidChange]; + [self doWindowDidChangeScreen]; } -- (void)_wk_windowDidChangeScreen:(NSNotification *)notification +- (void)_windowDidChangeScreen:(NSNotification *)notification { - [self _wk_windowScreenDidChange]; + [self doWindowDidChangeScreen]; } -- (void)_wk_windowDidResignKey:(NSNotification *)notification +- (void)_windowDidResignKey:(NSNotification *)notification { NSWindow *formerKeyWindow = [notification object]; if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) { - [self _wk_updateSecureInputState]; + [self _updateSecureInputState]; _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); } } -- (void)_wk_windowDidMiniaturize:(NSNotification *)notification +- (void)_windowDidMiniaturize:(NSNotification *)notification { _data->_windowHasValidBackingStore = NO; - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; } -- (void)_wk_windowDidDeminiaturize:(NSNotification *)notification +- (void)_windowDidDeminiaturize:(NSNotification *)notification { - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; } -- (void)_wk_windowDidMove:(NSNotification *)notification +- (void)_windowDidMove:(NSNotification *)notification { - [self _wk_updateWindowAndViewFrames]; + [self _updateWindowAndViewFrames]; } -- (void)_wk_windowDidResize:(NSNotification *)notification +- (void)_windowDidResize:(NSNotification *)notification { _data->_windowHasValidBackingStore = NO; - [self _wk_updateWindowAndViewFrames]; + [self _updateWindowAndViewFrames]; } -- (void)_wk_windowDidOrderOffScreen:(NSNotification *)notification +- (void)_windowDidOrderOffScreen:(NSNotification *)notification { - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; // We want to make sure to update the active state while hidden, so since the view is about to be hidden, // we hide it first and then update the active state. @@ -2020,9 +2029,9 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); } -- (void)_wk_windowDidOrderOnScreen:(NSNotification *)notification +- (void)_windowDidOrderOnScreen:(NSNotification *)notification { - [self _wk_updateWindowVisibility]; + [self _updateWindowVisibility]; // We want to make sure to update the active state while hidden, so since the view is about to become visible, // we update the active state first and then make it visible. @@ -2030,10 +2039,10 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); } -- (void)_wk_windowDidChangeBackingProperties:(NSNotification *)notification +- (void)_windowDidChangeBackingProperties:(NSNotification *)notification { CGFloat oldBackingScaleFactor = [[notification.userInfo objectForKey:backingPropertyOldScaleFactorKey] doubleValue]; - CGFloat newBackingScaleFactor = [self _wk_intrinsicDeviceScaleFactor]; + CGFloat newBackingScaleFactor = [self _intrinsicDeviceScaleFactor]; if (oldBackingScaleFactor == newBackingScaleFactor) return; @@ -2130,7 +2139,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I drawingArea->colorSpaceDidChange(); } -- (void)_wk_accessibilityRegisterUIProcessTokens +- (void)_accessibilityRegisterUIProcessTokens { // Initialize remote accessibility when the window connection has been established. NSData *remoteElementToken = WKAXRemoteTokenForElement(self); @@ -2140,7 +2149,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_page->registerUIProcessAccessibilityTokens(elementToken, windowToken); } -- (void)_wk_updateRemoteAccessibilityRegistration:(BOOL)registerProcess +- (void)_updateRemoteAccessibilityRegistration:(BOOL)registerProcess { // When the tree is connected/disconnected, the remote accessibility registration // needs to be updated with the pid of the remote process. If the process is going @@ -2212,7 +2221,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return hitView; } -- (void)_wk_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent +- (void)_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent { NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved location:[[flagsChangedEvent window] convertScreenToBase:[NSEvent mouseLocation]] modifierFlags:[flagsChangedEvent modifierFlags] timestamp:[flagsChangedEvent timestamp] windowNumber:[flagsChangedEvent windowNumber] @@ -2226,7 +2235,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return (NSInteger)self; } -- (float)_wk_intrinsicDeviceScaleFactor +- (float)_intrinsicDeviceScaleFactor { NSWindow *window = [self window]; #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @@ -2240,7 +2249,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I #endif } -- (void)_wk_setDrawingAreaSize:(NSSize)size +- (void)_setDrawingAreaSize:(NSSize)size { if (!_data->_page->drawingArea()) return; @@ -2249,6 +2258,11 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_resizeScrollOffset = NSZeroSize; } +- (BOOL)_shouldUseTiledDrawingArea +{ + return NO; +} + #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 - (void)quickLookWithEvent:(NSEvent *)event { @@ -2261,17 +2275,21 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I @implementation WKView (Internal) -- (PassOwnPtr<WebKit::DrawingAreaProxy>)_wk_createDrawingAreaProxy +- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy { #if ENABLE(THREADED_SCROLLING) - if ([self _shouldUseTiledDrawingArea]) + if ([self _shouldUseTiledDrawingArea]) { + if (getenv("WK_USE_REMOTE_LAYER_TREE_DRAWING_AREA")) + return RemoteLayerTreeDrawingAreaProxy::create(_data->_page.get()); + return TiledCoreAnimationDrawingAreaProxy::create(_data->_page.get()); + } #endif return DrawingAreaProxyImpl::create(_data->_page.get()); } -- (BOOL)_wk_isFocused +- (BOOL)_isFocused { if (_data->_inBecomeFirstResponder) return YES; @@ -2280,7 +2298,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return [[self window] firstResponder] == self; } -- (WebKit::ColorSpaceData)_wk_colorSpace +- (WebKit::ColorSpaceData)_colorSpace { if (!_data->_colorSpace) { if ([self window]) @@ -2295,32 +2313,32 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return colorSpaceData; } -- (void)_wk_processDidCrash +- (void)_processDidCrash { if (_data->_layerHostingView) - [self _wk_exitAcceleratedCompositingMode]; + [self _exitAcceleratedCompositingMode]; - [self _wk_updateRemoteAccessibilityRegistration:NO]; + [self _updateRemoteAccessibilityRegistration:NO]; } -- (void)_wk_pageClosed +- (void)_pageClosed { - [self _wk_updateRemoteAccessibilityRegistration:NO]; + [self _updateRemoteAccessibilityRegistration:NO]; } -- (void)_wk_didRelaunchProcess +- (void)_didRelaunchProcess { - [self _wk_accessibilityRegisterUIProcessTokens]; + [self _accessibilityRegisterUIProcessTokens]; } -- (void)_wk_setCursor:(NSCursor *)cursor +- (void)_setCursor:(NSCursor *)cursor { if ([NSCursor currentCursor] == cursor) return; [cursor set]; } -- (void)_wk_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState +- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState { ValidationVector items = _data->_validationMap.take(commandName); size_t size = items.size(); @@ -2333,7 +2351,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I } } -- (BOOL)_wk_tryPostProcessPluginComplexTextInputKeyDown:(NSEvent *)event +- (BOOL)_tryPostProcessPluginComplexTextInputKeyDown:(NSEvent *)event { if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled) return NO; @@ -2342,15 +2360,15 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy) return NO; - return [self _wk_handlePluginComplexTextInputKeyDown:event]; + return [self _handlePluginComplexTextInputKeyDown:event]; } -- (void)_wk_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled +- (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled { if ([event type] != NSKeyDown) return; - if ([self _wk_tryPostProcessPluginComplexTextInputKeyDown:event]) + if ([self _tryPostProcessPluginComplexTextInputKeyDown:event]) return; if (eventWasHandled) { @@ -2369,7 +2387,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_keyDownEventBeingResent = nullptr; } -- (BOOL)_wk_interpretKeyEvent:(NSEvent *)event savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands +- (BOOL)_interpretKeyEvent:(NSEvent *)event savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands { ASSERT(!_data->_interpretKeyEventsParameters); ASSERT(commands.isEmpty()); @@ -2404,12 +2422,12 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return parameters.eventInterpretationHadSideEffects; } -- (NSRect)_wk_convertToDeviceSpace:(NSRect)rect +- (NSRect)_convertToDeviceSpace:(NSRect)rect { return toDeviceSpace(rect, [self window]); } -- (NSRect)_wk_convertToUserSpace:(NSRect)rect +- (NSRect)_convertToUserSpace:(NSRect)rect { return toUserSpace(rect, [self window]); } @@ -2425,7 +2443,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return TRACKING_RECT_TAG; } -- (NSTrackingRectTag)_wk_addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside useTrackingNum:(int)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); @@ -2434,7 +2452,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return TRACKING_RECT_TAG; } -- (void)_wk_addTrackingRects:(NSRect *)rects owner:(id)owner userDataList:(void **)userDataList assumeInsideList:(BOOL *)assumeInsideList trackingNums:(NSTrackingRectTag *)trackingNums count:(int)count +- (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); @@ -2468,7 +2486,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I ASSERT_NOT_REACHED(); } -- (void)_wk_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count +- (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count { int i; for (i = 0; i < count; ++i) { @@ -2482,7 +2500,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I } } -- (void)_wk_sendToolTipMouseExited +- (void)_sendToolTipMouseExited { // Nothing matters except window, trackingNumber, and userData. NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited @@ -2497,7 +2515,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [_data->_trackingRectOwner mouseExited:fakeEvent]; } -- (void)_wk_sendToolTipMouseEntered +- (void)_sendToolTipMouseEntered { // Nothing matters except window, trackingNumber, and userData. NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered @@ -2517,21 +2535,21 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return nsStringFromWebCoreString(_data->_page->toolTip()); } -- (void)_wk_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip +- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip { if (oldToolTip) - [self _wk_sendToolTipMouseExited]; + [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 _wk_sendToolTipMouseEntered]; + [self _sendToolTipMouseEntered]; } } -- (void)_wk_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate +- (void)_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate { if (!findIndicator) { _data->_findIndicatorWindow = nullptr; @@ -2544,7 +2562,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut, animate); } -- (void)_wk_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext +- (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext { ASSERT(!_data->_layerHostingView); ASSERT(!layerTreeContext.isEmpty()); @@ -2573,7 +2591,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [CATransaction commit]; } -- (void)_wk_exitAcceleratedCompositingMode +- (void)_exitAcceleratedCompositingMode { ASSERT(_data->_layerHostingView); @@ -2584,7 +2602,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_layerHostingView = nullptr; } -- (void)_wk_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext +- (void)_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext { if (_data->_layerHostingView) { // Wrap the call to setSublayers: in a CATransaction with actions disabled to @@ -2597,18 +2615,18 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [CATransaction commit]; } else { - [self _wk_exitAcceleratedCompositingMode]; - [self _wk_enterAcceleratedCompositingMode:layerTreeContext]; + [self _exitAcceleratedCompositingMode]; + [self _enterAcceleratedCompositingMode:layerTreeContext]; } } -- (void)_wk_setAccessibilityWebProcessToken:(NSData *)data +- (void)_setAccessibilityWebProcessToken:(NSData *)data { _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data); - [self _wk_updateRemoteAccessibilityRegistration:YES]; + [self _updateRemoteAccessibilityRegistration:YES]; } -- (void)_wk_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier +- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier { BOOL inputSourceChanged = _data->_pluginComplexTextInputIdentifier; @@ -2636,17 +2654,17 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I [NSApp updateWindows]; } -- (void)_wk_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier +- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier { if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier) { // We're asked to update the state for a plug-in that doesn't have focus. return; } - [self _wk_setPluginComplexTextInputState:pluginComplexTextInputState]; + [self _setPluginComplexTextInputState:pluginComplexTextInputState]; } -- (void)_wk_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation +- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation { bool hadPDFView = _data->_pdfViewController; _data->_pdfViewController = nullptr; @@ -2658,14 +2676,14 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_page->drawingArea()->pageCustomRepresentationChanged(); } -- (void)_wk_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference +- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference { ASSERT(_data->_pdfViewController); _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), suggestedFilename, dataReference); } -- (double)_wk_customRepresentationZoomFactor +- (double)_customRepresentationZoomFactor { if (!_data->_pdfViewController) return 1; @@ -2673,7 +2691,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I return _data->_pdfViewController->zoomFactor(); } -- (void)_wk_setCustomRepresentationZoomFactor:(double)zoomFactor +- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor { if (!_data->_pdfViewController) return; @@ -2681,7 +2699,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pdfViewController->setZoomFactor(zoomFactor); } -- (void)_wk_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count +- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count { if (!_data->_pdfViewController) return; @@ -2689,7 +2707,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pdfViewController->findString(string, options, count); } -- (void)_wk_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count +- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count { if (!_data->_pdfViewController) return; @@ -2697,7 +2715,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pdfViewController->countStringMatches(string, options, count); } -- (void)_wk_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag +- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag { IntSize size([image size]); size.scale(1.0 / _data->_page->deviceScaleFactor()); @@ -2722,7 +2740,7 @@ static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension && hasCaseInsensitiveSuffix(filename, @".jpg")); } -- (void)_wk_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName +- (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName { NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName]; @@ -2830,9 +2848,9 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return [NSArray arrayWithObject:[path lastPathComponent]]; } -- (void)_wk_updateSecureInputState +- (void)_updateSecureInputState { - if (![[self window] isKeyWindow] || ![self _wk_isFocused]) { + if (![[self window] isKeyWindow] || ![self _isFocused]) { if (_data->_inSecureInputState) { DisableSecureEventInput(); _data->_inSecureInputState = NO; @@ -2858,13 +2876,13 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) _data->_inSecureInputState = isInPasswordField; } -- (void)_wk_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState +- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState { const EditorState& editorState = _data->_page->editorState(); if (updateSecureInputState) { // This is a temporary state when editing. Flipping secure input state too quickly can expose race conditions. if (!editorState.selectionIsNone) - [self _wk_updateSecureInputState]; + [self _updateSecureInputState]; } if (!editorState.hasComposition || editorState.shouldIgnoreCompositionSelectionChange) @@ -2872,12 +2890,12 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) _data->_page->cancelComposition(); - [self _wk_notifyInputContextAboutDiscardedComposition]; + [self _notifyInputContextAboutDiscardedComposition]; } -- (void)_wk_resetTextInputState +- (void)_resetTextInputState { - [self _wk_notifyInputContextAboutDiscardedComposition]; + [self _notifyInputContextAboutDiscardedComposition]; if (_data->_inSecureInputState) { DisableSecureEventInput(); @@ -2885,7 +2903,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) } } -- (void)_wk_didChangeScrollbarsForMainFrame +- (void)_didChangeScrollbarsForMainFrame { #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060 [self _updateGrowBoxForWindowFrameChange]; @@ -2893,13 +2911,12 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) } #if ENABLE(FULLSCREEN_API) - -- (BOOL)_wk_hasFullScreenWindowController +- (BOOL)hasFullScreenWindowController { return (bool)_data->_fullScreenWindowController; } -- (WKFullScreenWindowController*)_wk_fullScreenWindowController +- (WKFullScreenWindowController*)fullScreenWindowController { if (!_data->_fullScreenWindowController) { _data->_fullScreenWindowController.adoptNS([[WKFullScreenWindowController alloc] init]); @@ -2908,17 +2925,16 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return _data->_fullScreenWindowController.get(); } -- (void)_wk_closeFullScreenWindowController +- (void)closeFullScreenWindowController { if (!_data->_fullScreenWindowController) return; [_data->_fullScreenWindowController.get() close]; _data->_fullScreenWindowController = nullptr; } - #endif -- (bool)_wk_executeSavedCommandBySelector:(SEL)selector +- (bool)_executeSavedCommandBySelector:(SEL)selector { // The sink does two things: 1) Tells us if the responder went unhandled, and // 2) prevents any NSBeep; we don't ever want to beep here. @@ -2928,7 +2944,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return ![sink.get() didReceiveUnhandledCommand]; } -- (void)_wk_cacheWindowBottomCornerRect +- (void)_cacheWindowBottomCornerRect { #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 // FIXME: We should remove this code when <rdar://problem/9362085> is resolved. @@ -2942,7 +2958,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) #endif } -- (NSInteger)_wk_spellCheckerDocumentTag +- (NSInteger)spellCheckerDocumentTag { if (!_data->_hasSpellCheckerDocumentTag) { _data->_spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag]; @@ -2951,17 +2967,17 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return _data->_spellCheckerDocumentTag; } -- (void)_wk_handleAcceptedAlternativeText:(NSString*)text +- (void)handleAcceptedAlternativeText:(NSString*)text { _data->_page->handleAlternativeTextUIResult(text); } -- (void)_wk_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates +- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates { _data->_page->setSuppressVisibilityUpdates(suppressVisibilityUpdates); } -- (BOOL)_wk_suppressVisibilityUpdates +- (BOOL)_suppressVisibilityUpdates { return _data->_page->suppressVisibilityUpdates(); } @@ -2970,7 +2986,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) @implementation WKView (Private) -- (void)_wk_registerDraggedTypes +- (void)_registerDraggedTypes { NSMutableSet *types = [[NSMutableSet alloc] initWithArray:PasteboardTypes::forEditing()]; [types addObjectsFromArray:PasteboardTypes::forURL()]; @@ -3016,7 +3032,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) _data->_pageClient = PageClientImpl::create(self); _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef), toImpl(relatedPage)); - _data->_page->setIntrinsicDeviceScaleFactor([self _wk_intrinsicDeviceScaleFactor]); + _data->_page->setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]); _data->_page->initializeWebPage(); #if ENABLE(FULLSCREEN_API) _data->_page->fullScreenManager()->setWebView(self); @@ -3024,7 +3040,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) _data->_mouseDownEvent = nil; _data->_ignoringMouseDraggedEvents = NO; - [self _wk_registerDraggedTypes]; + [self _registerDraggedTypes]; if ([self _shouldUseTiledDrawingArea]) { self.wantsLayer = YES; @@ -3039,7 +3055,6 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) } #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 - - (BOOL)wantsUpdateLayer { return [self _shouldUseTiledDrawingArea]; @@ -3052,7 +3067,6 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea()) drawingArea->waitForPossibleGeometryUpdate(); } - #endif - (WKPageRef)pageRef @@ -3107,7 +3121,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return; if (!(--_data->_frameSizeUpdatesDisabledCount)) - [self _wk_setDrawingAreaSize:[self frame].size]; + [self _setDrawingAreaSize:[self frame].size]; } - (BOOL)frameSizeUpdatesDisabled @@ -3131,11 +3145,6 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) #endif } -- (BOOL)_shouldUseTiledDrawingArea -{ - return NO; -} - @end @implementation WKResponderChainSink diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h index f2b681649..2e99e7976 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. + * 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 @@ -50,59 +50,58 @@ namespace WebKit { @class WKFullScreenWindowController; @interface WKView (Internal) - -- (PassOwnPtr<WebKit::DrawingAreaProxy>)_wk_createDrawingAreaProxy; -- (BOOL)_wk_isFocused; -- (void)_wk_processDidCrash; -- (void)_wk_pageClosed; -- (void)_wk_didRelaunchProcess; -- (void)_wk_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip; -- (void)_wk_setCursor:(NSCursor *)cursor; -- (void)_wk_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState; -- (BOOL)_wk_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands; -- (void)_wk_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled; -- (bool)_wk_executeSavedCommandBySelector:(SEL)selector; -- (NSRect)_wk_convertToDeviceSpace:(NSRect)rect; -- (NSRect)_wk_convertToUserSpace:(NSRect)rect; -- (void)_wk_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate; - -- (void)_wk_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext; -- (void)_wk_exitAcceleratedCompositingMode; -- (void)_wk_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext; - -- (void)_wk_setAccessibilityWebProcessToken:(NSData *)data; - -- (void)_wk_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; -- (void)_wk_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; - -- (void)_wk_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation; -- (void)_wk_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference; -- (double)_wk_customRepresentationZoomFactor; -- (void)_wk_setCustomRepresentationZoomFactor:(double)zoomFactor; -- (void)_wk_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; -- (void)_wk_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; -- (void)_wk_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; -- (void)_wk_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName; -- (void)_wk_updateSecureInputState; -- (void)_wk_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState; -- (void)_wk_resetTextInputState; - -- (void)_wk_didChangeScrollbarsForMainFrame; - -- (WebKit::ColorSpaceData)_wk_colorSpace; +- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy; +- (BOOL)_isFocused; +- (void)_processDidCrash; +- (void)_pageClosed; +- (void)_didRelaunchProcess; +- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip; +- (void)_setCursor:(NSCursor *)cursor; +- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState; +- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands; +- (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled; +- (bool)_executeSavedCommandBySelector:(SEL)selector; +- (NSRect)_convertToDeviceSpace:(NSRect)rect; +- (NSRect)_convertToUserSpace:(NSRect)rect; +- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate; + +- (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext; +- (void)_exitAcceleratedCompositingMode; +- (void)_updateAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext; + +- (void)_setAccessibilityWebProcessToken:(NSData *)data; + +- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; +- (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier; + +- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation; +- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference; +- (double)_customRepresentationZoomFactor; +- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor; +- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; +- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count; +- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag; +- (void)_setPromisedData:(WebCore::Image *)image withFileName:(NSString *)filename withExtension:(NSString *)extension withTitle:(NSString *)title withURL:(NSString *)url withVisibleURL:(NSString *)visibleUrl withArchive:(WebCore::SharedBuffer*) archiveBuffer forPasteboard:(NSString *)pasteboardName; +- (void)_updateSecureInputState; +- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState; +- (void)_resetTextInputState; + +- (void)_didChangeScrollbarsForMainFrame; + +- (WebKit::ColorSpaceData)_colorSpace; #if ENABLE(FULLSCREEN_API) -- (BOOL)_wk_hasFullScreenWindowController; -- (WKFullScreenWindowController*)_wk_fullScreenWindowController; -- (void)_wk_closeFullScreenWindowController; +- (BOOL)hasFullScreenWindowController; +- (WKFullScreenWindowController*)fullScreenWindowController; +- (void)closeFullScreenWindowController; #endif -- (void)_wk_cacheWindowBottomCornerRect; +- (void)_cacheWindowBottomCornerRect; -- (NSInteger)_wk_spellCheckerDocumentTag; -- (void)_wk_handleAcceptedAlternativeText:(NSString*)text; +- (NSInteger)spellCheckerDocumentTag; +- (void)handleAcceptedAlternativeText:(NSString*)text; -- (void)_wk_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates; -- (BOOL)_wk_suppressVisibilityUpdates; +- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates; +- (BOOL)_suppressVisibilityUpdates; @end diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h index 035b1ea2c..51578764f 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. + * 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 @@ -50,8 +50,4 @@ - (void)performDictionaryLookupAtCurrentMouseLocation; + (void)hideWordDefinitionWindow; -// FIXME: This method currently overridden by Safari to turn tiled drawing area on. -// We should come up with a cleaner SPI or API for this. -- (BOOL)_shouldUseTiledDrawingArea; - @end diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 9a0433b66..21ed5be10 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -258,6 +258,7 @@ QPointF QQuickWebViewPrivate::FlickableAxisLocker::adjust(const QPointF& positio QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) : q_ptr(viewport) + , experimental(new QQuickWebViewExperimental(viewport, this)) , alertDialog(0) , confirmDialog(0) , promptDialog(0) @@ -321,6 +322,9 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController); webPageProxy->initializeWebPage(); + + q_ptr->setAcceptedMouseButtons(Qt::MouseButtonMask); + q_ptr->setAcceptHoverEvents(true); } void QQuickWebViewPrivate::loadDidStop() @@ -419,9 +423,6 @@ void QQuickWebViewPrivate::handleMouseEvent(QMouseEvent* event) { switch (event->type()) { case QEvent::MouseButtonPress: - case QEvent::MouseButtonDblClick: - // If a MouseButtonDblClick was received then we got a MouseButtonPress before - // handleMousePressEvent will take care of double clicks. pageView->eventHandler()->handleMousePressEvent(event); break; case QEvent::MouseMove: @@ -430,6 +431,11 @@ void QQuickWebViewPrivate::handleMouseEvent(QMouseEvent* event) case QEvent::MouseButtonRelease: pageView->eventHandler()->handleMouseReleaseEvent(event); break; + case QEvent::MouseButtonDblClick: + // If a MouseButtonDblClick was received then we got a MouseButtonPress before. + // WebCore will build double-clicks out of press events. + event->accept(); + break; default: ASSERT_NOT_REACHED(); break; @@ -503,7 +509,7 @@ void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download) downloadItem->d->downloadProxy = download; q->connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), q, SLOT(_q_onReceivedResponseFromDownload(QWebDownloadItem*))); - context->downloadManager()->addDownload(download, downloadItem); + QtWebContext::downloadManager()->addDownload(download, downloadItem); } void QQuickWebViewPrivate::_q_onVisibleChanged() @@ -805,12 +811,8 @@ QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport) void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) { - Q_Q(QQuickWebView); QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); - q->setAcceptedMouseButtons(Qt::MouseButtonMask); - q->setAcceptHoverEvents(true); - // Trigger setting of correct visibility flags after everything was allocated and initialized. _q_onVisibleChanged(); } @@ -847,7 +849,6 @@ void QQuickWebViewLegacyPrivate::setZoomFactor(qreal factor) QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport) : QQuickWebViewPrivate(viewport) { - viewport->setAcceptHoverEvents(false); } void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) @@ -897,12 +898,12 @@ void QQuickWebViewFlickablePrivate::handleMouseEvent(QMouseEvent* event) pageView->eventHandler()->handleInputEvent(event); } -QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView) +QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView, QQuickWebViewPrivate* webViewPrivate) : QObject(webView) , q_ptr(webView) - , d_ptr(webView->d_ptr.data()) + , d_ptr(webViewPrivate) , schemeParent(new QObject(this)) - , m_test(new QWebKitTest(webView->d_ptr.data(), this)) + , m_test(new QWebKitTest(webViewPrivate, this)) { } @@ -1473,7 +1474,6 @@ QQuickWebPage* QQuickWebViewExperimental::page() QQuickWebView::QQuickWebView(QQuickItem* parent) : QQuickFlickable(parent) , d_ptr(createPrivateObject(this)) - , m_experimental(new QQuickWebViewExperimental(this)) { Q_D(QQuickWebView); d->initialize(); @@ -1482,7 +1482,6 @@ QQuickWebView::QQuickWebView(QQuickItem* parent) QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent) : QQuickFlickable(parent) , d_ptr(createPrivateObject(this)) - , m_experimental(new QQuickWebViewExperimental(this)) { Q_D(QQuickWebView); d->initialize(contextRef, pageGroupRef); @@ -1762,7 +1761,8 @@ QVariant QQuickWebView::inputMethodQuery(Qt::InputMethodQuery property) const */ QQuickWebViewExperimental* QQuickWebView::experimental() const { - return m_experimental; + Q_D(const QQuickWebView); + return d->experimental; } /*! diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index 89e7fbc99..dfe7ad88e 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -213,9 +213,9 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_onUrlChanged()); Q_PRIVATE_SLOT(d_func(), void _q_onReceivedResponseFromDownload(QWebDownloadItem*)); Q_PRIVATE_SLOT(d_func(), void _q_onIconChangedForPageURL(const QString&)); + // Hides QObject::d_ptr allowing us to use the convenience macros. QScopedPointer<QQuickWebViewPrivate> d_ptr; - QQuickWebViewExperimental* m_experimental; friend class QWebKitTest; friend class WebKit::PageViewportControllerClientQt; @@ -284,7 +284,6 @@ public: DownloadRequest = QQuickWebView::IgnoreRequest - 1 }; - QQuickWebViewExperimental(QQuickWebView* webView); virtual ~QQuickWebViewExperimental(); QQmlComponent* alertDialog() const; @@ -380,6 +379,7 @@ Q_SIGNALS: void remoteInspectorUrlChanged(); private: + QQuickWebViewExperimental(QQuickWebView* webView, QQuickWebViewPrivate* webViewPrivate); QQuickWebView* q_ptr; QQuickWebViewPrivate* d_ptr; QObject* schemeParent; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index 15bf818d7..adedb6a31 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -171,6 +171,7 @@ protected: QScopedPointer<QQuickWebPage> pageView; QQuickWebView* q_ptr; + QQuickWebViewExperimental* experimental; FlickableAxisLocker axisLocker; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp index 63dce28d0..aa26c0737 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp @@ -49,13 +49,8 @@ WTF::String QWebIconImageProvider::iconURLForPageURLInContext(const WTF::String QUrl url; url.setScheme(QStringLiteral("image")); url.setHost(QWebIconImageProvider::identifier()); - - QString path; - path.append(QLatin1Char('/')); - path.append(QString::number(context->contextID())); - path.append(QLatin1Char('/')); - path.append(QString::number(WTF::StringHash::hash(iconURL))); - url.setPath(path); + // Make sure that QML doesn't show cached versions of the previous icon if the icon location changed. + url.setPath(QLatin1Char('/') + QString::number(WTF::StringHash::hash(iconURL))); // FIXME: Use QUrl::DecodedMode when landed in Qt url.setFragment(QString::fromLatin1(QByteArray(QString(pageURL).toUtf8()).toBase64())); @@ -70,21 +65,12 @@ WTF::String QWebIconImageProvider::iconURLForPageURLInContext(const WTF::String QImage QWebIconImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) { - // The string identifier has the leading image://webicon/ already stripped, so we just - // need to truncate from the first slash to get the context id. - QString contextIDString = id.left(id.indexOf(QLatin1Char('/'))); - bool ok = false; - uint64_t contextId = contextIDString.toUInt(&ok); - if (!ok) - return QImage(); + QString pageURL = QString::fromUtf8(QByteArray::fromBase64(id.midRef(id.indexOf('#') + 1).toLatin1())); - QtWebContext* context = QtWebContext::contextByID(contextId); - if (!context) + QtWebIconDatabaseClient* iconDatabase = QtWebContext::iconDatabase(); + if (!iconDatabase) return QImage(); - QString pageURL = QString::fromUtf8(QByteArray::fromBase64(id.midRef(id.indexOf('#') + 1).toLatin1())); - - QtWebIconDatabaseClient* iconDatabase = context->iconDatabase(); QImage icon = requestedSize.isValid() ? iconDatabase->iconImageForPageURL(pageURL, requestedSize) : iconDatabase->iconImageForPageURL(pageURL); ASSERT(!icon.isNull()); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp index e27f51264..7ddfd9269 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp @@ -20,11 +20,8 @@ #include "config.h" #include "qwebpreferences_p.h" -#include "WKPageGroup.h" -#include "WKPreferences.h" -#include "WKPreferencesPrivate.h" -#include "WKRetainPtr.h" -#include "WKStringQt.h" +#include "WebPageGroup.h" +#include "WebPageProxy.h" #include "qquickwebview_p_p.h" #include "qwebpreferences_p_p.h" @@ -40,41 +37,49 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute { switch (attr) { case AutoLoadImages: - return WKPreferencesGetLoadsImagesAutomatically(preferencesRef()); + return preferences()->loadsImagesAutomatically(); #if ENABLE(FULLSCREEN_API) case FullScreenEnabled: - return WKPreferencesGetFullScreenEnabled(preferencesRef()); + return preferences()->fullScreenEnabled(); #endif case JavascriptEnabled: - return WKPreferencesGetJavaScriptEnabled(preferencesRef()); + return preferences()->javaScriptEnabled(); case PluginsEnabled: - return WKPreferencesGetPluginsEnabled(preferencesRef()); + return preferences()->pluginsEnabled(); case OfflineWebApplicationCacheEnabled: - return WKPreferencesGetOfflineWebApplicationCacheEnabled(preferencesRef()); + return preferences()->offlineWebApplicationCacheEnabled(); case LocalStorageEnabled: - return WKPreferencesGetLocalStorageEnabled(preferencesRef()); + return preferences()->localStorageEnabled(); case XSSAuditingEnabled: - return WKPreferencesGetXSSAuditorEnabled(preferencesRef()); + return preferences()->xssAuditorEnabled(); case PrivateBrowsingEnabled: - return WKPreferencesGetPrivateBrowsingEnabled(preferencesRef()); + return preferences()->privateBrowsingEnabled(); case DnsPrefetchEnabled: - return WKPreferencesGetDNSPrefetchingEnabled(preferencesRef()); + return preferences()->dnsPrefetchingEnabled(); case FrameFlatteningEnabled: - return WKPreferencesGetFrameFlatteningEnabled(preferencesRef()); + return preferences()->frameFlatteningEnabled(); case DeveloperExtrasEnabled: - return WKPreferencesGetDeveloperExtrasEnabled(preferencesRef()); + return preferences()->developerExtrasEnabled(); #if ENABLE(WEBGL) case WebGLEnabled: - return WKPreferencesGetWebGLEnabled(preferencesRef()); + return preferences()->webGLEnabled(); #if ENABLE(CSS_SHADERS) case CSSCustomFilterEnabled: - return WKPreferencesGetCSSCustomFilterEnabled(preferencesRef()); + return preferences()->cssCustomFilterEnabled(); #endif #endif #if ENABLE(WEB_AUDIO) case WebAudioEnabled: - return WKPreferencesGetWebAudioEnabled(preferencesRef()); + return preferences()->webAudioEnabled(); #endif +#if ENABLE(SMOOTH_SCROLLING) + case ScrollAnimatorEnabled: + return preferences()->scrollAnimatorEnabled(); +#endif + case CaretBrowsingEnabled: + return preferences()->caretBrowsingEnabled(); + case NotificationsEnabled: + return preferences()->notificationsEnabled(); default: ASSERT_NOT_REACHED(); return false; @@ -85,54 +90,66 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a { switch (attr) { case AutoLoadImages: - WKPreferencesSetLoadsImagesAutomatically(preferencesRef(), enable); + preferences()->setLoadsImagesAutomatically(enable); break; #if ENABLE(FULLSCREEN_API) case FullScreenEnabled: - WKPreferencesSetFullScreenEnabled(preferencesRef(), enable); + preferences()->setFullScreenEnabled(enable); break; #endif case JavascriptEnabled: - WKPreferencesSetJavaScriptEnabled(preferencesRef(), enable); + preferences()->setJavaScriptEnabled(enable); break; case PluginsEnabled: - WKPreferencesSetPluginsEnabled(preferencesRef(), enable); + preferences()->setPluginsEnabled(enable); break; case OfflineWebApplicationCacheEnabled: - WKPreferencesSetOfflineWebApplicationCacheEnabled(preferencesRef(), enable); + preferences()->setOfflineWebApplicationCacheEnabled(enable); break; case LocalStorageEnabled: - WKPreferencesSetLocalStorageEnabled(preferencesRef(), enable); + preferences()->setLocalStorageEnabled(enable); break; case XSSAuditingEnabled: - WKPreferencesSetXSSAuditorEnabled(preferencesRef(), enable); + preferences()->setXSSAuditorEnabled(enable); break; case PrivateBrowsingEnabled: - WKPreferencesSetPrivateBrowsingEnabled(preferencesRef(), enable); + preferences()->setPrivateBrowsingEnabled(enable); break; case DnsPrefetchEnabled: - WKPreferencesSetDNSPrefetchingEnabled(preferencesRef(), enable); + preferences()->setDNSPrefetchingEnabled(enable); break; case FrameFlatteningEnabled: - WKPreferencesSetFrameFlatteningEnabled(preferencesRef(), enable); + preferences()->setFrameFlatteningEnabled(enable); case DeveloperExtrasEnabled: - WKPreferencesSetDeveloperExtrasEnabled(preferencesRef(), enable); + preferences()->setDeveloperExtrasEnabled(enable); break; #if ENABLE(WEBGL) case WebGLEnabled: - WKPreferencesSetWebGLEnabled(preferencesRef(), enable); + preferences()->setWebGLEnabled(enable); break; #if ENABLE(CSS_SHADERS) case CSSCustomFilterEnabled: - WKPreferencesSetCSSCustomFilterEnabled(preferencesRef(), enable); + preferences()->setCSSCustomFilterEnabled(enable); break; #endif #endif #if ENABLE(WEB_AUDIO) case WebAudioEnabled: - WKPreferencesSetWebAudioEnabled(preferencesRef(), enable); + preferences()->setWebAudioEnabled(enable); + break; +#endif +#if ENABLE(SMOOTH_SCROLLING) + case ScrollAnimatorEnabled: + preferences()->setScrollAnimatorEnabled(enable); break; #endif + case CaretBrowsingEnabled: + // FIXME: Caret browsing doesn't make much sense in touch mode. + preferences()->setCaretBrowsingEnabled(enable); + break; + case NotificationsEnabled: + preferences()->setNotificationsEnabled(enable); + break; default: ASSERT_NOT_REACHED(); } @@ -166,22 +183,22 @@ void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily wh { switch (which) { case StandardFont: - WKPreferencesSetStandardFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setStandardFontFamily(family); break; case FixedFont: - WKPreferencesSetFixedFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setFixedFontFamily(family); break; case SerifFont: - WKPreferencesSetSerifFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setSerifFontFamily(family); break; case SansSerifFont: - WKPreferencesSetSansSerifFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setSansSerifFontFamily(family); break; case CursiveFont: - WKPreferencesSetCursiveFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setCursiveFontFamily(family); break; case FantasyFont: - WKPreferencesSetFantasyFontFamily(preferencesRef(), WKStringCreateWithQString(family)); + preferences()->setFantasyFontFamily(family); break; default: break; @@ -191,30 +208,18 @@ void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily wh QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const { switch (which) { - case StandardFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } - case FixedFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } - case SerifFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } - case SansSerifFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } - case CursiveFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } - case FantasyFont: { - WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(preferencesRef())); - return WKStringCopyQString(stringRef.get()); - } + case StandardFont: + return preferences()->standardFontFamily(); + case FixedFont: + return preferences()->fixedFontFamily(); + case SerifFont: + return preferences()->serifFontFamily(); + case SansSerifFont: + return preferences()->sansSerifFontFamily(); + case CursiveFont: + return preferences()->cursiveFontFamily(); + case FantasyFont: + return preferences()->fantasyFontFamily(); default: return QString(); } @@ -224,14 +229,14 @@ void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType ty { switch (type) { case MinimumFontSize: - WKPreferencesSetMinimumFontSize(preferencesRef(), size); - break; + preferences()->setMinimumFontSize(size); + break; case DefaultFontSize: - WKPreferencesSetDefaultFontSize(preferencesRef(), size); - break; + preferences()->setDefaultFontSize(size); + break; case DefaultFixedFontSize: - WKPreferencesSetDefaultFixedFontSize(preferencesRef(), size); - break; + preferences()->setDefaultFixedFontSize(size); + break; default: ASSERT_NOT_REACHED(); } @@ -241,11 +246,11 @@ unsigned QWebPreferencesPrivate::fontSize(QWebPreferencesPrivate::FontSizeType t { switch (type) { case MinimumFontSize: - return WKPreferencesGetMinimumFontSize(preferencesRef()); + return preferences()->minimumFontSize(); case DefaultFontSize: - return WKPreferencesGetDefaultFontSize(preferencesRef()); + return preferences()->defaultFontSize(); case DefaultFixedFontSize: - return WKPreferencesGetDefaultFixedFontSize(preferencesRef()); + return preferences()->defaultFixedFontSize(); default: ASSERT_NOT_REACHED(); return false; @@ -541,10 +546,50 @@ void QWebPreferences::setWebAudioEnabled(bool enable) #endif } -WKPreferencesRef QWebPreferencesPrivate::preferencesRef() const +bool QWebPreferences::scrollAnimatorEnabled() const +{ +#if ENABLE(SMOOTH_SCROLLING) + return d->testAttribute(QWebPreferencesPrivate::ScrollAnimatorEnabled); +#else + return false; +#endif +} + +void QWebPreferences::setScrollAnimatorEnabled(bool enable) +{ +#if ENABLE(SMOOTH_SCROLLING) + d->setAttribute(QWebPreferencesPrivate::ScrollAnimatorEnabled, enable); + emit scrollAnimatorEnabledChanged(); +#else + UNUSED_PARAM(enable); +#endif +} + +bool QWebPreferences::caretBrowsingEnabled() const +{ + return d->testAttribute(QWebPreferencesPrivate::CaretBrowsingEnabled); +} + +void QWebPreferences::setCaretBrowsingEnabled(bool enable) +{ + d->setAttribute(QWebPreferencesPrivate::CaretBrowsingEnabled, enable); + emit caretBrowsingEnabledChanged(); +} + +bool QWebPreferences::notificationsEnabled() const +{ + return d->testAttribute(QWebPreferencesPrivate::NotificationsEnabled); +} + +void QWebPreferences::setNotificationsEnabled(bool enable) +{ + d->setAttribute(QWebPreferencesPrivate::NotificationsEnabled, enable); + emit notificationsEnabledChanged(); +} + +WebKit::WebPreferences* QWebPreferencesPrivate::preferences() const { - WKPageGroupRef pageGroupRef = toAPI(webViewPrivate->webPageProxy->pageGroup()); - return WKPageGroupGetPreferences(pageGroupRef); + return webViewPrivate->webPageProxy->pageGroup()->preferences(); } QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences) diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h index 373df7504..e3fab79ab 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h @@ -45,6 +45,9 @@ public: Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled NOTIFY developerExtrasEnabledChanged FINAL) Q_PROPERTY(bool webGLEnabled READ webGLEnabled WRITE setWebGLEnabled NOTIFY webGLEnabledChanged FINAL) Q_PROPERTY(bool webAudioEnabled READ webAudioEnabled WRITE setWebAudioEnabled NOTIFY webAudioEnabledChanged FINAL) + Q_PROPERTY(bool scrollAnimatorEnabled READ scrollAnimatorEnabled WRITE setScrollAnimatorEnabled NOTIFY scrollAnimatorEnabledChanged FINAL) + Q_PROPERTY(bool caretBrowsingEnabled READ caretBrowsingEnabled WRITE setCaretBrowsingEnabled NOTIFY caretBrowsingEnabledChanged FINAL) + Q_PROPERTY(bool notificationsEnabled READ notificationsEnabled WRITE setNotificationsEnabled NOTIFY notificationsEnabledChanged FINAL) Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL) Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL) @@ -99,6 +102,15 @@ public: bool webAudioEnabled() const; void setWebAudioEnabled(bool enable); + bool scrollAnimatorEnabled() const; + void setScrollAnimatorEnabled(bool enable); + + bool caretBrowsingEnabled() const; + void setCaretBrowsingEnabled(bool enable); + + bool notificationsEnabled() const; + void setNotificationsEnabled(bool enable); + QString standardFontFamily() const; void setStandardFontFamily(const QString& family); @@ -141,6 +153,9 @@ Q_SIGNALS: void developerExtrasEnabledChanged(); void webGLEnabledChanged(); void webAudioEnabledChanged(); + void scrollAnimatorEnabledChanged(); + void caretBrowsingEnabledChanged(); + void notificationsEnabledChanged(); void standardFontFamilyChanged(); void fixedFontFamilyChanged(); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h index c606bbe89..c8098b50e 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h @@ -20,7 +20,7 @@ #ifndef qwebpreferences_p_p_h #define qwebpreferences_p_p_h -#include "WKPreferences.h" +#include "WebPreferences.h" class QQuickWebViewPrivate; @@ -41,7 +41,10 @@ public: DeveloperExtrasEnabled, WebGLEnabled, CSSCustomFilterEnabled, - WebAudioEnabled + WebAudioEnabled, + ScrollAnimatorEnabled, + CaretBrowsingEnabled, + NotificationsEnabled }; enum FontFamily { @@ -71,7 +74,7 @@ public: void setFontSize(FontSizeType type, unsigned size); unsigned fontSize(FontSizeType type) const; - WKPreferencesRef preferencesRef() const; + WebKit::WebPreferences* preferences() const; QQuickWebViewPrivate* webViewPrivate; diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml index fcd3d9301..01192a8af 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml @@ -93,5 +93,39 @@ Item { compare(documentSize(), "960x1440") compare(test.contentsScale, 1.0) } + + function test_localPageDeviceWidth() { + webView.url = "about:blank" + verify(webView.waitForLoadSucceeded()) + + webView.url = "../common/test5.html" + verify(webView.waitForLoadSucceeded()) + compare(test.contentsScale, 0.5) + + // Add user interaction. + test.touchTap(webView, 10, 10) + + webView.reload() + verify(webView.waitForLoadSucceeded()) + // The page should still fit to view after a reload + compare(test.contentsScale, 0.5) + } + + function test_localPageInitialScale() { + webView.url = "about:blank" + verify(webView.waitForLoadSucceeded()) + + webView.url = "../common/test4.html" + verify(webView.waitForLoadSucceeded()) + + compare(test.contentsScale, 2.0) + + // Add user interaction. + test.touchTap(webView, 10, 10) + + webView.reload() + verify(webView.waitForLoadSucceeded()) + compare(test.contentsScale, 2.0) + } } } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html index e31d689d8..8f75af606 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test4.html @@ -9,6 +9,7 @@ font-size: 50px; } </style> + <meta name="viewport" content="initial-scale=2.0"/> </head> <body> <div id="content"> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html new file mode 100644 index 000000000..3630ea6bd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test5.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>Local page with viewport meta tag: width=device-width</title> + <meta name="viewport" content="width=device-width"/> + </head> + <body> + <style type="text/css">body {width: 960px; height: 1440px; margin: 0; padding: 0;}</style> + <div>blah</div> + </body> +</html> diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp index 558053729..6e2c342cb 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp @@ -258,11 +258,8 @@ void tst_QQuickWebView::show() void tst_QQuickWebView::showWebView() { - webView()->setSize(QSizeF(300, 400)); - webView()->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/direct-image-compositing.html"))); QVERIFY(waitForLoadSucceeded(webView())); - m_window->show(); // This should not crash. webView()->setVisible(true); @@ -295,13 +292,11 @@ void tst_QQuickWebView::multipleWebViewWindows() QQuickWebView* webView2 = newWebView(); QScopedPointer<TestWindow> window2(new TestWindow(webView2)); - webView1->setSize(QSizeF(300, 400)); webView1->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html"))); QVERIFY(waitForLoadSucceeded(webView1)); window1->show(); webView1->setVisible(true); - webView2->setSize(QSizeF(300, 400)); webView2->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"))); QVERIFY(waitForLoadSucceeded(webView2)); window2->show(); @@ -334,14 +329,10 @@ void tst_QQuickWebView::multipleWebViews() void tst_QQuickWebView::basicRenderingSanity() { showWebView(); - webView()->setSize(QSizeF(300, 400)); webView()->setUrl(QUrl(QString::fromUtf8("data:text/html,<html><body bgcolor=\"#00ff00\"></body></html>"))); QVERIFY(waitForLoadSucceeded(webView())); - // We have to explicitly move the window into the screen, otherwise it's not rendered. - m_window->setGeometry(0, 0, 300, 400); - m_window->show(); // This should not crash. webView()->setVisible(true); QTest::qWait(200); diff --git a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h index 4b2cfcf11..9d5d656e9 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h +++ b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h @@ -44,6 +44,7 @@ inline TestWindow::TestWindow(QQuickItem* webView) { Q_ASSERT(webView); webView->setParentItem(contentItem()); + resize(300, 400); } inline void TestWindow::resizeEvent(QResizeEvent* event) |