diff options
Diffstat (limited to 'Source/WebKit2/UIProcess')
281 files changed, 8551 insertions, 2446 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index 28a70821b..26e4ab6a4 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -266,6 +266,16 @@ void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef loca toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string()); } +WK_EXPORT void WKContextSetDiskCacheDirectory(WKContextRef contextRef, WKStringRef diskCacheDirectory) +{ + toImpl(contextRef)->setDiskCacheDirectory(toImpl(diskCacheDirectory)->string()); +} + +WK_EXPORT void WKContextSetCookieStorageDirectory(WKContextRef contextRef, WKStringRef cookieStorageDirectory) +{ + toImpl(contextRef)->setCookieStorageDirectory(toImpl(cookieStorageDirectory)->string()); +} + void WKContextDisableProcessTermination(WKContextRef contextRef) { toImpl(contextRef)->disableProcessTermination(); @@ -300,6 +310,12 @@ void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef contextRef, { toImpl(contextRef)->setJavaScriptGarbageCollectorTimerEnabled(enable); } + +void WKContextSetUsesNetworkProcess(WKContextRef contextRef, bool usesNetworkProcess) +{ + toImpl(contextRef)->setUsesNetworkProcess(usesNetworkProcess); +} + // Deprecated functions. void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory) { diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h index 49aec7f53..79c2ef50f 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -60,6 +60,8 @@ WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef ic // we should really change these settings to be on WebPreferences and changeable at runtime. WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory); WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory); +WK_EXPORT void WKContextSetDiskCacheDirectory(WKContextRef context, WKStringRef diskCacheDirectory); +WK_EXPORT void WKContextSetCookieStorageDirectory(WKContextRef context, WKStringRef cookieStorageDirectory); // FIXME: This is a workaround for testing purposes only and should be removed once a better // solution has been found for testing. @@ -70,6 +72,10 @@ WK_EXPORT void WKContextSetHTTPPipeliningEnabled(WKContextRef context, bool enab WK_EXPORT void WKContextWarmInitialProcess(WKContextRef context); +// FIXME: This function is temporary and useful during the development of the NetworkProcess feature. +// At some point it should be removed. +WK_EXPORT void WKContextSetUsesNetworkProcess(WKContextRef context, bool usesNetworkProcess); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp index 99195c79c..5d94f3e86 100644 --- a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,6 +38,11 @@ WKTypeID WKGeolocationPositionGetTypeID() WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy) { - RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy); + return WKGeolocationPositionCreate_b(timestamp, latitude, longitude, accuracy, false, 0., false, 0., false, 0., false, 0.); +} + +WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) +{ + RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed); return toAPI(position.release().leakRef()); } diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h index 85183fd60..4727e9763 100644 --- a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h +++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h @@ -35,6 +35,7 @@ extern "C" { WK_EXPORT WKTypeID WKGeolocationPositionGetTypeID(); WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy); +WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h index 45ceec765..eec4ab3af 100644 --- a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h +++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h @@ -35,16 +35,22 @@ extern "C" { // IconDatabase Client. typedef void (*WKIconDatabaseDidChangeIconForPageURLCallback)(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); typedef void (*WKIconDatabaseDidRemoveAllIconsCallback)(WKIconDatabaseRef iconDatabase, const void* clientInfo); +typedef void (*WKIconDatabaseIconDataReadyForPageURLCallback)(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); struct WKIconDatabaseClient { int version; const void * clientInfo; + + // Version 0 WKIconDatabaseDidChangeIconForPageURLCallback didChangeIconForPageURL; WKIconDatabaseDidRemoveAllIconsCallback didRemoveAllIcons; + + // Version 1 + WKIconDatabaseIconDataReadyForPageURLCallback iconDataReadyForPageURL; }; typedef struct WKIconDatabaseClient WKIconDatabaseClient; -enum { kWKIconDatabaseClientCurrentVersion = 0 }; +enum { kWKIconDatabaseClientCurrentVersion = 1 }; WK_EXPORT WKTypeID WKIconDatabaseGetTypeID(); diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp index 94fda474a..52e1cebf8 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp @@ -365,6 +365,16 @@ bool WKPageIsPinnedToRightSide(WKPageRef pageRef) return toImpl(pageRef)->isPinnedToRightSide(); } +bool WKPageIsPinnedToTopSide(WKPageRef pageRef) +{ + return toImpl(pageRef)->isPinnedToTopSide(); +} + +bool WKPageIsPinnedToBottomSide(WKPageRef pageRef) +{ + return toImpl(pageRef)->isPinnedToBottomSide(); +} + void WKPageSetPaginationMode(WKPageRef pageRef, WKPaginationMode paginationMode) { Pagination::Mode mode; @@ -738,3 +748,7 @@ void WKPagePostMessageToInjectedBundle(WKPageRef pageRef, WKStringRef messageNam toImpl(pageRef)->postMessageToInjectedBundle(toImpl(messageNameRef)->string(), toImpl(messageBodyRef)); } +WKArrayRef WKPageCopyRelatedPages(WKPageRef pageRef) +{ + return toAPI(toImpl(pageRef)->relatedPages().leakRef()); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 62db9174c..9dfd52e3c 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -439,6 +439,8 @@ WK_EXPORT bool WKPageAreScrollbarAnimationsSuppressed(WKPageRef page); WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page); WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page); +WK_EXPORT bool WKPageIsPinnedToTopSide(WKPageRef page); +WK_EXPORT bool WKPageIsPinnedToBottomSide(WKPageRef page); WK_EXPORT bool WKPageCanDelete(WKPageRef page); WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page); diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp index 8a4d86a05..51298cd14 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp @@ -57,3 +57,23 @@ WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroupRef) { return toAPI(toImpl(pageGroupRef)->preferences()); } + +void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames) +{ + toImpl(pageGroupRef)->addUserStyleSheet(toWTFString(sourceRef), toWTFString(baseURL), toImpl(whitelistedURLPatterns), toImpl(blacklistedURLPatterns), toUserContentInjectedFrames(injectedFrames), WebCore::UserStyleUserLevel); +} + +void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroupRef) +{ + toImpl(pageGroupRef)->removeAllUserStyleSheets(); +} + +void WKPageGroupAddUserScript(WKPageGroupRef pageGroupRef, WKStringRef sourceRef, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames injectedFrames, WKUserScriptInjectionTime injectionTime) +{ + toImpl(pageGroupRef)->addUserScript(toWTFString(sourceRef), toWTFString(baseURL), toImpl(whitelistedURLPatterns), toImpl(blacklistedURLPatterns), toUserContentInjectedFrames(injectedFrames), toUserScriptInjectionTime(injectionTime)); +} + +void WKPageGroupRemoveAllUserScripts(WKPageGroupRef pageGroupRef) +{ + toImpl(pageGroupRef)->removeAllUserScripts(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.h b/Source/WebKit2/UIProcess/API/C/WKPageGroup.h index 705df083e..01edb51c6 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPageGroup.h +++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.h @@ -40,6 +40,12 @@ WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup); WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences); WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup); + +WK_EXPORT void WKPageGroupAddUserStyleSheet(WKPageGroupRef pageGroup, WKStringRef source, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames); +WK_EXPORT void WKPageGroupRemoveAllUserStyleSheets(WKPageGroupRef pageGroup); + +WK_EXPORT void WKPageGroupAddUserScript(WKPageGroupRef pageGroup, WKStringRef source, WKURLRef baseURL, WKArrayRef whitelistedURLPatterns, WKArrayRef blacklistedURLPatterns, WKUserContentInjectedFrames, WKUserScriptInjectionTime); +WK_EXPORT void WKPageGroupRemoveAllUserScripts(WKPageGroupRef pageGroup); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h index 4a13ae7a2..3a9de69af 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h @@ -94,6 +94,8 @@ WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync) WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume); +WK_EXPORT WKArrayRef WKPageCopyRelatedPages(WKPageRef page); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 657b1b730..532d82caf 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -298,6 +298,16 @@ bool WKPreferencesGetScreenFontSubstitutionEnabled(WKPreferencesRef preferencesR return toImpl(preferencesRef)->screenFontSubstitutionEnabled(); } +void WKPreferencesSetCookieEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setCookieEnabled(enabled); +} + +bool WKPreferencesGetCookieEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->cookieEnabled(); +} + void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior wkBehavior) { toImpl(preferencesRef)->setEditableLinkBehavior(toEditableLinkBehavior(wkBehavior)); @@ -913,3 +923,23 @@ bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef prefere { return toImpl(preferencesRef)->scrollingPerformanceLoggingEnabled(); } + +void WKPreferencesSetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setPlugInSnapshottingEnabled(enabled); +} + +bool WKPreferencesGetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->plugInSnapshottingEnabled(); +} + +void WKPreferencesSetPDFPluginEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setPDFPluginEnabled(enabled); +} + +bool WKPreferencesGetPDFPluginEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->pdfPluginEnabled(); +} diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h index c0fde67fd..d91b82d83 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -216,6 +216,10 @@ WK_EXPORT bool WKPreferencesGetShouldRespectImageOrientation(WKPreferencesRef pr WK_EXPORT void WKPreferencesSetStorageBlockingPolicy(WKPreferencesRef preferencesRef, WKStorageBlockingPolicy policy); WK_EXPORT WKStorageBlockingPolicy WKPreferencesGetStorageBlockingPolicy(WKPreferencesRef preferencesRef); +// Defaults to false +WK_EXPORT void WKPreferencesSetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetPlugInSnapshottingEnabled(WKPreferencesRef preferencesRef); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index 11311704d..af5f73b34 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -219,6 +219,14 @@ WK_EXPORT bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesR WK_EXPORT void WKPreferencesSetScreenFontSubstitutionEnabled(WKPreferencesRef preferences, bool enabled); WK_EXPORT bool WKPreferencesGetScreenFontSubstitutionEnabled(WKPreferencesRef preferences); +// Defaults to true +WK_EXPORT void WKPreferencesSetCookieEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetCookieEnabled(WKPreferencesRef preferences); + +// Defaults to false +WK_EXPORT void WKPreferencesSetPDFPluginEnabled(WKPreferencesRef preferences, bool enabled); +WK_EXPORT bool WKPreferencesGetPDFPluginEnabled(WKPreferencesRef preferences); + WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef); #ifdef __cplusplus diff --git a/Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.h b/Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.h index 1c9c001f2..4dba13908 100644 --- a/Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.h +++ b/Source/WebKit2/UIProcess/API/C/soup/WKSoupRequestManager.h @@ -33,7 +33,7 @@ extern "C" { #endif -typedef void (*WKSoupRequestManagerDidReceiveURIRequestCallback)(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, uint64_t requestID, const void* clientInfo); +typedef void (*WKSoupRequestManagerDidReceiveURIRequestCallback)(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef pageRef, uint64_t requestID, const void* clientInfo); typedef void (*WKSoupRequestManagerDidFailToLoadURIRequestCallback)(WKSoupRequestManagerRef soupRequestManagerRef, uint64_t requestID, const void* clientInfo); struct WKSoupRequestManagerClient { diff --git a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp b/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp index 83cc37119..810711597 100644 --- a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp +++ b/Source/WebKit2/UIProcess/API/efl/BatteryProvider.cpp @@ -31,6 +31,7 @@ #include "WKAPICast.h" #include "WKBatteryManager.h" #include "WKBatteryStatus.h" +#include "WKContext.h" using namespace WebCore; using namespace WebKit; @@ -53,17 +54,25 @@ static void stopUpdatingCallback(WKBatteryManagerRef, const void* clientInfo) BatteryProvider::~BatteryProvider() { m_provider.stopUpdating(); + + WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(m_wkContext.get()); + ASSERT(wkBatteryManager); + + WKBatteryManagerSetProvider(wkBatteryManager, 0); } -PassRefPtr<BatteryProvider> BatteryProvider::create(WKBatteryManagerRef wkBatteryManager) +PassRefPtr<BatteryProvider> BatteryProvider::create(WKContextRef wkContext) { - return adoptRef(new BatteryProvider(wkBatteryManager)); + return adoptRef(new BatteryProvider(wkContext)); } -BatteryProvider::BatteryProvider(WKBatteryManagerRef wkBatteryManager) - : m_wkBatteryManager(wkBatteryManager) +BatteryProvider::BatteryProvider(WKContextRef wkContext) + : m_wkContext(wkContext) , m_provider(this) { + ASSERT(m_wkContext); + + WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(m_wkContext.get()); ASSERT(wkBatteryManager); WKBatteryProvider wkBatteryProvider = { @@ -72,7 +81,7 @@ BatteryProvider::BatteryProvider(WKBatteryManagerRef wkBatteryManager) startUpdatingCallback, stopUpdatingCallback }; - WKBatteryManagerSetProvider(m_wkBatteryManager.get(), &wkBatteryProvider); + WKBatteryManagerSetProvider(wkBatteryManager, &wkBatteryProvider); } void BatteryProvider::startUpdating() @@ -87,8 +96,11 @@ void BatteryProvider::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(m_wkBatteryManager.get(), toAPI(eventType.impl()), wkBatteryStatus.get()); + WKBatteryManagerProviderDidChangeBatteryStatus(wkBatteryManager, toAPI(eventType.impl()), wkBatteryStatus.get()); } #endif // ENABLE(BATTERY_STATUS) diff --git a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h b/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h index e9e4cf5f0..c54414e68 100644 --- a/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/BatteryProvider.h @@ -38,18 +38,18 @@ class BatteryProvider : public RefCounted<BatteryProvider>, public WebCore::BatteryProviderEflClient { public: virtual ~BatteryProvider(); - static PassRefPtr<BatteryProvider> create(WKBatteryManagerRef); + static PassRefPtr<BatteryProvider> create(WKContextRef); void startUpdating(); void stopUpdating(); private: - BatteryProvider(WKBatteryManagerRef); + BatteryProvider(WKContextRef); // BatteryProviderEflClient interface. virtual void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<WebCore::BatteryStatus>); - WKRetainPtr<WKBatteryManagerRef> m_wkBatteryManager; + WKRetainPtr<WKContextRef> m_wkContext; WebCore::BatteryProviderEfl m_provider; }; diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index 13efab13a..17afb115d 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -33,19 +33,22 @@ #include "ewk_context.h" #include "ewk_cookie_manager.h" #include "ewk_download_job.h" +#include "ewk_error.h" +#include "ewk_favicon_database.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_popup_menu_item.h" +#include "ewk_resource.h" #include "ewk_settings.h" +#include "ewk_text_checker.h" #include "ewk_touch.h" #include "ewk_url_request.h" #include "ewk_url_response.h" #include "ewk_url_scheme_request.h" #include "ewk_view.h" -#include "ewk_web_error.h" -#include "ewk_web_resource.h" #endif // EWebKit2_h diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp index eb3d007fe..b1a034496 100644 --- a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp @@ -53,15 +53,22 @@ DrawingAreaProxy* EflViewportHandler::drawingArea() const return ewk_view_page_get(m_viewWidget)->drawingArea(); } -void EflViewportHandler::display(const IntRect& rect) +void EflViewportHandler::setRendererActive(bool active) +{ + drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setActive(active); +} + +void EflViewportHandler::display(const IntRect& rect, const IntPoint& viewPosition) { WebCore::TransformationMatrix matrix; - matrix.setMatrix(m_scaleFactor, 0, 0, m_scaleFactor, -m_visibleContentRect.x(), -m_visibleContentRect.y()); + 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(); - renderer->paintToCurrentGLContext(matrix, 1, rect); + IntRect clipRect(rect); + clipRect.move(viewPosition.x(), viewPosition.y()); + renderer->paintToCurrentGLContext(matrix, 1, clipRect); } void EflViewportHandler::updateViewportSize(const IntSize& viewportSize) diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h index a23f4e147..1dd231e49 100644 --- a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h @@ -44,11 +44,11 @@ public: DrawingAreaProxy* drawingArea() const; WebCore::IntSize viewSize() { return m_viewportSize; } - void display(const WebCore::IntRect& rect); + 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 didChangeContentsSize(const WebCore::IntSize& size); - + void setRendererActive(bool); private: explicit EflViewportHandler(Evas_Object*); diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp index 54a6921da..1431c83a7 100644 --- a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp +++ b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.cpp @@ -28,6 +28,7 @@ #if ENABLE(NETWORK_INFO) +#include "WKContext.h" #include "WKNetworkInfoManager.h" #include <NotImplemented.h> @@ -56,15 +57,18 @@ static bool isMeteredCallback(WKNetworkInfoManagerRef, const void* clientInfo) return toNetworkInfoProvider(clientInfo)->metered(); } -PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(WKNetworkInfoManagerRef wkManager) +PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(WKContextRef wkContext) { - return adoptRef(new NetworkInfoProvider(wkManager)); + return adoptRef(new NetworkInfoProvider(wkContext)); } -NetworkInfoProvider::NetworkInfoProvider(WKNetworkInfoManagerRef wkManager) - : m_wkNetworkInfoManager(wkManager) +NetworkInfoProvider::NetworkInfoProvider(WKContextRef wkContext) + : m_wkContext(wkContext) { - ASSERT(wkManager); + ASSERT(wkContext); + + WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_wkContext.get()); + ASSERT(wkNetworkInfoManager); WKNetworkInfoProvider wkNetworkInfoProvider = { kWKNetworkInfoProviderCurrentVersion, @@ -74,11 +78,15 @@ NetworkInfoProvider::NetworkInfoProvider(WKNetworkInfoManagerRef wkManager) getBandwidthCallback, isMeteredCallback }; - WKNetworkInfoManagerSetProvider(m_wkNetworkInfoManager.get(), &wkNetworkInfoProvider); + WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, &wkNetworkInfoProvider); } NetworkInfoProvider::~NetworkInfoProvider() { + WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_wkContext.get()); + ASSERT(wkNetworkInfoManager); + + WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, 0); } double NetworkInfoProvider::bandwidth() const diff --git a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h index b9f86e6e5..0a5d60e4f 100644 --- a/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/NetworkInfoProvider.h @@ -37,7 +37,7 @@ class NetworkInfoProvider : public RefCounted<NetworkInfoProvider>, public WebCore::NetworkInfoClient { public: virtual ~NetworkInfoProvider(); - static PassRefPtr<NetworkInfoProvider> create(WKNetworkInfoManagerRef); + static PassRefPtr<NetworkInfoProvider> create(WKContextRef); // NetworkInfoClient interface. virtual double bandwidth() const; @@ -47,9 +47,9 @@ public: virtual void stopUpdating(); private: - NetworkInfoProvider(WKNetworkInfoManagerRef); + NetworkInfoProvider(WKContextRef); - WKRetainPtr<WKNetworkInfoManagerRef> m_wkNetworkInfoManager; + WKRetainPtr<WKContextRef> m_wkContext; WebCore::NetworkInfoProviderEfl m_provider; }; diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index ef2ce603f..0ca7569b9 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -94,8 +94,7 @@ bool PageClientImpl::isViewFocused() bool PageClientImpl::isViewVisible() { - notImplemented(); - return true; + return evas_object_visible_get(m_viewWidget); } bool PageClientImpl::isViewInWindow() @@ -124,9 +123,9 @@ void PageClientImpl::pageClosed() notImplemented(); } -void PageClientImpl::toolTipChanged(const String&, const String&) +void PageClientImpl::toolTipChanged(const String&, const String& newToolTip) { - notImplemented(); + ewk_view_tooltip_text_set(m_viewWidget, newToolTip.utf8().data()); } void PageClientImpl::setCursor(const Cursor& cursor) @@ -284,9 +283,8 @@ void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, Fin void PageClientImpl::handleDownloadRequest(DownloadProxy* download) { - Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget); - ewk_context_download_job_add(ewk_view_context_get(m_viewWidget), ewkDownload); - ewk_download_job_unref(ewkDownload); + RefPtr<Ewk_Download_Job> ewkDownload = Ewk_Download_Job::create(download, m_viewWidget); + ewk_context_download_job_add(ewk_view_context_get(m_viewWidget), ewkDownload.get()); } #if USE(TILED_BACKING_STORE) diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp index 29fb6a4fc..13d4de6d6 100644 --- a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp +++ b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.cpp @@ -29,6 +29,7 @@ #if ENABLE(VIBRATION) #include "WKAPICast.h" +#include "WKContext.h" #include "WKVibration.h" #include <Evas.h> @@ -65,15 +66,18 @@ static void cancelVibrationCallback(WKVibrationRef, const void* clientInfo) toVibrationProvider(clientInfo)->cancelVibration(); } -PassRefPtr<VibrationProvider> VibrationProvider::create(WKVibrationRef wkVibrationRef) +PassRefPtr<VibrationProvider> VibrationProvider::create(WKContextRef wkContext) { - return adoptRef(new VibrationProvider(wkVibrationRef)); + return adoptRef(new VibrationProvider(wkContext)); } -VibrationProvider::VibrationProvider(WKVibrationRef wkVibrationRef) - : m_wkVibrationRef(wkVibrationRef) +VibrationProvider::VibrationProvider(WKContextRef wkContext) + : m_wkContext(wkContext) { - ASSERT(wkVibrationRef); + ASSERT(m_wkContext.get()); + + WKVibrationRef wkVibration = WKContextGetVibration(m_wkContext.get()); + ASSERT(wkVibration); WKVibrationProvider wkVibrationProvider = { kWKVibrationProviderCurrentVersion, @@ -81,11 +85,15 @@ VibrationProvider::VibrationProvider(WKVibrationRef wkVibrationRef) vibrateCallback, cancelVibrationCallback }; - WKVibrationSetProvider(m_wkVibrationRef.get(), &wkVibrationProvider); + WKVibrationSetProvider(wkVibration, &wkVibrationProvider); } VibrationProvider::~VibrationProvider() { + WKVibrationRef wkVibration = WKContextGetVibration(m_wkContext.get()); + ASSERT(wkVibration); + + WKVibrationSetProvider(wkVibration, 0); } void VibrationProvider::vibrate(uint64_t vibrationTime) diff --git a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h index c2643b638..6b2db4eec 100644 --- a/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h +++ b/Source/WebKit2/UIProcess/API/efl/VibrationProvider.h @@ -37,7 +37,7 @@ typedef struct _Ewk_Vibration_Client Ewk_Vibration_Client; class VibrationProvider : public RefCounted<VibrationProvider> { public: - static PassRefPtr<VibrationProvider> create(WKVibrationRef); + static PassRefPtr<VibrationProvider> create(WKContextRef); virtual ~VibrationProvider(); void vibrate(uint64_t vibrationTime); @@ -45,9 +45,9 @@ public: void setVibrationClientCallbacks(Ewk_Vibration_Client_Vibrate_Cb, Ewk_Vibration_Client_Vibration_Cancel_Cb, void*); private: - explicit VibrationProvider(WKVibrationRef); + explicit VibrationProvider(WKContextRef); - WKRetainPtr<WKVibrationRef> m_wkVibrationRef; + WKRetainPtr<WKContextRef> m_wkContext; OwnPtr<Ewk_Vibration_Client> m_vibrationClient; }; diff --git a/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp new file mode 100644 index 000000000..2ff39c4df --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp @@ -0,0 +1,139 @@ +/* + * 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/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.h new file mode 100644 index 000000000..4123244c3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.h @@ -0,0 +1,60 @@ +/* + * 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. + */ + +#ifndef WebKitTextChecker_h +#define WebKitTextChecker_h + +#if ENABLE(SPELLCHECK) + +#include "TextCheckerEnchant.h" +#include "WKArray.h" +#include "WKPage.h" +#include "WKString.h" + +namespace WebKit { + +// The functions mainly choose between client's implementation of spelling and the WebKit one. + +// Callbacks required by WKTextChecker. +bool isContinuousSpellCheckingEnabled(const void* clientInfo); +void setContinuousSpellCheckingEnabled(bool enabled, const void* clientInfo); + +uint64_t uniqueSpellDocumentTag(WKPageRef page, const void* clientInfo); +void closeSpellDocumentWithTag(uint64_t tag, const void* clientInfo); + +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); + +// Enchant's helper. +Vector<String> availableSpellCheckingLanguages(); +void updateSpellCheckingLanguages(const Vector<String>& languages); +Vector<String> loadedSpellCheckingLanguages(); + +} // namespace WebKit + +#endif // ENABLE(SPELLCHECK) +#endif // WebKitTextChecker_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 be866fa0a..63408d02b 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp @@ -29,35 +29,11 @@ #include "WKAPICast.h" #include "WKArray.h" #include "WKBackForwardList.h" -#include "WKRetainPtr.h" -#include "ewk_back_forward_list_item_private.h" +#include "ewk_back_forward_list_private.h" #include <wtf/text/CString.h> using namespace WebKit; -typedef HashMap<WKBackForwardListItemRef, Ewk_Back_Forward_List_Item*> ItemsMap; - -/** - * \struct _Ewk_Back_Forward_List - * @brief Contains the Back Forward List data. - */ -struct _Ewk_Back_Forward_List { - WKRetainPtr<WKBackForwardListRef> wkList; - mutable ItemsMap wrapperCache; - - _Ewk_Back_Forward_List(WKBackForwardListRef listRef) - : wkList(listRef) - { } - - ~_Ewk_Back_Forward_List() - { - ItemsMap::iterator it = wrapperCache.begin(); - ItemsMap::iterator end = wrapperCache.end(); - for (; it != end; ++it) - ewk_back_forward_list_item_unref(it->second); - } -}; - #define EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList_, ...) \ if (!(list)) { \ EINA_LOG_CRIT("list is NULL."); \ @@ -75,13 +51,13 @@ static inline Ewk_Back_Forward_List_Item* addItemToWrapperCache(const Ewk_Back_F EINA_SAFETY_ON_NULL_RETURN_VAL(list, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(wkItem, 0); - Ewk_Back_Forward_List_Item* item = list->wrapperCache.get(wkItem); + RefPtr<Ewk_Back_Forward_List_Item> item = list->wrapperCache.get(wkItem); if (!item) { - item = ewk_back_forward_list_item_new(wkItem); + item = Ewk_Back_Forward_List_Item::create(wkItem); list->wrapperCache.set(wkItem, item); } - return item; + return item.get(); } static inline Eina_List* createEinaList(const Ewk_Back_Forward_List* list, WKArrayRef wkList) @@ -174,29 +150,6 @@ void ewk_back_forward_list_changed(Ewk_Back_Forward_List* list, WKBackForwardLis const size_t removedItemsSize = wkRemovedItems ? WKArrayGetSize(wkRemovedItems) : 0; for (size_t i = 0; i < removedItemsSize; ++i) { WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkRemovedItems, i)); - if (Ewk_Back_Forward_List_Item* item = list->wrapperCache.take(wkItem)) - ewk_back_forward_list_item_unref(item); + list->wrapperCache.remove(wkItem); } } - -/** - * @internal - * Constructs a Ewk_Back_Forward_List from a WKBackForwardListRef. - */ -Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(wkBackForwardListRef, 0); - - return new Ewk_Back_Forward_List(wkBackForwardListRef); -} - -/** - * @internal - * Frees a Ewk_Back_Forward_List object. - */ -void ewk_back_forward_list_free(Ewk_Back_Forward_List* list) -{ - EINA_SAFETY_ON_NULL_RETURN(list); - - delete list; -} 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 5679773a0..8ca1e0d44 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 @@ -28,32 +28,10 @@ #include "WKAPICast.h" #include "WKBackForwardListItem.h" -#include "WKEinaSharedString.h" +#include "ewk_back_forward_list_item_private.h" using namespace WebKit; -/** - * \struct _Ewk_Back_Forward_List - * @brief Contains the Back Forward List data. - */ -struct _Ewk_Back_Forward_List_Item { - unsigned int __ref; /**< the reference count of the object */ - WKRetainPtr<WKBackForwardListItemRef> wkItem; - mutable WKEinaSharedString uri; - mutable WKEinaSharedString title; - mutable WKEinaSharedString originalUri; - - _Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef) - : __ref(1) - , wkItem(itemRef) - { } - - ~_Ewk_Back_Forward_List_Item() - { - ASSERT(!__ref); - } -}; - #define EWK_BACK_FORWARD_LIST_ITEM_WK_GET_OR_RETURN(item, wkItem_, ...) \ if (!(item)) { \ EINA_LOG_CRIT("item is NULL."); \ @@ -68,7 +46,7 @@ struct _Ewk_Back_Forward_List_Item { 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; + item->ref(); return item; } @@ -77,19 +55,16 @@ void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item* item) { EINA_SAFETY_ON_NULL_RETURN(item); - if (--item->__ref) - return; - - delete item; + item->deref(); } -const char* ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item* item) +const char* ewk_back_forward_list_item_url_get(const Ewk_Back_Forward_List_Item* item) { EWK_BACK_FORWARD_LIST_ITEM_WK_GET_OR_RETURN(item, wkItem, 0); - item->uri = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyURL(wkItem)); + item->url = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyURL(wkItem)); - return item->uri; + return item->url; } const char* ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item* item) @@ -101,18 +76,11 @@ const char* ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Ite return item->title; } -const char* ewk_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item* item) +const char* ewk_back_forward_list_item_original_url_get(const Ewk_Back_Forward_List_Item* item) { EWK_BACK_FORWARD_LIST_ITEM_WK_GET_OR_RETURN(item, wkItem, 0); - item->originalUri = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyOriginalURL(wkItem)); - - return item->originalUri; -} - -Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef backForwardListItemData) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(backForwardListItemData, 0); + item->originalURL = WKEinaSharedString(AdoptWK, WKBackForwardListItemCopyOriginalURL(wkItem)); - return new Ewk_Back_Forward_List_Item(backForwardListItemData); + return item->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 a1227dfc0..3c544f3ef 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 @@ -59,21 +59,21 @@ EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_ref(Ewk_Back_Forward EAPI void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item); /** - * Returns URI of the item. + * Returns URL of the item. * - * The returned URI may differ from the original URI (For example if the page was redirected). + * The returned URL may differ from the original URL (For example if the page was redirected). * - * @see ewk_back_forward_list_item_original_uri_get() + * @see ewk_back_forward_list_item_original_url_get() * * @param item the back-forward list item instance * - * @return the URI of the @a item or @c NULL in case of error. This pointer is + * @return the URL of the @a item or @c NULL in case of error. 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_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item *item); +EAPI const char *ewk_back_forward_list_item_url_get(const Ewk_Back_Forward_List_Item *item); /** * Returns title of the item. @@ -89,19 +89,19 @@ EAPI const char *ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_ EAPI const char *ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item *item); /** - * Returns original URI of the item. + * Returns original URL of the item. * - * @see ewk_back_forward_list_item_uri_get() + * @see ewk_back_forward_list_item_url_get() * * @param item the back-forward list item instance * - * @return the original URI of the @a item or @c NULL in case of error. This pointer is + * @return the original URL of the @a item or @c NULL in case of error. 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_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item *item); +EAPI const char *ewk_back_forward_list_item_original_url_get(const Ewk_Back_Forward_List_Item *item); #ifdef __cplusplus } 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 8c2c684d4..254074ab5 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 @@ -26,10 +26,33 @@ #ifndef ewk_back_forward_list_item_private_h #define ewk_back_forward_list_item_private_h +#include "WKEinaSharedString.h" #include <WebKit2/WKBase.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> -typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item; +/** + * \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> { +public: + WKRetainPtr<WKBackForwardListItemRef> wkItem; + mutable WKEinaSharedString url; + mutable WKEinaSharedString title; + mutable WKEinaSharedString originalURL; + + static PassRefPtr<_Ewk_Back_Forward_List_Item> create(WKBackForwardListItemRef itemRef) + { + return adoptRef(new _Ewk_Back_Forward_List_Item(itemRef)); + } -Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef wkBackForwardListItemRef); +private: + explicit _Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef) + : wkItem(itemRef) + { } +}; + +typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item; #endif // ewk_back_forward_list_private_h 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 592a4f48d..26b050d82 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 @@ -26,12 +26,32 @@ #ifndef ewk_back_forward_list_private_h #define ewk_back_forward_list_private_h +#include "WKRetainPtr.h" +#include "ewk_back_forward_list_item_private.h" #include <WebKit2/WKBase.h> +#include <wtf/HashMap.h> +#include <wtf/PassOwnPtr.h> typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List; +typedef HashMap<WKBackForwardListItemRef, RefPtr<Ewk_Back_Forward_List_Item> > ItemsMap; + +class _Ewk_Back_Forward_List { +public: + WKRetainPtr<WKBackForwardListRef> wkList; + mutable ItemsMap wrapperCache; + + static PassOwnPtr<_Ewk_Back_Forward_List> create(WKBackForwardListRef listRef) + { + return adoptPtr(new _Ewk_Back_Forward_List(listRef)); + } + +private: + explicit _Ewk_Back_Forward_List(WKBackForwardListRef listRef) + : wkList(listRef) + { } +}; + void ewk_back_forward_list_changed(Ewk_Back_Forward_List*, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems); -Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef); -void ewk_back_forward_list_free(Ewk_Back_Forward_List* list); #endif // ewk_back_forward_list_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index b34ff77df..6338eac82 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -22,6 +22,7 @@ #include "ewk_context.h" #include "BatteryProvider.h" +#include "NetworkInfoProvider.h" #include "VibrationProvider.h" #include "WKAPICast.h" #include "WKContextSoup.h" @@ -30,15 +31,24 @@ #include "WKString.h" #include "WebContext.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_favicon_database_private.h" +#include "ewk_private.h" #include <WebCore/FileSystem.h> +#include <WebCore/IconDatabase.h> #include <wtf/HashMap.h> #include <wtf/text/WTFString.h> +#if ENABLE(SPELLCHECK) +#include "ewk_settings.h" +#include "ewk_text_checker_private.h" +#endif + using namespace WebCore; using namespace WebKit; @@ -63,32 +73,40 @@ struct _Ewk_Context { unsigned __ref; /**< the reference count of the object */ WKRetainPtr<WKContextRef> context; - Ewk_Cookie_Manager* cookieManager; + OwnPtr<Ewk_Cookie_Manager> cookieManager; + OwnPtr<Ewk_Favicon_Database> faviconDatabase; #if ENABLE(BATTERY_STATUS) RefPtr<BatteryProvider> batteryProvider; #endif +#if ENABLE(NETWORK_INFO) + RefPtr<NetworkInfoProvider> networkInfoProvider; +#endif #if ENABLE(VIBRATION) RefPtr<VibrationProvider> vibrationProvider; #endif - HashMap<uint64_t, Ewk_Download_Job*> downloadJobs; + HashMap<uint64_t, RefPtr<Ewk_Download_Job> > downloadJobs; WKRetainPtr<WKSoupRequestManagerRef> requestManager; URLSchemeHandlerMap urlSchemeHandlers; + Ewk_Context_History_Client historyClient; + _Ewk_Context(WKRetainPtr<WKContextRef> contextRef) : __ref(1) , context(contextRef) - , cookieManager(0) , requestManager(WKContextGetSoupRequestManager(contextRef.get())) + , historyClient() { #if ENABLE(BATTERY_STATUS) - WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(contextRef.get()); - batteryProvider = BatteryProvider::create(wkBatteryManager); + batteryProvider = BatteryProvider::create(context.get()); +#endif + +#if ENABLE(NETWORK_INFO) + networkInfoProvider = NetworkInfoProvider::create(context.get()); #endif #if ENABLE(VIBRATION) - WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef.get()); - vibrationProvider = VibrationProvider::create(wkVibrationRef); + vibrationProvider = VibrationProvider::create(context.get()); #endif #if ENABLE(MEMORY_SAMPLER) @@ -103,17 +121,14 @@ struct _Ewk_Context { #endif ewk_context_request_manager_client_attach(this); ewk_context_download_client_attach(this); - } - - ~_Ewk_Context() - { - if (cookieManager) - ewk_cookie_manager_free(cookieManager); - - HashMap<uint64_t, Ewk_Download_Job*>::iterator it = downloadJobs.begin(); - HashMap<uint64_t, Ewk_Download_Job*>::iterator end = downloadJobs.end(); - for ( ; it != end; ++it) - ewk_download_job_unref(it->second); + ewk_context_history_client_attach(this); +#if ENABLE(SPELLCHECK) + ewk_text_checker_client_attach(); + if (ewk_settings_continuous_spell_checking_enabled_get()) { + // Load the default language. + ewk_settings_spell_checking_languages_set(0); + } +#endif } }; @@ -141,9 +156,25 @@ Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); if (!ewkContext->cookieManager) - const_cast<Ewk_Context*>(ewkContext)->cookieManager = ewk_cookie_manager_new(WKContextGetCookieManager(ewkContext->context.get())); + const_cast<Ewk_Context*>(ewkContext)->cookieManager = Ewk_Cookie_Manager::create(WKContextGetCookieManager(ewkContext->context.get())); - return ewkContext->cookieManager; + return ewkContext->cookieManager.get(); +} + +Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + + if (!ewkContext->faviconDatabase) { + // Set database path. + WebContext* webContext = toImpl(ewkContext->context.get()); + String databasePath = webContext->iconDatabasePath() + "/" + WebCore::IconDatabase::defaultDatabaseFilename(); + webContext->setIconDatabasePath(databasePath); + + const_cast<Ewk_Context*>(ewkContext)->faviconDatabase = Ewk_Favicon_Database::create(WKContextGetIconDatabase(ewkContext->context.get())); + } + + return ewkContext->faviconDatabase.get(); } WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext) @@ -175,7 +206,7 @@ void ewk_context_download_job_add(Ewk_Context* ewkContext, Ewk_Download_Job* ewk if (ewkContext->downloadJobs.contains(downloadId)) return; - ewkContext->downloadJobs.add(downloadId, ewk_download_job_ref(ewkDownload)); + ewkContext->downloadJobs.add(downloadId, ewkDownload); } /** @@ -187,7 +218,7 @@ Ewk_Download_Job* ewk_context_download_job_get(const Ewk_Context* ewkContext, ui { EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); - return ewkContext->downloadJobs.get(downloadId); + return ewkContext->downloadJobs.get(downloadId).get(); } /** @@ -198,9 +229,7 @@ Ewk_Download_Job* ewk_context_download_job_get(const Ewk_Context* ewkContext, ui void ewk_context_download_job_remove(Ewk_Context* ewkContext, uint64_t downloadId) { EINA_SAFETY_ON_NULL_RETURN(ewkContext); - Ewk_Download_Job* download = ewkContext->downloadJobs.take(downloadId); - if (download) - ewk_download_job_unref(download); + ewkContext->downloadJobs.remove(downloadId); } /** @@ -255,7 +284,7 @@ Ewk_Context* ewk_context_new_with_injected_bundle_path(const char* path) return new Ewk_Context(adoptWK(WKContextCreateWithInjectedBundlePath(pathRef.get()))); } -Eina_Bool ewk_context_uri_scheme_register(Ewk_Context* ewkContext, const char* scheme, Ewk_Url_Scheme_Request_Cb callback, void* userData) +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); EINA_SAFETY_ON_NULL_RETURN_VAL(scheme, false); @@ -276,3 +305,51 @@ void ewk_context_vibration_client_callbacks_set(Ewk_Context* ewkContext, Ewk_Vib ewkContext->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); + + ewkContext->historyClient.navigate_func = navigate; + ewkContext->historyClient.client_redirect_func = clientRedirect; + ewkContext->historyClient.server_redirect_func = serverRedirect; + ewkContext->historyClient.title_update_func = titleUpdate; + ewkContext->historyClient.populate_visited_links_func = populateVisitedLinks; + ewkContext->historyClient.user_data = data; +} + +const Ewk_Context_History_Client* ewk_context_history_client_get(const Ewk_Context* ewkContext) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0); + + return &ewkContext->historyClient; +} + +void ewk_context_visited_link_add(Ewk_Context* ewkContext, const char* visitedURL) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkContext); + EINA_SAFETY_ON_NULL_RETURN(visitedURL); + + WKRetainPtr<WKStringRef> wkVisitedURL(AdoptWK, WKStringCreateWithUTF8CString(visitedURL)); + WKContextAddVisitedLink(ewkContext->context.get(), wkVisitedURL.get()); +} + +// Ewk_Cache_Model enum validation +COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_VIEWER, kWKCacheModelDocumentViewer); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_DOCUMENT_BROWSER, kWKCacheModelDocumentBrowser); +COMPILE_ASSERT_MATCHING_ENUM(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, kWKCacheModelPrimaryWebBrowser); + +Eina_Bool ewk_context_cache_model_set(Ewk_Context* ewkContext, Ewk_Cache_Model cacheModel) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false); + WKContextSetCacheModel(ewk_context_WKContext_get(ewkContext), static_cast<Ewk_Cache_Model>(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); + WKCacheModel cacheModel = WKContextGetCacheModel(ewk_context_WKContext_get(ewkContext)); + return static_cast<Ewk_Cache_Model>(cacheModel); +} + diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.h b/Source/WebKit2/UIProcess/API/efl/ewk_context.h index e6e9e0c7b..0cb413363 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.h @@ -38,6 +38,8 @@ #define ewk_context_h #include "ewk_cookie_manager.h" +#include "ewk_favicon_database.h" +#include "ewk_navigation_data.h" #include "ewk_url_scheme_request.h" #include <Evas.h> @@ -49,8 +51,25 @@ extern "C" { typedef struct _Ewk_Context Ewk_Context; /** + * \enum _Ewk_Cache_Model + * + * @brief Contains option for cache model + */ +enum _Ewk_Cache_Model { + /// Use the smallest cache capacity. + EWK_CACHE_MODEL_DOCUMENT_VIEWER, + /// Use bigger cache capacity than EWK_CACHE_MODEL_DOCUMENT_VIEWER. + EWK_CACHE_MODEL_DOCUMENT_BROWSER, + /// Use the biggest cache capacity. + EWK_CACHE_MODEL_PRIMARY_WEBBROWSER +}; + +/// Creates a type name for the _Ewk_Cache_Model. +typedef enum _Ewk_Cache_Model Ewk_Cache_Model; + +/** * @typedef Ewk_Url_Scheme_Request_Cb Ewk_Url_Scheme_Request_Cb - * @brief Callback type for use with ewk_context_uri_scheme_register(). + * @brief Callback type for use with ewk_context_url_scheme_register(). */ typedef void (*Ewk_Url_Scheme_Request_Cb) (Ewk_Url_Scheme_Request *request, void *user_data); @@ -69,6 +88,38 @@ typedef void (*Ewk_Vibration_Client_Vibrate_Cb)(uint64_t vibration_time, void *u typedef void (*Ewk_Vibration_Client_Vibration_Cancel_Cb)(void *user_data); /** + * @typedef Ewk_History_Navigation_Cb Ewk_History_Navigation_Cb + * @brief Type definition for a function that will be called back when @a view did navigation (loaded new URL). + */ +typedef void (*Ewk_History_Navigation_Cb)(const Evas_Object *view, Ewk_Navigation_Data *navigation_data, void *user_data); + +/** + * @typedef Ewk_History_Client_Redirection_Cb Ewk_History_Client_Redirection_Cb + * @brief Type definition for a function that will be called back when @a view performed a client redirect. + */ +typedef void (*Ewk_History_Client_Redirection_Cb)(const Evas_Object *view, const char *source_url, const char *destination_url, void *user_data); + +/** + * @typedef Ewk_History_Server_Redirection_Cb Ewk_History_Server_Redirection_Cb + * @brief Type definition for a function that will be called back when @a view performed a server redirect. + */ +typedef void (*Ewk_History_Server_Redirection_Cb)(const Evas_Object *view, const char *source_url, const char *destination_url, void *user_data); + +/** + * @typedef Ewk_History_Title_Update_Cb Ewk_History_Title_Update_Cb + * @brief Type definition for a function that will be called back when history title is updated. + */ +typedef void (*Ewk_History_Title_Update_Cb)(const Evas_Object *view, const char *title, const char *url, void *user_data); + +/** + * @typedef Ewk_Context_History_Client_Visited_Links_Populate_Cb Ewk_Context_History_Client_Visited_Links_Populate_Cb + * @brief Type definition for a function that will be called back when client is asked to provide visited links from a client-managed storage. + * + * @see ewk_context_visited_link_add + */ +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 @@ -132,6 +183,15 @@ 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 favicon database instance for this @a context. + * + * @param context context object to query. + * + * @return Ewk_Favicon_Database object instance or @c NULL in case of failure. + */ +EAPI Ewk_Favicon_Database *ewk_context_favicon_database_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 @@ -147,7 +207,7 @@ EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *conte * @param user_data data to pass to callback function * * @code - * static void about_uri_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data) + * static void about_url_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data) * { * const char *path; * char *contents_data = NULL; @@ -172,7 +232,7 @@ EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *conte * } * @endcode */ -EAPI Eina_Bool ewk_context_uri_scheme_register(Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data); +EAPI Eina_Bool ewk_context_url_scheme_register(Ewk_Context *context, const char *scheme, Ewk_Url_Scheme_Request_Cb callback, void *user_data); /** * Sets vibration client callbacks to handle the tactile feedback in the form of @@ -190,6 +250,62 @@ EAPI Eina_Bool ewk_context_uri_scheme_register(Ewk_Context *context, const char */ EAPI void ewk_context_vibration_client_callbacks_set(Ewk_Context *context, Ewk_Vibration_Client_Vibrate_Cb vibrate, Ewk_Vibration_Client_Vibration_Cancel_Cb cancel, void *data); +/** + * Sets history callbacks for the given @a context. + * + * To stop listening for history events, you may call this function with @c + * NULL for the callbacks. + * + * @param context context object to set history callbacks + * @param navigate_func The function to call when @c ewk_view did navigation (may be @c NULL). + * @param client_redirect_func The function to call when @c ewk_view performed a client redirect (may be @c NULL). + * @param server_redirect_func The function to call when @c ewk_view performed a server redirect (may be @c NULL). + * @param title_update_func The function to call when history title is updated (may be @c NULL). + * @param populate_visited_links_func The function is called when client is asked to provide visited links from a + * client-managed storage (may be @c NULL). + * @param data User data (may be @c NULL). + */ +EAPI void ewk_context_history_callbacks_set(Ewk_Context *context, + 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, + void *data); + +/** + * Registers the given @a visited_url as visited link in @a context visited link cache. + * + * This function shall be invoked as a response to @c populateVisitedLinks callback of the history cient. + * + * @param context context object to add visited link data + * @param visited_url visited url + * + * @see Ewk_Context_History_Client + */ +EAPI void ewk_context_visited_link_add(Ewk_Context *context, const char *visited_url); + +/** + * Set @a cache_model as the cache model for @a context. + * + * By default, it is EWK_CACHE_MODEL_DOCUMENT_VIEWER. + * + * @param context context object to update. + * @param cache_model a #Ewk_Cache_Model. + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_context_cache_model_set(Ewk_Context *context, Ewk_Cache_Model cache_model); + +/** + * Gets the cache model for @a context. + * + * @param context context object to query. + * + * @return the cache model for the @a context. + */ +EAPI Ewk_Cache_Model ewk_context_cache_model_get(const Ewk_Context *context); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp index 9d924bff2..8822e6ae1 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_download_client.cpp @@ -33,12 +33,12 @@ #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 "ewk_web_error.h" -#include "ewk_web_error_private.h" #include <string.h> +#include <wtf/OwnPtr.h> #include <wtf/text/CString.h> using namespace WebKit; @@ -59,7 +59,7 @@ static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownlo // and the suggested file name. ewk_view_download_job_requested(ewk_download_job_view_get(download), download); - // DownloadSoup expects the destination to be a URI. + // DownloadSoup expects the destination to be a URL. String destination = String("file://") + String::fromUTF8(ewk_download_job_destination_get(download)); return WKStringCreateWithUTF8CString(destination.utf8().data()); @@ -69,9 +69,8 @@ static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResp { Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), toImpl(wkDownload)->downloadID()); ASSERT(download); - Ewk_Url_Response* response = ewk_url_response_new(toImpl(wkResponse)->resourceResponse()); - ewk_download_job_response_set(download, response); - ewk_url_response_unref(response); + RefPtr<Ewk_Url_Response> response = Ewk_Url_Response::create(wkResponse); + ewk_download_job_response_set(download, response.get()); } static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef /*path*/, const void* clientInfo) @@ -95,10 +94,9 @@ static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, co Ewk_Download_Job* download = ewk_context_download_job_get(toEwkContext(clientInfo), downloadId); ASSERT(download); - Ewk_Web_Error* ewkError = ewk_web_error_new(error); + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); ewk_download_job_state_set(download, EWK_DOWNLOAD_JOB_STATE_FAILED); - ewk_view_download_job_failed(ewk_download_job_view_get(download), download, ewkError); - ewk_web_error_free(ewkError); + ewk_view_download_job_failed(ewk_download_job_view_get(download), download, ewkError.get()); ewk_context_download_job_remove(toEwkContext(clientInfo), downloadId); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp new file mode 100644 index 000000000..1038b4df5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client.cpp @@ -0,0 +1,130 @@ +/* + * 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* getEwkHistoryDelegate(const void* clientInfo) +{ + ASSERT(clientInfo); + return ewk_context_history_client_get(static_cast<const Ewk_Context*>(clientInfo)); +} + +static void didNavigateWithNavigationData(WKContextRef, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef, const void* clientInfo) +{ + const Ewk_Context_History_Client* historyDelegate = getEwkHistoryDelegate(clientInfo); + ASSERT(historyDelegate); + + if (!historyDelegate->navigate_func) + return; + + RefPtr<Ewk_Navigation_Data> navigationDataEwk = Ewk_Navigation_Data::create(navigationData); + historyDelegate->navigate_func(ewk_view_from_page_get(toImpl(page)), navigationDataEwk.get(), historyDelegate->user_data); +} + +static void didPerformClientRedirect(WKContextRef, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void* clientInfo) +{ + const Ewk_Context_History_Client* historyDelegate = getEwkHistoryDelegate(clientInfo); + ASSERT(historyDelegate); + + if (!historyDelegate->client_redirect_func) + return; + + WKEinaSharedString sourceURLString(sourceURL); + WKEinaSharedString destinationURLString(destinationURL); + + historyDelegate->client_redirect_func(ewk_view_from_page_get(toImpl(page)), sourceURLString, destinationURLString, historyDelegate->user_data); +} + +static void didPerformServerRedirect(WKContextRef, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void* clientInfo) +{ + const Ewk_Context_History_Client* historyDelegate = getEwkHistoryDelegate(clientInfo); + ASSERT(historyDelegate); + + if (!historyDelegate->server_redirect_func) + return; + + WKEinaSharedString sourceURLString(sourceURL); + WKEinaSharedString destinationURLString(destinationURL); + + historyDelegate->server_redirect_func(ewk_view_from_page_get(toImpl(page)), sourceURLString, destinationURLString, historyDelegate->user_data); +} + +static void didUpdateHistoryTitle(WKContextRef, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef, const void* clientInfo) +{ + const Ewk_Context_History_Client* historyDelegate = getEwkHistoryDelegate(clientInfo); + ASSERT(historyDelegate); + + if (!historyDelegate->title_update_func) + return; + + WKEinaSharedString titleString(title); + WKEinaSharedString stringURL(URL); + + historyDelegate->title_update_func(ewk_view_from_page_get(toImpl(page)), titleString, stringURL, historyDelegate->user_data); +} + +static void populateVisitedLinks(WKContextRef, const void* clientInfo) +{ + const Ewk_Context_History_Client* historyDelegate = getEwkHistoryDelegate(clientInfo); + ASSERT(historyDelegate); + + if (!historyDelegate->populate_visited_links_func) + return; + + historyDelegate->populate_visited_links_func(historyDelegate->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(ewk_context_WKContext_get(ewkContext), &wkHistoryClient); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client_private.h new file mode 100644 index 000000000..d9518ced9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_history_client_private.h @@ -0,0 +1,44 @@ +/* + * 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_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; +}; + +typedef struct _Ewk_Context_History_Client Ewk_Context_History_Client; + +void ewk_context_history_client_attach(Ewk_Context*); + +#endif // ewk_context_history_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h index d1b695e0c..29f74a184 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h @@ -24,7 +24,8 @@ typedef struct _Ewk_Context Ewk_Context; typedef struct _Ewk_Download_Job Ewk_Download_Job; -typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; +typedef struct Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; +typedef struct _Ewk_Context_History_Client Ewk_Context_History_Client; WKContextRef ewk_context_WKContext_get(const Ewk_Context*); Ewk_Context* ewk_context_new_from_WKContext(WKContextRef); @@ -35,4 +36,6 @@ void ewk_context_download_job_add(Ewk_Context*, Ewk_Download_Job*); Ewk_Download_Job* ewk_context_download_job_get(const Ewk_Context*, uint64_t downloadId); void ewk_context_download_job_remove(Ewk_Context*, uint64_t downloadId); +const Ewk_Context_History_Client* ewk_context_history_client_get(const Ewk_Context*); + #endif // ewk_context_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp index b22bd36ff..b2573ca8e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_request_manager_client.cpp @@ -27,6 +27,7 @@ #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" @@ -37,11 +38,10 @@ static inline Ewk_Context* toEwkContext(const void* clientInfo) return static_cast<Ewk_Context*>(const_cast<void*>(clientInfo)); } -static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, uint64_t requestID, const void* clientInfo) +static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef, uint64_t requestID, const void* clientInfo) { - Ewk_Url_Scheme_Request* schemeRequest = ewk_url_scheme_request_new(soupRequestManagerRef, urlRef, requestID); - ewk_context_url_scheme_request_received(toEwkContext(clientInfo), schemeRequest); - ewk_url_scheme_request_unref(schemeRequest); + RefPtr<Ewk_Url_Scheme_Request> schemeRequest = Ewk_Url_Scheme_Request::create(soupRequestManagerRef, urlRef, requestID); + ewk_context_url_scheme_request_received(toEwkContext(clientInfo), schemeRequest.get()); } void ewk_context_request_manager_client_attach(Ewk_Context* context) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp index 45dd75e63..52b7ca7cc 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.cpp @@ -29,59 +29,35 @@ #include "SoupCookiePersistentStorageType.h" #include "WKAPICast.h" #include "WKArray.h" -#include "WKCookieManager.h" -#include "WKRetainPtr.h" #include "WKString.h" #include "WebCookieManagerProxy.h" +#include "ewk_cookie_manager_private.h" +#include "ewk_error_private.h" #include "ewk_private.h" -#include "ewk_web_error_private.h" +#include <wtf/OwnPtr.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> using namespace WebKit; -struct Cookie_Change_Handler { - Ewk_Cookie_Manager_Changes_Watch_Cb callback; - void* userData; - - Cookie_Change_Handler() - : callback(0) - , userData(0) - { } - - Cookie_Change_Handler(Ewk_Cookie_Manager_Changes_Watch_Cb _callback, void* _userData) - : callback(_callback) - , userData(_userData) - { } -}; - static void cookiesDidChange(WKCookieManagerRef, const void* clientInfo); -/** - * \struct _Ewk_Cookie_Manager - * @brief Contains the cookie manager data. - */ -struct _Ewk_Cookie_Manager { - WKRetainPtr<WKCookieManagerRef> wkCookieManager; - Cookie_Change_Handler changeHandler; - - _Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef) - : wkCookieManager(cookieManagerRef) - { - WKCookieManagerClient wkCookieManagerClient = { - kWKCookieManagerClientCurrentVersion, - this, // clientInfo - cookiesDidChange - }; - WKCookieManagerSetClient(wkCookieManager.get(), &wkCookieManagerClient); - } +_Ewk_Cookie_Manager::_Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef) + : wkCookieManager(cookieManagerRef) +{ + WKCookieManagerClient wkCookieManagerClient = { + kWKCookieManagerClientCurrentVersion, + this, // clientInfo + cookiesDidChange + }; + WKCookieManagerSetClient(wkCookieManager.get(), &wkCookieManagerClient); +} - ~_Ewk_Cookie_Manager() - { - if (changeHandler.callback) - WKCookieManagerStopObservingCookieChanges(wkCookieManager.get()); - } -}; +_Ewk_Cookie_Manager::~_Ewk_Cookie_Manager() +{ + if (changeHandler.callback) + WKCookieManagerStopObservingCookieChanges(wkCookieManager.get()); +} #define EWK_COOKIE_MANAGER_WK_GET_OR_RETURN(manager, wkManager_, ...) \ if (!(manager)) { \ @@ -142,12 +118,10 @@ struct Get_Policy_Async_Data { static void getAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef wkError, void* data) { Get_Policy_Async_Data* callbackData = static_cast<Get_Policy_Async_Data*>(data); - Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0; + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); - callbackData->callback(static_cast<Ewk_Cookie_Accept_Policy>(policy), ewkError, callbackData->userData); + callbackData->callback(static_cast<Ewk_Cookie_Accept_Policy>(policy), ewkError.get(), callbackData->userData); - if (ewkError) - ewk_web_error_free(ewkError); delete callbackData; } @@ -172,7 +146,7 @@ static void getHostnamesWithCookiesCallback(WKArrayRef wkHostnames, WKErrorRef w { Eina_List* hostnames = 0; Get_Hostnames_Async_Data* callbackData = static_cast<Get_Hostnames_Async_Data*>(context); - Ewk_Web_Error* ewkError = wkError ? ewk_web_error_new(wkError) : 0; + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); const size_t hostnameCount = WKArrayGetSize(wkHostnames); for (size_t i = 0; i < hostnameCount; ++i) { @@ -183,13 +157,12 @@ static void getHostnamesWithCookiesCallback(WKArrayRef wkHostnames, WKErrorRef w hostnames = eina_list_append(hostnames, eina_stringshare_add(hostname.utf8().data())); } - callbackData->callback(hostnames, ewkError, callbackData->userData); + callbackData->callback(hostnames, ewkError.get(), callbackData->userData); void* item; EINA_LIST_FREE(hostnames, item) eina_stringshare_del(static_cast<Eina_Stringshare*>(item)); - if (ewkError) - ewk_web_error_free(ewkError); + delete callbackData; } @@ -232,25 +205,3 @@ void ewk_cookie_manager_changes_watch(Ewk_Cookie_Manager* manager, Ewk_Cookie_Ma else WKCookieManagerStopObservingCookieChanges(wkManager); } - -/** - * @internal - * Frees a Ewk_Cookie_Manager object. - */ -void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager) -{ - EINA_SAFETY_ON_NULL_RETURN(manager); - - delete manager; -} - -/** - * @internal - * Constructs a Ewk_Cookie_Manager from a WKCookieManagerRef. - */ -Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(wkCookieManager, 0); - - return new Ewk_Cookie_Manager(wkCookieManager); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h index e37780864..c31b90018 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager.h @@ -31,7 +31,7 @@ #ifndef ewk_cookie_manager_h #define ewk_cookie_manager_h -#include "ewk_web_error.h" +#include "ewk_error.h" #include <Eina.h> #ifdef __cplusplus @@ -77,7 +77,7 @@ typedef enum _Ewk_Cookie_Persistent_Storage Ewk_Cookie_Persistent_Storage; * @typedef Ewk_Cookie_Manager_Async_Policy_Get_Cb Ewk_Cookie_Manager_Async_Policy_Get_Cb * @brief Callback type for use with ewk_cookie_manager_async_accept_policy_get */ -typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error *error, void *event_info); +typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy policy, Ewk_Error *error, void *event_info); /** * @typedef Ewk_Cookie_Manager_Async_Hostnames_Get_Cb Ewk_Cookie_Manager_Async_Hostnames_Get_Cb @@ -87,7 +87,7 @@ typedef void (*Ewk_Cookie_Manager_Async_Policy_Get_Cb)(Ewk_Cookie_Accept_Policy * save yourself some cpu cycles and use eina_stringshare_ref() instead of eina_stringshare_add() * or strdup(). */ -typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List* hostnames, Ewk_Web_Error *error, void *event_info); +typedef void (*Ewk_Cookie_Manager_Async_Hostnames_Get_Cb)(Eina_List *hostnames, Ewk_Error *error, void *event_info); /** * @typedef Ewk_Cookie_Manager_Changes_Watch_Cb Ewk_Cookie_Manager_Changes_Watch_Cb diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h index 64285c981..691322b6c 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_cookie_manager_private.h @@ -26,11 +26,44 @@ #ifndef ewk_cookie_manager_private_h #define ewk_cookie_manager_private_h +#include "WKCookieManager.h" +#include "WKRetainPtr.h" +#include "ewk_cookie_manager.h" #include <WebKit2/WKBase.h> +#include <wtf/PassOwnPtr.h> + +struct Cookie_Change_Handler { + Ewk_Cookie_Manager_Changes_Watch_Cb callback; + void* userData; + + Cookie_Change_Handler() + : callback(0) + , userData(0) + { } + + Cookie_Change_Handler(Ewk_Cookie_Manager_Changes_Watch_Cb _callback, void* _userData) + : callback(_callback) + , userData(_userData) + { } +}; + typedef struct _Ewk_Cookie_Manager Ewk_Cookie_Manager; -Ewk_Cookie_Manager* ewk_cookie_manager_new(WKCookieManagerRef wkCookieManager); -void ewk_cookie_manager_free(Ewk_Cookie_Manager* manager); +class _Ewk_Cookie_Manager { +public: + WKRetainPtr<WKCookieManagerRef> wkCookieManager; + Cookie_Change_Handler changeHandler; + + static PassOwnPtr<_Ewk_Cookie_Manager> create(WKCookieManagerRef cookieManagerRef) + { + return adoptPtr(new _Ewk_Cookie_Manager(cookieManagerRef)); + } + + ~_Ewk_Cookie_Manager(); + +private: + explicit _Ewk_Cookie_Manager(WKCookieManagerRef cookieManagerRef); +}; #endif // ewk_cookie_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 61297920b..de8f597e0 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.cpp @@ -28,59 +28,18 @@ #include "DownloadProxy.h" #include "WKAPICast.h" -#include "WKEinaSharedString.h" #include "WKRetainPtr.h" #include "WebURLRequest.h" #include "ewk_download_job_private.h" -#include "ewk_url_request_private.h" #include <Ecore.h> using namespace WebKit; -/** - * \struct _Ewk_Download_Job - * @brief Contains the download data. - */ -struct _Ewk_Download_Job { - unsigned int __ref; /**< the reference count of the object */ - DownloadProxy* downloadProxy; - Evas_Object* view; - Ewk_Download_Job_State state; - Ewk_Url_Request* request; - Ewk_Url_Response* response; - double startTime; - double endTime; - uint64_t downloaded; /**< length already downloaded */ - WKEinaSharedString destination; - WKEinaSharedString suggestedFilename; - - _Ewk_Download_Job(DownloadProxy* download, Evas_Object* ewkView) - : __ref(1) - , downloadProxy(download) - , view(ewkView) - , state(EWK_DOWNLOAD_JOB_STATE_NOT_STARTED) - , request(0) - , response(0) - , startTime(-1) - , endTime(-1) - , downloaded(0) - { } - - ~_Ewk_Download_Job() - { - ASSERT(!__ref); - if (request) - ewk_url_request_unref(request); - if (response) - ewk_url_response_unref(response); - } -}; - Ewk_Download_Job* ewk_download_job_ref(Ewk_Download_Job* download) { EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); - ++download->__ref; + download->ref(); return download; } @@ -89,10 +48,7 @@ void ewk_download_job_unref(Ewk_Download_Job* download) { EINA_SAFETY_ON_NULL_RETURN(download); - if (--download->__ref) - return; - - delete download; + download->deref(); } /** @@ -133,17 +89,17 @@ Ewk_Url_Request* ewk_download_job_request_get(const Ewk_Download_Job* download) if (!download->request) { EINA_SAFETY_ON_NULL_RETURN_VAL(download->downloadProxy, 0); WKRetainPtr<WKURLRequestRef> wkURLRequest(AdoptWK, toAPI(WebURLRequest::create(download->downloadProxy->request()).leakRef())); - const_cast<Ewk_Download_Job*>(download)->request = ewk_url_request_new(wkURLRequest.get()); + const_cast<Ewk_Download_Job*>(download)->request = Ewk_Url_Request::create(wkURLRequest.get()); } - return download->request; + return download->request.get(); } Ewk_Url_Response* ewk_download_job_response_get(const Ewk_Download_Job* download) { EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); - return download->response; + return download->response.get(); } const char* ewk_download_job_destination_get(const Ewk_Download_Job* download) @@ -190,7 +146,7 @@ double ewk_download_job_estimated_progress_get(const Ewk_Download_Job* download) if (!download->response) return 0; - const unsigned long contentLength = ewk_url_response_content_length_get(download->response); + const unsigned long contentLength = ewk_url_response_content_length_get(download->response.get()); if (!contentLength) return 0; @@ -266,15 +222,3 @@ void ewk_download_job_state_set(Ewk_Download_Job* download, Ewk_Download_Job_Sta || state == EWK_DOWNLOAD_JOB_STATE_FINISHED) download->endTime = ecore_time_get(); } - -/** - * @internal - * Constructs a Ewk_Download_Job from a DownloadProxy. - */ -Ewk_Download_Job* ewk_download_job_new(DownloadProxy* download, Evas_Object* ewkView) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(download, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0); - - return new _Ewk_Download_Job(download, ewkView); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h index fdcc10e98..388276c9c 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job.h @@ -112,7 +112,7 @@ EAPI Ewk_Url_Request *ewk_download_job_request_get(const Ewk_Download_Job *downl EAPI Ewk_Url_Response *ewk_download_job_response_get(const Ewk_Download_Job *download); /** - * Query the URI to which the downloaded file will be written. + * Query the URL to which the downloaded file will be written. * * @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 d043494c3..a4a40c0f6 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_download_job_private.h @@ -27,17 +27,52 @@ #define ewk_download_job_private_h #include "WKBase.h" +#include "WKEinaSharedString.h" +#include "ewk_url_request_private.h" +#include "ewk_url_response_private.h" #include <Evas.h> - -typedef struct _Ewk_Download_Job Ewk_Download_Job; -typedef struct _Ewk_Url_Response Ewk_Url_Response; -typedef struct _Ewk_Web_Error Ewk_Web_Error; +#include <wtf/PassRefPtr.h> namespace WebKit { class DownloadProxy; } -Ewk_Download_Job* ewk_download_job_new(WebKit::DownloadProxy*, Evas_Object* ewkView); +/** + * \struct _Ewk_Download_Job + * @brief Contains the download data. + */ +class _Ewk_Download_Job : public RefCounted<_Ewk_Download_Job> { +public: + WebKit::DownloadProxy* downloadProxy; + Evas_Object* view; + Ewk_Download_Job_State state; + RefPtr<Ewk_Url_Request> request; + RefPtr<Ewk_Url_Response> response; + double startTime; + double endTime; + uint64_t downloaded; /**< length already downloaded */ + WKEinaSharedString destination; + WKEinaSharedString suggestedFilename; + + static PassRefPtr<_Ewk_Download_Job> create(WebKit::DownloadProxy* download, Evas_Object* ewkView) + { + return adoptRef(new _Ewk_Download_Job(download, ewkView)); + } + +private: + _Ewk_Download_Job(WebKit::DownloadProxy* download, Evas_Object* ewkView) + : downloadProxy(download) + , view(ewkView) + , state(EWK_DOWNLOAD_JOB_STATE_NOT_STARTED) + , startTime(-1) + , endTime(-1) + , downloaded(0) + { } +}; + +typedef struct _Ewk_Download_Job Ewk_Download_Job; +typedef struct _Ewk_Error Ewk_Error; + uint64_t ewk_download_job_id_get(const Ewk_Download_Job*); Evas_Object* ewk_download_job_view_get(const Ewk_Download_Job*); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_error.cpp index 70380bdd2..fed8e2cc3 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_error.cpp @@ -24,39 +24,25 @@ */ #include "config.h" -#include "ewk_web_error.h" +#include "ewk_error.h" #include "ErrorsEfl.h" -#include "WKEinaSharedString.h" #include "WKString.h" #include "WKURL.h" -#include "ewk_web_error_private.h" +#include "ewk_error_private.h" #include <WKAPICast.h> -#include <WKError.h> -#include <WKRetainPtr.h> #include <wtf/text/CString.h> using namespace WebCore; using namespace WebKit; -struct _Ewk_Web_Error { - WKRetainPtr<WKErrorRef> wkError; +_Ewk_Error::_Ewk_Error(WKErrorRef errorRef) + : wkError(errorRef) + , url(AdoptWK, WKErrorCopyFailingURL(errorRef)) + , description(AdoptWK, WKErrorCopyLocalizedDescription(errorRef)) +{ } - WKEinaSharedString url; - WKEinaSharedString description; - - _Ewk_Web_Error(WKErrorRef errorRef) - : wkError(errorRef) - , url(AdoptWK, WKErrorCopyFailingURL(errorRef)) - , description(AdoptWK, WKErrorCopyLocalizedDescription(errorRef)) - { } - - ~_Ewk_Web_Error() - { - } -}; - -#define EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError_, ...) \ +#define EWK_ERROR_WK_GET_OR_RETURN(error, wkError_, ...) \ if (!(error)) { \ EINA_LOG_CRIT("error is NULL."); \ return __VA_ARGS__; \ @@ -67,64 +53,50 @@ struct _Ewk_Web_Error { } \ WKErrorRef wkError_ = (error)->wkError.get() -void ewk_web_error_free(Ewk_Web_Error* error) -{ - EINA_SAFETY_ON_NULL_RETURN(error); - - delete error; -} - -Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error* error) +Ewk_Error_Type ewk_error_type_get(const Ewk_Error* error) { - EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, EWK_WEB_ERROR_TYPE_NONE); + EWK_ERROR_WK_GET_OR_RETURN(error, wkError, EWK_ERROR_TYPE_NONE); WKRetainPtr<WKStringRef> wkDomain(AdoptWK, WKErrorCopyDomain(wkError)); WTF::String errorDomain = toWTFString(wkDomain.get()); if (errorDomain == errorDomainNetwork) - return EWK_WEB_ERROR_TYPE_NETWORK; + return EWK_ERROR_TYPE_NETWORK; if (errorDomain == errorDomainPolicy) - return EWK_WEB_ERROR_TYPE_POLICY; + return EWK_ERROR_TYPE_POLICY; if (errorDomain == errorDomainPlugin) - return EWK_WEB_ERROR_TYPE_PLUGIN; + return EWK_ERROR_TYPE_PLUGIN; if (errorDomain == errorDomainDownload) - return EWK_WEB_ERROR_TYPE_DOWNLOAD; + return EWK_ERROR_TYPE_DOWNLOAD; if (errorDomain == errorDomainPrint) - return EWK_WEB_ERROR_TYPE_PRINT; - return EWK_WEB_ERROR_TYPE_INTERNAL; + return EWK_ERROR_TYPE_PRINT; + return EWK_ERROR_TYPE_INTERNAL; } -const char* ewk_web_error_url_get(const Ewk_Web_Error* error) +const char* ewk_error_url_get(const Ewk_Error* error) { EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); return error->url; } -int ewk_web_error_code_get(const Ewk_Web_Error* error) +int ewk_error_code_get(const Ewk_Error* error) { - EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, 0); + EWK_ERROR_WK_GET_OR_RETURN(error, wkError, 0); return WKErrorGetErrorCode(wkError); } -const char* ewk_web_error_description_get(const Ewk_Web_Error* error) +const char* ewk_error_description_get(const Ewk_Error* error) { EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); return error->description; } -Eina_Bool ewk_web_error_cancellation_get(const Ewk_Web_Error* error) +Eina_Bool ewk_error_cancellation_get(const Ewk_Error* error) { - EWK_WEB_ERROR_WK_GET_OR_RETURN(error, wkError, false); + EWK_ERROR_WK_GET_OR_RETURN(error, wkError, false); return toImpl(wkError)->platformError().isCancellation(); } - -Ewk_Web_Error* ewk_web_error_new(WKErrorRef error) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(error, 0); - - return new Ewk_Web_Error(error); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h b/Source/WebKit2/UIProcess/API/efl/ewk_error.h index 4ba0c7acd..01214d121 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_error.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_error.h @@ -24,12 +24,12 @@ */ /** - * @file ewk_web_error.h + * @file ewk_error.h * @brief Describes the Web Error API. */ -#ifndef ewk_web_error_h -#define ewk_web_error_h +#ifndef ewk_error_h +#define ewk_error_h #include <Eina.h> @@ -37,26 +37,19 @@ extern "C" { #endif -/** Creates a type name for @a Ewk_Web_Error. */ -typedef struct _Ewk_Web_Error Ewk_Web_Error; +/** Creates a type name for @a Ewk_Error. */ +typedef struct _Ewk_Error Ewk_Error; -/// Creates a type name for Ewk_Web_Error_Type. +/// Creates a type name for Ewk_Error_Type. typedef enum { - EWK_WEB_ERROR_TYPE_NONE, - EWK_WEB_ERROR_TYPE_INTERNAL, - EWK_WEB_ERROR_TYPE_NETWORK, - EWK_WEB_ERROR_TYPE_POLICY, - EWK_WEB_ERROR_TYPE_PLUGIN, - EWK_WEB_ERROR_TYPE_DOWNLOAD, - EWK_WEB_ERROR_TYPE_PRINT -} Ewk_Web_Error_Type; - -/** - * Frees the given object. - * - * @param error the error object to free - */ -EAPI void ewk_web_error_free(Ewk_Web_Error *error); + EWK_ERROR_TYPE_NONE, + EWK_ERROR_TYPE_INTERNAL, + EWK_ERROR_TYPE_NETWORK, + EWK_ERROR_TYPE_POLICY, + EWK_ERROR_TYPE_PLUGIN, + EWK_ERROR_TYPE_DOWNLOAD, + EWK_ERROR_TYPE_PRINT +} Ewk_Error_Type; /** * Query type for this error. @@ -69,7 +62,7 @@ EAPI void ewk_web_error_free(Ewk_Web_Error *error); * eina_stringshare_ref() instead of eina_stringshare_add() or * strdup(). */ -EAPI Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error *error); +EAPI Ewk_Error_Type ewk_error_type_get(const Ewk_Error *error); /** * Query failing URL for this error. @@ -84,7 +77,7 @@ EAPI Ewk_Web_Error_Type ewk_web_error_type_get(const Ewk_Web_Error *error); * eina_stringshare_ref() instead of eina_stringshare_add() or * strdup(). */ -EAPI const char *ewk_web_error_url_get(const Ewk_Web_Error *error); +EAPI const char *ewk_error_url_get(const Ewk_Error *error); /** * Query HTTP error code. @@ -93,7 +86,7 @@ EAPI const char *ewk_web_error_url_get(const Ewk_Web_Error *error); * * @return the HTTP error code. */ -EAPI int ewk_web_error_code_get(const Ewk_Web_Error *error); +EAPI int ewk_error_code_get(const Ewk_Error *error); /** * Query description for this error. @@ -106,7 +99,7 @@ EAPI int ewk_web_error_code_get(const Ewk_Web_Error *error); * eina_stringshare_ref() instead of eina_stringshare_add() or * strdup(). */ -EAPI const char *ewk_web_error_description_get(const Ewk_Web_Error *error); +EAPI const char *ewk_error_description_get(const Ewk_Error *error); /** * Query if error should be treated as a cancellation. @@ -115,10 +108,10 @@ EAPI const char *ewk_web_error_description_get(const Ewk_Web_Error *error); * * @return @c EINA_TRUE if this error should be treated as a cancellation, @c EINA_FALSE otherwise */ -EAPI Eina_Bool ewk_web_error_cancellation_get(const Ewk_Web_Error *error); +EAPI Eina_Bool ewk_error_cancellation_get(const Ewk_Error *error); #ifdef __cplusplus } #endif -#endif // ewk_web_error_h +#endif // ewk_error_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_error_private.h index 5b44fe19f..5ae457bf0 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_error_private.h @@ -23,11 +23,32 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_web_resource_private_h -#define ewk_web_resource_private_h +#ifndef ewk_error_private_h +#define ewk_error_private_h -typedef struct _Ewk_Web_Resource Ewk_Web_Resource; +#include "WKEinaSharedString.h" +#include <WKError.h> +#include <WKRetainPtr.h> +#include <wtf/PassOwnPtr.h> -Ewk_Web_Resource* ewk_web_resource_new(const char* uri, bool isMainResource); +typedef struct _Ewk_Error Ewk_Error; -#endif // ewk_web_resource_private_h +class _Ewk_Error { +public: + WKRetainPtr<WKErrorRef> wkError; + WKEinaSharedString url; + WKEinaSharedString description; + + static PassOwnPtr<_Ewk_Error> create(WKErrorRef errorRef) + { + if (!errorRef) + return nullptr; + + return adoptPtr(new _Ewk_Error(errorRef)); + } + +private: + explicit _Ewk_Error(WKErrorRef errorRef); +}; + +#endif // ewk_error_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp new file mode 100644 index 000000000..6e52c3510 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp @@ -0,0 +1,189 @@ +/* + * 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_favicon_database.h" + +#include "WKAPICast.h" +#include "WKURL.h" +#include "WebIconDatabase.h" +#include "WebURL.h" +#include "ewk_favicon_database_private.h" +#include <WebCore/CairoUtilitiesEfl.h> +#include <WebCore/RefPtrCairo.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +using namespace WebKit; + +static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); +static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo); + +_Ewk_Favicon_Database::_Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef) + : wkIconDatabase(iconDatabaseRef) +{ + WKIconDatabaseClient iconDatabaseClient; + memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient)); + iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion; + iconDatabaseClient.clientInfo = this; + iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL; + iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL; + WKIconDatabaseSetIconDatabaseClient(wkIconDatabase.get(), &iconDatabaseClient); +} + +static void didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURLRef, const void* clientInfo) +{ + const Ewk_Favicon_Database* ewkIconDatabase = static_cast<const Ewk_Favicon_Database*>(clientInfo); + + if (ewkIconDatabase->changeListeners.isEmpty()) + return; + + CString pageURL = toImpl(pageURLRef)->string().utf8(); + + ChangeListenerMap::const_iterator it = ewkIconDatabase->changeListeners.begin(); + ChangeListenerMap::const_iterator end = ewkIconDatabase->changeListeners.end(); + for (; it != end; ++it) + it->value.callback(pageURL.data(), it->value.userData); +} + +static cairo_surface_t* getIconSurfaceSynchronously(WebIconDatabase* webIconDatabase, const String& pageURL) +{ + webIconDatabase->retainIconForPageURL(pageURL); + + WebCore::NativeImagePtr icon = webIconDatabase->nativeImageForPageURL(pageURL); + if (!icon) { + webIconDatabase->releaseIconForPageURL(pageURL); + return 0; + } + + return icon->surface(); +} + +static void iconDataReadyForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo) +{ + Ewk_Favicon_Database* ewkIconDatabase = const_cast<Ewk_Favicon_Database*>(static_cast<const Ewk_Favicon_Database*>(clientInfo)); + + String urlString = toImpl(pageURL)->string(); + if (!ewkIconDatabase->iconRequests.contains(urlString)) + return; + + WebIconDatabase* webIconDatabase = toImpl(ewkIconDatabase->wkIconDatabase.get()); + RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(webIconDatabase, urlString); + + PendingIconRequestVector requestsForURL = ewkIconDatabase->iconRequests.take(urlString); + size_t requestCount = requestsForURL.size(); + for (size_t i = 0; i < requestCount; ++i) { + const IconRequestCallbackData& callbackData = requestsForURL[i]; + RefPtr<Evas_Object> icon = surface ? WebCore::evasObjectFromCairoImageSurface(callbackData.evas, surface.get()) : 0; + callbackData.callback(urlString.utf8().data(), icon.get(), callbackData.userData); + } +} + +const char* ewk_favicon_database_icon_url_get(Ewk_Favicon_Database* ewkIconDatabase, const char* pageURL) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(pageURL, 0); + + String iconURL; + toImpl(ewkIconDatabase->wkIconDatabase.get())->synchronousIconURLForPageURL(pageURL, iconURL); + + return eina_stringshare_add(iconURL.utf8().data()); +} + +struct AsyncIconRequestResponse { + String pageURL; + RefPtr<cairo_surface_t> surface; + IconRequestCallbackData callbackData; + + AsyncIconRequestResponse(const String& _pageURL, PassRefPtr<cairo_surface_t> _surface, const IconRequestCallbackData& _callbackData) + : pageURL(_pageURL) + , surface(_surface) + , callbackData(_callbackData) + { } +}; + +static Eina_Bool respond_icon_request_idle(void* data) +{ + AsyncIconRequestResponse* response = static_cast<AsyncIconRequestResponse*>(data); + + RefPtr<Evas_Object> icon = response->surface ? WebCore::evasObjectFromCairoImageSurface(response->callbackData.evas, response->surface.get()) : 0; + response->callbackData.callback(response->pageURL.utf8().data(), icon.get(), response->callbackData.userData); + + delete response; + + return ECORE_CALLBACK_DONE; +} + +Eina_Bool ewk_favicon_database_async_icon_get(Ewk_Favicon_Database* ewkIconDatabase, const char* page_url, Evas* evas, Ewk_Favicon_Database_Async_Icon_Get_Cb callback, void* userData) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(ewkIconDatabase, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(page_url, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(evas, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false); + + WebIconDatabase* webIconDatabase = toImpl(ewkIconDatabase->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(webIconDatabase, page_url); + + // If there's no valid icon, but there's an iconURL registered, + // or it's still not registered but the import process hasn't + // finished yet, we need to wait for iconDataReadyForPageURL to be + // called before making and informed decision. + String iconURLForPageURL; + webIconDatabase->synchronousIconURLForPageURL(page_url, iconURLForPageURL); + if (!surface && (!iconURLForPageURL.isEmpty() || !webIconDatabase->isUrlImportCompleted())) { + PendingIconRequestVector requests = ewkIconDatabase->iconRequests.get(page_url); + requests.append(IconRequestCallbackData(callback, userData, evas)); + ewkIconDatabase->iconRequests.set(page_url, requests); + return true; + } + + // Respond when idle. + AsyncIconRequestResponse* response = new AsyncIconRequestResponse(page_url, surface.release(), IconRequestCallbackData(callback, userData, evas)); + ecore_idler_add(respond_icon_request_idle, response); + + return true; +} + +void ewk_favicon_database_icon_change_callback_add(Ewk_Favicon_Database* ewkIconDatabase, Ewk_Favicon_Database_Icon_Change_Cb callback, void* userData) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkIconDatabase); + EINA_SAFETY_ON_NULL_RETURN(callback); + + if (ewkIconDatabase->changeListeners.contains(callback)) + return; + + ewkIconDatabase->changeListeners.add(callback, IconChangeCallbackData(callback, userData)); +} + +void ewk_favicon_database_icon_change_callback_del(Ewk_Favicon_Database* ewkIconDatabase, Ewk_Favicon_Database_Icon_Change_Cb callback) +{ + EINA_SAFETY_ON_NULL_RETURN(ewkIconDatabase); + EINA_SAFETY_ON_NULL_RETURN(callback); + + ewkIconDatabase->changeListeners.remove(callback); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h new file mode 100644 index 000000000..c3d44e47e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.h @@ -0,0 +1,108 @@ +/* + * 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_favicon_database.h + * @brief Describes the Ewk Favicon Database API. + */ + +#ifndef ewk_favicon_database_h +#define ewk_favicon_database_h + +#include <Evas.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for @a _Ewk_Favicon_Database. */ +typedef struct _Ewk_Favicon_Database Ewk_Favicon_Database; + +/** + * @typedef Ewk_Favicon_Database_Icon_Change_Cb Ewk_Favicon_Database_Icon_Change_Cb + * @brief Callback type for use with ewk_favicon_database_icon_change_callback_add and ewk_favicon_database_icon_change_callback_del + */ +typedef void (*Ewk_Favicon_Database_Icon_Change_Cb)(const char *page_url, void *event_info); + +/** + * @typedef Ewk_Favicon_Database_Async_Icon_Get_Cb Ewk_Favicon_Database_Async_Icon_Get_Cb + * @brief Callback type for use with ewk_favicon_database_async_icon_get + * + * The @a icon may be NULL if there is no favicon associated to the given @a page_url. + * + * You need to call evas_object_ref() on the @a icon if you wish to keep it after the + * callback is executed. + */ +typedef void (*Ewk_Favicon_Database_Async_Icon_Get_Cb)(const char *page_url, Evas_Object *icon, void *event_info); + +/** + * Retrieves from the database the favicon URL for the given @a page_url + * + * @param database database object to query + * @param page_url URL of the page to get the favicon URL for + * + * @return the favicon URL 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_favicon_database_icon_url_get(Ewk_Favicon_Database *database, const char *page_url); + +/** + * Retrieves asynchronously from the database the favicon for the given @a page_url + * + * @param database database object to query + * @param page_url URL of the page to get the favicon for + * @param evas The canvas to add the favicon to + * @param callback callback function to be called when the icon is retrieved + * @param data the data pointer that was to be passed to the callback + * + * @return @c EINA_TRUE if the icon was successfuly requested, @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_favicon_database_async_icon_get(Ewk_Favicon_Database *database, const char *page_url, Evas *evas, Ewk_Favicon_Database_Async_Icon_Get_Cb callback, void *data); + +/** + * Add (register) a callback function to a icon change event + * + * @param database database object to register the callback + * @param callback callback function to be called when an icon changes + * @param data the data pointer that was to be passed to the callback + */ +EAPI void ewk_favicon_database_icon_change_callback_add(Ewk_Favicon_Database *database, Ewk_Favicon_Database_Icon_Change_Cb callback, void *data); + +/** + * Delete (unregister) a callback function registered to a icon change event + * + * @param database database object to unregister the callback. + * @param callback callback function to unregister + */ +EAPI void ewk_favicon_database_icon_change_callback_del(Ewk_Favicon_Database *database, Ewk_Favicon_Database_Icon_Change_Cb callback); + +#ifdef __cplusplus +} +#endif + +#endif // ewk_favicon_database_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h new file mode 100644 index 000000000..c58842430 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_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_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> + +struct IconChangeCallbackData { + Ewk_Favicon_Database_Icon_Change_Cb callback; + void* userData; + + IconChangeCallbackData() + : callback(0) + , userData(0) + { } + + IconChangeCallbackData(Ewk_Favicon_Database_Icon_Change_Cb _callback, void* _userData) + : callback(_callback) + , userData(_userData) + { } +}; + +struct IconRequestCallbackData { + Ewk_Favicon_Database_Async_Icon_Get_Cb callback; + void* userData; + Evas* evas; + + IconRequestCallbackData() + : callback(0) + , userData(0) + , evas(0) + { } + + IconRequestCallbackData(Ewk_Favicon_Database_Async_Icon_Get_Cb _callback, void* _userData, Evas* _evas) + : callback(_callback) + , userData(_userData) + , evas(_evas) + { } +}; + +typedef HashMap<Ewk_Favicon_Database_Icon_Change_Cb, IconChangeCallbackData> ChangeListenerMap; +typedef Vector<IconRequestCallbackData> PendingIconRequestVector; +typedef HashMap<String /* pageURL */, PendingIconRequestVector> PendingIconRequestMap; + +class _Ewk_Favicon_Database { +public: + WKRetainPtr<WKIconDatabaseRef> wkIconDatabase; + ChangeListenerMap changeListeners; + PendingIconRequestMap iconRequests; + + static PassOwnPtr<_Ewk_Favicon_Database> create(WKIconDatabaseRef iconDatabaseRef) + { + return adoptPtr(new _Ewk_Favicon_Database(iconDatabaseRef)); + } + +private: + explicit _Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef); +}; + +#endif // ewk_favicon_database_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp index 80a5fd9fb..ee140f94e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request.cpp @@ -29,46 +29,16 @@ #include "WKAPICast.h" #include "WKArray.h" #include "WKBase.h" -#include "WKDictionary.h" -#include "WKFormSubmissionListener.h" -#include "WKRetainPtr.h" #include "WKString.h" #include "ewk_form_submission_request_private.h" #include <wtf/text/CString.h> using namespace WebKit; -/** - * \struct _Ewk_Form_Submission_Request - * @brief Contains the form submission request data. - */ -struct _Ewk_Form_Submission_Request { - unsigned int __ref; /**< the reference count of the object */ - WKRetainPtr<WKDictionaryRef> wkValues; - WKRetainPtr<WKFormSubmissionListenerRef> wkListener; - bool handledRequest; - - _Ewk_Form_Submission_Request(WKDictionaryRef values, WKFormSubmissionListenerRef listener) - : __ref(1) - , wkValues(values) - , wkListener(listener) - , handledRequest(false) - { } - - ~_Ewk_Form_Submission_Request() - { - ASSERT(!__ref); - - // Make sure the request is always handled before destroying. - if (!handledRequest) - WKFormSubmissionListenerContinue(wkListener.get()); - } -}; - Ewk_Form_Submission_Request* ewk_form_submission_request_ref(Ewk_Form_Submission_Request* request) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - ++request->__ref; + request->ref(); return request; } @@ -77,10 +47,7 @@ void ewk_form_submission_request_unref(Ewk_Form_Submission_Request* request) { EINA_SAFETY_ON_NULL_RETURN(request); - if (--request->__ref) - return; - - delete request; + request->deref(); } Eina_List* ewk_form_submission_request_field_names_get(Ewk_Form_Submission_Request* request) @@ -119,15 +86,3 @@ Eina_Bool ewk_form_submission_request_submit(Ewk_Form_Submission_Request* reques return true; } - -/** - * @internal ewk_form_submission_request_new - * Creates a Ewk_Form_Submission_Request from a dictionary and a WKFormSubmissionListenerRef. - */ -Ewk_Form_Submission_Request* ewk_form_submission_request_new(WKDictionaryRef values, WKFormSubmissionListenerRef listener) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(values, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(listener, 0); - - return new Ewk_Form_Submission_Request(values, listener); -} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h index feb3d606b..b9bf57a14 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_form_submission_request_private.h @@ -26,8 +26,38 @@ #ifndef ewk_form_submission_request_private_h #define ewk_form_submission_request_private_h +#include "WKDictionary.h" +#include "WKFormSubmissionListener.h" +#include "WKRetainPtr.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + typedef struct _Ewk_Form_Submission_Request Ewk_Form_Submission_Request; -Ewk_Form_Submission_Request* ewk_form_submission_request_new(WKDictionaryRef values, WKFormSubmissionListenerRef); +class _Ewk_Form_Submission_Request : public RefCounted<_Ewk_Form_Submission_Request> { +public: + WKRetainPtr<WKDictionaryRef> wkValues; + WKRetainPtr<WKFormSubmissionListenerRef> wkListener; + bool handledRequest; + + ~_Ewk_Form_Submission_Request() + { + // Make sure the request is always handled before destroying. + if (!handledRequest) + WKFormSubmissionListenerContinue(wkListener.get()); + } + + static PassRefPtr<_Ewk_Form_Submission_Request> create(WKDictionaryRef values, WKFormSubmissionListenerRef listener) + { + return adoptRef(new _Ewk_Form_Submission_Request(values, listener)); + } + +private: + _Ewk_Form_Submission_Request(WKDictionaryRef values, WKFormSubmissionListenerRef listener) + : wkValues(values) + , wkListener(listener) + , handledRequest(false) + { } +}; #endif // ewk_form_submission_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp index ee6b93b4b..7e5b919a1 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp @@ -29,9 +29,6 @@ #include "WKAPICast.h" #include "WKArray.h" #include "WKDictionary.h" -#include "WKEinaSharedString.h" -#include "WKIntentData.h" -#include "WKRetainPtr.h" #include "WKString.h" #include "WKURL.h" #include "ewk_intent_private.h" @@ -39,35 +36,6 @@ using namespace WebKit; -/** - * \struct _Ewk_Intent - * @brief Contains the intent data. - */ -struct _Ewk_Intent { - unsigned int __ref; /**< the reference count of the object */ -#if ENABLE(WEB_INTENTS) - WKRetainPtr<WKIntentDataRef> wkIntent; -#endif - WKEinaSharedString action; - WKEinaSharedString type; - WKEinaSharedString service; - - _Ewk_Intent(WKIntentDataRef intentRef) - : __ref(1) -#if ENABLE(WEB_INTENTS) - , wkIntent(intentRef) - , action(AdoptWK, WKIntentDataCopyAction(intentRef)) - , type(AdoptWK, WKIntentDataCopyType(intentRef)) - , service(AdoptWK, WKIntentDataCopyService(intentRef)) -#endif - { } - - ~_Ewk_Intent() - { - ASSERT(!__ref); - } -}; - #define EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent_, ...) \ if (!(intent)) { \ EINA_LOG_CRIT("intent is NULL."); \ @@ -83,7 +51,8 @@ Ewk_Intent* ewk_intent_ref(Ewk_Intent* intent) { #if ENABLE(WEB_INTENTS) EINA_SAFETY_ON_NULL_RETURN_VAL(intent, 0); - ++intent->__ref; + + intent->ref(); #endif return intent; @@ -94,10 +63,7 @@ void ewk_intent_unref(Ewk_Intent* intent) #if ENABLE(WEB_INTENTS) EINA_SAFETY_ON_NULL_RETURN(intent); - if (--intent->__ref) - return; - - delete intent; + intent->deref(); #endif } @@ -177,18 +143,3 @@ Eina_List* ewk_intent_extra_names_get(const Ewk_Intent* intent) return 0; #endif } - -#if ENABLE(WEB_INTENTS) -Ewk_Intent* ewk_intent_new(WKIntentDataRef intentData) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(intentData, 0); - - return new Ewk_Intent(intentData); -} - -WKIntentDataRef ewk_intent_WKIntentDataRef_get(const Ewk_Intent* intent) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(intent, 0); - return intent->wkIntent.get(); -} -#endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h index 0f8268930..95ffbb248 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h @@ -28,12 +28,39 @@ #if ENABLE(WEB_INTENTS) +#include "WKEinaSharedString.h" +#include "WKIntentData.h" +#include "WKRetainPtr.h" #include <WebKit2/WKBase.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> typedef struct _Ewk_Intent Ewk_Intent; -Ewk_Intent* ewk_intent_new(WKIntentDataRef intentData); -WKIntentDataRef ewk_intent_WKIntentDataRef_get(const Ewk_Intent* intent); +/** + * \struct _Ewk_Intent + * @brief Contains the intent data. + */ +class _Ewk_Intent : public RefCounted<_Ewk_Intent> { +public: + WKRetainPtr<WKIntentDataRef> wkIntent; + WKEinaSharedString action; + WKEinaSharedString type; + WKEinaSharedString service; + + static PassRefPtr<_Ewk_Intent> create(WKIntentDataRef intentRef) + { + return adoptRef(new _Ewk_Intent(intentRef)); + } + +private: + explicit _Ewk_Intent(WKIntentDataRef intentRef) + : wkIntent(intentRef) + , action(AdoptWK, WKIntentDataCopyAction(intentRef)) + , type(AdoptWK, WKIntentDataCopyType(intentRef)) + , service(AdoptWK, WKIntentDataCopyService(intentRef)) + { } +}; #endif // ENABLE(WEB_INTENTS) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp index 279e90904..9702834e9 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp @@ -28,8 +28,6 @@ #include "IntentServiceInfo.h" #include "WKAPICast.h" -#include "WKEinaSharedString.h" -#include "WKIntentServiceInfo.h" #include "WKRetainPtr.h" #include "WKURL.h" #include "ewk_intent_service_private.h" @@ -37,41 +35,11 @@ using namespace WebKit; -/** - * \struct _Ewk_Intent_Service - * @brief Contains the intent service data. - */ -struct _Ewk_Intent_Service { - unsigned int __ref; /**< the reference count of the object */ - - WKEinaSharedString action; - WKEinaSharedString type; - WKEinaSharedString href; - WKEinaSharedString title; - WKEinaSharedString disposition; - - _Ewk_Intent_Service(WKIntentServiceInfoRef serviceRef) - : __ref(1) -#if ENABLE(WEB_INTENTS_TAG) - , action(AdoptWK, WKIntentServiceInfoCopyAction(serviceRef)) - , type(AdoptWK, WKIntentServiceInfoCopyType(serviceRef)) - , href(AdoptWK, WKIntentServiceInfoCopyHref(serviceRef)) - , title(AdoptWK, WKIntentServiceInfoCopyTitle(serviceRef)) - , disposition(AdoptWK, WKIntentServiceInfoCopyDisposition(serviceRef)) -#endif - { } - - ~_Ewk_Intent_Service() - { - ASSERT(!__ref); - } -}; - Ewk_Intent_Service* ewk_intent_service_ref(Ewk_Intent_Service* service) { #if ENABLE(WEB_INTENTS_TAG) EINA_SAFETY_ON_NULL_RETURN_VAL(service, 0); - ++service->__ref; + service->ref(); #endif return service; @@ -82,10 +50,7 @@ void ewk_intent_service_unref(Ewk_Intent_Service* service) #if ENABLE(WEB_INTENTS_TAG) EINA_SAFETY_ON_NULL_RETURN(service); - if (--service->__ref) - return; - - delete service; + service->deref(); #endif } @@ -123,12 +88,3 @@ const char* ewk_intent_service_disposition_get(const Ewk_Intent_Service* service return service->disposition; } - -#if ENABLE(WEB_INTENTS_TAG) -Ewk_Intent_Service* ewk_intent_service_new(WKIntentServiceInfoRef wkService) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(wkService, 0); - - return new Ewk_Intent_Service(wkService); -} -#endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h index 7ff4923cc..ca561c548 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h @@ -28,11 +28,40 @@ #if ENABLE(WEB_INTENTS_TAG) +#include "WKEinaSharedString.h" +#include "WKIntentServiceInfo.h" #include <WebKit2/WKBase.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> typedef struct _Ewk_Intent_Service Ewk_Intent_Service; -Ewk_Intent_Service* ewk_intent_service_new(WKIntentServiceInfoRef wkService); +/** + * \struct _Ewk_Intent_Service + * @brief Contains the intent service data. + */ +class _Ewk_Intent_Service : public RefCounted<_Ewk_Intent_Service> { +public: + WKEinaSharedString action; + WKEinaSharedString type; + WKEinaSharedString href; + WKEinaSharedString title; + WKEinaSharedString disposition; + + static PassRefPtr<_Ewk_Intent_Service> create(WKIntentServiceInfoRef serviceRef) + { + return adoptRef(new _Ewk_Intent_Service(serviceRef)); + } + +private: + explicit _Ewk_Intent_Service(WKIntentServiceInfoRef serviceRef) + : action(AdoptWK, WKIntentServiceInfoCopyAction(serviceRef)) + , type(AdoptWK, WKIntentServiceInfoCopyType(serviceRef)) + , href(AdoptWK, WKIntentServiceInfoCopyHref(serviceRef)) + , title(AdoptWK, WKIntentServiceInfoCopyTitle(serviceRef)) + , disposition(AdoptWK, WKIntentServiceInfoCopyDisposition(serviceRef)) + { } +}; #endif // ENABLE(WEB_INTENTS_TAG) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp index fcc9faf1a..17e2b1eea 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_main.cpp @@ -31,6 +31,10 @@ #include <glib-object.h> #include <glib.h> +#ifdef HAVE_ECORE_X +#include <Ecore_X.h> +#endif + static int _ewkInitCount = 0; /** @@ -68,6 +72,13 @@ int ewk_init(void) goto error_ecore_evas; } +#ifdef HAVE_ECORE_X + if (!ecore_x_init(0)) { + CRITICAL("could not init ecore_x."); + goto error_ecore_x; + } +#endif + g_type_init(); if (!ecore_main_loop_glib_integrate()) { @@ -77,6 +88,10 @@ int ewk_init(void) return ++_ewkInitCount; +#ifdef HAVE_ECORE_X +error_ecore_x: + ecore_evas_shutdown(); +#endif error_ecore_evas: ecore_shutdown(); error_ecore: @@ -95,6 +110,9 @@ int ewk_shutdown(void) if (--_ewkInitCount) return _ewkInitCount; +#ifdef HAVE_ECORE_X + ecore_x_shutdown(); +#endif 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 new file mode 100644 index 000000000..a58459eb4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.cpp @@ -0,0 +1,68 @@ +/* + * 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_navigation_data.h" + +#include "ewk_navigation_data_private.h" + +using namespace WebKit; + +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); + + return data->title; +} + +Ewk_Url_Request* ewk_navigation_data_original_request_get(const Ewk_Navigation_Data* data) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + + return data->request.get(); +} + +const char* ewk_navigation_data_url_get(const Ewk_Navigation_Data* data) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + + return data->url; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h new file mode 100644 index 000000000..1a1e60732 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data.h @@ -0,0 +1,105 @@ +/* + * 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_navigation_data.h + * @brief Describes the Ewk navigation data API. + */ + +#ifndef ewk_navigation_data_h +#define ewk_navigation_data_h + +#include "ewk_url_request.h" +#include <Eina.h> + +#ifdef __cplusplus +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. + * + * @param data the navigation data object to decrease the reference count + */ +EAPI void ewk_navigation_data_unref(Ewk_Navigation_Data *data); + +/** + * Returns title for this navigation data. + * + * The title of the navigated page. + * + * @param data navigation data object to query + * + * @return the title or @c NULL in case of error. 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_navigation_data_title_get(const Ewk_Navigation_Data *data); + +/** + * Returns the original request for this navigation data. + * + * @param data navigation data object to query + * + * @return The URL request pointer or @c NULL in case of error. + */ +EAPI Ewk_Url_Request *ewk_navigation_data_original_request_get(const Ewk_Navigation_Data *data); + +/** + * Returns URL for this navigation data. + * + * The URL of the navigated page. + * + * @param data navigation data object to query + * + * @return the URL of the @a data or @c NULL in case of error. 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_navigation_data_url_get(const Ewk_Navigation_Data *data); + +#ifdef __cplusplus +} +#endif + +#endif // ewk_navigation_data_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h new file mode 100644 index 000000000..08ad0ce16 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_data_private.h @@ -0,0 +1,63 @@ +/* + * 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_navigation_data_private_h +#define ewk_navigation_data_private_h + +#include "WKAPICast.h" +#include "WKEinaSharedString.h" +#include "WKNavigationData.h" +#include "WKRetainPtr.h" +#include "ewk_private.h" +#include "ewk_url_request_private.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +/** + * \struct _Ewk_Navigation_Data + * @brief Contains the navigation data details. + */ +class _Ewk_Navigation_Data : public RefCounted<_Ewk_Navigation_Data> { +public: + RefPtr<Ewk_Url_Request> request; + WKEinaSharedString title; + WKEinaSharedString url; + + static PassRefPtr<_Ewk_Navigation_Data> create(WKNavigationDataRef dataRef) + { + return adoptRef(new _Ewk_Navigation_Data(dataRef)); + } + +private: + explicit _Ewk_Navigation_Data(WKNavigationDataRef dataRef) + : request(Ewk_Url_Request::create(adoptWK(WKNavigationDataCopyOriginalRequest(dataRef)).get())) + , title(AdoptWK, WKNavigationDataCopyTitle(dataRef)) + , url(AdoptWK, WKNavigationDataCopyURL(dataRef)) + { } +}; + +typedef struct _Ewk_Navigation_Data Ewk_Navigation_Data; + +#endif // ewk_navigation_data_private_h 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 d46805faa..d35c07e5f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_navigation_policy_decision.cpp @@ -26,58 +26,17 @@ #include "config.h" #include "ewk_navigation_policy_decision.h" -#include "WKAPICast.h" -#include "WKEinaSharedString.h" -#include "WKFramePolicyListener.h" -#include "WKRetainPtr.h" #include "ewk_navigation_policy_decision_private.h" #include "ewk_private.h" #include "ewk_url_request_private.h" using namespace WebKit; -/** - * \struct _Ewk_Navigation_Policy_Decision - * @brief Contains the navigation policy decision data. - */ -struct _Ewk_Navigation_Policy_Decision { - unsigned int __ref; /**< the reference count of the object */ - WKRetainPtr<WKFramePolicyListenerRef> listener; - bool actedUponByClient; - Ewk_Navigation_Type navigationType; - Event_Mouse_Button mouseButton; - Event_Modifier_Keys modifiers; - Ewk_Url_Request* request; - WKEinaSharedString frameName; - - _Ewk_Navigation_Policy_Decision(WKFramePolicyListenerRef _listener, Ewk_Navigation_Type _navigationType, Event_Mouse_Button _mouseButton, Event_Modifier_Keys _modifiers, Ewk_Url_Request* _request, const char* _frameName) - : __ref(1) - , listener(_listener) - , actedUponByClient(false) - , navigationType(_navigationType) - , mouseButton(_mouseButton) - , modifiers(_modifiers) - , request(_request) - , frameName(_frameName) - { } - - ~_Ewk_Navigation_Policy_Decision() - { - ASSERT(!__ref); - - // This is the default choice for all policy decisions in WebPageProxy.cpp. - if (!actedUponByClient) - WKFramePolicyListenerUse(listener.get()); - - ewk_url_request_unref(request); - } -}; - Ewk_Navigation_Policy_Decision* ewk_navigation_policy_decision_ref(Ewk_Navigation_Policy_Decision* decision) { EINA_SAFETY_ON_NULL_RETURN_VAL(decision, 0); - ++decision->__ref; + decision->ref(); return decision; } @@ -86,10 +45,7 @@ void ewk_navigation_policy_decision_unref(Ewk_Navigation_Policy_Decision* decisi { EINA_SAFETY_ON_NULL_RETURN(decision); - if (--decision->__ref) - return; - - delete decision; + decision->deref(); } Ewk_Navigation_Type ewk_navigation_policy_navigation_type_get(const Ewk_Navigation_Policy_Decision* decision) @@ -124,7 +80,7 @@ Ewk_Url_Request* ewk_navigation_policy_request_get(const Ewk_Navigation_Policy_D { EINA_SAFETY_ON_NULL_RETURN_VAL(decision, 0); - return decision->request; + return decision->request.get(); } void ewk_navigation_policy_decision_accept(Ewk_Navigation_Policy_Decision* decision) @@ -170,13 +126,3 @@ COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_SHIFT, kWKEventModifiersShiftKey COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_CTRL, kWKEventModifiersControlKey); COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_ALT, kWKEventModifiersAltKey); COMPILE_ASSERT_MATCHING_ENUM(EVENT_MODIFIER_KEY_META, kWKEventModifiersMetaKey); - -Ewk_Navigation_Policy_Decision* ewk_navigation_policy_decision_new(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef request, const char* frameName, WKFramePolicyListenerRef listener) -{ - return new Ewk_Navigation_Policy_Decision(listener, - static_cast<Ewk_Navigation_Type>(navigationType), - static_cast<Event_Mouse_Button>(mouseButton), - static_cast<Event_Modifier_Keys>(modifiers), - ewk_url_request_new(request), - frameName); -} 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 abc8bedc0..be1a8df5b 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 @@ -26,12 +26,55 @@ #ifndef ewk_navigation_policy_decision_private_h #define ewk_navigation_policy_decision_private_h +#include "WKAPICast.h" #include "WKBase.h" +#include "WKEinaSharedString.h" #include "WKEvent.h" +#include "WKFramePolicyListener.h" #include "WKPageLoadTypes.h" +#include "WKRetainPtr.h" +#include "ewk_url_request_private.h" +#include <wtf/PassRefPtr.h> -typedef struct _Ewk_Navigation_Policy_Decision Ewk_Navigation_Policy_Decision; +/** + * \struct _Ewk_Navigation_Policy_Decision + * @brief Contains the navigation policy decision data. + */ +class _Ewk_Navigation_Policy_Decision : public RefCounted<_Ewk_Navigation_Policy_Decision> { +public: + WKRetainPtr<WKFramePolicyListenerRef> listener; + bool actedUponByClient; + Ewk_Navigation_Type navigationType; + Event_Mouse_Button mouseButton; + Event_Modifier_Keys modifiers; + RefPtr<Ewk_Url_Request> request; + WKEinaSharedString frameName; + + ~_Ewk_Navigation_Policy_Decision() + { + // This is the default choice for all policy decisions in WebPageProxy.cpp. + if (!actedUponByClient) + WKFramePolicyListenerUse(listener.get()); + } -Ewk_Navigation_Policy_Decision* ewk_navigation_policy_decision_new(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef request, const char* frameName, WKFramePolicyListenerRef listener); + 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)); + } + +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) + : listener(listener) + , actedUponByClient(false) + , navigationType(navigationType) + , mouseButton(mouseButton) + , modifiers(modifiers) + , request(request) + , frameName(frameName) + { } +}; + +typedef struct _Ewk_Navigation_Policy_Decision Ewk_Navigation_Policy_Decision; #endif // ewk_navigation_policy_decision_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp index 566bbef89..d0a3f6061 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp @@ -26,65 +26,27 @@ #include "config.h" #include "ewk_popup_menu_item.h" -#include "WKEinaSharedString.h" #include "ewk_popup_menu_item_private.h" #include "ewk_private.h" #include <wtf/text/CString.h> using namespace WebKit; -/** - * \struct _Ewk_Popup_Menu_Item - * @brief Contains the popup menu data. - */ -struct _Ewk_Popup_Menu_Item { - Ewk_Popup_Menu_Item_Type type; - Ewk_Text_Direction textDirection; - - bool hasTextDirectionOverride; - bool isEnabled; - bool isLabel; - bool isSelected; - - WKEinaSharedString text; - WKEinaSharedString toolTip; - WKEinaSharedString accessibilityText; - - explicit _Ewk_Popup_Menu_Item(const WebKit::WebPopupItem& item) - : type(static_cast<Ewk_Popup_Menu_Item_Type>(item.m_type)) - , textDirection(static_cast<Ewk_Text_Direction>(item.m_textDirection)) - , hasTextDirectionOverride(item.m_hasTextDirectionOverride) - , isEnabled(item.m_isEnabled) - , isLabel(item.m_isLabel) - , isSelected(item.m_isSelected) - , text(item.m_text.utf8().data()) - , toolTip(item.m_toolTip.utf8().data()) - , accessibilityText(item.m_accessibilityText.utf8().data()) - { } -}; +_Ewk_Popup_Menu_Item::_Ewk_Popup_Menu_Item(const WebKit::WebPopupItem& item) + : type(static_cast<Ewk_Popup_Menu_Item_Type>(item.m_type)) + , textDirection(static_cast<Ewk_Text_Direction>(item.m_textDirection)) + , hasTextDirectionOverride(item.m_hasTextDirectionOverride) + , isEnabled(item.m_isEnabled) + , isLabel(item.m_isLabel) + , isSelected(item.m_isSelected) + , text(item.m_text.utf8().data()) + , toolTip(item.m_toolTip.utf8().data()) + , accessibilityText(item.m_accessibilityText.utf8().data()) +{ } COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_SEPARATOR, WebPopupItem::Separator); COMPILE_ASSERT_MATCHING_ENUM(EWK_POPUP_MENU_ITEM, WebPopupItem::Item); -/** - * @internal - * Constructs a Ewk_Popup_Menu_Item. - */ -Ewk_Popup_Menu_Item* ewk_popup_menu_item_new(const WebKit::WebPopupItem& item) -{ - return new Ewk_Popup_Menu_Item(item); -} - -/** - * @internal - * Frees a Ewk_Popup_Menu_Item. - */ -void ewk_popup_menu_item_free(Ewk_Popup_Menu_Item* item) -{ - EINA_SAFETY_ON_NULL_RETURN(item); - delete item; -} - Ewk_Popup_Menu_Item_Type ewk_popup_menu_item_type_get(const Ewk_Popup_Menu_Item* item) { EINA_SAFETY_ON_NULL_RETURN_VAL(item, EWK_POPUP_MENU_UNKNOWN); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item_private.h index 6a4a435bf..ec2ec36a8 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item_private.h @@ -26,9 +26,36 @@ #ifndef ewk_popup_menu_item_private_h #define ewk_popup_menu_item_private_h +#include "WKEinaSharedString.h" #include "WebPopupItem.h" +#include "ewk_popup_menu_item.h" +#include <wtf/PassOwnPtr.h> -Ewk_Popup_Menu_Item* ewk_popup_menu_item_new(const WebKit::WebPopupItem& item); -void ewk_popup_menu_item_free(Ewk_Popup_Menu_Item* item); +/** + * \struct _Ewk_Popup_Menu_Item + * @brief Contains the popup menu data. + */ +class _Ewk_Popup_Menu_Item { +public: + Ewk_Popup_Menu_Item_Type type; + Ewk_Text_Direction textDirection; + + bool hasTextDirectionOverride; + bool isEnabled; + bool isLabel; + bool isSelected; + + WKEinaSharedString text; + WKEinaSharedString toolTip; + WKEinaSharedString accessibilityText; + + static PassOwnPtr<_Ewk_Popup_Menu_Item> create(const WebKit::WebPopupItem& item) + { + return adoptPtr(new _Ewk_Popup_Menu_Item(item)); + } + +private: + explicit _Ewk_Popup_Menu_Item(const WebKit::WebPopupItem& item); +}; #endif // ewk_popup_menu_item_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_resource.cpp index 89879eead..714a48978 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_resource.cpp @@ -24,67 +24,35 @@ */ #include "config.h" -#include "ewk_web_resource.h" +#include "ewk_resource.h" -#include "WKEinaSharedString.h" -#include "ewk_web_resource_private.h" +#include "ewk_resource_private.h" #include <wtf/text/CString.h> -struct _Ewk_Web_Resource { - unsigned int __ref; /**< the reference count of the object */ - WKEinaSharedString url; - bool isMainResource; - - _Ewk_Web_Resource(const char* url, bool isMainResource) - : __ref(1) - , url(url) - , isMainResource(isMainResource) - { } - - ~_Ewk_Web_Resource() - { - ASSERT(!__ref); - } -}; - -Ewk_Web_Resource* ewk_web_resource_ref(Ewk_Web_Resource* resource) +Ewk_Resource* ewk_resource_ref(Ewk_Resource* resource) { EINA_SAFETY_ON_NULL_RETURN_VAL(resource, 0); - ++resource->__ref; + resource->ref(); return resource; } -void ewk_web_resource_unref(Ewk_Web_Resource* resource) +void ewk_resource_unref(Ewk_Resource* resource) { EINA_SAFETY_ON_NULL_RETURN(resource); - if (--resource->__ref) - return; - - delete resource; + resource->deref(); } -const char* ewk_web_resource_url_get(const Ewk_Web_Resource* resource) +const char* ewk_resource_url_get(const Ewk_Resource* resource) { EINA_SAFETY_ON_NULL_RETURN_VAL(resource, 0); return resource->url; } -/** - * @internal - * Constructs a Ewk_Web_Resource. - */ -Ewk_Web_Resource* ewk_web_resource_new(const char* url, bool isMainResource) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0); - - return new Ewk_Web_Resource(url, isMainResource); -} - -Eina_Bool ewk_web_resource_main_resource_get(const Ewk_Web_Resource* resource) +Eina_Bool ewk_resource_main_resource_get(const Ewk_Resource* resource) { EINA_SAFETY_ON_NULL_RETURN_VAL(resource, false); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.h b/Source/WebKit2/UIProcess/API/efl/ewk_resource.h index dc2cf087d..a2f4786b8 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_resource.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_resource.h @@ -24,12 +24,12 @@ */ /** - * @file ewk_web_resource.h + * @file ewk_resource.h * @brief Describes the Web Resource API. */ -#ifndef ewk_web_resource_h -#define ewk_web_resource_h +#ifndef ewk_resource_h +#define ewk_resource_h #include <Eina.h> @@ -37,8 +37,8 @@ extern "C" { #endif -/** Creates a type name for @a Ewk_Web_Resource. */ -typedef struct _Ewk_Web_Resource Ewk_Web_Resource; +/** Creates a type name for @a Ewk_Resource. */ +typedef struct _Ewk_Resource Ewk_Resource; /** * Increases the reference count of the given object. @@ -47,7 +47,7 @@ typedef struct _Ewk_Web_Resource Ewk_Web_Resource; * * @return a pointer to the object on success, @c NULL otherwise. */ -EAPI Ewk_Web_Resource *ewk_web_resource_ref(Ewk_Web_Resource *resource); +EAPI Ewk_Resource *ewk_resource_ref(Ewk_Resource *resource); /** * Decreases the reference count of the given object, possibly freeing it. @@ -56,7 +56,7 @@ EAPI Ewk_Web_Resource *ewk_web_resource_ref(Ewk_Web_Resource *resource); * * @param resource the resource object to decrease the reference count */ -EAPI void ewk_web_resource_unref(Ewk_Web_Resource *resource); +EAPI void ewk_resource_unref(Ewk_Resource *resource); /** * Query URL for this resource. @@ -69,7 +69,7 @@ EAPI void ewk_web_resource_unref(Ewk_Web_Resource *resource); * eina_stringshare_ref() instead of eina_stringshare_add() or * strdup(). */ -EAPI const char *ewk_web_resource_url_get(const Ewk_Web_Resource *resource); +EAPI const char *ewk_resource_url_get(const Ewk_Resource *resource); /** * Query if this is the main resource. @@ -78,10 +78,10 @@ EAPI const char *ewk_web_resource_url_get(const Ewk_Web_Resource *resource); * * @return @c EINA_TRUE if this is the main resource, @c EINA_FALSE otherwise */ -EAPI Eina_Bool ewk_web_resource_main_resource_get(const Ewk_Web_Resource *resource); +EAPI Eina_Bool ewk_resource_main_resource_get(const Ewk_Resource *resource); #ifdef __cplusplus } #endif -#endif // ewk_web_resource_h +#endif // ewk_resource_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_resource_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_resource_private.h new file mode 100644 index 000000000..d86d67be8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_resource_private.h @@ -0,0 +1,55 @@ +/* + * 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_resource_private_h +#define ewk_resource_private_h + +#include "WKEinaSharedString.h" +#include "WKURL.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +typedef struct _Ewk_Resource Ewk_Resource; + +class _Ewk_Resource : public RefCounted<_Ewk_Resource> { +public: + WKEinaSharedString url; + bool isMainResource; + + static PassRefPtr<_Ewk_Resource> create(WKURLRef url, bool isMainResource) + { + return adoptRef(new _Ewk_Resource(url, isMainResource)); + } + +private: + _Ewk_Resource(WKURLRef url, bool isMainResource) + : url(url) + , isMainResource(isMainResource) + { } +}; + +#endif // ewk_resource_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp index a1f51b8bc..803761168 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp @@ -28,9 +28,47 @@ #include "ewk_settings_private.h" #include <WebKit2/WKPreferences.h> +#include <WebKit2/WKPreferencesPrivate.h> + +#if ENABLE(SPELLCHECK) +#include "WKTextChecker.h" +#include "WebKitTextChecker.h" +#include <Ecore.h> +#include <wtf/Vector.h> +#include <wtf/text/CString.h> +#endif using namespace WebKit; +#if ENABLE(SPELLCHECK) +static struct { + bool isContinuousSpellCheckingEnabled : 1; + Vector<String> spellCheckingLanguages; + Ewk_Settings_Continuous_Spell_Checking_Change_Cb onContinuousSpellChecking; +} ewkTextCheckerSettings = { false, Vector<String>(), 0 }; + +static Eina_Bool onContinuousSpellCheckingIdler(void*) +{ + if (ewkTextCheckerSettings.onContinuousSpellChecking) + ewkTextCheckerSettings.onContinuousSpellChecking(ewkTextCheckerSettings.isContinuousSpellCheckingEnabled); + + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool spellCheckingLanguagesSetUpdate(void*) +{ + // FIXME: Consider to delegate calling of this method in WebProcess to do not delay/block UIProcess. + updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages); + return ECORE_CALLBACK_CANCEL; +} + +static void spellCheckingLanguagesSet(const Vector<String>& newLanguages) +{ + ewkTextCheckerSettings.spellCheckingLanguages = newLanguages; + ecore_idler_add(spellCheckingLanguagesSetUpdate, 0); +} +#endif // ENABLE(SPELLCHECK) + Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool enable) { #if ENABLE(FULLSCREEN_API) @@ -99,3 +137,123 @@ Eina_Bool ewk_settings_developer_extras_enabled_get(const Ewk_Settings* settings return WKPreferencesGetDeveloperExtrasEnabled(settings->preferences.get()); } + +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); + + return true; +} + +Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings* settings) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + return WKPreferencesGetFileAccessFromFileURLsAllowed(settings->preferences.get()); +} + +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); + + return true; +} + +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()); +} + +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); + + return true; +} + +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()); +} + +void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb callback) +{ +#if ENABLE(SPELLCHECK) + ewkTextCheckerSettings.onContinuousSpellChecking = callback; +#endif +} + +Eina_Bool ewk_settings_continuous_spell_checking_enabled_get() +{ +#if ENABLE(SPELLCHECK) + return ewkTextCheckerSettings.isContinuousSpellCheckingEnabled; +#else + return false; +#endif +} + +void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable) +{ +#if ENABLE(SPELLCHECK) + enable = !!enable; + if (ewkTextCheckerSettings.isContinuousSpellCheckingEnabled != enable) { + ewkTextCheckerSettings.isContinuousSpellCheckingEnabled = enable; + + WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enable); + + // Sets the default language if user didn't specify any. + if (enable && loadedSpellCheckingLanguages().isEmpty()) + spellCheckingLanguagesSet(Vector<String>()); + + if (ewkTextCheckerSettings.onContinuousSpellChecking) + ecore_idler_add(onContinuousSpellCheckingIdler, 0); + } +#endif +} + +Eina_List* ewk_settings_spell_checking_available_languages_get() +{ + Eina_List* listOflanguages = 0; +#if ENABLE(SPELLCHECK) + Vector<String> languages = availableSpellCheckingLanguages(); + size_t numberOfLanuages = languages.size(); + + for (size_t i = 0; i < numberOfLanuages; ++i) + listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data())); +#endif + return listOflanguages; +} + +void ewk_settings_spell_checking_languages_set(const char* languages) +{ +#if ENABLE(SPELLCHECK) + Vector<String> newLanguages; + String::fromUTF8(languages).split(',', newLanguages); + + spellCheckingLanguagesSet(newLanguages); +#endif +} + +Eina_List* ewk_settings_spell_checking_languages_get() +{ + Eina_List* listOflanguages = 0; +#if ENABLE(SPELLCHECK) + Vector<String> languages = loadedSpellCheckingLanguages(); + size_t numberOfLanuages = languages.size(); + + for (size_t i = 0; i < numberOfLanuages; ++i) + listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data())); + +#endif + return listOflanguages; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.h b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h index 1d8b213d0..1f178b6ae 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_settings.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h @@ -44,6 +44,15 @@ extern "C" { typedef struct _Ewk_Settings Ewk_Settings; /** + * Creates a type name for the callback function used to notify the client when + * the continuous spell checking setting was changed by WebKit. + * + * @param enable @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled + */ +typedef void (*Ewk_Settings_Continuous_Spell_Checking_Change_Cb)(Eina_Bool enable); + + +/** * Enables/disables the Javascript Fullscreen API. The Javascript API allows * to request full screen mode, for more information see: * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html @@ -71,16 +80,18 @@ EAPI Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings *settings) /** * Enables/disables the javascript executing. * + * By default, JavaScript execution is enabled. + * * @param settings settings object to set javascript executing * @param enable @c EINA_TRUE to enable javascript executing - * @c EINA_FALSE to disable + * @c EINA_FALSE to disable * * @return @c EINA_TRUE on success or @c EINA_FALSE on failure */ EAPI Eina_Bool ewk_settings_javascript_enabled_set(Ewk_Settings *settings, Eina_Bool enable); /** - * Returns the javascript can be executable or not. + * Returns whether JavaScript execution is enabled. * * @param settings settings object to query if the javascript can be executed * @@ -92,20 +103,22 @@ EAPI Eina_Bool ewk_settings_javascript_enabled_get(const Ewk_Settings *settings) /** * Enables/disables auto loading of the images. * + * By default, auto loading of the images is enabled. + * * @param settings settings object to set auto loading of the images - * @param automatic @c EINA_TRUE to enable auto loading of the images, - * @c EINA_FALSE to disable + * @param automatic @c EINA_TRUE to enable auto loading of the images + * @c EINA_FALSE to disable * * @return @c EINA_TRUE on success or @c EINA_FALSE on failure */ EAPI Eina_Bool ewk_settings_loads_images_automatically_set(Ewk_Settings *settings, Eina_Bool automatic); /** - * Returns the images can be loaded automatically or not. + * Returns whether the images can be loaded automatically or not. * * @param settings settings object to get auto loading of the images * - * @return @c EINA_TRUE if the images are loaded automatically, + * @return @c EINA_TRUE if the images are loaded automatically * @c EINA_FALSE if not or on failure */ EAPI Eina_Bool ewk_settings_loads_images_automatically_get(const Ewk_Settings *settings); @@ -116,7 +129,8 @@ EAPI Eina_Bool ewk_settings_loads_images_automatically_get(const Ewk_Settings *s * By default, the developer extensions are disabled. * * @param settings settings object to set developer extensions - * @param enable @c EINA_TRUE to enable developer extensions, @c EINA_FALSE to disable + * @param enable @c EINA_TRUE to enable developer extensions + * @c EINA_FALSE to disable * * @return @c EINA_TRUE on success or @EINA_FALSE on failure */ @@ -134,6 +148,156 @@ EAPI Eina_Bool ewk_settings_developer_extras_enabled_set(Ewk_Settings *settings, */ EAPI Eina_Bool ewk_settings_developer_extras_enabled_get(const Ewk_Settings *settings); +/** + * Allow / Disallow file access from file:// URLs. + * + * By default, file access from file:// URLs is not allowed. + * + * @param settings settings object to set file access permission + * @param enable @c EINA_TRUE to enable file access permission + * @c EINA_FALSE to disable + * + * @return @c EINA_TRUE on success or @EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_set(Ewk_Settings *settings, Eina_Bool enable); + +/** + * Queries if file access from file:// URLs is allowed. + * + * By default, file access from file:// URLs is not allowed. + * + * @param settings settings object to query file access permission + * + * @return @c EINA_TRUE if file access from file:// URLs is allowed + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings *settings); + +/** + * Enables/disables frame flattening. + * + * By default, the frame flattening is disabled. + * + * @param settings settings object to set the frame flattening + * @param enable @c EINA_TRUE to enable the frame flattening + * @c EINA_FALSE to disable + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + * + * @see ewk_settings_enable_frame_flattening_get() + */ +EAPI Eina_Bool ewk_settings_frame_flattening_enabled_set(Ewk_Settings *settings, Eina_Bool enable); + +/** + * Returns whether the frame flattening is enabled. + * + * The frame flattening is a feature which expands sub frames until all the frames become + * one scrollable page. + * + * @param settings settings object to get the frame flattening. + * + * @return @c EINA_TRUE if the frame flattening is enabled + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_settings_frame_flattening_enabled_get(const Ewk_Settings *settings); + +/** + * Enables/disables DNS prefetching. + * + * By default, DNS prefetching is disabled. + * + * @param settings settings object to set DNS prefetching + * @param enable @c EINA_TRUE to enable DNS prefetching or + * @c EINA_FALSE to disable + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + * + * @see ewk_settings_DNS_prefetching_enabled_get() + */ +EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_set(Ewk_Settings *settings, Eina_Bool enable); + +/** + * Returns whether DNS prefetching is enabled or not. + * + * DNS prefetching is an attempt to resolve domain names before a user tries to follow a link. + * + * @param settings settings object to get DNS prefetching + * + * @return @c EINA_TRUE if DNS prefetching is enabled + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings *settings); + +/** + * Sets a callback function used to notify the client when + * the continuous spell checking setting was changed by WebKit. + * + * Specifying of this callback is needed if the application wants to receive notifications + * once WebKit changes this setting. + * If the application is not interested, this callback is not set. + * Changing of this setting at the WebKit level can be made as a result of modifying + * options in a Context Menu by a user. + * + * @param cb a new callback function to set or @c NULL to invalidate the previous one + */ +EAPI void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb cb); + +/** + * Queries if continuous spell checking is enabled. + * + * @return @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled + */ +EAPI Eina_Bool ewk_settings_continuous_spell_checking_enabled_get(void); + +/** + * Enables/disables continuous spell checking. + * + * Additionally, this function calls a callback function (if defined) to notify + * the client about the change of the setting. + * This feature is disabled by default. + * + * @see ewk_settings_continuous_spell_checking_change_cb_set + * + * @param enable @c EINA_TRUE to enable continuous spell checking or @c EINA_FALSE to disable + */ +EAPI void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable); + +/** + * Gets the the list of all available the spell checking languages to use. + * + * @see ewk_settings_spell_checking_languages_set + * + * @return the list with available spell checking languages, or @c NULL on failure + * the Eina_List and its items should be freed after, use eina_stringshare_del() + */ +EAPI Eina_List *ewk_settings_spell_checking_available_languages_get(void); + +/** + * Sets @a languages as the list of languages to use by default WebKit + * implementation of spellchecker feature with Enchant library support. + * + * If @languages is @c NULL, the default language is used. + * If the default language can not be determined then any available dictionary will be used. + * + * @note This function invalidates the previously set languages. + * The dictionaries are requested asynchronously. + * + * @param languages a list of comma (',') separated language codes + * of the form 'en_US', ie, language_VARIANT, may be @c NULL. + */ +EAPI void ewk_settings_spell_checking_languages_set(const char *languages); + +/** + * Gets the the list of the spell checking languages in use. + * + * @see ewk_settings_spell_checking_available_languages_get + * @see ewk_settings_spell_checking_languages_set + * + * @return the list with the spell checking languages in use, + * the Eina_List and its items should be freed after, use eina_stringshare_del() + */ +EAPI Eina_List *ewk_settings_spell_checking_languages_get(void); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp new file mode 100644 index 000000000..525d6d4db --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp @@ -0,0 +1,124 @@ +/* + * 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_text_checker.h" + +#if ENABLE(SPELLCHECK) + +#include "WKTextChecker.h" +#include "WebKitTextChecker.h" +#include "ewk_text_checker_private.h" + +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 +}; + +#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ +void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \ +{ \ + ewkTextCheckerCallbacks.NAME = cb; \ +} + +/** + * Attaches spellchecker feature. + * + * @internal + * + * The default spellchecker feature is based on Enchant library. + * Client may use own implementation of spellchecker previously set + * through the callback functions. + */ +void ewk_text_checker_client_attach() +{ + static bool didInitializeTextCheckerClient = false; + if (didInitializeTextCheckerClient) + return; + + WKTextCheckerClient textCheckerClient = { + kWKTextCheckerClientCurrentVersion, + 0, // clientInfo + 0, // isContinuousSpellCheckingAllowed + isContinuousSpellCheckingEnabled, + setContinuousSpellCheckingEnabled, + 0, // isGrammarCheckingEnabled + 0, // setGrammarCheckingEnabled + uniqueSpellDocumentTag, + closeSpellDocumentWithTag, + checkSpellingOfString, + 0, // checkGrammarOfString + 0, // spellingUIIsShowing + 0, // toggleSpellingUIIsShowing + 0, // updateSpellingUIWithMisspelledWord + 0, // updateSpellingUIWithGrammarString + guessesForWord, + learnWord, + ignoreWord + }; + WKTextCheckerSetClient(&textCheckerClient); + + 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; +} + +#else + +// Defines an empty API to do not break build. +#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ +void ewk_text_checker_##NAME##_cb_set(TYPE_NAME) \ +{ \ +} +#endif // ENABLE(SPELLCHECK) + +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb, unique_spell_document_tag_get) +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb, unique_spell_document_tag_close) +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_String_Spelling_Check_Cb, string_spelling_check) +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Guesses_Get_Cb, word_guesses_get) +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Learn_Cb, word_learn) +EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Ignore_Cb, word_ignore) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h new file mode 100644 index 000000000..b7aea882f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h @@ -0,0 +1,156 @@ +/* + * 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_text_checker.h + * @brief Provides API to overwrite the default WebKit spellchecker implementation. + * + * There is one spellchecker object per application and it's disabled by default. + * It allows to check spelling in the editable areas. + * If application wants to enable the feature, API from ewk_settings.h + * should be used. + * + * The default WebKit spellchecker implementation is based on the Enchant library. + * It doesn't ensure grammar checking. Application is able to overwrite the default + * WebKit spellchecker implementation by defining its own implementation and setting + * appropriate callback functions. + */ + +#ifndef ewk_text_checker_h +#define ewk_text_checker_h + +#include <Evas.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Defines a type name for the callback function to return a tag (identifier) which is guaranteed to be unique. + * + * Unique tags help to avoid collisions with other objects that are checked for spelling mistakes. + * + * @param o the view object to get unique tag + * + * @return unique tag for the given @a o view object + */ +typedef uint64_t (*Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb)(const Evas_Object *o); + +/** + * Defines a type name for the callback function to close the prviously set tag. + * + * This callback will notify the receiver that the user has finished with the tagged document. + * + * @param tag the tag to be closed + */ +typedef void (*Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb)(uint64_t tag); + +/** + * Defines a type name for the callback function to search for a misspelled words in the given string. + * + * @param tag unique tag to notify the spell checker which document that @a text is associated, + * in most cases not necessarily, just for ignored word, + * @c 0 can be passed in for text not associated with a particular document + * @param text the text containing the words to spellcheck + * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct + * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct + */ +typedef void (*Ewk_Text_Checker_String_Spelling_Check_Cb)(uint64_t tag, const char *text, int32_t *misspelling_location, int32_t *misspelling_length); + +/** + * Defines a type name for the callback function to get a list of suggested spellings for a misspelled @a word. + * + * @param tag unique tag to notify the spell checker which document that @a text is associated, + * @c 0 can be passed for text not associated with a particular document + * @param word the word to get guesses + * @return a list of dynamically allocated strings (as char*) and + * caller is responsible for destroying them. + */ +typedef Eina_List *(*Ewk_Text_Checker_Word_Guesses_Get_Cb)(uint64_t tag, const char *word); + +/** + * Sets a callback function to add the word to the spell checker dictionary. + * + * @param tag unique tag to notify the spell checker which document that @a text is associated, + * @c 0 can be passed for text not associated with a particular document + * @param word the word to add + */ +typedef void (*Ewk_Text_Checker_Word_Learn_Cb)(uint64_t tag, const char *word); + +/** + * Sets a callback function to tell the spell checker to ignore a given word. + * + * @param tag unique tag to notify the spell checker which document that @a text is associated, + * @c 0 can be passed for text not associated with a particular document + * @param word the word to ignore + */ +typedef void (*Ewk_Text_Checker_Word_Ignore_Cb)(uint64_t tag, const char *word); + +/** + * Sets a callback function to get a unique spell document tag. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_unique_spell_document_tag_get_cb_set(Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb cb); + +/** + * Sets a callback function to close a unique spell document tag. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_unique_spell_document_tag_close_cb_set(Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb cb); + +/** + * Sets a callback function to search for a misspelled words in the given string. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_string_spelling_check_cb_set(Ewk_Text_Checker_String_Spelling_Check_Cb cb); + +/** + * Sets a callback function to get an array of suggested spellings for a misspelled word. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_word_guesses_get_cb_set(Ewk_Text_Checker_Word_Guesses_Get_Cb cb); + +/** + * Sets a callback function to add the word to the spell checker dictionary. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_word_learn_cb_set(Ewk_Text_Checker_Word_Learn_Cb cb); + +/** + * Sets a callback function to tell the spell checker to ignore a given word. + * + * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation + */ +EAPI void ewk_text_checker_word_ignore_cb_set(Ewk_Text_Checker_Word_Ignore_Cb cb); + +#ifdef __cplusplus +} +#endif +#endif // ewk_text_checker_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h new file mode 100644 index 000000000..d45505ad9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#ifndef ewk_text_checker_private_h +#define ewk_text_checker_private_h + +#if ENABLE(SPELLCHECK) + +#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; +}; +typedef _Ewk_Text_Checker Ewk_Text_Checker; + +Ewk_Text_Checker* ewk_text_checker_callbacks_get(); + +// Makes it visible for WTR. +EAPI void ewk_text_checker_client_attach(); + +#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 9e7c80c40..ab569ccc0 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request.cpp @@ -26,44 +26,14 @@ #include "config.h" #include "ewk_url_request.h" -#include "WKAPICast.h" -#include "WKEinaSharedString.h" -#include "WKURL.h" -#include "WKURLRequest.h" -#include "WebURLRequest.h" #include "ewk_url_request_private.h" -#include <wtf/text/CString.h> using namespace WebKit; -/** - * \struct _Ewk_Url_Request - * @brief Contains the URL request data. - */ -struct _Ewk_Url_Request { - unsigned int __ref; /**< the reference count of the object */ - - WKEinaSharedString url; - WKEinaSharedString first_party; - WKEinaSharedString http_method; - - _Ewk_Url_Request(WKURLRequestRef requestRef) - : __ref(1) - , url(AdoptWK, WKURLRequestCopyURL(requestRef)) - , first_party(AdoptWK, WKURLRequestCopyFirstPartyForCookies(requestRef)) - , http_method(AdoptWK, WKURLRequestCopyHTTPMethod(requestRef)) - { } - - ~_Ewk_Url_Request() - { - ASSERT(!__ref); - } -}; - Ewk_Url_Request* ewk_url_request_ref(Ewk_Url_Request* request) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - ++request->__ref; + request->ref(); return request; } @@ -72,10 +42,7 @@ void ewk_url_request_unref(Ewk_Url_Request* request) { EINA_SAFETY_ON_NULL_RETURN(request); - if (--request->__ref) - return; - - delete request; + request->deref(); } const char* ewk_url_request_url_get(const Ewk_Url_Request* request) @@ -89,23 +56,12 @@ const char* ewk_request_cookies_first_party_get(const Ewk_Url_Request* request) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - return request->first_party; + return request->firstParty; } const char* ewk_url_request_http_method_get(const Ewk_Url_Request* request) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - return request->http_method; -} - -/** - * @internal - * Constructs a Ewk_Url_Request from a WKURLRequest. - */ -Ewk_Url_Request* ewk_url_request_new(WKURLRequestRef wkUrlRequest) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(wkUrlRequest, 0); - - return new Ewk_Url_Request(wkUrlRequest); + return request->httpMethod; } 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 548b6e91e..b1bc13318 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_request_private.h @@ -26,6 +26,35 @@ #ifndef ewk_url_request_private_h #define ewk_url_request_private_h -Ewk_Url_Request* ewk_url_request_new(WKURLRequestRef); +#include "WKEinaSharedString.h" +#include "WKURL.h" +#include "WKURLRequest.h" +#include "WebURLRequest.h" +#include <wtf/PassRefPtr.h> + +/** + * \struct _Ewk_Url_Request + * @brief Contains the URL request data. + */ +class _Ewk_Url_Request : public RefCounted<_Ewk_Url_Request> { +public: + WKEinaSharedString url; + WKEinaSharedString firstParty; + WKEinaSharedString httpMethod; + + static PassRefPtr<_Ewk_Url_Request> create(WKURLRequestRef requestRef) + { + return adoptRef(new _Ewk_Url_Request(requestRef)); + } + +private: + explicit _Ewk_Url_Request(WKURLRequestRef requestRef) + : url(AdoptWK, WKURLRequestCopyURL(requestRef)) + , firstParty(AdoptWK, WKURLRequestCopyFirstPartyForCookies(requestRef)) + , httpMethod(AdoptWK, WKURLRequestCopyHTTPMethod(requestRef)) + { } +}; + +typedef struct _Ewk_Url_Request Ewk_Url_Request; #endif // ewk_url_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp index 8c1b1b57f..17223044f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response.cpp @@ -26,42 +26,15 @@ #include "config.h" #include "ewk_url_response.h" -#include "WKAPICast.h" -#include "WKEinaSharedString.h" -#include "WKURLResponse.h" #include "ewk_url_response_private.h" #include <wtf/text/CString.h> using namespace WebKit; -/** - * \struct _Ewk_Url_Response - * @brief Contains the URL response data. - */ -struct _Ewk_Url_Response { - unsigned int __ref; /**< the reference count of the object */ - WebCore::ResourceResponse coreResponse; - - WKEinaSharedString url; - WKEinaSharedString mimeType; - - _Ewk_Url_Response(const WebCore::ResourceResponse& _coreResponse) - : __ref(1) - , coreResponse(_coreResponse) - , url(AdoptWK, WKURLResponseCopyURL(toAPI(coreResponse))) - , mimeType(AdoptWK, WKURLResponseCopyMIMEType(toAPI(coreResponse))) - { } - - ~_Ewk_Url_Response() - { - ASSERT(!__ref); - } -}; - Ewk_Url_Response* ewk_url_response_ref(Ewk_Url_Response* response) { EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0); - ++response->__ref; + response->ref(); return response; } @@ -70,10 +43,7 @@ void ewk_url_response_unref(Ewk_Url_Response* response) { EINA_SAFETY_ON_NULL_RETURN(response); - if (--response->__ref) - return; - - delete response; + response->deref(); } const char* ewk_url_response_url_get(const Ewk_Url_Response* response) @@ -103,12 +73,3 @@ unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* respon return response->coreResponse.expectedContentLength(); } - -/** - * @internal - * Constructs a Ewk_Url_Response from a WebCore::ResourceResponse. - */ -Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& coreResponse) -{ - return new Ewk_Url_Response(coreResponse); -} 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 32d563fdf..885d32bec 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_response_private.h @@ -26,10 +26,38 @@ #ifndef ewk_url_response_private_h #define ewk_url_response_private_h +#include "WKAPICast.h" +#include "WKEinaSharedString.h" +#include "WKURLResponse.h" #include <WebCore/ResourceResponse.h> +#include <wtf/PassRefPtr.h> -typedef struct _Ewk_Url_Response Ewk_Url_Response; +/** + * \struct _Ewk_Url_Response + * @brief Contains the URL response data. + */ +class _Ewk_Url_Response : public RefCounted<_Ewk_Url_Response> { +public: + WebCore::ResourceResponse coreResponse; + WKEinaSharedString url; + WKEinaSharedString mimeType; + + static PassRefPtr<_Ewk_Url_Response> create(WKURLResponseRef wkResponse) + { + if (!wkResponse) + return 0; -Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& resourceResponse); + return adoptRef(new _Ewk_Url_Response(WebKit::toImpl(wkResponse)->resourceResponse())); + } + +private: + explicit _Ewk_Url_Response(const WebCore::ResourceResponse& _coreResponse) + : coreResponse(_coreResponse) + , url(AdoptWK, WKURLResponseCopyURL(WebKit::toAPI(coreResponse))) + , mimeType(AdoptWK, WKURLResponseCopyMIMEType(WebKit::toAPI(coreResponse))) + { } +}; + +typedef struct _Ewk_Url_Response Ewk_Url_Response; #endif // ewk_url_response_private_h 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 c60c5d2b1..fac36289e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.cpp @@ -27,50 +27,15 @@ #include "ewk_url_scheme_request.h" #include "WKData.h" -#include "WKRetainPtr.h" -#include "WKSoupRequestManager.h" #include "WKString.h" -#include <wtf/text/CString.h> +#include "ewk_url_scheme_request_private.h" using namespace WebKit; -/** - * \struct _Ewk_Url_Scheme_Request - * @brief Contains the URL scheme request data. - */ -struct _Ewk_Url_Scheme_Request { - unsigned int __ref; /**< the reference count of the object */ - WKRetainPtr<WKSoupRequestManagerRef> wkRequestManager; - const char* url; - uint64_t requestID; - const char* scheme; - const char* path; - - _Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, const char* _url, uint64_t _requestID) - : __ref(1) - , wkRequestManager(manager) - , url(eina_stringshare_add(_url)) - , requestID(_requestID) - { - SoupURI* soupURI = soup_uri_new(_url); - scheme = eina_stringshare_add(soupURI->scheme); - path = eina_stringshare_add(soupURI->path); - soup_uri_free(soupURI); - } - - ~_Ewk_Url_Scheme_Request() - { - ASSERT(!__ref); - eina_stringshare_del(url); - eina_stringshare_del(scheme); - eina_stringshare_del(path); - } -}; - Ewk_Url_Scheme_Request* ewk_url_scheme_request_ref(Ewk_Url_Scheme_Request* request) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - ++request->__ref; + request->ref(); return request; } @@ -79,10 +44,7 @@ void ewk_url_scheme_request_unref(Ewk_Url_Scheme_Request* request) { EINA_SAFETY_ON_NULL_RETURN(request); - if (--request->__ref) - return; - - delete request; + request->deref(); } const char* ewk_url_scheme_request_scheme_get(const Ewk_Url_Scheme_Request* request) @@ -106,17 +68,6 @@ const char* ewk_url_scheme_request_path_get(const Ewk_Url_Scheme_Request* reques return request->path; } -/** - * @internal - * Returns the #Ewk_Url_Scheme_Request identifier. - */ -uint64_t ewk_url_scheme_request_id_get(const Ewk_Url_Scheme_Request* request) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(request, 0); - - return request->requestID; -} - Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request* request, const void* contentData, unsigned int contentLength, const char* mimeType) { EINA_SAFETY_ON_NULL_RETURN_VAL(request, false); @@ -129,15 +80,3 @@ Eina_Bool ewk_url_scheme_request_finish(const Ewk_Url_Scheme_Request* request, c return true; } - -/** - * @internal - * Constructs a Ewk_Url_Scheme_Request. - */ -Ewk_Url_Scheme_Request* ewk_url_scheme_request_new(WKSoupRequestManagerRef requestManager, WKURLRef url, uint64_t requestID) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(requestManager, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0); - - return new Ewk_Url_Scheme_Request(requestManager, toImpl(url)->string().utf8().data(), requestID); -} 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 9727590a0..94b502913 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_url_scheme_request.h @@ -38,7 +38,7 @@ extern "C" { #endif /** Creates a type name for _Ewk_Url_Scheme_Request */ -typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; +typedef struct Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; /** * Increases the reference count of the given object. 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 e5dd4174b..8c781022e 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 @@ -26,13 +26,42 @@ #ifndef ewk_url_scheme_request_private_h #define ewk_url_scheme_request_private_h +#include "GOwnPtrSoup.h" +#include "WKAPICast.h" #include "WKBase.h" +#include "WKEinaSharedString.h" +#include "WKRetainPtr.h" +#include "WKSoupRequestManager.h" -typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; -typedef struct _Ewk_Context Ewk_Context; +/** + * \struct _Ewk_Url_Scheme_Request + * @brief Contains the URL scheme request data. + */ +struct Ewk_Url_Scheme_Request : public RefCounted<Ewk_Url_Scheme_Request> { + WKRetainPtr<WKSoupRequestManagerRef> wkRequestManager; + WKEinaSharedString url; + uint64_t requestID; + WKEinaSharedString scheme; + WKEinaSharedString path; + + static PassRefPtr<Ewk_Url_Scheme_Request> create(WKSoupRequestManagerRef manager, WKURLRef url, uint64_t requestID) + { + if (!manager || !url) + return 0; -Ewk_Url_Scheme_Request* ewk_url_scheme_request_new(WKSoupRequestManagerRef, WKURLRef, uint64_t requestID); + return adoptRef(new Ewk_Url_Scheme_Request(manager, url, requestID)); + } -uint64_t ewk_url_scheme_request_id_get(const Ewk_Url_Scheme_Request* request); +private: + Ewk_Url_Scheme_Request(WKSoupRequestManagerRef manager, WKURLRef urlRef, uint64_t requestID) + : wkRequestManager(manager) + , url(urlRef) + , requestID(requestID) + { + GOwnPtr<SoupURI> soupURI(soup_uri_new(url)); + scheme = soupURI->scheme; + path = soupURI->path; + } +}; #endif // ewk_url_scheme_request_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index 10a68c404..95b084e10 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -44,6 +44,8 @@ #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" @@ -52,7 +54,6 @@ #include "ewk_view_private.h" #include "ewk_view_resource_load_client_private.h" #include "ewk_view_ui_client_private.h" -#include "ewk_web_resource.h" #include <Ecore_Evas.h> #include <Edje.h> #include <WebCore/Cursor.h> @@ -64,6 +65,10 @@ #include "WebFullScreenManagerProxy.h" #endif +#if ENABLE(INSPECTOR) +#include "WebInspectorProxy.h" +#endif + #if USE(ACCELERATED_COMPOSITING) #include <Evas_GL.h> #endif @@ -79,8 +84,32 @@ static const char EWK_VIEW_TYPE_STR[] = "EWK2_View"; static const int defaultCursorSize = 16; -typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap; -static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap); +typedef HashMap< uint64_t, RefPtr<Ewk_Resource> > LoadingResourcesMap; +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; @@ -89,18 +118,22 @@ struct _Ewk_View_Private_Data { #endif RefPtr<WebPageProxy> pageProxy; - WKEinaSharedString uri; + WKEinaSharedString url; WKEinaSharedString title; WKEinaSharedString theme; WKEinaSharedString customEncoding; WKEinaSharedString cursorGroup; + WKEinaSharedString faviconURL; Evas_Object* cursorObject; LoadingResourcesMap loadingResourcesMap; - Ewk_Back_Forward_List* backForwardList; + OwnPtr<Ewk_Back_Forward_List> backForwardList; OwnPtr<Ewk_Settings> settings; bool areMouseEventsEnabled; WKColorPickerResultListenerRef colorPickerResultListener; Ewk_Context* context; +#if ENABLE(TOUCH_EVENTS) + bool areTouchEventsEnabled; +#endif WebPopupMenuProxyEfl* popupMenuProxy; Eina_List* popupMenuItems; @@ -117,10 +150,12 @@ struct _Ewk_View_Private_Data { _Ewk_View_Private_Data() : cursorObject(0) - , backForwardList(0) , areMouseEventsEnabled(false) , colorPickerResultListener(0) , context(0) +#if ENABLE(TOUCH_EVENTS) + , areTouchEventsEnabled(false) +#endif , popupMenuProxy(0) , popupMenuItems(0) #ifdef HAVE_ECORE_X @@ -135,16 +170,16 @@ struct _Ewk_View_Private_Data { ~_Ewk_View_Private_Data() { - _ewk_view_priv_loading_resources_clear(loadingResourcesMap); + /* Unregister icon change callback */ + Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(context); + ewk_favicon_database_icon_change_callback_del(iconDatabase, _ewk_view_on_favicon_changed); if (cursorObject) evas_object_del(cursorObject); - ewk_back_forward_list_free(backForwardList); - void* item; EINA_LIST_FREE(popupMenuItems, item) - ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item)); + delete static_cast<Ewk_Popup_Menu_Item*>(item); } }; @@ -216,6 +251,17 @@ 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) { @@ -356,6 +402,65 @@ static void _ewk_view_on_key_up(void* data, Evas*, Evas_Object*, void* eventInfo smartData->api->key_up(smartData, upEvent); } +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); +} + +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); + + // 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); +} + +#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) @@ -373,17 +478,6 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) return priv; } -static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap) -{ - // Clear the loadingResources HashMap. - LoadingResourcesMap::iterator it = loadingResourcesMap.begin(); - LoadingResourcesMap::iterator end = loadingResourcesMap.end(); - for ( ; it != end; ++it) - ewk_web_resource_unref(it->second); - - loadingResourcesMap.clear(); -} - static void _ewk_view_priv_del(Ewk_View_Private_Data* priv) { ewk_context_unref(priv->context); @@ -434,11 +528,14 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel); CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down); CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up); + CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show); + CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide); #undef CONNECT } 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); @@ -530,6 +627,7 @@ bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView) return false; } + priv->viewportHandler->setRendererActive(true); return true; } @@ -562,6 +660,7 @@ 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); Evas_Coord x, y, width, height; + bool needsNewSurface = false; smartData->changed.any = false; @@ -571,19 +670,13 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) #if USE(COORDINATED_GRAPHICS) priv->viewportHandler->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()); -#if USE(ACCELERATED_COMPOSITING) - if (!priv->evasGlSurface) - return; - 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))); -#endif - smartData->view.w = width; smartData->view.h = height; smartData->changed.size = false; @@ -595,6 +688,15 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) smartData->view.y = y; smartData->changed.position = false; } + +#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))); + } +#endif } static void _ewk_view_smart_show(Evas_Object* ewkView) @@ -708,6 +810,9 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->pageProxy = toImpl(ewk_context_WKContext_get(context))->createWebPage(priv->pageClient.get(), toImpl(pageGroupRef)); else priv->pageProxy = toImpl(ewk_context_WKContext_get(context))->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); @@ -715,7 +820,7 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP #endif priv->pageProxy->initializeWebPage(); - priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList())); + 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 = ewk_context_ref(context); @@ -734,6 +839,10 @@ static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKP priv->pageProxy->fullScreenManager()->setWebView(ewkView); ewk_settings_fullscreen_enabled_set(priv->settings.get(), true); #endif + + /* Listen for favicon changes */ + Ewk_Favicon_Database* iconDatabase = ewk_context_favicon_database_get(priv->context); + ewk_favicon_database_icon_change_callback_add(iconDatabase, _ewk_view_on_favicon_changed, ewkView); } static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) @@ -812,11 +921,11 @@ Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView) /** * @internal - * The uri of view was changed by the frame loader. + * The url of view was changed by the frame loader. * - * Emits signal: "uri,changed" with pointer to new uri string. + * Emits signal: "url,changed" with pointer to new url string. */ -void ewk_view_uri_update(Evas_Object* ewkView) +void ewk_view_url_update(Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); @@ -825,32 +934,43 @@ void ewk_view_uri_update(Evas_Object* ewkView) if (activeURL.isEmpty()) return; - if (priv->uri == activeURL.utf8().data()) + if (priv->url == activeURL.utf8().data()) return; - priv->uri = activeURL.utf8().data(); - const char* callbackArgument = static_cast<const char*>(priv->uri); - evas_object_smart_callback_call(ewkView, "uri,changed", const_cast<char*>(callbackArgument)); + 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); } -Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri) +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); - EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(url, false); - priv->pageProxy->loadURL(uri); - ewk_view_uri_update(ewkView); + priv->pageProxy->loadURL(url); + ewk_view_url_update(ewkView); return true; } -const char* ewk_view_uri_get(const Evas_Object* ewkView) +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); - return priv->uri; + return priv->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); + + return priv->faviconURL; } Eina_Bool ewk_view_reload(Evas_Object* ewkView) @@ -859,7 +979,7 @@ Eina_Bool ewk_view_reload(Evas_Object* ewkView) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->pageProxy->reload(/*reloadFromOrigin*/ false); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -870,7 +990,7 @@ Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->pageProxy->reload(/*reloadFromOrigin*/ true); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -899,15 +1019,15 @@ Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView) * * Emits signal: "resource,request,new" with pointer to resource request. */ -void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request) +void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Resource* resource, Ewk_Url_Request* request) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - Ewk_Web_Resource_Request resourceRequest = {resource, request, 0}; + Ewk_Resource_Request resourceRequest = {resource, request, 0}; // Keep the resource internally to reuse it later. - priv->loadingResourcesMap.add(resourceIdentifier, ewk_web_resource_ref(resource)); + priv->loadingResourcesMap.add(resourceIdentifier, resource); evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest); } @@ -926,8 +1046,8 @@ void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIden if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Load_Response resourceLoadResponse = {resource.get(), response}; evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse); } @@ -937,7 +1057,7 @@ void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIden * * Emits signal: "resource,request,finished" with pointer to the resource load error. */ -void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error) +void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Error* error) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); @@ -945,8 +1065,8 @@ void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdenti if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Load_Error resourceLoadError = {resource.get(), error}; evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError); } @@ -964,10 +1084,8 @@ void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIden if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier); - evas_object_smart_callback_call(ewkView, "resource,request,finished", resource); - - ewk_web_resource_unref(resource); + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.take(resourceIdentifier); + evas_object_smart_callback_call(ewkView, "resource,request,finished", resource.get()); } /** @@ -984,8 +1102,8 @@ void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdent if (!priv->loadingResourcesMap.contains(resourceIdentifier)) return; - Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier); - Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse}; + RefPtr<Ewk_Resource> resource = priv->loadingResourcesMap.get(resourceIdentifier); + Ewk_Resource_Request resourceRequest = {resource.get(), request, redirectResponse}; evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest); } @@ -1023,6 +1141,17 @@ 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); +} + double ewk_view_load_progress_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); @@ -1171,7 +1300,7 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); evas_gl_make_current(priv->evasGl, priv->evasGlSurface, priv->evasGlContext); - priv->viewportHandler->display(rect); + priv->viewportHandler->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()); @@ -1207,6 +1336,22 @@ void ewk_view_full_screen_exit(Evas_Object* ewkView) } #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 @@ -1236,7 +1381,7 @@ void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* dow * * 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_Web_Error* 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); @@ -1289,7 +1434,7 @@ Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false); WebPageProxy* page = priv->pageProxy.get(); - page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent))); + page->deliverIntentToFrame(page->mainFrame(), toImpl(intent->wkIntent.get())); return true; #else @@ -1318,7 +1463,7 @@ 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; + return priv->backForwardList.get(); } void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size) @@ -1347,11 +1492,11 @@ void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submiss * @internal * Reports load failed with error information. * - * Emits signal: "load,error" with pointer to Ewk_Web_Error. + * Emits signal: "load,error" with pointer to Ewk_Error. */ -void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error) +void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Error* error) { - evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error)); + evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Error*>(error)); } /** @@ -1362,7 +1507,7 @@ void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error) */ void ewk_view_load_finished(Evas_Object* ewkView) { - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,finished", 0); } @@ -1370,11 +1515,11 @@ void ewk_view_load_finished(Evas_Object* ewkView) * @internal * Reports view provisional load failed with error information. * - * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error. + * Emits signal: "load,provisional,failed" with pointer to Ewk_Error. */ -void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* 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_Web_Error*>(error)); + evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Error*>(error)); } /** @@ -1385,7 +1530,7 @@ void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* */ void ewk_view_load_provisional_redirect(Evas_Object* ewkView) { - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0); } @@ -1402,14 +1547,45 @@ void ewk_view_load_provisional_started(Evas_Object* ewkView) // The main frame started provisional load, we should clear // the loadingResources HashMap to start clean. - _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap); + priv->loadingResourcesMap.clear(); - ewk_view_uri_update(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 = ewk_context_favicon_database_get(priv->context); + 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". @@ -1440,7 +1616,7 @@ Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, cons priv->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); else priv->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); return true; } @@ -1458,6 +1634,13 @@ void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Ser } #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); + + return pageViewMap().get(page); +} + WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); @@ -1517,14 +1700,13 @@ COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOv COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator); COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight); -Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned int maxMatchCount) +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); EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); - WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text)); - WKPageFindString(toAPI(priv->pageProxy.get()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount); + priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } @@ -1534,7 +1716,18 @@ 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); - WKPageHideFindUI(toAPI(priv->pageProxy.get())); + priv->pageProxy->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); + EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); + + priv->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount); return true; } @@ -1573,7 +1766,7 @@ void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* pop 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_new(items[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); @@ -1595,7 +1788,7 @@ Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView) void* item; EINA_LIST_FREE(priv->popupMenuItems, item) - ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item)); + delete static_cast<Ewk_Popup_Menu_Item*>(item); return true; } @@ -1778,3 +1971,85 @@ Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type t return false; #endif } + +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; + + 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); + } + + return true; +#else + return false; +#endif +} + +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); + + return priv->areTouchEventsEnabled; +#else + return false; +#endif +} + +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); + + WebInspectorProxy* inspector = priv->pageProxy->inspector(); + if (inspector) + inspector->show(); + + return true; +#else + return false; +#endif +} + +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); + + WebInspectorProxy* inspector = priv->pageProxy->inspector(); + if (inspector) + inspector->close(); + + return true; +#else + return false; +#endif +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 13f138c87..7d8bb6acb 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -26,6 +26,7 @@ * * The following signals (see evas_object_smart_callback_add()) are emitted: * + * - "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. * - "download,cancelled", Ewk_Download_Job*: reports that a download was effectively cancelled. @@ -42,12 +43,13 @@ * when done to continue with the form submission. If the last reference is removed on a * #Ewk_Form_Submission_Request and the form has not been submitted yet, * ewk_form_submission_request_submit() will be called automatically. + * - "icon,changed", void: reports that the view's favicon has changed. * - "intent,request,new", Ewk_Intent*: reports new Web intent request. * - "intent,service,register", Ewk_Intent_Service*: reports new Web intent service registration. - * - "load,error", const Ewk_Web_Error*: reports main frame load failed. + * - "load,error", const Ewk_Error*: reports main frame load failed. * - "load,finished", void: reports load finished. * - "load,progress", double*: load progress has changed (value from 0.0 to 1.0). - * - "load,provisional,failed", const Ewk_Web_Error*: view provisional load failed. + * - "load,provisional,failed", const Ewk_Error*: view provisional load failed. * - "load,provisional,redirect", void: view received redirect for provisional load. * - "load,provisional,started", void: view started provisional load. * - "policy,decision,navigation", Ewk_Navigation_Policy_Decision*: a navigation policy decision should be taken. @@ -56,14 +58,16 @@ * - "policy,decision,new,window", Ewk_Navigation_Policy_Decision*: a new window policy decision should be taken. * To make a policy decision asynchronously, simply increment the reference count of the * #Ewk_Navigation_Policy_Decision object using ewk_navigation_policy_decision_ref(). - * - "resource,request,failed", const Ewk_Web_Resource_Load_Error*: a resource failed loading. - * - "resource,request,finished", const Ewk_Web_Resource*: a resource finished loading. - * - "resource,request,new", const Ewk_Web_Resource_Request*: a resource request was initiated. - * - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received. - * - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent. + * - "resource,request,failed", const Ewk_Resource_Load_Error*: a resource failed loading. + * - "resource,request,finished", const Ewk_Resource*: a resource finished loading. + * - "resource,request,new", const Ewk_Resource_Request*: a resource request was initiated. + * - "resource,request,response", Ewk_Resource_Load_Response*: a response to a resource request was received. + * - "resource,request,sent", const Ewk_Resource_Request*: a resource request was sent. * - "text,found", unsigned int*: the requested text was found and it gives the number of matches. * - "title,changed", const char*: title of the main frame was changed. - * - "uri,changed", const char*: uri of the main frame was changed. + * - "tooltip,text,set", const char*: tooltip was set. + * - "tooltip,text,unset", void: tooltip was unset. + * - "url,changed", const char*: url of the main frame was changed. * - "webprocess,crashed", Eina_Bool*: expects a @c EINA_TRUE if web process crash is handled; @c EINA_FALSE, otherwise. */ @@ -73,13 +77,13 @@ #include "ewk_back_forward_list.h" #include "ewk_context.h" #include "ewk_download_job.h" +#include "ewk_error.h" #include "ewk_intent.h" +#include "ewk_resource.h" #include "ewk_settings.h" #include "ewk_touch.h" #include "ewk_url_request.h" #include "ewk_url_response.h" -#include "ewk_web_error.h" -#include "ewk_web_resource.h" #include <Evas.h> #ifdef __cplusplus @@ -127,13 +131,17 @@ struct _Ewk_View_Smart_Class { // - 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_dismiss)(Ewk_View_Smart_Data *sd); + + // storage: + // - Web database. + unsigned long long (*exceeded_database_quota)(Ewk_View_Smart_Data *sd, const char *databaseName, const char *displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); }; /** * The version you have to put into the version field * in the @a Ewk_View_Smart_Class structure. */ -#define EWK_VIEW_SMART_CLASS_VERSION 5UL +#define EWK_VIEW_SMART_CLASS_VERSION 6UL /** * Initializer for whole Ewk_View_Smart_Class structure. @@ -145,7 +153,7 @@ struct _Ewk_View_Smart_Class { * @see EWK_VIEW_SMART_CLASS_INIT_VERSION * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION */ -#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /** * Initializer to zero a whole Ewk_View_Smart_Class structure. @@ -197,40 +205,40 @@ struct _Ewk_View_Smart_Data { } changed; }; -/// Creates a type name for _Ewk_Web_Resource_Request. -typedef struct _Ewk_Web_Resource_Request Ewk_Web_Resource_Request; +/// Creates a type name for _Ewk_Resource_Request. +typedef struct _Ewk_Resource_Request Ewk_Resource_Request; /** * @brief Structure containing details about a resource request. */ -struct _Ewk_Web_Resource_Request { - Ewk_Web_Resource *resource; /**< resource being requested */ +struct _Ewk_Resource_Request { + Ewk_Resource *resource; /**< resource being requested */ Ewk_Url_Request *request; /**< URL request for the resource */ Ewk_Url_Response *redirect_response; /**< Possible redirect response for the resource or @c NULL */ }; -/// Creates a type name for _Ewk_Web_Resource_Load_Response. -typedef struct _Ewk_Web_Resource_Load_Response Ewk_Web_Resource_Load_Response; +/// Creates a type name for _Ewk_Resource_Load_Response. +typedef struct _Ewk_Resource_Load_Response Ewk_Resource_Load_Response; /** * @brief Structure containing details about a response to a resource request. */ -struct _Ewk_Web_Resource_Load_Response { - Ewk_Web_Resource *resource; /**< resource requested */ - Ewk_Url_Response *response; /**< resource load response */ +struct _Ewk_Resource_Load_Response { + Ewk_Resource *resource; /**< resource requested */ + Ewk_Url_Response *response; /**< resource load response */ }; -/// Creates a type name for _Ewk_Web_Resource_Load_Error. -typedef struct _Ewk_Web_Resource_Load_Error Ewk_Web_Resource_Load_Error; +/// Creates a type name for _Ewk_Resource_Load_Error. +typedef struct _Ewk_Resource_Load_Error Ewk_Resource_Load_Error; /** * @brief Structure containing details about a resource load error. * * Details given about a resource load failure. */ -struct _Ewk_Web_Resource_Load_Error { - Ewk_Web_Resource *resource; /**< resource that failed loading */ - Ewk_Web_Error *error; /**< load error */ +struct _Ewk_Resource_Load_Error { + Ewk_Resource *resource; /**< resource that failed loading */ + Ewk_Error *error; /**< load error */ }; /// Creates a type name for _Ewk_Download_Job_Error. @@ -241,7 +249,7 @@ typedef struct _Ewk_Download_Job_Error Ewk_Download_Job_Error; */ struct _Ewk_Download_Job_Error { Ewk_Download_Job *download_job; /**< download that failed */ - Ewk_Web_Error *error; /**< download error */ + Ewk_Error *error; /**< download error */ }; /** @@ -329,27 +337,39 @@ EAPI Evas_Object *ewk_view_add_with_context(Evas *e, Ewk_Context *context); EAPI Ewk_Context *ewk_view_context_get(const Evas_Object *o); /** - * Asks the object to load the given URI. + * Asks the object to load the given URL. * - * @param o view object to load @a URI - * @param uri uniform resource identifier to load + * @param o view object to load @a URL + * @param url uniform resource identifier to load * * @return @c EINA_TRUE is returned if @a o is valid, irrespective of load, * or @c EINA_FALSE on failure */ -EAPI Eina_Bool ewk_view_uri_set(Evas_Object *o, const char *uri); +EAPI Eina_Bool ewk_view_url_set(Evas_Object *o, const char *url); /** - * Returns the current URI string of view object. + * Returns the current URL string of view object. * * It returns an internal string and should not * be modified. The string is guaranteed to be stringshared. * - * @param o view object to get current URI + * @param o view object to get current URL * - * @return current URI on success or @c NULL on failure + * @return current URL on success or @c NULL on failure */ -EAPI const char *ewk_view_uri_get(const Evas_Object *o); +EAPI const char *ewk_view_url_get(const Evas_Object *o); + +/** + * Returns the current icon URL of view object. + * + * It returns an internal string and should not + * be modified. The string is guaranteed to be stringshared. + * + * @param o view object to get current icon URL + * + * @return current icon URL on success or @c NULL if unavailable or on failure + */ +EAPI const char *ewk_view_icon_url_get(const Evas_Object *o); /** * Asks the main frame to reload the current document. @@ -613,27 +633,50 @@ EAPI const char *ewk_view_setting_encoding_custom_get(const Evas_Object *o); EAPI Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding); /** -* Searches the given string in the document. -* -* @param o view object to find text -* @param text text to find -* @param options options to find -* @param max count to find, unlimited if 0 -* -* @return @c EINA_TRUE on success, @c EINA_FALSE on errors -*/ -EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned int max_match_count); + * Searches and hightlights the given string in the document. + * + * @param o view object to find text + * @param text text to find + * @param options options to find + * @param max_match_count maximum match count to find, unlimited if 0 + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on errors + */ +EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned max_match_count); /** -* Clears the highlight of searched text. -* -* @param o view object to find text -* -* @return @c EINA_TRUE on success, @c EINA_FALSE on errors -*/ + * Clears the highlight of searched text. + * + * @param o view object to find text + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on errors + */ EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o); /** + * Counts the given string in the document. + * + * This does not highlight the matched string and just count the matched string. + * + * As the search is carried out through the whole document, + * only the following EWK_FIND_OPTIONS are valid. + * - EWK_FIND_OPTIONS_NONE + * - EWK_FIND_OPTIONS_CASE_INSENSITIVE + * - EWK_FIND_OPTIONS_AT_WORD_START + * - EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START + * + * The "text,found" callback will be called with the number of matched string. + * + * @param o view object to find text + * @param text text to find + * @param options options to find + * @param max_match_count maximum match count to find, unlimited if 0 + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on errors + */ +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. @@ -708,6 +751,48 @@ EAPI Eina_Bool ewk_view_color_picker_color_set(Evas_Object *o, int r, int g, int */ EAPI Eina_Bool ewk_view_feed_touch_event(Evas_Object *o, Ewk_Touch_Event_Type type, const Eina_List *points, const Evas_Modifier *modifiers); +/** + * Sets whether the ewk_view supports the touch events or not. + * + * The ewk_view will support the touch events if @c EINA_TRUE or not support the + * touch events otherwise. The default value is @c EINA_FALSE. + * + * @param o view object to enable/disable the touch events + * @param enabled a state to set + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object *o, Eina_Bool enabled); + +/** + * Queries if the ewk_view supports the touch events. + * + * @param o view object to query if the touch events are enabled + * + * @return @c EINA_TRUE if the touch events are enabled or @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object *o); + +/** + * Show the inspector to debug a web page. + * + * @param o The view to show the inspector. + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + * + * @see ewk_settings_developer_extras_enabled_set() + */ +EAPI Eina_Bool ewk_view_inspector_show(Evas_Object *o); + +/** + * Close the inspector + * + * @param o The view to close the inspector. + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_view_inspector_close(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 index 637e7aec2..1edc3cbfd 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp @@ -34,9 +34,19 @@ static inline Evas_Object* toEwkView(const void* clientInfo) return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); } -static void didFindString(WKPageRef, WKStringRef /*string*/, unsigned matchCount, const void* clientInfo) +static void didFindString(WKPageRef, WKStringRef, unsigned matchCount, const void* clientInfo) { - ewk_view_text_found(toEwkView(clientInfo), static_cast<unsigned int>(matchCount)); + 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) @@ -46,5 +56,7 @@ void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView) 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_form_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp index 37cc9bf8f..7509ed96d 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_form_client.cpp @@ -35,9 +35,8 @@ static void willSubmitForm(WKPageRef, WKFrameRef /*frame*/, WKFrameRef /*sourceF { Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - Ewk_Form_Submission_Request* request = ewk_form_submission_request_new(values, listener); - ewk_view_form_submission_request_new(ewkView, request); - ewk_form_submission_request_unref(request); + 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) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp index 997ca35a8..8c7a064a4 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp @@ -28,14 +28,14 @@ #include "WKFrame.h" #include "ewk_back_forward_list_private.h" +#include "ewk_error_private.h" #include "ewk_intent.h" #include "ewk_intent_private.h" #include "ewk_intent_service.h" #include "ewk_intent_service_private.h" #include "ewk_view_loader_client_private.h" #include "ewk_view_private.h" -#include "ewk_web_error.h" -#include "ewk_web_error_private.h" +#include <wtf/OwnPtr.h> #include <wtf/text/CString.h> using namespace WebKit; @@ -53,9 +53,8 @@ static void didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef fra static void didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef intent, WKTypeRef, const void* clientInfo) { Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - Ewk_Intent* ewkIntent = ewk_intent_new(intent); - ewk_view_intent_request_new(ewkView, ewkIntent); - ewk_intent_unref(ewkIntent); + RefPtr<Ewk_Intent> ewkIntent = Ewk_Intent::create(intent); + ewk_view_intent_request_new(ewkView, ewkIntent.get()); } #endif @@ -63,9 +62,8 @@ static void didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef inte static void registerIntentServiceForFrame(WKPageRef, WKFrameRef, WKIntentServiceInfoRef serviceInfo, WKTypeRef, const void *clientInfo) { Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - Ewk_Intent_Service* ewkIntentService = ewk_intent_service_new(serviceInfo); - ewk_view_intent_service_register(ewkView, ewkIntentService); - ewk_intent_service_unref(ewkIntentService); + RefPtr<Ewk_Intent_Service> ewkIntentService = Ewk_Intent_Service::create(serviceInfo); + ewk_view_intent_service_register(ewkView, ewkIntentService.get()); } #endif @@ -90,10 +88,9 @@ static void didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef return; Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - Ewk_Web_Error* ewkError = ewk_web_error_new(error); - ewk_view_load_error(ewkView, ewkError); + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); + ewk_view_load_error(ewkView, ewkError.get()); ewk_view_load_finished(ewkView); - ewk_web_error_free(ewkError); } static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) @@ -120,9 +117,8 @@ static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, return; Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - Ewk_Web_Error* ewkError = ewk_web_error_new(error); - ewk_view_load_provisional_failed(ewkView, ewkError); - ewk_web_error_free(ewkError); + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error); + ewk_view_load_provisional_failed(ewkView, ewkError.get()); } static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) @@ -131,6 +127,7 @@ static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedIt ASSERT(ewkView); ewk_back_forward_list_changed(ewk_view_back_forward_list_get(ewkView), addedItem, removedItems); + ewk_view_back_forward_list_changed(ewkView); } static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo) @@ -139,7 +136,7 @@ static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSam return; Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); - ewk_view_uri_update(ewkView); + ewk_view_url_update(ewkView); } void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp index cf2f10eb4..bdec9f625 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp @@ -44,16 +44,14 @@ static inline Evas_Object* toEwkView(const void* clientInfo) static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef /*userData*/, const void* clientInfo) { - Ewk_Navigation_Policy_Decision* decision = ewk_navigation_policy_decision_new(navigationType, mouseButton, modifiers, request, 0, listener); - ewk_view_navigation_policy_decision(toEwkView(clientInfo), decision); - ewk_navigation_policy_decision_unref(decision); + 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) { - Ewk_Navigation_Policy_Decision* decision = ewk_navigation_policy_decision_new(navigationType, mouseButton, modifiers, request, toImpl(frameName)->string().utf8().data(), listener); - ewk_view_new_window_policy_decision(toEwkView(clientInfo), decision); - ewk_navigation_policy_decision_unref(decision); + 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*/) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index 4cba22d36..64f7e8d5e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -43,8 +43,8 @@ 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_Web_Error Ewk_Web_Error; -typedef struct _Ewk_Web_Resource Ewk_Web_Resource; +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; @@ -56,7 +56,7 @@ typedef struct _Ewk_Intent_Service Ewk_Intent_Service; 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_Web_Error*); +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*); @@ -65,10 +65,10 @@ 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_Web_Error* error); +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_Web_Error* error); +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); @@ -76,14 +76,17 @@ void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Po 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_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error); +void ewk_view_tooltip_text_set(Evas_Object* ewkView, const char* text); +void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Error* error); void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier); -void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request); +void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Resource* resource, Ewk_Url_Request* request); void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response); void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse); void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount); -void ewk_view_uri_update(Evas_Object* ewkView); +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); Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef); @@ -94,6 +97,7 @@ void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkInte 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); @@ -114,4 +118,8 @@ void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, in 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_resource_load_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp index 113e178b9..ce62539d3 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_resource_load_client.cpp @@ -32,16 +32,16 @@ #include "WKURL.h" #include "WKURLRequest.h" #include "WKURLResponse.h" +#include "ewk_error_private.h" +#include "ewk_resource.h" +#include "ewk_resource_private.h" #include "ewk_url_request.h" #include "ewk_url_request_private.h" #include "ewk_url_response.h" #include "ewk_url_response_private.h" #include "ewk_view_private.h" #include "ewk_view_resource_load_client_private.h" -#include "ewk_web_error.h" -#include "ewk_web_error_private.h" -#include "ewk_web_resource.h" -#include "ewk_web_resource_private.h" +#include <wtf/OwnPtr.h> #include <wtf/text/CString.h> using namespace WebCore; @@ -57,28 +57,22 @@ static void didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t r bool isMainResource = (WKFrameIsMainFrame(wkFrame) && pageIsProvisionallyLoading); WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKURLRequestCopyURL(wkRequest)); - Ewk_Web_Resource* resource = ewk_web_resource_new(toImpl(wkUrl.get())->string().utf8().data(), isMainResource); - Ewk_Url_Request* request = ewk_url_request_new(wkRequest); - ewk_view_resource_load_initiated(toEwkView(clientInfo), resourceIdentifier, resource, request); - ewk_web_resource_unref(resource); - ewk_url_request_unref(request); + RefPtr<Ewk_Resource> resource = Ewk_Resource::create(wkUrl.get(), isMainResource); + RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); + ewk_view_resource_load_initiated(toEwkView(clientInfo), resourceIdentifier, resource.get(), request.get()); } static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) { - Ewk_Url_Request* request = ewk_url_request_new(wkRequest); - Ewk_Url_Response* redirectResponse = wkRedirectResponse ? ewk_url_response_new(toImpl(wkRedirectResponse)->resourceResponse()) : 0; - ewk_view_resource_request_sent(toEwkView(clientInfo), resourceIdentifier, request, redirectResponse); - ewk_url_request_unref(request); - if (redirectResponse) - ewk_url_response_unref(redirectResponse); + RefPtr<Ewk_Url_Request> request = Ewk_Url_Request::create(wkRequest); + RefPtr<Ewk_Url_Response> redirectResponse = Ewk_Url_Response::create(wkRedirectResponse); + ewk_view_resource_request_sent(toEwkView(clientInfo), resourceIdentifier, request.get(), redirectResponse.get()); } static void didReceiveResponseForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLResponseRef wkResponse, const void* clientInfo) { - Ewk_Url_Response* response = ewk_url_response_new(toImpl(wkResponse)->resourceResponse()); - ewk_view_resource_load_response(toEwkView(clientInfo), resourceIdentifier, response); - ewk_url_response_unref(response); + RefPtr<Ewk_Url_Response> response = Ewk_Url_Response::create(wkResponse); + ewk_view_resource_load_response(toEwkView(clientInfo), resourceIdentifier, response.get()); } static void didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, const void* clientInfo) @@ -88,10 +82,9 @@ static void didFinishLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIde static void didFailLoadForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKErrorRef wkError, const void* clientInfo) { - Ewk_Web_Error* ewkError = ewk_web_error_new(wkError); - ewk_view_resource_load_failed(toEwkView(clientInfo), resourceIdentifier, ewkError); + OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(wkError); + ewk_view_resource_load_failed(toEwkView(clientInfo), resourceIdentifier, ewkError.get()); ewk_view_resource_load_finished(toEwkView(clientInfo), resourceIdentifier); - ewk_web_error_free(ewkError); } void ewk_view_resource_load_client_attach(WKPageRef pageRef, Evas_Object* ewkView) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp index 6bbf8956c..0f7bd9277 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp @@ -28,6 +28,7 @@ #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) { @@ -73,6 +74,45 @@ static void hideColorPicker(WKPageRef, const void* 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; @@ -84,6 +124,14 @@ void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView) 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; diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp index 1691f0d7c..e02f011ca 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp @@ -50,10 +50,7 @@ void EWK2UnitTestBase::SetUp() unsigned int width = environment->defaultWidth(); unsigned int height = environment->defaultHeight(); - if (environment->useX11Window()) - m_ecoreEvas = ecore_evas_new(0, 0, 0, width, height, 0); - else - m_ecoreEvas = ecore_evas_buffer_new(width, height); + m_ecoreEvas = ecore_evas_new(0, 0, 0, width, height, 0); ecore_evas_show(m_ecoreEvas); Evas* evas = ecore_evas_get(m_ecoreEvas); @@ -74,17 +71,17 @@ void EWK2UnitTestBase::TearDown() ewk_shutdown(); } -void EWK2UnitTestBase::loadUrlSync(const char* url) +bool EWK2UnitTestBase::loadUrlSync(const char* url, double timeoutSeconds) { - ewk_view_uri_set(m_webView, url); - waitUntilLoadFinished(); + ewk_view_url_set(m_webView, url); + return waitUntilLoadFinished(timeoutSeconds); } class CallbackDataTimer { public: - CallbackDataTimer(double timeoutSeconds, Ecore_Task_Cb callback) + explicit CallbackDataTimer(double timeoutSeconds) : m_done(false) - , m_timer(timeoutSeconds >= 0 ? ecore_timer_add(timeoutSeconds, callback, this) : 0) + , m_timer(timeoutSeconds >= 0 ? ecore_timer_add(timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutCallback), this) : 0) , m_didTimeOut(false) { } @@ -108,6 +105,19 @@ public: bool didTimeOut() const { return m_didTimeOut; } +protected: + bool m_done; + Ecore_Timer* m_timer; + bool m_didTimeOut; + +private: + static bool timeOutCallback(void* userData) + { + CallbackDataTimer* data = static_cast<CallbackDataTimer*>(userData); + data->setTimedOut(); + return ECORE_CALLBACK_CANCEL; + } + void setTimedOut() { m_done = true; @@ -115,17 +125,13 @@ public: m_didTimeOut = true; } -protected: - bool m_done; - Ecore_Timer* m_timer; - bool m_didTimeOut; }; template <class T> class CallbackDataExpectedValue : public CallbackDataTimer { public: - CallbackDataExpectedValue(const T& expectedValue, double timeoutSeconds, Ecore_Task_Cb callback) - : CallbackDataTimer(timeoutSeconds, callback) + CallbackDataExpectedValue(const T& expectedValue, double timeoutSeconds) + : CallbackDataTimer(timeoutSeconds) , m_expectedValue(expectedValue) { } @@ -145,17 +151,9 @@ static void onLoadFinished(void* userData, Evas_Object* webView, void* eventInfo data->setDone(); } -static bool timeOutWhileWaitingUntilLoadFinished(void* userData) -{ - CallbackDataTimer* data = static_cast<CallbackDataTimer*>(userData); - data->setTimedOut(); - - return ECORE_CALLBACK_CANCEL; -} - bool EWK2UnitTestBase::waitUntilLoadFinished(double timeoutSeconds) { - CallbackDataTimer data(timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutWhileWaitingUntilLoadFinished)); + CallbackDataTimer data(timeoutSeconds); evas_object_smart_callback_add(m_webView, "load,finished", onLoadFinished, &data); @@ -177,17 +175,9 @@ static void onTitleChanged(void* userData, Evas_Object* webView, void*) data->setDone(); } -static bool timeOutWhileWaitingUntilTitleChangedTo(void* userData) -{ - CallbackDataExpectedValue<CString>* data = static_cast<CallbackDataExpectedValue<CString>*>(userData); - data->setTimedOut(); - - return ECORE_CALLBACK_CANCEL; -} - bool EWK2UnitTestBase::waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds) { - CallbackDataExpectedValue<CString> data(expectedTitle, timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutWhileWaitingUntilTitleChangedTo)); + CallbackDataExpectedValue<CString> data(expectedTitle, timeoutSeconds); evas_object_smart_callback_add(m_webView, "title,changed", onTitleChanged, &data); @@ -199,34 +189,26 @@ bool EWK2UnitTestBase::waitUntilTitleChangedTo(const char* expectedTitle, double return !data.didTimeOut(); } -static void onURIChanged(void* userData, Evas_Object* webView, void*) +static void onURLChanged(void* userData, Evas_Object* webView, void*) { CallbackDataExpectedValue<CString>* data = static_cast<CallbackDataExpectedValue<CString>*>(userData); - if (strcmp(ewk_view_uri_get(webView), data->expectedValue().data())) + if (strcmp(ewk_view_url_get(webView), data->expectedValue().data())) return; data->setDone(); } -static bool timeOutWhileWaitingUntilURIChangedTo(void* userData) -{ - CallbackDataExpectedValue<CString>* data = static_cast<CallbackDataExpectedValue<CString>*>(userData); - data->setTimedOut(); - - return ECORE_CALLBACK_CANCEL; -} - -bool EWK2UnitTestBase::waitUntilURIChangedTo(const char* expectedURI, double timeoutSeconds) +bool EWK2UnitTestBase::waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds) { - CallbackDataExpectedValue<CString> data(expectedURI, timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutWhileWaitingUntilURIChangedTo)); + CallbackDataExpectedValue<CString> data(expectedURL, timeoutSeconds); - evas_object_smart_callback_add(m_webView, "uri,changed", onURIChanged, &data); + evas_object_smart_callback_add(m_webView, "url,changed", onURLChanged, &data); while (!data.isDone()) ecore_main_loop_iterate(); - evas_object_smart_callback_del(m_webView, "uri,changed", onURIChanged); + evas_object_smart_callback_del(m_webView, "url,changed", onURLChanged); return !data.didTimeOut(); } @@ -239,4 +221,38 @@ void EWK2UnitTestBase::mouseClick(int x, int y) evas_event_feed_mouse_up(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0); } +void EWK2UnitTestBase::mouseDown(int x, int y) +{ + Evas* evas = evas_object_evas_get(m_webView); + evas_event_feed_mouse_move(evas, x, y, 0, 0); + evas_event_feed_mouse_down(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0); +} + +void EWK2UnitTestBase::mouseUp(int x, int y) +{ + Evas* evas = evas_object_evas_get(m_webView); + evas_event_feed_mouse_move(evas, x, y, 0, 0); + evas_event_feed_mouse_up(evas, /* Left */ 1, EVAS_BUTTON_NONE, 0, 0); +} + +void EWK2UnitTestBase::mouseMove(int x, int y) +{ + evas_event_feed_mouse_move(evas_object_evas_get(m_webView), x, y, 0, 0); +} + +void EWK2UnitTestBase::multiDown(int id, int x, int y) +{ + evas_event_feed_multi_down(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, EVAS_BUTTON_NONE, 0, 0); +} + +void EWK2UnitTestBase::multiUp(int id, int x, int y) +{ + evas_event_feed_multi_up(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, EVAS_BUTTON_NONE, 0, 0); +} + +void EWK2UnitTestBase::multiMove(int id, int x, int y) +{ + evas_event_feed_multi_move(evas_object_evas_get(m_webView), id, x, y, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h index e1146b198..2ebb95093 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h @@ -40,14 +40,20 @@ protected: virtual void SetUp(); virtual void TearDown(); - void loadUrlSync(const char* url); - static const double defaultTimeoutSeconds = 10.0; + + bool loadUrlSync(const char* url, double timeoutSeconds = defaultTimeoutSeconds); bool waitUntilLoadFinished(double timeoutSeconds = defaultTimeoutSeconds); bool waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds = defaultTimeoutSeconds); - bool waitUntilURIChangedTo(const char* expectedURI, double timeoutSeconds = defaultTimeoutSeconds); + bool waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds = defaultTimeoutSeconds); void mouseClick(int x, int y); + void mouseDown(int x, int y); + void mouseUp(int x, int y); + void mouseMove(int x, int y); + void multiDown(int id, int x, int y); + void multiUp(int id, int x, int y); + void multiMove(int id, int x, int y); private: Evas_Object* m_webView; diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp index 0b7977f54..f9e0f7b73 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp @@ -26,10 +26,9 @@ namespace EWK2UnitTest { -EWK2UnitTestEnvironment::EWK2UnitTestEnvironment(bool useX11Window) +EWK2UnitTestEnvironment::EWK2UnitTestEnvironment() : m_defaultWidth(800) , m_defaultHeight(600) - , m_useX11Window(useX11Window) { } diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h index 4255b01b4..8b401b56a 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h @@ -27,9 +27,8 @@ namespace EWK2UnitTest { class EWK2UnitTestEnvironment : public ::testing::Environment { public: - EWK2UnitTestEnvironment(bool useX11Window); + EWK2UnitTestEnvironment(); - bool useX11Window() const { return m_useX11Window; } const char* defaultTestPageUrl() const; const char* defaultTheme() const; const char* injectedBundleSample() const; @@ -42,8 +41,6 @@ public: private: unsigned int m_defaultWidth; unsigned int m_defaultHeight; - - bool m_useX11Window; }; } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestMain.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestMain.cpp index 06e9c069a..778d261e8 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestMain.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestMain.cpp @@ -26,27 +26,11 @@ using namespace EWK2UnitTest; EWK2UnitTestEnvironment* environment = 0; -static bool parseArguments(int argc, char** argv) -{ - int useX11Window = 0; - - static const option options[] = { - {"useX11Window", no_argument, &useX11Window, 1}, - {0, 0, 0, 0} - }; - - while (getopt_long(argc, argv, "", options, 0) != -1) { } - - return useX11Window; -} - int main(int argc, char** argv) { - bool useX11Window = parseArguments(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - environment = new EWK2UnitTestEnvironment(useX11Window); + environment = new EWK2UnitTestEnvironment(); testing::AddGlobalTestEnvironment(environment); return RUN_ALL_TESTS(); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp index 52e6af46e..4ef4cf76f 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.cpp @@ -27,14 +27,14 @@ EWK2UnitTestServer::EWK2UnitTestServer() soup_address_resolve_sync(address, 0); m_soupServer = soup_server_new(SOUP_SERVER_INTERFACE, address, static_cast<char*>(0)); - m_baseURI = soup_uri_new("http://127.0.0.1/"); - soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer)); + m_baseURL = soup_uri_new("http://127.0.0.1/"); + soup_uri_set_port(m_baseURL, soup_server_get_port(m_soupServer)); g_object_unref(address); } EWK2UnitTestServer::~EWK2UnitTestServer() { - soup_uri_free(m_baseURI); + soup_uri_free(m_baseURL); g_object_unref(m_soupServer); } @@ -44,13 +44,13 @@ void EWK2UnitTestServer::run(SoupServerCallback serverCallback) soup_server_add_handler(m_soupServer, 0, serverCallback, 0, 0); } -CString EWK2UnitTestServer::getURIForPath(const char* path) const +CString EWK2UnitTestServer::getURLForPath(const char* path) const { - SoupURI* soupURI = soup_uri_new_with_base(m_baseURI, path); - char* uri = soup_uri_to_string(soupURI, false); - CString uriString = uri; - free(uri); - soup_uri_free(soupURI); + SoupURI* soupURL = soup_uri_new_with_base(m_baseURL, path); + char* url = soup_uri_to_string(soupURL, false); + CString urlString = url; + free(url); + soup_uri_free(soupURL); - return uriString; + return urlString; } diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h index 3eb146f06..b967ce409 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestServer.h @@ -29,14 +29,12 @@ public: EWK2UnitTestServer(); virtual ~EWK2UnitTestServer(); - SoupURI* baseURI() const { return m_baseURI; } - - CString getURIForPath(const char* path) const; + CString getURLForPath(const char* path) const; void run(SoupServerCallback); private: SoupServer* m_soupServer; - SoupURI* m_baseURI; + SoupURI* m_baseURL; }; #endif // EWK2UnitTestServer_h diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/blank.ico b/Source/WebKit2/UIProcess/API/efl/tests/resources/blank.ico Binary files differnew file mode 100644 index 000000000..ea848b991 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/blank.ico diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test.html new file mode 100644 index 000000000..6367992bb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test.html @@ -0,0 +1,4 @@ +<!doctype html> +<body onload="document.title=document.getElementById('test').offsetWidth;"> +<iframe id="test" src="./frame_flattening_test_subframe.html" width="200" frameborder="0"></iframe> +</body> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test_subframe.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test_subframe.html new file mode 100644 index 000000000..56ef7c9bd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/frame_flattening_test_subframe.html @@ -0,0 +1,11 @@ +<!doctype html> +<head> +<style> +body { +width:600px; +margin:0px; +padding:0px; +} +</style> +</head> +<body></body> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html new file mode 100644 index 000000000..a71fbf976 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html @@ -0,0 +1,31 @@ +<html> +<head> +<script> +function checkFrameLoaded() +{ + var myframe = document.getElementById('myframe'); + var testWindow = myframe.contentWindow; + var state = null; + try { + var state = testWindow.document.readyState; + if (state == "complete") { + document.title = "Frame loaded"; + return; + } + } catch(e) {} + document.title = "Frame NOT loaded"; +} + +function loadFrame() +{ + var myframe = document.getElementById('myframe'); + myframe.src = "default_test_page.html"; + + setTimeout("checkFrameLoaded()", 300); +} +</script> +</head> +<body onload="loadFrame()"> +<iframe id="myframe"></iframe> +</body> +</html> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_uri_to_default.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_url_to_default.html index 846fd1113..846fd1113 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_uri_to_default.html +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/redirect_url_to_default.html diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/spelling_test.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/spelling_test.html new file mode 100644 index 000000000..bf93820f1 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/spelling_test.html @@ -0,0 +1,23 @@ +<!-- + The page contains the input field element which is filled + with the misspelled word to perform spelling. +--> +<HTML> +<HEAD> + <TITLE>Testing Web Page for Spelling</TITLE> + <SCRIPT> + function setInputFieldValue() + { + // The input field has to be focused before typing to it. + document.getElementById("input").focus(); + + // 'Space' notifies WebKit that word has been inserted. + document.getElementById("input").value = "aa "; + } + </SCRIPT> +</HEAD> + +<BODY onload="setInputFieldValue()"> +<INPUT type="text" id="input"> +</BODY> +</HTML> diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/window_move_resize.html b/Source/WebKit2/UIProcess/API/efl/tests/resources/window_move_resize.html new file mode 100644 index 000000000..693ac2ef2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/window_move_resize.html @@ -0,0 +1,15 @@ +<html> +<head> +<title>Window move and resize test</title> +<script> +function test() +{ + window.resizeTo(200, 100); + window.moveTo(150, 200); + document.title = "Moved and resized"; +} +</script> +</head> +<body onload="test()"> +</body> +</html> 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 9542b76f0..80d7755ec 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 @@ -61,19 +61,19 @@ static void serverCallbackNavigation(SoupServer* server, SoupMessage* message, c soup_message_body_complete(message->response_body); } -static inline void checkItem(Ewk_Back_Forward_List_Item* item, const char* title, const char* uri, const char* originalURI) +static inline void checkItem(Ewk_Back_Forward_List_Item* item, const char* title, const char* url, const char* originalURL) { ASSERT_TRUE(item); - EXPECT_STREQ(uri, ewk_back_forward_list_item_uri_get(item)); + EXPECT_STREQ(url, ewk_back_forward_list_item_url_get(item)); EXPECT_STREQ(title, ewk_back_forward_list_item_title_get(item)); - EXPECT_STREQ(originalURI, ewk_back_forward_list_item_original_uri_get(item)); + EXPECT_STREQ(originalURL, ewk_back_forward_list_item_original_url_get(item)); } static inline WKEinaSharedString urlFromTitle(EWK2UnitTestServer* httpServer, const char* title) { Eina_Strbuf* path = eina_strbuf_new(); eina_strbuf_append_printf(path, "/%s", title); - WKEinaSharedString res = httpServer->getURIForPath(eina_strbuf_string_get(path)).data(); + WKEinaSharedString res = httpServer->getURLForPath(eina_strbuf_string_get(path)).data(); eina_strbuf_free(path); return res; @@ -89,7 +89,7 @@ static inline void freeEinaList(Eina_List* list) TEST_F(EWK2UnitTestBase, ewk_back_forward_list_current_item_get) { const char* url = environment->defaultTestPageUrl(); - loadUrlSync(url); + ASSERT_TRUE(loadUrlSync(url)); Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); ASSERT_TRUE(backForwardList); @@ -106,11 +106,11 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_previous_item_get) httpServer->run(serverCallbackNavigation); WKEinaSharedString url1 = urlFromTitle(httpServer.get(), title1); - loadUrlSync(url1); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(url1)); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); - loadUrlSync(urlFromTitle(httpServer.get(), title2)); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title2))); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); ASSERT_TRUE(backForwardList); @@ -127,12 +127,12 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_next_item_get) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallbackNavigation); - loadUrlSync(urlFromTitle(httpServer.get(), title1)); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title1))); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); WKEinaSharedString url2 = urlFromTitle(httpServer.get(), title2); - loadUrlSync(url2); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(url2)); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); // Go back to Page1. ewk_view_back(webView()); @@ -154,11 +154,11 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_item_at_index_get) httpServer->run(serverCallbackNavigation); WKEinaSharedString url1 = urlFromTitle(httpServer.get(), title1); - loadUrlSync(url1); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(url1)); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); - loadUrlSync(urlFromTitle(httpServer.get(), title2)); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title2))); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); ASSERT_TRUE(backForwardList); @@ -178,16 +178,16 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_count) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallbackNavigation); - loadUrlSync(urlFromTitle(httpServer.get(), title1)); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title1))); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); - loadUrlSync(urlFromTitle(httpServer.get(), title2)); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title2))); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); ASSERT_TRUE(backForwardList); - EXPECT_EQ(ewk_back_forward_list_count(backForwardList), 2); + EXPECT_EQ(2, ewk_back_forward_list_count(backForwardList)); } TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_back_items_copy) @@ -196,22 +196,22 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_back_items_copy) httpServer->run(serverCallbackNavigation); WKEinaSharedString url1 = urlFromTitle(httpServer.get(), title1); - loadUrlSync(url1); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(url1)); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); WKEinaSharedString url2 = urlFromTitle(httpServer.get(), title2); - loadUrlSync(url2); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(url2)); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); - loadUrlSync(urlFromTitle(httpServer.get(), title3)); - ASSERT_STREQ(ewk_view_title_get(webView()), title3); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title3))); + ASSERT_STREQ(title3, ewk_view_title_get(webView())); Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); ASSERT_TRUE(backForwardList); Eina_List* backList = ewk_back_forward_list_n_back_items_copy(backForwardList, 1); ASSERT_TRUE(backList); - ASSERT_EQ(eina_list_count(backList), 1); + ASSERT_EQ(1, eina_list_count(backList)); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(backList, 0)), title2, url2, url2); freeEinaList(backList); @@ -221,7 +221,7 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_back_items_copy) backList = ewk_back_forward_list_n_back_items_copy(backForwardList, -1); ASSERT_TRUE(backList); - ASSERT_EQ(eina_list_count(backList), 2); + ASSERT_EQ(2, eina_list_count(backList)); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(backList, 0)), title1, url1, url1); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(backList, 1)), title2, url2, url2); freeEinaList(backList); @@ -232,16 +232,16 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_forward_items_copy) OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallbackNavigation); - loadUrlSync(urlFromTitle(httpServer.get(), title1)); - ASSERT_STREQ(ewk_view_title_get(webView()), title1); + ASSERT_TRUE(loadUrlSync(urlFromTitle(httpServer.get(), title1))); + ASSERT_STREQ(title1, ewk_view_title_get(webView())); WKEinaSharedString url2 = urlFromTitle(httpServer.get(), title2); - loadUrlSync(url2); - ASSERT_STREQ(ewk_view_title_get(webView()), title2); + ASSERT_TRUE(loadUrlSync(url2)); + ASSERT_STREQ(title2, ewk_view_title_get(webView())); WKEinaSharedString url3 = urlFromTitle(httpServer.get(), title3); - loadUrlSync(url3); - ASSERT_STREQ(ewk_view_title_get(webView()), title3); + ASSERT_TRUE(loadUrlSync(url3)); + ASSERT_STREQ(title3, ewk_view_title_get(webView())); // Go back to Page1. ewk_view_back(webView()); @@ -254,7 +254,7 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_forward_items_copy) Eina_List* forwardList = ewk_back_forward_list_n_forward_items_copy(backForwardList, 1); ASSERT_TRUE(forwardList); - ASSERT_EQ(eina_list_count(forwardList), 1); + ASSERT_EQ(1, eina_list_count(forwardList)); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(forwardList, 0)), title2, url2, url2); freeEinaList(forwardList); @@ -264,7 +264,7 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_forward_items_copy) forwardList = ewk_back_forward_list_n_forward_items_copy(backForwardList, -1); ASSERT_TRUE(forwardList); - ASSERT_EQ(eina_list_count(forwardList), 2); + ASSERT_EQ(2, eina_list_count(forwardList)); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(forwardList, 0)), title2, url2, url2); checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(forwardList, 1)), title3, url3, url3); freeEinaList(forwardList); 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 82ded55da..27e46dc1e 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context.cpp @@ -53,22 +53,30 @@ TEST_F(EWK2UnitTestBase, ewk_context_cookie_manager_get) ASSERT_EQ(cookieManager, ewk_context_cookie_manager_get(context)); } +TEST_F(EWK2UnitTestBase, ewk_context_favicon_database_get) +{ + Ewk_Context* context = ewk_view_context_get(webView()); + Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context); + ASSERT_TRUE(faviconDatabase); + ASSERT_EQ(faviconDatabase, ewk_context_favicon_database_get(context)); +} + static void schemeRequestCallback(Ewk_Url_Scheme_Request* request, void* userData) { const char* scheme = ewk_url_scheme_request_scheme_get(request); - ASSERT_STREQ(scheme, "fooscheme"); + ASSERT_STREQ("fooscheme", scheme); const char* url = ewk_url_scheme_request_url_get(request); - ASSERT_STREQ(url, "fooscheme:MyPath"); + ASSERT_STREQ("fooscheme:MyPath", url); const char* path = ewk_url_scheme_request_path_get(request); - ASSERT_STREQ(path, "MyPath"); + ASSERT_STREQ("MyPath", path); ASSERT_TRUE(ewk_url_scheme_request_finish(request, htmlReply, strlen(htmlReply), "text/html")); } -TEST_F(EWK2UnitTestBase, ewk_context_uri_scheme_register) +TEST_F(EWK2UnitTestBase, ewk_context_url_scheme_register) { - ewk_context_uri_scheme_register(ewk_view_context_get(webView()), "fooscheme", schemeRequestCallback, 0); - loadUrlSync("fooscheme:MyPath"); - ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); + ewk_context_url_scheme_register(ewk_view_context_get(webView()), "fooscheme", schemeRequestCallback, 0); + ASSERT_TRUE(loadUrlSync("fooscheme:MyPath")); + ASSERT_STREQ("Foo", ewk_view_title_get(webView())); } struct VibrationCbData { @@ -128,7 +136,7 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) // This case the pattern will cause the device to vibrate for 200 ms, be still for 100 ms, and then vibrate for 5000 ms. loadVibrationHTMLString(webView(), "[200, 100, 5000]", true, &data); - ASSERT_EQ(data.vibrateCalledCount, 2); + ASSERT_EQ(2, data.vibrateCalledCount); ASSERT_TRUE(data.didReceiveVibrateCallback); // Cancel outstanding vibration pattern. @@ -141,16 +149,32 @@ TEST_F(EWK2UnitTestBase, ewk_context_vibration_client_callbacks_set) // Make sure we don't receive vibration event. loadVibrationHTMLString(webView(), "[5000]", false, &data); ASSERT_TRUE(waitUntilTitleChangedTo("Loaded")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Loaded"); + ASSERT_STREQ("Loaded", ewk_view_title_get(webView())); ASSERT_FALSE(data.didReceiveVibrateCallback); // Make sure we don't receive cancel vibration event. loadVibrationHTMLString(webView(), "0", false, &data); ASSERT_TRUE(waitUntilTitleChangedTo("Loaded")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Loaded"); + ASSERT_STREQ("Loaded", ewk_view_title_get(webView())); ASSERT_FALSE(data.didReceiveCancelVibrationCallback); } +TEST_F(EWK2UnitTestBase, ewk_context_cache_model) +{ + Ewk_Context* context = ewk_view_context_get(webView()); + + ASSERT_EQ(EWK_CACHE_MODEL_DOCUMENT_VIEWER, ewk_context_cache_model_get(context)); + + ASSERT_TRUE(ewk_context_cache_model_set(context, EWK_CACHE_MODEL_DOCUMENT_BROWSER)); + ASSERT_EQ(EWK_CACHE_MODEL_DOCUMENT_BROWSER, ewk_context_cache_model_get(context)); + + ASSERT_TRUE(ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER)); + ASSERT_EQ(EWK_CACHE_MODEL_PRIMARY_WEBBROWSER, ewk_context_cache_model_get(context)); + + ASSERT_TRUE(ewk_context_cache_model_set(context, EWK_CACHE_MODEL_DOCUMENT_VIEWER)); + ASSERT_EQ(EWK_CACHE_MODEL_DOCUMENT_VIEWER, ewk_context_cache_model_get(context)); +} + TEST_F(EWK2UnitTestBase, ewk_context_new) { Ewk_Context* context = ewk_context_new(); @@ -172,3 +196,4 @@ TEST_F(EWK2UnitTestBase, ewk_context_ref) ewk_context_unref(context); ewk_context_unref(context); } + diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_history_callbacks.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_history_callbacks.cpp new file mode 100644 index 000000000..f60a16c2f --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_context_history_callbacks.cpp @@ -0,0 +1,183 @@ +/* + * 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 <gtest/gtest.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static const char defaultTitle[] = "Default Testing Web Page"; + +static const char toBeRedirectedPath[] = "/some_page_to_be_redirected"; +static const char redirectionTargetPath[] = "/redirection_target"; + +static EWK2UnitTestServer* httpServer() +{ + static EWK2UnitTestServer* server = 0; + + if (!server) + server = new EWK2UnitTestServer; + + return server; +} + +#define DECLARE_INVOKE_FLAG(functionName) \ + static bool functionName##Invoked = false; + +#define WAS_INVOKED(functionName) \ + if (functionName##Invoked) \ + return; \ + functionName##Invoked = true + +#define CHECK_WAS_INVOKED(functionName) \ + ASSERT_TRUE(functionName##Invoked) + +DECLARE_INVOKE_FLAG(navigateWithNavigationData) +DECLARE_INVOKE_FLAG(performClientRedirect) +DECLARE_INVOKE_FLAG(performServerRedirect) +DECLARE_INVOKE_FLAG(updateHistoryTitle) +DECLARE_INVOKE_FLAG(populateVisitedLinks) + +static void navigateWithNavigationData(const Evas_Object* view, Ewk_Navigation_Data* navigationData, void* userData) +{ + WAS_INVOKED(navigateWithNavigationData); + + EWK2UnitTestBase* unitTest = static_cast<EWK2UnitTestBase*>(userData); + ASSERT_TRUE(unitTest); + ASSERT_EQ(unitTest->webView(), view); + // FIXME: WebFrameLoaderClient sends empty title. + // ASSERT_STREQ(defaultTitle, ewk_navigation_data_title_get(navigationData)); + ASSERT_STREQ(environment->defaultTestPageUrl(), ewk_navigation_data_url_get(navigationData)); + + Ewk_Url_Request* request = ewk_navigation_data_original_request_get(navigationData); + ASSERT_STREQ("GET", ewk_url_request_http_method_get(request)); + ASSERT_STREQ(environment->defaultTestPageUrl(), ewk_url_request_url_get(request)); + ASSERT_EQ(0, ewk_request_cookies_first_party_get(request)); +} + +static void performClientRedirect(const Evas_Object* view, const char* sourceUrl, const char* destinationUrl, void* userData) +{ + WAS_INVOKED(performClientRedirect); + + EWK2UnitTestBase* unitTest = static_cast<EWK2UnitTestBase*>(userData); + ASSERT_TRUE(unitTest); + ASSERT_EQ(unitTest->webView(), view); + ASSERT_STREQ(environment->urlForResource("redirect_url_to_default.html").data(), sourceUrl); + ASSERT_STREQ(environment->defaultTestPageUrl(), destinationUrl); +} + +static void performServerRedirect(const Evas_Object* view, const char* sourceUrl, const char* destinationUrl, void* userData) +{ + WAS_INVOKED(performServerRedirect); + + EWK2UnitTestBase* unitTest = static_cast<EWK2UnitTestBase*>(userData); + ASSERT_TRUE(unitTest); + ASSERT_EQ(unitTest->webView(), view); + ASSERT_STREQ(httpServer()->getURLForPath(toBeRedirectedPath).data(), sourceUrl); + ASSERT_STREQ(httpServer()->getURLForPath(redirectionTargetPath).data(), destinationUrl); +} + +static void updateHistoryTitle(const Evas_Object* view, const char* title, const char* url, void* userData) +{ + WAS_INVOKED(updateHistoryTitle); + + EWK2UnitTestBase* unitTest = static_cast<EWK2UnitTestBase*>(userData); + ASSERT_TRUE(unitTest); + ASSERT_EQ(unitTest->webView(), view); + ASSERT_STREQ(defaultTitle, title); + ASSERT_STREQ(environment->defaultTestPageUrl(), url); +} + +static void populateVisitedLinks(void* userData) +{ + WAS_INVOKED(populateVisitedLinks); + + EWK2UnitTestBase* unitTest = static_cast<EWK2UnitTestBase*>(userData); + ASSERT_TRUE(unitTest); +} + +static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*) +{ + int* countLoadFinished = static_cast<int*>(userData); + --(*countLoadFinished); +} + +static void serverCallbackRedirection(SoupServer*, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + if (strcmp(path, redirectionTargetPath)) { // Redirect if 'path' is not equal to 'redirectionTargetPath'. + soup_message_set_status(message, SOUP_STATUS_TEMPORARY_REDIRECT); + soup_message_headers_append(message->response_headers, "Location", httpServer()->getURLForPath(redirectionTargetPath).data()); + return; + } + + soup_message_set_status(message, SOUP_STATUS_OK); + Eina_Strbuf* body = eina_strbuf_new(); + eina_strbuf_append_printf(body, "<html><title>Redirection Target</title></html>"); + const size_t bodyLength = eina_strbuf_length_get(body); + soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, eina_strbuf_string_steal(body), bodyLength); + eina_strbuf_free(body); + + soup_message_body_complete(message->response_body); +} + +TEST_F(EWK2UnitTestBase, ewk_context_history_callbacks_set) +{ + ewk_context_history_callbacks_set(ewk_view_context_get(webView()), navigateWithNavigationData, performClientRedirect, performServerRedirect, updateHistoryTitle, populateVisitedLinks, this); + + // Test navigation. + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + CHECK_WAS_INVOKED(navigateWithNavigationData); + CHECK_WAS_INVOKED(updateHistoryTitle); + CHECK_WAS_INVOKED(populateVisitedLinks); + + // Test client redirect. + int countLoadFinished = 2; + evas_object_smart_callback_add(webView(), "load,finished", onLoadFinishedForRedirection, &countLoadFinished); + ewk_view_url_set(webView(), environment->urlForResource("redirect_url_to_default.html").data()); + while (countLoadFinished) + ecore_main_loop_iterate(); + evas_object_smart_callback_del(webView(), "load,finished", onLoadFinishedForRedirection); + CHECK_WAS_INVOKED(performClientRedirect); + + // Test server redirect. + httpServer()->run(serverCallbackRedirection); + + ASSERT_TRUE(loadUrlSync(httpServer()->getURLForPath(toBeRedirectedPath).data())); + CHECK_WAS_INVOKED(performServerRedirect); +} + diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp index 4353ced79..6d00b8bf3 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp @@ -61,11 +61,12 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* } else if (!strcmp(path, "/image.png")) soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60"); else - FAIL(); + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); } -static void getAcceptPolicyCallback(Ewk_Cookie_Accept_Policy policy, Ewk_Web_Error* error, void* event_info) +static void getAcceptPolicyCallback(Ewk_Cookie_Accept_Policy policy, Ewk_Error* error, void* event_info) { ASSERT_FALSE(error); Ewk_Cookie_Accept_Policy* ret = static_cast<Ewk_Cookie_Accept_Policy*>(event_info); @@ -81,7 +82,7 @@ static Ewk_Cookie_Accept_Policy getAcceptPolicy(Ewk_Cookie_Manager* manager) return policy; } -static void getHostnamesWithCookiesCallback(Eina_List* hostnames, Ewk_Web_Error* error, void* event_info) +static void getHostnamesWithCookiesCallback(Eina_List* hostnames, Ewk_Error* error, void* event_info) { ASSERT_FALSE(error); @@ -116,6 +117,11 @@ static int countHostnamesWithCookies(Ewk_Cookie_Manager* manager) return count; } +static int compareHostNames(const void* hostName1, const void* hostName2) +{ + return strcmp(static_cast<const char*>(hostName1), static_cast<const char*>(hostName2)); +} + TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy) { OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); @@ -125,32 +131,33 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_accept_policy) ASSERT_TRUE(cookieManager); // Default policy is EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY. - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY, getAcceptPolicy(cookieManager)); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); Eina_List* hostnames = getHostnamesWithCookies(cookieManager); - ASSERT_EQ(eina_list_count(hostnames), 1); - ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN); + ASSERT_EQ(1, eina_list_count(hostnames)); + ASSERT_STREQ(FIRST_PARTY_DOMAIN, static_cast<char*>(eina_list_nth(hostnames, 0))); freeHostNames(hostnames); ewk_cookie_manager_cookies_clear(cookieManager); // Change policy to EWK_COOKIE_ACCEPT_POLICY_ALWAYS ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, getAcceptPolicy(cookieManager)); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); hostnames = getHostnamesWithCookies(cookieManager); - ASSERT_EQ(eina_list_count(hostnames), 2); - ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), FIRST_PARTY_DOMAIN); - ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 1)), THIRD_PARTY_DOMAIN); + ASSERT_EQ(2, eina_list_count(hostnames)); + hostnames = eina_list_sort(hostnames, eina_list_count(hostnames), compareHostNames); + ASSERT_STREQ(FIRST_PARTY_DOMAIN, static_cast<char*>(eina_list_nth(hostnames, 0))); + ASSERT_STREQ(THIRD_PARTY_DOMAIN, static_cast<char*>(eina_list_nth(hostnames, 1))); freeHostNames(hostnames); ewk_cookie_manager_cookies_clear(cookieManager); // Change policy to EWK_COOKIE_ACCEPT_POLICY_NEVER ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_NEVER); - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_NEVER); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_NEVER, getAcceptPolicy(cookieManager)); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); } void onCookiesChanged(void *eventInfo) @@ -168,14 +175,14 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch) ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, getAcceptPolicy(cookieManager)); // Watch for changes bool cookiesChanged = false; ewk_cookie_manager_changes_watch(cookieManager, onCookiesChanged, &cookiesChanged); // Check for cookie changes notifications - loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); while (!cookiesChanged) ecore_main_loop_iterate(); @@ -190,8 +197,8 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch) // Stop watching for notifications ewk_cookie_manager_changes_watch(cookieManager, 0, 0); cookiesChanged = false; - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); ASSERT_FALSE(cookiesChanged); // Watch again for notifications @@ -204,15 +211,15 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_changes_watch) ASSERT_TRUE(mktemp(textStorage2)); ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage1, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); cookiesChanged = false; ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage2, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage1, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); ASSERT_FALSE(cookiesChanged); @@ -231,31 +238,31 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete) ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, getAcceptPolicy(cookieManager)); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); Eina_List* hostnames = getHostnamesWithCookies(cookieManager); - ASSERT_EQ(eina_list_count(hostnames), 2); + ASSERT_EQ(2, eina_list_count(hostnames)); freeHostNames(hostnames); // Delete first party cookie ewk_cookie_manager_hostname_cookies_clear(cookieManager, FIRST_PARTY_DOMAIN); hostnames = getHostnamesWithCookies(cookieManager); - ASSERT_EQ(eina_list_count(hostnames), 1); - ASSERT_STREQ(static_cast<char*>(eina_list_nth(hostnames, 0)), THIRD_PARTY_DOMAIN); + ASSERT_EQ(1, eina_list_count(hostnames)); + ASSERT_STREQ(THIRD_PARTY_DOMAIN, static_cast<char*>(eina_list_nth(hostnames, 0))); freeHostNames(hostnames); // Delete third party cookie ewk_cookie_manager_hostname_cookies_clear(cookieManager, THIRD_PARTY_DOMAIN); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); // Get all cookies again - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); // Clear all cookies ewk_cookie_manager_cookies_clear(cookieManager); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); } TEST_F(EWK2UnitTestBase, DISABLED_ewk_cookie_manager_permanent_storage) @@ -273,33 +280,33 @@ TEST_F(EWK2UnitTestBase, DISABLED_ewk_cookie_manager_permanent_storage) ASSERT_TRUE(cookieManager); ewk_cookie_manager_accept_policy_set(cookieManager, EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - ASSERT_EQ(getAcceptPolicy(cookieManager), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + ASSERT_EQ(EWK_COOKIE_ACCEPT_POLICY_ALWAYS, getAcceptPolicy(cookieManager)); // Text storage using a new file. ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); // SQLite storage using a new file. ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); - loadUrlSync(httpServer->getURIForPath("/index.html").data()); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data())); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); // Text storage using an existing file. ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); ewk_cookie_manager_cookies_clear(cookieManager); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); // SQLite storage with an existing file. ewk_cookie_manager_persistent_storage_set(cookieManager, sqliteStorage, EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 2); + ASSERT_EQ(2, countHostnamesWithCookies(cookieManager)); ewk_cookie_manager_cookies_clear(cookieManager); - ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); + ASSERT_EQ(0, countHostnamesWithCookies(cookieManager)); // Final clean up. unlink(textStorage); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp index 22c97aad8..1494926e2 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp @@ -102,23 +102,23 @@ static void on_download_requested(void* userData, Evas_Object* webview, void* ev { DownloadTestData* testData = static_cast<DownloadTestData*>(userData); Ewk_Download_Job* download = static_cast<Ewk_Download_Job*>(eventInfo); - ASSERT_EQ(ewk_download_job_state_get(download), EWK_DOWNLOAD_JOB_STATE_NOT_STARTED); - ASSERT_EQ(ewk_download_job_estimated_progress_get(download), 0); - ASSERT_EQ(ewk_download_job_elapsed_time_get(download), 0); + ASSERT_EQ(EWK_DOWNLOAD_JOB_STATE_NOT_STARTED, ewk_download_job_state_get(download)); + ASSERT_EQ(0, ewk_download_job_estimated_progress_get(download)); + ASSERT_EQ(0, ewk_download_job_elapsed_time_get(download)); Ewk_Url_Request* request = ewk_download_job_request_get(download); ASSERT_TRUE(request); - EXPECT_STREQ(ewk_url_request_url_get(request), testData->fileUrl); + EXPECT_STREQ(testData->fileUrl, ewk_url_request_url_get(request)); Ewk_Url_Response* response = ewk_download_job_response_get(download); ASSERT_TRUE(response); - EXPECT_STREQ(ewk_url_response_mime_type_get(response), "application/pdf"); + EXPECT_STREQ("application/pdf", ewk_url_response_mime_type_get(response)); - EXPECT_STREQ(ewk_download_job_suggested_filename_get(download), serverSuggestedFilename); + EXPECT_STREQ(serverSuggestedFilename, ewk_download_job_suggested_filename_get(download)); ASSERT_FALSE(fileExists(testData->destinationPath)); ewk_download_job_destination_set(download, testData->destinationPath); - EXPECT_STREQ(ewk_download_job_destination_get(download), testData->destinationPath); + EXPECT_STREQ(testData->destinationPath, ewk_download_job_destination_get(download)); } static void on_download_cancelled(void* userData, Evas_Object* webview, void* eventInfo) @@ -131,7 +131,7 @@ static void on_download_cancelled(void* userData, Evas_Object* webview, void* ev static void on_download_failed(void* userData, Evas_Object* webview, void* eventInfo) { Ewk_Download_Job_Error* downloadError = static_cast<Ewk_Download_Job_Error*>(eventInfo); - fprintf(stderr, "Download error: %s\n", ewk_web_error_description_get(downloadError->error)); + fprintf(stderr, "Download error: %s\n", ewk_error_description_get(downloadError->error)); ecore_main_loop_quit(); FAIL(); } @@ -141,8 +141,8 @@ static void on_download_finished(void* userData, Evas_Object* webview, void* eve DownloadTestData* testData = static_cast<DownloadTestData*>(userData); Ewk_Download_Job* download = static_cast<Ewk_Download_Job*>(eventInfo); - ASSERT_EQ(ewk_download_job_estimated_progress_get(download), 1); - ASSERT_EQ(ewk_download_job_state_get(download), EWK_DOWNLOAD_JOB_STATE_FINISHED); + ASSERT_EQ(1, ewk_download_job_estimated_progress_get(download)); + ASSERT_EQ(EWK_DOWNLOAD_JOB_STATE_FINISHED, ewk_download_job_state_get(download)); ASSERT_GT(ewk_download_job_elapsed_time_get(download), 0); ASSERT_TRUE(fileExists(testData->destinationPath)); @@ -159,7 +159,7 @@ TEST_F(EWK2UnitTestBase, ewk_download) char destinationPath[] = "/tmp/pdf-file.XXXXXX"; ASSERT_TRUE(mktemp(destinationPath)); - CString fileUrl = httpServer->getURIForPath(testFilePath); + CString fileUrl = httpServer->getURLForPath(testFilePath); DownloadTestData userData = { fileUrl.data(), destinationPath }; ASSERT_FALSE(fileExists(destinationPath)); @@ -170,7 +170,7 @@ TEST_F(EWK2UnitTestBase, ewk_download) evas_object_smart_callback_add(webView(), "download,finished", on_download_finished, &userData); // Download test pdf - ewk_view_uri_set(webView(), fileUrl.data()); + ewk_view_url_set(webView(), fileUrl.data()); ecore_main_loop_begin(); // Clean up 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 new file mode 100644 index 000000000..7a57b9122 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp @@ -0,0 +1,169 @@ +/* + * 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 <EWebKit2.h> +#include <Ecore.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static void serverCallback(SoupServer* httpServer, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + if (!strcmp(path, "/favicon.ico")) { + CString faviconPath = environment->pathForResource("blank.ico"); + Eina_File* f = eina_file_open(faviconPath.data(), false); + if (!f) { + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); + return; + } + + size_t fileSize = eina_file_size_get(f); + + void* contents = eina_file_map_all(f, EINA_FILE_POPULATE); + if (!contents) { + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); + return; + } + + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, contents, fileSize); + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_complete(message->response_body); + + eina_file_map_free(f, contents); + eina_file_close(f); + return; + } + + const char contents[] = "<html><body>favicon test</body></html>"; + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, contents, strlen(contents)); + soup_message_body_complete(message->response_body); +} + +static void onIconChanged(void* userData, Evas_Object*, void* eventInfo) +{ + bool* iconChanged = static_cast<bool*>(userData); + *iconChanged = true; +} + +TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + bool iconChanged = false; + evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged); + + // We need to load the page first to ensure the icon data will be + // in the database in case there's an associated favicon. + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/").data())); + + while (!iconChanged) + ecore_main_loop_iterate(); + + ASSERT_TRUE(iconChanged); + 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); + + CString expectedFaviconURL = httpServer->getURLForPath("/favicon.ico"); + WKEinaSharedString iconURL = ewk_favicon_database_icon_url_get(faviconDatabase, ewk_view_url_get(webView())); + EXPECT_STREQ(expectedFaviconURL.data(), iconURL); + + const char* viewIconURL = ewk_view_icon_url_get(webView()); + EXPECT_STREQ(expectedFaviconURL.data(), viewIconURL); +} + +static void onIconDataReady(const char* page_url, Evas_Object* icon, void* event_info) +{ + Evas_Object** returnIcon = static_cast<Evas_Object**>(event_info); + if (icon) + evas_object_ref(icon); + *returnIcon = icon; +} + +struct IconRequestData { + Evas_Object* view; + Evas_Object* icon; +}; + +static void requestFaviconData(void* userData, Evas_Object*, void* eventInfo) +{ + IconRequestData* data = static_cast<IconRequestData*>(userData); + + // Check the API retrieving a valid favicon. + Ewk_Context* context = ewk_view_context_get(data->view); + Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context); + ASSERT_TRUE(faviconDatabase); + + Evas* evas = evas_object_evas_get(data->view); + ASSERT_TRUE(ewk_favicon_database_async_icon_get(faviconDatabase, ewk_view_url_get(data->view), evas, onIconDataReady, &data->icon)); +} + +TEST_F(EWK2UnitTestBase, ewk_favicon_database_async_icon_get) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallback); + + IconRequestData data = { webView(), 0 }; + evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data); + + // We need to load the page first to ensure the icon data will be + // in the database in case there's an associated favicon. + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/").data())); + + while (!data.icon) + ecore_main_loop_iterate(); + + ASSERT_TRUE(data.icon); + evas_object_smart_callback_del(webView(), "icon,changed", requestFaviconData); + + // It is a 16x16 favicon. + int width, height; + evas_object_image_size_get(data.icon, &width, &height); + EXPECT_EQ(16, width); + EXPECT_EQ(16, height); + + evas_object_unref(data.icon); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_intents.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_intents.cpp index be8b0ffa8..4b46cd883 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_intents.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_intents.cpp @@ -43,18 +43,18 @@ static void onIntentServiceRegistration(void* userData, Evas_Object*, void* even Ewk_Intent_Service* service = static_cast<Ewk_Intent_Service*>(eventInfo); ASSERT_TRUE(service); - EXPECT_STREQ(ewk_intent_service_action_get(service), "action"); - EXPECT_STREQ(ewk_intent_service_type_get(service), "type"); - EXPECT_STREQ(ewk_intent_service_title_get(service), "Title"); - EXPECT_STREQ(ewk_intent_service_href_get(service), "http://example.com/service"); - EXPECT_STREQ(ewk_intent_service_disposition_get(service), "inline"); + EXPECT_STREQ("action", ewk_intent_service_action_get(service)); + EXPECT_STREQ("type", ewk_intent_service_type_get(service)); + EXPECT_STREQ("Title", ewk_intent_service_title_get(service)); + EXPECT_STREQ("http://example.com/service", ewk_intent_service_href_get(service)); + EXPECT_STREQ("inline", ewk_intent_service_disposition_get(service)); } TEST_F(EWK2UnitTestBase, ewk_intent_service_registration) { bool intentRegistered = false; evas_object_smart_callback_add(webView(), "intent,service,register", onIntentServiceRegistration, &intentRegistered); - loadUrlSync(environment->urlForResource("intent-service.html").data()); + ASSERT_TRUE(loadUrlSync(environment->urlForResource("intent-service.html").data())); evas_object_smart_callback_del(webView(), "intent,service,register", onIntentServiceRegistration); ASSERT_TRUE(intentRegistered); } @@ -76,22 +76,22 @@ static void onIntentReceived(void* userData, Evas_Object*, void* eventInfo) if (*intentReceivedCount == 1) { // First intent. - EXPECT_STREQ(ewk_intent_action_get(intent), "action1"); - EXPECT_STREQ(ewk_intent_type_get(intent), "mime/type1"); - EXPECT_STREQ(ewk_intent_service_get(intent), "http://service1.com/"); - EXPECT_STREQ(ewk_intent_extra_get(intent, "key1"), "value1"); - EXPECT_STREQ(ewk_intent_extra_get(intent, "key2"), "value2"); + EXPECT_STREQ("action1", ewk_intent_action_get(intent)); + EXPECT_STREQ("mime/type1", ewk_intent_type_get(intent)); + EXPECT_STREQ("http://service1.com/", ewk_intent_service_get(intent)); + EXPECT_STREQ("value1", ewk_intent_extra_get(intent, "key1")); + EXPECT_STREQ("value2", ewk_intent_extra_get(intent, "key2")); } else { // Second intent. - EXPECT_STREQ(ewk_intent_action_get(intent), "action2"); - EXPECT_STREQ(ewk_intent_type_get(intent), "mime/type2"); + EXPECT_STREQ("action2", ewk_intent_action_get(intent)); + EXPECT_STREQ("mime/type2", ewk_intent_type_get(intent)); Eina_List* suggestions = ewk_intent_suggestions_get(intent); ASSERT_TRUE(suggestions); - ASSERT_EQ(eina_list_count(suggestions), 2); + ASSERT_EQ(2, eina_list_count(suggestions)); // We need to sort the suggestions since Intent is using a HashSet internally. suggestions = eina_list_sort(suggestions, 2, stringSortCb); - EXPECT_STREQ(static_cast<const char*>(eina_list_nth(suggestions, 0)), "http://service1.com/"); - EXPECT_STREQ(static_cast<const char*>(eina_list_nth(suggestions, 1)), "http://service2.com/"); + EXPECT_STREQ("http://service1.com/", static_cast<const char*>(eina_list_nth(suggestions, 0))); + EXPECT_STREQ("http://service2.com/", static_cast<const char*>(eina_list_nth(suggestions, 1))); void* listData = 0; EINA_LIST_FREE(suggestions, listData) @@ -103,18 +103,18 @@ TEST_F(EWK2UnitTestBase, ewk_intent_request) { unsigned intentReceivedCount = 0; evas_object_smart_callback_add(webView(), "intent,request,new", onIntentReceived, &intentReceivedCount); - loadUrlSync(environment->urlForResource("intent-request.html").data()); + ASSERT_TRUE(loadUrlSync(environment->urlForResource("intent-request.html").data())); // A user gesture is required for the intent to start. mouseClick(5, 5); while (intentReceivedCount != 1) ecore_main_loop_iterate(); - ASSERT_EQ(intentReceivedCount, 1); + ASSERT_EQ(1, intentReceivedCount); // Generate a second intent request. mouseClick(5, 5); while (intentReceivedCount != 2) ecore_main_loop_iterate(); - ASSERT_EQ(intentReceivedCount, 2); + ASSERT_EQ(2, intentReceivedCount); evas_object_smart_callback_del(webView(), "intent,request,new", onIntentReceived); } diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp index fb6e57269..939d20c6d 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_refptr_evas_object.cpp @@ -65,14 +65,14 @@ TEST_F(EWK2UnitTestBase, reffing) RefPtr<Evas_Object> object = adoptRef(evas_object_box_add(canvas())); ASSERT_TRUE(object); // Evas_Objec external ref count is not as you would expect. - ASSERT_EQ(evas_object_ref_get(object.get()), 0); + ASSERT_EQ(0, evas_object_ref_get(object.get())); { RefPtr<Evas_Object> aRef = object; ASSERT_TRUE(object); ASSERT_TRUE(aRef); - ASSERT_EQ(evas_object_ref_get(object.get()), 1); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 1); + ASSERT_EQ(1, evas_object_ref_get(object.get())); + ASSERT_EQ(1, evas_object_ref_get(aRef.get())); { RefPtr<Evas_Object> bRef = object; @@ -81,51 +81,51 @@ TEST_F(EWK2UnitTestBase, reffing) ASSERT_TRUE(aRef); ASSERT_TRUE(bRef); - ASSERT_EQ(evas_object_ref_get(object.get()), 2); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 2); + ASSERT_EQ(2, evas_object_ref_get(object.get())); + ASSERT_EQ(2, evas_object_ref_get(aRef.get())); RefPtr<Evas_Object> cRef = bRef; ASSERT_TRUE(cRef); - ASSERT_EQ(evas_object_ref_get(object.get()), 3); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 3); - ASSERT_EQ(evas_object_ref_get(bRef.get()), 3); - ASSERT_EQ(evas_object_ref_get(cRef.get()), 3); + ASSERT_EQ(3, evas_object_ref_get(object.get())); + ASSERT_EQ(3, evas_object_ref_get(aRef.get())); + ASSERT_EQ(3, evas_object_ref_get(bRef.get())); + ASSERT_EQ(3, evas_object_ref_get(cRef.get())); bRef.clear(); - ASSERT_EQ(evas_object_ref_get(object.get()), 2); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 2); - ASSERT_EQ(evas_object_ref_get(cRef.get()), 2); + ASSERT_EQ(2, evas_object_ref_get(object.get())); + ASSERT_EQ(2, evas_object_ref_get(aRef.get())); + ASSERT_EQ(2, evas_object_ref_get(cRef.get())); } - ASSERT_EQ(evas_object_ref_get(object.get()), 1); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 1); + ASSERT_EQ(1, evas_object_ref_get(object.get())); + ASSERT_EQ(1, evas_object_ref_get(aRef.get())); } - ASSERT_EQ(evas_object_ref_get(object.get()), 0); + ASSERT_EQ(0, evas_object_ref_get(object.get())); } TEST_F(EWK2UnitTestBase, destruction) { RefPtr<Evas_Object> object = adoptRef(evas_object_box_add(canvas())); ASSERT_TRUE(object); - ASSERT_EQ(evas_object_ref_get(object.get()), 0); + ASSERT_EQ(0, evas_object_ref_get(object.get())); RefPtr<Evas_Object> aRef = object; ASSERT_TRUE(object); ASSERT_TRUE(aRef); - ASSERT_EQ(evas_object_ref_get(object.get()), 1); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 1); + ASSERT_EQ(1, evas_object_ref_get(object.get())); + ASSERT_EQ(1, evas_object_ref_get(aRef.get())); object = nullptr; - ASSERT_EQ(evas_object_ref_get(object.get()), 0); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 0); + ASSERT_EQ(0, evas_object_ref_get(object.get())); + ASSERT_EQ(0, evas_object_ref_get(aRef.get())); object = aRef; - ASSERT_EQ(evas_object_ref_get(object.get()), 1); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 1); + ASSERT_EQ(1, evas_object_ref_get(object.get())); + ASSERT_EQ(1, evas_object_ref_get(aRef.get())); object = 0; - ASSERT_EQ(evas_object_ref_get(object.get()), 0); - ASSERT_EQ(evas_object_ref_get(aRef.get()), 0); + ASSERT_EQ(0, evas_object_ref_get(object.get())); + ASSERT_EQ(0, evas_object_ref_get(aRef.get())); aRef.clear(); ASSERT_FALSE(aRef); 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 9889bbae7..32f981788 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp @@ -26,11 +26,14 @@ #include "config.h" #include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" #include <EWebKit2.h> #include <Eina.h> using namespace EWK2UnitTest; +extern EWK2UnitTestEnvironment* environment; + TEST_F(EWK2UnitTestBase, ewk_settings_fullscreen_enabled) { Ewk_Settings* settings = ewk_view_settings_get(webView()); @@ -95,3 +98,62 @@ TEST_F(EWK2UnitTestBase, ewk_settings_developer_extras_enabled) ASSERT_TRUE(ewk_settings_developer_extras_enabled_set(settings, EINA_FALSE)); ASSERT_FALSE(ewk_settings_developer_extras_enabled_get(settings)); } + +TEST_F(EWK2UnitTestBase, ewk_settings_file_access_from_file_urls_allowed) +{ + CString testURL = environment->urlForResource("local_file_access.html"); + Ewk_Settings* settings = ewk_view_settings_get(webView()); + + ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings)); + + ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, true)); + ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_get(settings)); + + // Check that file access from file:// URLs is allowed. + ewk_view_url_set(webView(), testURL.data()); + ASSERT_TRUE(waitUntilTitleChangedTo("Frame loaded")); + + ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, false)); + ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings)); + + // Check that file access from file:// URLs is NOT allowed. + ewk_view_url_set(webView(), testURL.data()); + ASSERT_TRUE(waitUntilTitleChangedTo("Frame NOT loaded")); +} + +TEST_F(EWK2UnitTestBase, ewk_settings_frame_flattening_enabled_set) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + ASSERT_TRUE(settings); + + // The frame flattening is disabled by default. + ASSERT_FALSE(ewk_settings_frame_flattening_enabled_get(settings)); + ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data()); + waitUntilTitleChangedTo("200"); // width of iframe tag. + ASSERT_STREQ("200", ewk_view_title_get(webView())); + + ASSERT_TRUE(ewk_settings_frame_flattening_enabled_set(settings, true)); + ASSERT_TRUE(ewk_settings_frame_flattening_enabled_get(settings)); + ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data()); + waitUntilTitleChangedTo("600"); // width of frame_flattening_test_subframe.html + ASSERT_STREQ("600", ewk_view_title_get(webView())); + + ASSERT_TRUE(ewk_settings_frame_flattening_enabled_set(settings, false)); + ASSERT_FALSE(ewk_settings_frame_flattening_enabled_get(settings)); + ewk_view_url_set(webView(), environment->urlForResource("frame_flattening_test.html").data()); + waitUntilTitleChangedTo("200"); // width of iframe tag. + ASSERT_STREQ("200", ewk_view_title_get(webView())); +} + +TEST_F(EWK2UnitTestBase, ewk_settings_dns_prefetching_enabled) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + + // DNS prefeching is disabled by default. + ASSERT_FALSE(ewk_settings_dns_prefetching_enabled_get(settings)); + ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_set(settings, true)); + ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_get(settings)); + + ASSERT_TRUE(ewk_settings_dns_prefetching_enabled_set(settings, false)); + ASSERT_FALSE(ewk_settings_dns_prefetching_enabled_get(settings)); +} diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp new file mode 100644 index 000000000..5fcde5cd5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp @@ -0,0 +1,535 @@ +/* + * 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. + */ + +/** + * @brief covers API from ewk_text_checker.h + * @file test_ewk2_text_checker.cpp + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include "UnitTestUtils/EWK2UnitTestEnvironment.h" +#include <EWebKit2.h> +#include <Ecore.h> +#include <Eina.h> +#include <wtf/text/CString.h> +#include <wtf/text/StringBuilder.h> + +using namespace EWK2UnitTest; + +extern EWK2UnitTestEnvironment* environment; + +static const uint64_t defaultDocumentTag = 123; +static const char expectedMisspelledWord[] = "aa"; +static const Evas_Object* defaultView = 0; +static bool isSettingEnabled = false; +static Ecore_Timer* timeoutTimer = 0; +static double defaultTimeoutInSeconds = 0.5; + +/** + * Structure keeps information which callbacks were called. + * Its values are reset before each test. + */ +static struct { + bool spellDocumentTag : 1; + bool spellDocumentTagClose : 1; + bool spellingCheck : 1; + bool wordGuesses : 1; + bool wordLearn : 1; + bool wordIgnore : 1; +} callbacksExecutionStats; + +static void resetCallbacksExecutionStats() +{ + callbacksExecutionStats.spellDocumentTag = false; + callbacksExecutionStats.spellDocumentTagClose = false; + callbacksExecutionStats.spellingCheck = false; + callbacksExecutionStats.wordGuesses = false; + callbacksExecutionStats.wordLearn = false; + callbacksExecutionStats.wordIgnore = false; +} + +/** + * Handle the timeout, it may happen for the asynchronous tests. + * + * @internal + * + * @return the ECORE_CALLBACK_CANCEL flag to delete the timer automatically + */ +static Eina_Bool onTimeout(void*) +{ + ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; +} + +/** + * This callback tests whether the client's callback is called when the spell checking setting was changed. + * + * @internal + * + * Verify the new setting value (passes in the @a flag parameter) if it equals to the previously set. + * + * @internal + * + * @param flag the new setting value + */ +static void onSettingChange(Eina_Bool flag) +{ + EXPECT_EQ(isSettingEnabled, flag); + + ecore_timer_del(timeoutTimer); + timeoutTimer = 0; + ecore_main_loop_quit(); +} + +/** + * Returns unique tag (an identifier). + * + * @internal + * + * It will be used for onSpellingCheck, onWordGuesses etc. to notify + * the client on which object (associated to the tag) the spelling is being invoked. + * + * @param ewkView the view object to get unique tag + * + * @return unique tag for the given @a ewkView object + */ +static uint64_t onSpellDocumentTag(const Evas_Object* ewkView) +{ + EXPECT_EQ(defaultView, ewkView); + callbacksExecutionStats.spellDocumentTag = true; + + return defaultDocumentTag; +} + +/** + * The view which is associated to the @a tag has been destroyed. + * + * @internal + * + * @param tag the tag to be closed + */ +static void onSpellDocumentTagClose(uint64_t tag) +{ + ASSERT_EQ(defaultDocumentTag, tag); + callbacksExecutionStats.spellDocumentTagClose = true; +} + +/** + * Checks spelling for the given @a text. + * + * @internal + * + * @param tag unique tag to notify the client on which object the spelling is being performed + * @param text the text containing the words to spellcheck + * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct + * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct + */ +static void onSpellingCheck(uint64_t tag, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength) +{ + ASSERT_EQ(defaultDocumentTag, tag); + ASSERT_STREQ(expectedMisspelledWord, text); + + ASSERT_TRUE(misspellingLocation); + ASSERT_TRUE(misspellingLength); + + // The client is able to show the misselled text through its location (the beginning of misspelling) + // and length (the end of misspelling). + *misspellingLocation = 0; + *misspellingLength = strlen(expectedMisspelledWord); + + callbacksExecutionStats.spellingCheck = true; +} + +/** + * Gets a list of suggested spellings for a misspelled @a word. + * + * @internal + * + * @param tag unique tag to notify the client on which object the spelling is being performed + * @param word the word to get guesses + * @return a list of dynamically allocated strings (as char*) and + * caller is responsible for destroying them. + */ +static Eina_List* onWordGuesses(uint64_t tag, const char* word) +{ + EXPECT_EQ(defaultDocumentTag, tag); + EXPECT_STREQ(expectedMisspelledWord, word); + + Eina_List* suggestionsForWord = 0; + // FIXME: Fill the Eina_List with suggestions for the misspelled word. + callbacksExecutionStats.wordGuesses = true; + + return suggestionsForWord; +} + +/** + * Adds the @a word to the spell checker dictionary. + * + * @internal + * + * @param tag unique tag to notify the client on which object the spelling is being performed + * @param word the word to add + */ +static void onWordLearn(uint64_t tag, const char* word) +{ + ASSERT_EQ(defaultDocumentTag, tag); + ASSERT_STREQ(expectedMisspelledWord, word); + callbacksExecutionStats.wordLearn = true; +} + +/** + * Tells the spell checker to ignore a given @a word. + * + * @internal + * + * @param tag unique tag to notify the client on which object the spelling is being performed + * @param word the word to ignore + */ +static void onWordIgnore(uint64_t tag, const char* word) +{ + ASSERT_EQ(defaultDocumentTag, tag); + ASSERT_STREQ(expectedMisspelledWord, word); + callbacksExecutionStats.wordIgnore = true; +} + +/** + * Test setter/getter for the continous spell checking: + * - ewk_settings_continuous_spell_checking_enabled_get + * - ewk_settings_continuous_spell_checking_enabled_set + */ +TEST_F(EWK2UnitTestBase, ewk_settings_continuous_spell_checking_enabled) +{ + ewk_settings_continuous_spell_checking_enabled_set(true); +#if ENABLE(SPELLCHECK) + EXPECT_TRUE(ewk_settings_continuous_spell_checking_enabled_get()); + + // When the spell checking has been enabled, the default language is set (if the user + // didn't set any). The languages are being loaded on the idler, wait for them. + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get(); + // No dictionary is available/installed. + if (!loadedLanguages) + return; + + EXPECT_EQ(1, eina_list_count(loadedLanguages)); + + void* data; + EINA_LIST_FREE(loadedLanguages, data) + eina_stringshare_del(static_cast<const char*>(data)); +#else + EXPECT_FALSE(ewk_settings_continuous_spell_checking_enabled_get()); +#endif + + ewk_settings_continuous_spell_checking_enabled_set(false); + EXPECT_FALSE(ewk_settings_continuous_spell_checking_enabled_get()); +} + +/** + * Test whether the callback is called when the spell checking setting has been changed. + */ +TEST_F(EWK2UnitTestBase, ewk_settings_continuous_spell_checking_change_cb_set) +{ + ewk_settings_continuous_spell_checking_change_cb_set(onSettingChange); + + isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get(); + isSettingEnabled = !isSettingEnabled; + ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled); + + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + + // Start proccesing Ecore events, the notification about the change of the spell + // checking setting is called on idler. + // We can't call ecore_main_loop_iterate because it doesn't process the idlers. + ecore_main_loop_begin(); + +#if ENABLE(SPELLCHECK) + EXPECT_FALSE(timeoutTimer); +#else + EXPECT_TRUE(timeoutTimer); +#endif + + // The callback shouldn't be called if the setting option is already set. + isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get(); + ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled); + + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + // When the SPELLCHECK macro is disabled the callback won't be called too. + EXPECT_TRUE(timeoutTimer); + + // The callback shouldn't be called if the user has invalidated it. + ewk_settings_continuous_spell_checking_change_cb_set(0); + isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get(); + isSettingEnabled = !isSettingEnabled; + ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled); + + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + // If the SPELLCHECK macro is disabled, the callback is not set. + EXPECT_TRUE(timeoutTimer); +} + +/** + * This unit test sets all available/installed dictionaries and verifies them + * if they are in use. + * All the dictionaries from the list can be set to perform spellchecking. + */ +TEST_F(EWK2UnitTestBase, ewk_settings_spell_checking_available_languages_get) +{ + Eina_List* availableLanguages = ewk_settings_spell_checking_available_languages_get(); + // No dictionary is available/installed or the SPELLCHECK macro is disabled. + if (!availableLanguages) + return; + + // Helper to create one string with comma separated languages. + void* actual = 0; + WTF::StringBuilder languages; + Eina_List* listIterator = 0; + unsigned lastIndex = eina_list_count(availableLanguages) - 1; + unsigned i = 0; + EINA_LIST_FOREACH(availableLanguages, listIterator, actual) { + languages.append(static_cast<const char*>(actual)); + // Add the comma after all but the last language IDs. + if (i++ != lastIndex) + languages.append(','); + } + + // Set all available languages. + ewk_settings_spell_checking_languages_set(languages.toString().utf8().data()); + + // Languages are being loaded on the idler, wait for them. + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + // Get the languages in use. + Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get(); + ASSERT_EQ(eina_list_count(loadedLanguages), eina_list_count(availableLanguages)); + + i = 0; + void* expected = 0; + // Verify whether the loaded languages list is equal to the available languages list. + EINA_LIST_FOREACH(loadedLanguages, listIterator, actual) { + expected = eina_list_nth(availableLanguages, i++); + EXPECT_STREQ(static_cast<const char*>(expected), static_cast<const char*>(actual)); + } + + // Delete the lists. + EINA_LIST_FREE(availableLanguages, actual) + eina_stringshare_del(static_cast<const char*>(actual)); + + EINA_LIST_FREE(loadedLanguages, actual) + eina_stringshare_del(static_cast<const char*>(actual)); +} + +/** + * Here we test the following scenarios: + * - setting the default language, + * - if two arbitrarily selected dictionaries are set correctly. + */ +TEST_F(EWK2UnitTestBase, ewk_settings_spell_checking_languages) +{ + // Set the default language. + ewk_settings_spell_checking_languages_set(0); + + // Languages are being loaded on the idler, wait for them. + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get(); + // No dictionary is available/installed or the SPELLCHECK macro is disabled. + if (!loadedLanguages) + return; + + ASSERT_EQ(1, eina_list_count(loadedLanguages)); + + // Delete the list. + void* actual = 0; + EINA_LIST_FREE(loadedLanguages, actual) + eina_stringshare_del(static_cast<const char*>(actual)); + + // Get the first and last language from installed dictionaries. + Eina_List* availableLanguages = ewk_settings_spell_checking_available_languages_get(); + unsigned numberOfAvailableLanguages = eina_list_count(availableLanguages); + // We assume that user has installed at lest two dictionaries. + if (numberOfAvailableLanguages < 2) + return; + + const char* firstExpected = static_cast<const char*>(eina_list_nth(availableLanguages, 0)); + const char* lastExpected = static_cast<const char*>(eina_list_data_get(eina_list_last(availableLanguages))); + + // Case sensitivity of dictionaries doesn't affect on loading the dictionaries, + // the Enchant library will 'normalize' them. + WTF::StringBuilder languages; + languages.append(String(firstExpected).upper()); + languages.append(','); + languages.append(String(lastExpected).lower()); + + // Set both languages (the first and the last) from the list. + ewk_settings_spell_checking_languages_set(languages.toString().utf8().data()); + + timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0); + ecore_main_loop_begin(); + + loadedLanguages = ewk_settings_spell_checking_languages_get(); + ASSERT_EQ(2, eina_list_count(loadedLanguages)); + + EXPECT_STREQ(firstExpected, static_cast<const char*>(eina_list_nth(loadedLanguages, 0))); + EXPECT_STREQ(lastExpected, static_cast<const char*>(eina_list_nth(loadedLanguages, 1))); + + // Delete the lists. + EINA_LIST_FREE(availableLanguages, actual) + eina_stringshare_del(static_cast<const char*>(actual)); + + EINA_LIST_FREE(loadedLanguages, actual) + eina_stringshare_del(static_cast<const char*>(actual)); +} + +/** + * Test whether the client's callbacks aren't called (if not specified). + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker) +{ + resetCallbacksExecutionStats(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + // If user doesn't specify callback functions responsible for spelling + // the default WebKit implementation (based on the Enchant library) will be used. + ASSERT_FALSE(callbacksExecutionStats.spellDocumentTag); + ASSERT_FALSE(callbacksExecutionStats.spellDocumentTagClose); + ASSERT_FALSE(callbacksExecutionStats.spellingCheck); + + // It doesn't make sense to verify others callbacks (onWordGuesses, + // onWordLearn, onWordIgnore) as they need the context menu feature + // which is not implemented for WK2-EFL. +} + +/** + * Test whether the client's callbacks (onSpellDocumentTag, onSpellDocumentTagClose) are called. + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker_unique_spell_document_tag) +{ + resetCallbacksExecutionStats(); + defaultView = webView(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ewk_text_checker_unique_spell_document_tag_get_cb_set(onSpellDocumentTag); + ewk_text_checker_unique_spell_document_tag_close_cb_set(onSpellDocumentTagClose); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + // Check whether the callback was called. + ASSERT_TRUE(callbacksExecutionStats.spellDocumentTag); + // It's not possible to check whether onSpellDocumentTagClose was called here, because + // it's invoked when WebPage is being destroyed. + // It should be verified for example when view is freed. +} + +/** + * Test whether the client's callback (onSpellingCheck) is called when + * the word to input field was put. + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker_string_spelling_check_cb_set) +{ + resetCallbacksExecutionStats(); + defaultView = webView(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ewk_text_checker_string_spelling_check_cb_set(onSpellingCheck); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + // Check whether the callback was called. + ASSERT_TRUE(callbacksExecutionStats.spellingCheck); +} + +/** + * Test whether the client's callback (onWordGuesses) is called when + * the context menu was shown on the misspelled word. + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker_word_guesses_get_cb_set) +{ + resetCallbacksExecutionStats(); + defaultView = webView(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ewk_text_checker_word_guesses_get_cb_set(onWordGuesses); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + /* FIXME: + 1) Invoke the context menu on the misspelled word (not implemented for WK2), + the word has to be selected first. + 2) Fill the suggestion list in the onWordGuesses callback. + 3) Compare context menu suggestions to the suggestion list. + 4) Check whether the callback was called. */ +} + +/** + * Test whether the client's callback (onWordLearn) is called when + * the context menu option "Learn spelling" was choosen. + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker_word_learn_cb_set) +{ + resetCallbacksExecutionStats(); + defaultView = webView(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ewk_text_checker_word_learn_cb_set(onWordLearn); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + /* FIXME: + 1) Invoke the context menu on the misspelled word (not implemented for WK2), + the word has to be selected first. + 2) Check whether the callback was called. */ +} + +/** + * Test whether the client's callback (onWordIgnore) is called when + * the context menu option "Ignore spelling" was choosen. + */ +TEST_F(EWK2UnitTestBase, ewk_text_checker_word_ignore_cb_set) +{ + resetCallbacksExecutionStats(); + defaultView = webView(); + ewk_settings_continuous_spell_checking_enabled_set(true); + + ewk_text_checker_word_ignore_cb_set(onWordIgnore); + + ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data())); + + /* FIXME: + 1) Invoke the context menu on the misspelled word (not implemented for WK2), + the word has to be selected first. + 2) Check whether the callback was called. */ +} 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 73f3ac749..0ab0c912e 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -44,42 +44,42 @@ static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*) (*countLoadFinished)--; } -TEST_F(EWK2UnitTestBase, ewk_view_uri_get) +TEST_F(EWK2UnitTestBase, ewk_view_url_get) { - loadUrlSync(environment->defaultTestPageUrl()); - EXPECT_STREQ(ewk_view_uri_get(webView()), environment->defaultTestPageUrl()); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); + EXPECT_STREQ(environment->defaultTestPageUrl(), ewk_view_url_get(webView())); int countLoadFinished = 2; evas_object_smart_callback_add(webView(), "load,finished", onLoadFinishedForRedirection, &countLoadFinished); - ewk_view_uri_set(webView(), environment->urlForResource("redirect_uri_to_default.html").data()); + ewk_view_url_set(webView(), environment->urlForResource("redirect_url_to_default.html").data()); while (countLoadFinished) ecore_main_loop_iterate(); evas_object_smart_callback_del(webView(), "load,finished", onLoadFinishedForRedirection); - EXPECT_STREQ(ewk_view_uri_get(webView()), environment->defaultTestPageUrl()); + EXPECT_STREQ(environment->defaultTestPageUrl(), ewk_view_url_get(webView())); } TEST_F(EWK2UnitTestBase, ewk_view_device_pixel_ratio) { - loadUrlSync(environment->defaultTestPageUrl()); + ASSERT_TRUE(loadUrlSync(environment->defaultTestPageUrl())); // Default pixel ratio is 1.0 - ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1); + ASSERT_FLOAT_EQ(1, ewk_view_device_pixel_ratio_get(webView())); ASSERT_TRUE(ewk_view_device_pixel_ratio_set(webView(), 1.2)); - ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1.2); + ASSERT_FLOAT_EQ(1.2, ewk_view_device_pixel_ratio_get(webView())); ASSERT_TRUE(ewk_view_device_pixel_ratio_set(webView(), 1)); - ASSERT_FLOAT_EQ(ewk_view_device_pixel_ratio_get(webView()), 1); + ASSERT_FLOAT_EQ(1, ewk_view_device_pixel_ratio_get(webView())); } TEST_F(EWK2UnitTestBase, ewk_view_html_string_load) { ewk_view_html_string_load(webView(), "<html><head><title>Foo</title></head><body>Bar</body></html>", 0, 0); ASSERT_TRUE(waitUntilTitleChangedTo("Foo")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Foo"); + ASSERT_STREQ("Foo", ewk_view_title_get(webView())); ewk_view_html_string_load(webView(), "<html><head><title>Bar</title></head><body>Foo</body></html>", 0, 0); ASSERT_TRUE(waitUntilTitleChangedTo("Bar")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Bar"); + ASSERT_STREQ("Bar", ewk_view_title_get(webView())); } static void serverCallbackNavigation(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) @@ -106,28 +106,28 @@ TEST_F(EWK2UnitTestBase, ewk_view_navigation) httpServer->run(serverCallbackNavigation); // Visit Page1 - loadUrlSync(httpServer->getURIForPath("/Page1").data()); - ASSERT_STREQ(ewk_view_title_get(webView()), "Page1"); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/Page1").data())); + ASSERT_STREQ("Page1", ewk_view_title_get(webView())); ASSERT_FALSE(ewk_view_back_possible(webView())); ASSERT_FALSE(ewk_view_forward_possible(webView())); // Visit Page2 - loadUrlSync(httpServer->getURIForPath("/Page2").data()); - ASSERT_STREQ(ewk_view_title_get(webView()), "Page2"); + ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/Page2").data())); + ASSERT_STREQ("Page2", ewk_view_title_get(webView())); ASSERT_TRUE(ewk_view_back_possible(webView())); ASSERT_FALSE(ewk_view_forward_possible(webView())); // Go back to Page1 ewk_view_back(webView()); ASSERT_TRUE(waitUntilTitleChangedTo("Page1")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Page1"); + ASSERT_STREQ("Page1", ewk_view_title_get(webView())); ASSERT_FALSE(ewk_view_back_possible(webView())); ASSERT_TRUE(ewk_view_forward_possible(webView())); // Go forward to Page2 ewk_view_forward(webView()); ASSERT_TRUE(waitUntilTitleChangedTo("Page2")); - ASSERT_STREQ(ewk_view_title_get(webView()), "Page2"); + ASSERT_STREQ("Page2", ewk_view_title_get(webView())); ASSERT_TRUE(ewk_view_back_possible(webView())); ASSERT_FALSE(ewk_view_forward_possible(webView())); } @@ -136,7 +136,7 @@ TEST_F(EWK2UnitTestBase, ewk_view_setting_encoding_custom) { ASSERT_FALSE(ewk_view_setting_encoding_custom_get(webView())); ASSERT_TRUE(ewk_view_setting_encoding_custom_set(webView(), "UTF-8")); - ASSERT_STREQ(ewk_view_setting_encoding_custom_get(webView()), "UTF-8"); + ASSERT_STREQ("UTF-8", ewk_view_setting_encoding_custom_get(webView())); // Set the default charset. ASSERT_TRUE(ewk_view_setting_encoding_custom_set(webView(), 0)); ASSERT_FALSE(ewk_view_setting_encoding_custom_get(webView())); @@ -151,19 +151,19 @@ static void onFormAboutToBeSubmitted(void* userData, Evas_Object*, void* eventIn Eina_List* fieldNames = ewk_form_submission_request_field_names_get(request); ASSERT_TRUE(fieldNames); - ASSERT_EQ(eina_list_count(fieldNames), 3); + ASSERT_EQ(3, eina_list_count(fieldNames)); void* data; EINA_LIST_FREE(fieldNames, data) eina_stringshare_del(static_cast<char*>(data)); const char* value1 = ewk_form_submission_request_field_value_get(request, "text1"); - ASSERT_STREQ(value1, "value1"); + ASSERT_STREQ("value1", value1); eina_stringshare_del(value1); const char* value2 = ewk_form_submission_request_field_value_get(request, "text2"); - ASSERT_STREQ(value2, "value2"); + ASSERT_STREQ("value2", value2); eina_stringshare_del(value2); const char* password = ewk_form_submission_request_field_value_get(request, "password"); - ASSERT_STREQ(password, "secret"); + ASSERT_STREQ("secret", password); eina_stringshare_del(password); *handled = true; @@ -195,9 +195,9 @@ TEST_F(EWK2UnitTestBase, ewk_view_form_submission_request) static inline void checkBasicPopupMenuItem(Ewk_Popup_Menu_Item* item, const char* title, bool enabled) { - EXPECT_EQ(ewk_popup_menu_item_type_get(item), EWK_POPUP_MENU_ITEM); - EXPECT_STREQ(ewk_popup_menu_item_text_get(item), title); - EXPECT_EQ(ewk_popup_menu_item_enabled_get(item), 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) @@ -208,25 +208,25 @@ static Eina_Bool selectItemAfterDelayed(void* data) static Eina_Bool showPopupMenu(Ewk_View_Smart_Data* smartData, Eina_Rectangle, Ewk_Text_Direction, double, Eina_List* list, int selectedIndex) { - EXPECT_EQ(selectedIndex, 2); + 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_popup_menu_item_text_direction_get(item), EWK_TEXT_DIRECTION_LEFT_TO_RIGHT); - EXPECT_STREQ(ewk_popup_menu_item_tooltip_get(item), ""); - EXPECT_STREQ(ewk_popup_menu_item_accessibility_text_get(item), ""); + 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_EQ(ewk_popup_menu_item_enabled_get(item), 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_popup_menu_item_text_direction_get(item), EWK_TEXT_DIRECTION_RIGHT_TO_LEFT); - EXPECT_STREQ(ewk_popup_menu_item_tooltip_get(item), "tooltip"); - EXPECT_STREQ(ewk_popup_menu_item_accessibility_text_get(item), "aria"); + 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)); @@ -237,8 +237,8 @@ static Eina_Bool showPopupMenu(Ewk_View_Smart_Data* smartData, Eina_Rectangle, E checkBasicPopupMenuItem(item, " forth", true); item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 5)); - EXPECT_EQ(ewk_popup_menu_item_type_get(item), EWK_POPUP_MENU_UNKNOWN); - EXPECT_STREQ(ewk_popup_menu_item_text_get(item), 0); + 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; @@ -310,18 +310,6 @@ static Eina_Bool fullScreenCallback(Ewk_View_Smart_Data* smartData) return false; } -static void checkFullScreenProperty(Evas_Object* webView, bool expectedState) -{ - if (environment->useX11Window()) { - Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(webView)); - Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); - bool windowState = false; - while (((windowState = ecore_evas_fullscreen_get(ecoreEvas)) != expectedState)) - ecore_main_loop_iterate(); - ASSERT_TRUE(expectedState == windowState); - } -} - TEST_F(EWK2UnitTestBase, ewk_view_full_screen_enter) { const char fullscreenHTML[] = @@ -339,7 +327,6 @@ TEST_F(EWK2UnitTestBase, ewk_view_full_screen_enter) mouseClick(50, 50); ASSERT_TRUE(waitUntilTitleChangedTo("fullscreen entered")); ASSERT_TRUE(fullScreenCallbackCalled); - checkFullScreenProperty(webView(), true); } TEST_F(EWK2UnitTestBase, ewk_view_full_screen_exit) @@ -360,18 +347,17 @@ TEST_F(EWK2UnitTestBase, ewk_view_full_screen_exit) mouseClick(50, 50); ASSERT_TRUE(waitUntilTitleChangedTo("fullscreen exited")); ASSERT_TRUE(fullScreenCallbackCalled); - checkFullScreenProperty(webView(), false); } TEST_F(EWK2UnitTestBase, ewk_view_same_page_navigation) { - // Tests that same page navigation updates the page URI. + // Tests that same page navigation updates the page URL. String testUrl = environment->urlForResource("same_page_navigation.html").data(); - loadUrlSync(testUrl.utf8().data()); - ASSERT_STREQ(testUrl.utf8().data(), ewk_view_uri_get(webView())); + ASSERT_TRUE(loadUrlSync(testUrl.utf8().data())); + ASSERT_STREQ(testUrl.utf8().data(), ewk_view_url_get(webView())); mouseClick(50, 50); testUrl = testUrl + '#'; - ASSERT_TRUE(waitUntilURIChangedTo(testUrl.utf8().data())); + ASSERT_TRUE(waitUntilURLChangedTo(testUrl.utf8().data())); } TEST_F(EWK2UnitTestBase, ewk_view_title_changed) @@ -381,21 +367,21 @@ TEST_F(EWK2UnitTestBase, ewk_view_title_changed) "<body onload=\"document.title='Title after changed';\"></body>"; ewk_view_html_string_load(webView(), titleChangedHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("Title after changed")); - EXPECT_STREQ(ewk_view_title_get(webView()), "Title after changed"); + EXPECT_STREQ("Title after changed", ewk_view_title_get(webView())); titleChangedHTML = "<!doctype html><head><title>Title before changed</title></head>" "<body onload=\"document.title='';\"></body>"; ewk_view_html_string_load(webView(), titleChangedHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("")); - EXPECT_STREQ(ewk_view_title_get(webView()), ""); + EXPECT_STREQ("", ewk_view_title_get(webView())); titleChangedHTML = "<!doctype html><head><title>Title before changed</title></head>" "<body onload=\"document.title=null;\"></body>"; ewk_view_html_string_load(webView(), titleChangedHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("")); - EXPECT_STREQ(ewk_view_title_get(webView()), ""); + EXPECT_STREQ("", ewk_view_title_get(webView())); } static struct { @@ -431,35 +417,35 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_alert) alertCallbackData.called = false; ewk_view_html_string_load(webView(), alertHTML, 0, 0); EXPECT_TRUE(waitUntilLoadFinished()); - EXPECT_EQ(alertCallbackData.called, true); + EXPECT_TRUE(alertCallbackData.called); alertHTML = "<!doctype html><body onload=\"alert('');\"></body>"; alertCallbackData.expectedMessage = ""; alertCallbackData.called = false; ewk_view_html_string_load(webView(), alertHTML, 0, 0); EXPECT_TRUE(waitUntilLoadFinished()); - EXPECT_EQ(alertCallbackData.called, true); + EXPECT_TRUE(alertCallbackData.called); alertHTML = "<!doctype html><body onload=\"alert(null);\"></body>"; alertCallbackData.expectedMessage = "null"; alertCallbackData.called = false; ewk_view_html_string_load(webView(), alertHTML, 0, 0); EXPECT_TRUE(waitUntilLoadFinished()); - EXPECT_EQ(alertCallbackData.called, true); + EXPECT_TRUE(alertCallbackData.called); alertHTML = "<!doctype html><body onload=\"alert();\"></body>"; alertCallbackData.expectedMessage = "undefined"; alertCallbackData.called = false; ewk_view_html_string_load(webView(), alertHTML, 0, 0); EXPECT_TRUE(waitUntilLoadFinished()); - EXPECT_EQ(alertCallbackData.called, true); + EXPECT_TRUE(alertCallbackData.called); ewkViewClass()->run_javascript_alert = 0; alertCallbackData.called = false; ewk_view_html_string_load(webView(), alertHTML, 0, 0); EXPECT_TRUE(waitUntilLoadFinished()); - EXPECT_EQ(alertCallbackData.called, false); + EXPECT_FALSE(alertCallbackData.called); } static Eina_Bool checkConfirm(Ewk_View_Smart_Data*, const char* message) @@ -479,16 +465,16 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_confirm) confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("true")); - EXPECT_STREQ(ewk_view_title_get(webView()), "true"); - EXPECT_EQ(confirmCallbackData.called, true); + EXPECT_STREQ("true", ewk_view_title_get(webView())); + EXPECT_TRUE(confirmCallbackData.called); confirmCallbackData.expectedMessage = "Confirm message"; confirmCallbackData.result = false; confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("false")); - EXPECT_STREQ(ewk_view_title_get(webView()), "false"); - EXPECT_EQ(confirmCallbackData.called, true); + EXPECT_STREQ("false", ewk_view_title_get(webView())); + EXPECT_TRUE(confirmCallbackData.called); confirmHTML = "<!doctype html><body onload=\"document.title = confirm('');\"></body>"; confirmCallbackData.expectedMessage = ""; @@ -496,8 +482,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_confirm) confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("true")); - EXPECT_STREQ(ewk_view_title_get(webView()), "true"); - EXPECT_EQ(confirmCallbackData.called, true); + EXPECT_STREQ("true", ewk_view_title_get(webView())); + EXPECT_TRUE(confirmCallbackData.called); confirmHTML = "<!doctype html><body onload=\"document.title = confirm(null);\"></body>"; confirmCallbackData.expectedMessage = "null"; @@ -505,8 +491,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_confirm) confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("true")); - EXPECT_STREQ(ewk_view_title_get(webView()), "true"); - EXPECT_EQ(confirmCallbackData.called, true); + EXPECT_STREQ("true", ewk_view_title_get(webView())); + EXPECT_TRUE(confirmCallbackData.called); confirmHTML = "<!doctype html><body onload=\"document.title = confirm();\"></body>"; confirmCallbackData.expectedMessage = "undefined"; @@ -514,16 +500,16 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_confirm) confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("true")); - EXPECT_STREQ(ewk_view_title_get(webView()), "true"); - EXPECT_EQ(confirmCallbackData.called, true); + EXPECT_STREQ("true", ewk_view_title_get(webView())); + EXPECT_TRUE(confirmCallbackData.called); ewkViewClass()->run_javascript_confirm = 0; confirmCallbackData.called = false; ewk_view_html_string_load(webView(), confirmHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("false")); - EXPECT_STREQ(ewk_view_title_get(webView()), "false"); - EXPECT_EQ(confirmCallbackData.called, false); + EXPECT_STREQ("false", ewk_view_title_get(webView())); + EXPECT_FALSE(confirmCallbackData.called); } static const char* checkPrompt(Ewk_View_Smart_Data*, const char* message, const char* defaultValue) @@ -552,8 +538,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo(promptResult)); - EXPECT_STREQ(ewk_view_title_get(webView()), promptResult); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ(promptResult, ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptHTML = "<!doctype html><body onload=\"document.title = prompt('Prompt message', '');\"></body>"; promptCallbackData.expectedMessage = promptMessage; @@ -562,8 +548,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo(promptResult)); - EXPECT_STREQ(ewk_view_title_get(webView()), promptResult); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ(promptResult, ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptHTML = "<!doctype html><body onload=\"document.title = prompt('Prompt message');\"></body>"; promptCallbackData.expectedMessage = promptMessage; @@ -572,8 +558,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo(promptResult)); - EXPECT_STREQ(ewk_view_title_get(webView()), promptResult); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ(promptResult, ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptHTML = "<!doctype html><body onload=\"document.title = prompt('');\"></body>"; promptCallbackData.expectedMessage = ""; @@ -582,8 +568,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo(promptResult)); - EXPECT_STREQ(ewk_view_title_get(webView()), promptResult); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ(promptResult, ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptHTML = "<!doctype html><body onload=\"document.title = prompt();\"></body>"; promptCallbackData.expectedMessage = "undefined"; @@ -592,8 +578,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo(promptResult)); - EXPECT_STREQ(ewk_view_title_get(webView()), promptResult); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ(promptResult, ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptHTML = "<html><head><title>Default title</title></head>" "<body onload=\"var promptResult = prompt('Prompt message');" @@ -605,8 +591,8 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("")); - EXPECT_STREQ(ewk_view_title_get(webView()), ""); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ("", ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); promptCallbackData.expectedMessage = promptMessage; promptCallbackData.expectedDefaultValue = ""; @@ -614,16 +600,16 @@ TEST_F(EWK2UnitTestBase, ewk_view_run_javascript_prompt) promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("null")); - EXPECT_STREQ(ewk_view_title_get(webView()), "null"); - EXPECT_EQ(promptCallbackData.called, true); + EXPECT_STREQ("null", ewk_view_title_get(webView())); + EXPECT_TRUE(promptCallbackData.called); ewkViewClass()->run_javascript_prompt = 0; promptCallbackData.called = false; ewk_view_html_string_load(webView(), promptHTML, 0, 0); EXPECT_TRUE(waitUntilTitleChangedTo("null")); - EXPECT_STREQ(ewk_view_title_get(webView()), "null"); - EXPECT_EQ(promptCallbackData.called, false); + EXPECT_STREQ("null", ewk_view_title_get(webView())); + EXPECT_FALSE(promptCallbackData.called); } #if ENABLE(INPUT_TYPE_COLOR) @@ -665,18 +651,18 @@ static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, int r, int g, i if (isFirstRun) { // 2. Check initial value from html file. - EXPECT_EQ(r, initialRed); - EXPECT_EQ(g, initialGreen); - EXPECT_EQ(b, initialBlue); - EXPECT_EQ(a, initialAlpha); + 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(r, changedRed); - EXPECT_EQ(g, changedGreen); - EXPECT_EQ(b, changedBlue); - EXPECT_EQ(a, changedAlpha); + 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; @@ -744,7 +730,7 @@ TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set) while (!handled) ecore_main_loop_iterate(); - // 8. Click button to remove input element during color picker is shown. + // 8. Click button to remove input element durlng color picker is shown. api->input_picker_color_dismiss = hideColorPickerByRemovingElement; mouseClick(80, 20); @@ -787,3 +773,168 @@ TEST_F(EWK2UnitTestBase, ewk_view_feed_touch_event) eina_list_free(points); } + +static void onTextFound(void* userData, Evas_Object*, void* eventInfo) +{ + int* result = static_cast<int*>(userData); + unsigned* matchCount = static_cast<unsigned*>(eventInfo); + + *result = *matchCount; +} + +TEST_F(EWK2UnitTestBase, ewk_view_text_find) +{ + const char textFindHTML[] = + "<!DOCTYPE html>" + "<body>" + "apple apple apple banana banana coconut" + "</body>"; + ewk_view_html_string_load(webView(), textFindHTML, 0, 0); + waitUntilLoadFinished(); + + int matchCount = -1; + evas_object_smart_callback_add(webView(), "text,found", onTextFound, &matchCount); + + ewk_view_text_find(webView(), "apple", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(3, matchCount); + + matchCount = -1; + ewk_view_text_find(webView(), "mango", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(0, matchCount); + + evas_object_smart_callback_del(webView(), "text,found", onTextFound); +} + +TEST_F(EWK2UnitTestBase, ewk_view_text_matches_count) +{ + const char textFindHTML[] = + "<!DOCTYPE html>" + "<body>" + "apple Apple apple apple banana bananaApple banana coconut" + "</body>"; + ewk_view_html_string_load(webView(), textFindHTML, 0, 0); + waitUntilLoadFinished(); + + int matchCount = -1; + evas_object_smart_callback_add(webView(), "text,found", onTextFound, &matchCount); + + ewk_view_text_matches_count(webView(), "apple", EWK_FIND_OPTIONS_NONE, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(3, matchCount); + + matchCount = -1; + ewk_view_text_matches_count(webView(), "apple", EWK_FIND_OPTIONS_CASE_INSENSITIVE, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(5, matchCount); + + matchCount = -1; + ewk_view_text_matches_count(webView(), "Apple", EWK_FIND_OPTIONS_AT_WORD_STARTS, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(1, matchCount); + + matchCount = -1; + ewk_view_text_matches_count(webView(), "Apple", EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(2, matchCount); + + matchCount = -1; + ewk_view_text_matches_count(webView(), "mango", EWK_FIND_OPTIONS_NONE, 100); + while (matchCount < 0) + ecore_main_loop_iterate(); + EXPECT_EQ(0, matchCount); + + // If we have more matches than allowed, -1 is returned as a matched count. + matchCount = -2; + ewk_view_text_matches_count(webView(), "apple", EWK_FIND_OPTIONS_NONE, 2); + while (matchCount < -1) + ecore_main_loop_iterate(); + EXPECT_EQ(-1, matchCount); + + evas_object_smart_callback_del(webView(), "text,found", onTextFound); +} + +TEST_F(EWK2UnitTestBase, ewk_view_touch_events_enabled) +{ + ASSERT_FALSE(ewk_view_touch_events_enabled_get(webView())); + + ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), true)); + ASSERT_TRUE(ewk_view_touch_events_enabled_get(webView())); + + ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), 2)); + ASSERT_TRUE(ewk_view_touch_events_enabled_get(webView())); + + const char* touchHTML = + "<!doctype html><body><div style=\"width:100px; height:100px;\" " + "ontouchstart=\"document.title='touchstarted' + event.touches.length;\" " + "ontouchmove=\"document.title='touchmoved' + event.touches.length;\" " + "ontouchend=\"document.title='touchended' + event.touches.length;\">" + "</div></body>"; + + ewk_view_html_string_load(webView(), touchHTML, "file:///", 0); + ASSERT_TRUE(waitUntilLoadFinished()); + + mouseDown(10, 10); + ASSERT_TRUE(waitUntilTitleChangedTo("touchstarted1")); + + multiDown(1, 30, 30); + ASSERT_TRUE(waitUntilTitleChangedTo("touchstarted2")); + + multiMove(1, 40, 40); + ASSERT_TRUE(waitUntilTitleChangedTo("touchmoved2")); + + multiUp(1, 40, 40); + ASSERT_TRUE(waitUntilTitleChangedTo("touchended1")); + + mouseMove(20, 20); + ASSERT_TRUE(waitUntilTitleChangedTo("touchmoved1")); + + mouseUp(20, 20); + ASSERT_TRUE(waitUntilTitleChangedTo("touchended0")); + + ASSERT_TRUE(ewk_view_touch_events_enabled_set(webView(), false)); + ASSERT_FALSE(ewk_view_touch_events_enabled_get(webView())); +} + +Eina_Bool windowMoveResizeTimedOut(void* data) +{ + *static_cast<bool*>(data) = true; +} + +TEST_F(EWK2UnitTestBase, window_move_resize) +{ + int x, y, width, height; + Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(webView())); + ecore_evas_geometry_get(ee, 0, 0, &width, &height); + + EXPECT_EQ(800, width); + EXPECT_EQ(600, height); + + ewk_view_url_set(webView(), environment->urlForResource("window_move_resize.html").data()); + ASSERT_TRUE(waitUntilTitleChangedTo("Moved and resized")); + + // Check that the window has been moved and resized. + ecore_evas_request_geometry_get(ee, &x, &y, &width, &height); + EXPECT_EQ(150, x); + EXPECT_EQ(200, y); + EXPECT_EQ(200, width); + EXPECT_EQ(100, height); +} + +TEST_F(EWK2UnitTestBase, ewk_view_inspector) +{ +#if ENABLE(INSPECTOR) + ASSERT_TRUE(ewk_view_inspector_show(webView())); + ASSERT_TRUE(ewk_view_inspector_close(webView())); +#else + ASSERT_FALSE(ewk_view_inspector_show(webView())); + ASSERT_FALSE(ewk_view_inspector_close(webView())); +#endif +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp index 6e72496ef..79c1c3e2a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp @@ -34,13 +34,13 @@ using namespace WebKit; static void didStart(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); webkitWebContextDownloadStarted(WEBKIT_WEB_CONTEXT(clientInfo), download.get()); } static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); if (webkitDownloadIsCancelled(download.get())) return; @@ -50,13 +50,13 @@ static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResp static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); webkitDownloadNotifyProgress(download.get(), length); } static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* allowOverwrite, const void* clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); CString destinationURI = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), toImpl(filename)->string().utf8()); return WKStringCreateWithUTF8CString(destinationURI.data()); @@ -64,33 +64,33 @@ static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownlo static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef path, const void* clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); webkitDownloadDestinationCreated(download.get(), toImpl(path)->string().utf8()); } static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void *clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); if (webkitDownloadIsCancelled(download.get())) { // Cancellation takes precedence over other errors. webkitDownloadCancelled(download.get()); } else webkitDownloadFailed(download.get(), toImpl(error)->platformError()); - webkitWebContextRemoveDownload(wkDownload); + webkitWebContextRemoveDownload(toImpl(wkDownload)); } static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); webkitDownloadCancelled(download.get()); - webkitWebContextRemoveDownload(wkDownload); + webkitWebContextRemoveDownload(toImpl(wkDownload)); } static void didFinish(WKContextRef wkContext, WKDownloadRef wkDownload, const void *clientInfo) { - GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(wkDownload); + GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); webkitDownloadFinished(download.get()); - webkitWebContextRemoveDownload(wkDownload); + webkitWebContextRemoveDownload(toImpl(wkDownload)); } void attachDownloadClientToContext(WebKitWebContext* webContext) @@ -110,6 +110,6 @@ void attachDownloadClientToContext(WebKitWebContext* webContext) didCancel, 0, // processDidCrash }; - WKContextSetDownloadClient(webkitWebContextGetWKContext(webContext), &wkDownloadClient); + WKContextSetDownloadClient(toAPI(webkitWebContextGetContext(webContext)), &wkDownloadClient); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp new file mode 100644 index 000000000..dc320bb77 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 + * 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 "WebKitFaviconDatabase.h" + +#include "WebKitFaviconDatabasePrivate.h" +#include "WebKitPrivate.h" +#include <WebCore/FileSystem.h> +#include <WebCore/Image.h> +#include <WebCore/IntSize.h> +#include <WebCore/RefPtrCairo.h> +#include <glib/gi18n-lib.h> +#include <wtf/MainThread.h> +#include <wtf/gobject/GOwnPtr.h> +#include <wtf/gobject/GRefPtr.h> +#include <wtf/text/CString.h> + +using namespace WebKit; + +enum { + ICON_READY, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0, }; + +typedef Vector<GRefPtr<GSimpleAsyncResult> > PendingIconRequestVector; +typedef HashMap<String, PendingIconRequestVector*> PendingIconRequestMap; + +struct _WebKitFaviconDatabasePrivate { + RefPtr<WebIconDatabase> iconDatabase; + PendingIconRequestMap pendingIconRequests; +}; + +G_DEFINE_TYPE(WebKitFaviconDatabase, webkit_favicon_database, G_TYPE_OBJECT) + +static void webkit_favicon_database_init(WebKitFaviconDatabase* manager) +{ + WebKitFaviconDatabasePrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(manager, WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabasePrivate); + manager->priv = priv; + new (priv) WebKitFaviconDatabasePrivate(); +} + +static void webkitFaviconDatabaseDispose(GObject* object) +{ + WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(object); + + WebKitFaviconDatabasePrivate* priv = database->priv; + if (priv->iconDatabase->isOpen()) + priv->iconDatabase->close(); + + G_OBJECT_CLASS(webkit_favicon_database_parent_class)->dispose(object); +} + +static void webkitFaviconDatabaseFinalize(GObject* object) +{ + WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(object); + database->priv->~WebKitFaviconDatabasePrivate(); + G_OBJECT_CLASS(webkit_favicon_database_parent_class)->finalize(object); +} + +static void webkit_favicon_database_class_init(WebKitFaviconDatabaseClass* faviconDatabaseClass) +{ + GObjectClass* gObjectClass = G_OBJECT_CLASS(faviconDatabaseClass); + gObjectClass->dispose = webkitFaviconDatabaseDispose; + gObjectClass->finalize = webkitFaviconDatabaseFinalize; + + /** + * WebKitFaviconDatabase::favicon-ready: + * @database: the object on which the signal is emitted + * @page_uri: the URI of the Web page containing the icon. + * + * This signal gets emitted when the favicon of @page_uri is + * ready. This means that the favicon's data is ready to be used + * by the application, either because it has been loaded from the + * network, if it's the first time it gets retrieved, or because + * it has been already imported from the icon database. + */ + signals[ICON_READY] = + g_signal_new("favicon-ready", + G_TYPE_FROM_CLASS(faviconDatabaseClass), + G_SIGNAL_RUN_LAST, + 0, 0, 0, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + g_type_class_add_private(faviconDatabaseClass, sizeof(WebKitFaviconDatabasePrivate)); +} + +struct GetFaviconSurfaceAsyncData { + ~GetFaviconSurfaceAsyncData() + { + if (shouldReleaseIconForPageURL) + faviconDatabase->priv->iconDatabase->releaseIconForPageURL(pageURL); + } + + GRefPtr<WebKitFaviconDatabase> faviconDatabase; + String pageURL; + RefPtr<cairo_surface_t> icon; + GRefPtr<GCancellable> cancellable; + bool shouldReleaseIconForPageURL; +}; +WEBKIT_DEFINE_ASYNC_DATA_STRUCT(GetFaviconSurfaceAsyncData) + +static cairo_surface_t* getIconSurfaceSynchronously(WebKitFaviconDatabase* database, const String& pageURL, GError** error) +{ + ASSERT(isMainThread()); + + // The exact size we pass is irrelevant to the iconDatabase code. + // We must pass something greater than 0x0 to get an icon. + WebCore::Image* iconImage = database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1)); + if (!iconImage) { + g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN, _("Unknown favicon for page %s"), pageURL.utf8().data()); + return 0; + } + + WebCore::NativeImagePtr icon = iconImage->nativeImageForCurrentFrame(); + if (!icon) { + g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, _("Page %s does not have a favicon"), pageURL.utf8().data()); + return 0; + } + + return icon->surface(); +} + +static void deletePendingIconRequests(WebKitFaviconDatabase* database, PendingIconRequestVector* requests, const String& pageURL) +{ + database->priv->pendingIconRequests.remove(pageURL); + delete requests; +} + +static void processPendingIconsForPageURL(WebKitFaviconDatabase* database, const String& pageURL) +{ + PendingIconRequestVector* pendingIconRequests = database->priv->pendingIconRequests.get(pageURL); + if (!pendingIconRequests) + return; + + GOwnPtr<GError> error; + RefPtr<cairo_surface_t> icon = getIconSurfaceSynchronously(database, pageURL, &error.outPtr()); + + for (size_t i = 0; i < pendingIconRequests->size(); ++i) { + GSimpleAsyncResult* result = pendingIconRequests->at(i).get(); + GetFaviconSurfaceAsyncData* data = static_cast<GetFaviconSurfaceAsyncData*>(g_simple_async_result_get_op_res_gpointer(result)); + if (!g_cancellable_is_cancelled(data->cancellable.get())) { + if (error) + g_simple_async_result_take_error(result, error.release()); + else { + data->icon = icon; + data->shouldReleaseIconForPageURL = false; + } + } + + g_simple_async_result_complete(result); + } + deletePendingIconRequests(database, pendingIconRequests, pageURL); +} + +static void iconDataReadyForPageURLCallback(WKIconDatabaseRef wkIconDatabase, WKURLRef wkPageURL, const void* clientInfo) +{ + ASSERT(isMainThread()); + + WebKitFaviconDatabase* database = WEBKIT_FAVICON_DATABASE(clientInfo); + String pageURL = toImpl(wkPageURL)->string(); + + processPendingIconsForPageURL(database, pageURL); + g_signal_emit(database, signals[ICON_READY], 0, pageURL.utf8().data()); +} + +WebKitFaviconDatabase* webkitFaviconDatabaseCreate(WebIconDatabase* iconDatabase) +{ + WebKitFaviconDatabase* faviconDatabase = WEBKIT_FAVICON_DATABASE(g_object_new(WEBKIT_TYPE_FAVICON_DATABASE, NULL)); + faviconDatabase->priv->iconDatabase = iconDatabase; + + WKIconDatabaseClient wkIconDatabaseClient = { + kWKIconDatabaseClientCurrentVersion, + faviconDatabase, // clientInfo + 0, // didChangeIconForPageURLCallback + 0, // didRemoveAllIconsCallback + iconDataReadyForPageURLCallback, + }; + WKIconDatabaseSetIconDatabaseClient(toAPI(iconDatabase), &wkIconDatabaseClient); + return faviconDatabase; +} + +cairo_surface_t* webkitFaviconDatabaseGetFavicon(WebKitFaviconDatabase* database, const CString& pageURL) +{ + ASSERT(WEBKIT_IS_FAVICON_DATABASE(database)); + ASSERT(!pageURL.isNull()); + + cairo_surface_t* iconSurface = getIconSurfaceSynchronously(database, String::fromUTF8(pageURL.data()), 0); + if (!iconSurface) + return 0; + + return cairo_surface_reference(iconSurface); +} + +static PendingIconRequestVector* getOrCreatePendingIconRequests(WebKitFaviconDatabase* database, const String& pageURL) +{ + PendingIconRequestVector* icons = database->priv->pendingIconRequests.get(pageURL); + if (!icons) { + icons = new PendingIconRequestVector; + database->priv->pendingIconRequests.set(pageURL, icons); + } + + return icons; +} + +static void setErrorForAsyncResult(GSimpleAsyncResult* result, WebKitFaviconDatabaseError error, const String& pageURL = String()) +{ + ASSERT(result); + + switch (error) { + case WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED: + g_simple_async_result_set_error(result, WEBKIT_FAVICON_DATABASE_ERROR, error, _("Favicons database not initialized yet")); + break; + + case WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND: + g_simple_async_result_set_error(result, WEBKIT_FAVICON_DATABASE_ERROR, error, _("Page %s does not have a favicon"), pageURL.utf8().data()); + break; + + case WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN: + g_simple_async_result_set_error(result, WEBKIT_FAVICON_DATABASE_ERROR, error, _("Unknown favicon for page %s"), pageURL.utf8().data()); + break; + + default: + ASSERT_NOT_REACHED(); + } +} + +GQuark webkit_favicon_database_error_quark(void) +{ + return g_quark_from_static_string("WebKitFaviconDatabaseError"); +} + +/** + * webkit_favicon_database_get_favicon: + * @database: a #WebKitFaviconDatabase + * @page_uri: URI of the page for which we want to retrieve the favicon + * @cancellable: (allow-none): A #GCancellable or %NULL. + * @callback: (scope async): A #GAsyncReadyCallback to call when the request is + * satisfied or %NULL if you don't care about the result. + * @user_data: (closure): The data to pass to @callback. + * + * Asynchronously obtains a #cairo_surface_t of the favicon for the + * given page URI. It returns the cached icon if it's in the database + * asynchronously waiting for the icon to be read from the database. + * + * This is an asynchronous method. When the operation is finished, callback will + * be invoked. You can then call webkit_favicon_database_get_favicon_finish() + * to get the result of the operation. + */ +void webkit_favicon_database_get_favicon(WebKitFaviconDatabase* database, const gchar* pageURI, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) +{ + g_return_if_fail(WEBKIT_IS_FAVICON_DATABASE(database)); + g_return_if_fail(pageURI); + + GRefPtr<GSimpleAsyncResult> result = adoptGRef(g_simple_async_result_new(G_OBJECT(database), callback, userData, reinterpret_cast<gpointer>(webkit_favicon_database_get_favicon))); + g_simple_async_result_set_check_cancellable(result.get(), cancellable); + + GetFaviconSurfaceAsyncData* data = createGetFaviconSurfaceAsyncData(); + g_simple_async_result_set_op_res_gpointer(result.get(), data, reinterpret_cast<GDestroyNotify>(destroyGetFaviconSurfaceAsyncData)); + data->faviconDatabase = database; + data->pageURL = String::fromUTF8(pageURI); + data->cancellable = cancellable; + + WebKitFaviconDatabasePrivate* priv = database->priv; + WebIconDatabase* iconDatabaseImpl = priv->iconDatabase.get(); + if (!iconDatabaseImpl->isOpen()) { + setErrorForAsyncResult(result.get(), WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED); + g_simple_async_result_complete_in_idle(result.get()); + return; + } + + if (data->pageURL.isEmpty() || data->pageURL.startsWith("about:")) { + setErrorForAsyncResult(result.get(), WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, data->pageURL); + g_simple_async_result_complete_in_idle(result.get()); + return; + } + + priv->iconDatabase->retainIconForPageURL(data->pageURL); + + // 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). + GOwnPtr<GError> error; + data->icon = getIconSurfaceSynchronously(database, data->pageURL, &error.outPtr()); + if (data->icon) { + g_simple_async_result_complete_in_idle(result.get()); + return; + } + + // At this point we still don't know whether we will get a valid icon for pageURL. + data->shouldReleaseIconForPageURL = true; + + if (g_error_matches(error.get(), WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND)) { + g_simple_async_result_take_error(result.get(), error.release()); + g_simple_async_result_complete_in_idle(result.get()); + return; + } + + // If there's not a valid icon, but there's an iconURL registered, + // or it's still not registered but the import process hasn't + // finished yet, we need to wait for iconDataReadyForPage to be + // called before making and informed decision. + String iconURLForPageURL; + iconDatabaseImpl->synchronousIconURLForPageURL(data->pageURL, iconURLForPageURL); + if (!iconURLForPageURL.isEmpty() || !iconDatabaseImpl->isUrlImportCompleted()) { + PendingIconRequestVector* icons = getOrCreatePendingIconRequests(database, data->pageURL); + ASSERT(icons); + icons->append(result); + return; + } + + setErrorForAsyncResult(result.get(), WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN, data->pageURL); + g_simple_async_result_complete_in_idle(result.get()); +} + +/** + * webkit_favicon_database_get_favicon_finish: + * @database: a #WebKitFaviconDatabase + * @result: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to webkit_favicon_database_get_favicon() + * @error: (allow-none): Return location for error or %NULL. + * + * Finishes an operation started with webkit_favicon_database_get_favicon(). + * + * Returns: (transfer full): a new reference to a #cairo_surface_t, or + * %NULL in case of error. + */ +cairo_surface_t* webkit_favicon_database_get_favicon_finish(WebKitFaviconDatabase* database, GAsyncResult* result, GError** error) +{ + GSimpleAsyncResult* simpleResult = G_SIMPLE_ASYNC_RESULT(result); + g_warn_if_fail(g_simple_async_result_get_source_tag(simpleResult) == webkit_favicon_database_get_favicon); + + if (g_simple_async_result_propagate_error(simpleResult, error)) + return 0; + + GetFaviconSurfaceAsyncData* data = static_cast<GetFaviconSurfaceAsyncData*>(g_simple_async_result_get_op_res_gpointer(simpleResult)); + ASSERT(data); + return cairo_surface_reference(data->icon.get()); +} + +/** + * webkit_favicon_database_get_favicon_uri: + * @database: a #WebKitFaviconDatabase + * @page_uri: URI of the page containing the icon + * + * Obtains the URI of the favicon for the given @page_uri. + * + * Returns: a newly allocated URI for the favicon, or %NULL if the + * database doesn't have a favicon for @page_uri. + */ +gchar* webkit_favicon_database_get_favicon_uri(WebKitFaviconDatabase* database, const gchar* pageURL) +{ + g_return_val_if_fail(WEBKIT_IS_FAVICON_DATABASE(database), 0); + g_return_val_if_fail(pageURL, 0); + ASSERT(isMainThread()); + + String iconURLForPageURL; + database->priv->iconDatabase->synchronousIconURLForPageURL(String::fromUTF8(pageURL), iconURLForPageURL); + if (iconURLForPageURL.isEmpty()) + return 0; + + return g_strdup(iconURLForPageURL.utf8().data()); +} + +/** + * webkit_favicon_database_clear: + * @database: a #WebKitFaviconDatabase + * + * Clears all icons from the database. + */ +void webkit_favicon_database_clear(WebKitFaviconDatabase* database) +{ + g_return_if_fail(WEBKIT_IS_FAVICON_DATABASE(database)); + + database->priv->iconDatabase->removeAllIcons(); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h new file mode 100644 index 000000000..811a8e6bb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 + * 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. + */ + +#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) +#error "Only <webkit2/webkit2.h> can be included directly." +#endif + +#ifndef WebKitFaviconDatabase_h +#define WebKitFaviconDatabase_h + +#include <cairo.h> +#include <gio/gio.h> +#include <glib-object.h> +#include <webkit2/WebKitDefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_FAVICON_DATABASE (webkit_favicon_database_get_type()) +#define WEBKIT_FAVICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabase)) +#define WEBKIT_IS_FAVICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FAVICON_DATABASE)) +#define WEBKIT_FAVICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabaseClass)) +#define WEBKIT_IS_FAVICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FAVICON_DATABASE)) +#define WEBKIT_FAVICON_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FAVICON_DATABASE, WebKitFaviconDatabaseClass)) +#define WEBKIT_FAVICON_DATABASE_ERROR (webkit_favicon_database_error_quark()) + +typedef struct _WebKitFaviconDatabase WebKitFaviconDatabase; +typedef struct _WebKitFaviconDatabaseClass WebKitFaviconDatabaseClass; +typedef struct _WebKitFaviconDatabasePrivate WebKitFaviconDatabasePrivate; + +struct _WebKitFaviconDatabase { + GObject parent; + + WebKitFaviconDatabasePrivate *priv; +}; + +struct _WebKitFaviconDatabaseClass { + GObjectClass parent_class; +}; + +/** + * WebKitFaviconDatabaseError: + * @WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED: The #WebKitFaviconDatabase has not been initialized yet + * @WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND: There is not an icon available for the requested URL + * @WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN: There might be an icon for the requested URL, but its data is unknown at the moment + * + * Enum values used to denote the various errors related to the #WebKitFaviconDatabase. + **/ +typedef enum { + WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED, + WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, + WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN +} WebKitFaviconDatabaseError; + +WEBKIT_API GQuark +webkit_favicon_database_error_quark (void); + +WEBKIT_API GType +webkit_favicon_database_get_type (void); + +WEBKIT_API void +webkit_favicon_database_get_favicon (WebKitFaviconDatabase *database, + const gchar *page_uri, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +WEBKIT_API cairo_surface_t * +webkit_favicon_database_get_favicon_finish (WebKitFaviconDatabase *database, + GAsyncResult *result, + GError **error); +WEBKIT_API gchar * +webkit_favicon_database_get_favicon_uri (WebKitFaviconDatabase *database, + const gchar *page_uri); +WEBKIT_API void +webkit_favicon_database_clear (WebKitFaviconDatabase *database); + +G_END_DECLS + +#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h new file mode 100644 index 000000000..6c50949fb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabasePrivate.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 WebKitFaviconDatabasePrivate_h +#define WebKitFaviconDatabasePrivate_h + +#include "WebIconDatabase.h" +#include "WebKitFaviconDatabase.h" +#include <wtf/text/CString.h> + +using namespace WebKit; + +WebKitFaviconDatabase* webkitFaviconDatabaseCreate(WebIconDatabase*); +cairo_surface_t* webkitFaviconDatabaseGetFavicon(WebKitFaviconDatabase*, const CString&); + +#endif // WebKitFaviconDatabasePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp index 84ad04d03..2a1b8d5a3 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResult.cpp @@ -21,15 +21,16 @@ #include "WebKitJavascriptResult.h" #include "WebKitJavascriptResultPrivate.h" +#include "WebSerializedScriptValue.h" #include <wtf/gobject/GRefPtr.h> struct _WebKitJavascriptResult { - _WebKitJavascriptResult(WebKitWebView* view, WKSerializedScriptValueRef wkSerializedScriptValue) + _WebKitJavascriptResult(WebKitWebView* view, WebSerializedScriptValue* serializedScriptValue) : webView(view) , referenceCount(1) - { - value = WKSerializedScriptValueDeserialize(wkSerializedScriptValue, webkit_web_view_get_javascript_global_context(view), 0); - } + { + value = serializedScriptValue->deserialize(webkit_web_view_get_javascript_global_context(view), 0); + } GRefPtr<WebKitWebView> webView; JSValueRef value; @@ -39,10 +40,10 @@ struct _WebKitJavascriptResult { G_DEFINE_BOXED_TYPE(WebKitJavascriptResult, webkit_javascript_result, webkit_javascript_result_ref, webkit_javascript_result_unref) -WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView* webView, WKSerializedScriptValueRef wkSerializedScriptValue) +WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView* webView, WebSerializedScriptValue* serializedScriptValue) { WebKitJavascriptResult* result = g_slice_new(WebKitJavascriptResult); - new (result) WebKitJavascriptResult(webView, wkSerializedScriptValue); + new (result) WebKitJavascriptResult(webView, serializedScriptValue); return result; } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h index 840ead058..ac7578857 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitJavascriptResultPrivate.h @@ -24,6 +24,8 @@ #include "WebKitPrivate.h" #include "WebKitWebView.h" -WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView*, WKSerializedScriptValueRef); +using namespace WebKit; + +WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView*, WebSerializedScriptValue*); #endif // WebKitJavascriptResultPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp index 6c3bf920a..457c40141 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp @@ -152,6 +152,7 @@ void attachLoaderClientToView(WebKitWebView* webView) 0, // pluginDidFail 0, // didReceiveIntentForFrame 0, // registerIntentServiceForFrame + 0, // didLayout }; WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); WKPageSetPageLoaderClient(wkPage, &wkLoaderClient); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h index 8fede827f..9ceafecb6 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h @@ -34,6 +34,7 @@ #include <WebKit2/WKGeolocationManager.h> #include <WebKit2/WKGeolocationPermissionRequest.h> #include <WebKit2/WKGeolocationPosition.h> +#include <WebKit2/WKIconDatabase.h> #include <WebKit2/WKInspector.h> #include <WebKit2/WKInspectorClientGtk.h> #include <WebKit2/WKRetainPtr.h> diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp index 8ea09f200..babafe651 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp @@ -26,10 +26,10 @@ using namespace WebKit; -static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, uint64_t requestID, const void* clientInfo) +static void didReceiveURIRequest(WKSoupRequestManagerRef soupRequestManagerRef, WKURLRef urlRef, WKPageRef initiatingPageRef, uint64_t requestID, const void* clientInfo) { WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(clientInfo); - GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(webContext, soupRequestManagerRef, urlRef, requestID)); + GRefPtr<WebKitURISchemeRequest> request = adoptGRef(webkitURISchemeRequestCreate(webContext, soupRequestManagerRef, urlRef, initiatingPageRef, requestID)); webkitWebContextReceivedURIRequest(webContext, request.get()); } @@ -46,6 +46,6 @@ void attachRequestManagerClientToContext(WebKitWebContext* webContext) didReceiveURIRequest, didFailToLoadURIRequest }; - WKSoupRequestManagerSetClient(webkitWebContextGetRequestManager(webContext), &wkRequestManagerClient); + WKSoupRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp index 53b46f875..d170fcf3f 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp @@ -74,7 +74,7 @@ WebKitSecurityManager* webkitSecurityManagerCreate(WebKitWebContext* webContext) static void registerSecurityPolicyForURIScheme(WebKitSecurityManager* manager, const char* scheme, SecurityPolicy policy) { String urlScheme = String::fromUTF8(scheme); - WebContext* webContext = toImpl(webkitWebContextGetWKContext(manager->priv->webContext)); + WebContext* webContext = webkitWebContextGetContext(manager->priv->webContext); // We keep the WebCore::SchemeRegistry of the UI process in sync with the // web process one, so that we can return the SecurityPolicy for diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp index c0a64162a..17d4c881b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp @@ -34,6 +34,7 @@ #include "WebKitPrivate.h" #include "WebKitSettingsPrivate.h" #include "WebPageProxy.h" +#include "WebPreferences.h" #include <WebCore/UserAgentGtk.h> #include <glib/gi18n-lib.h> #include <wtf/text/CString.h> @@ -117,7 +118,8 @@ enum { PROP_DRAW_COMPOSITING_INDICATORS, PROP_ENABLE_SITE_SPECIFIC_QUIRKS, PROP_ENABLE_PAGE_CACHE, - PROP_USER_AGENT + PROP_USER_AGENT, + PROP_ENABLE_SMOOTH_SCROLLING }; static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) @@ -251,6 +253,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu case PROP_USER_AGENT: webkit_settings_set_user_agent(settings, g_value_get_string(value)); break; + case PROP_ENABLE_SMOOTH_SCROLLING: + webkit_settings_set_enable_smooth_scrolling(settings, g_value_get_boolean(value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); break; @@ -388,6 +393,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val case PROP_USER_AGENT: g_value_set_string(value, webkit_settings_get_user_agent(settings)); break; + case PROP_ENABLE_SMOOTH_SCROLLING: + g_value_set_boolean(value, webkit_settings_get_enable_smooth_scrolling(settings)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); break; @@ -1039,6 +1047,19 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass) 0, // A null string forces the standard user agent. readWriteConstructParamFlags)); + /** + * WebKitSettings:enable-smooth-scrolling: + * + * Enable or disable smooth scrolling. + */ + g_object_class_install_property(gObjectClass, + PROP_ENABLE_SMOOTH_SCROLLING, + g_param_spec_boolean("enable-smooth-scrolling", + _("Enable smooth scrolling"), + _("Whether to enable smooth scrolling"), + FALSE, + readWriteConstructParamFlags)); + g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate)); } @@ -2644,3 +2665,38 @@ void webkit_settings_set_user_agent_with_application_details(WebKitSettings* set CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8(); webkit_settings_set_user_agent(settings, newUserAgent.data()); } + +/** + * webkit_settings_get_enable_smooth_scrolling: + * @settings: a #WebKitSettings + * + * Get the #WebKitSettings:enable-smooth-scrolling property. + * + * Returns: %TRUE if smooth scrolling is enabled or %FALSE otherwise. + */ +gboolean webkit_settings_get_enable_smooth_scrolling(WebKitSettings* settings) +{ + g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); + + return WebKit::toImpl(settings->priv->preferences.get())->scrollAnimatorEnabled(); +} + +/** + * webkit_settings_set_enable_smooth_scrolling: + * @settings: a #WebKitSettings + * @enabled: Value to be set + * + * Set the #WebKitSettings:enable-smooth-scrolling property. + */ +void webkit_settings_set_enable_smooth_scrolling(WebKitSettings* settings, gboolean enabled) +{ + g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); + + WebKitSettingsPrivate* priv = settings->priv; + bool currentValue = WebKit::toImpl(priv->preferences.get())->scrollAnimatorEnabled(); + if (currentValue == enabled) + return; + + WebKit::toImpl(priv->preferences.get())->setScrollAnimatorEnabled(enabled); + g_object_notify(G_OBJECT(settings), "enable-smooth-scrolling"); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h index b35a23f06..a9fe86a30 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h @@ -373,6 +373,13 @@ webkit_settings_set_user_agent_with_application_details (WebKitSettings * const gchar *application_name, const gchar *application_version); +WEBKIT_API gboolean +webkit_settings_get_enable_smooth_scrolling (WebKitSettings *settings); + +WEBKIT_API void +webkit_settings_set_enable_smooth_scrolling (WebKitSettings *settings, + gboolean enabled); + G_END_DECLS #endif /* WebKitSettings_h */ diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp index e62c1faf5..e69831f29 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp @@ -22,6 +22,8 @@ #include "WebKitURISchemeRequestPrivate.h" #include "WebKitWebContextPrivate.h" +#include "WebKitWebView.h" +#include "WebPageProxy.h" #include <WebCore/GOwnPtrSoup.h> #include <libsoup/soup.h> #include <wtf/gobject/GRefPtr.h> @@ -36,6 +38,7 @@ G_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT) struct _WebKitURISchemeRequestPrivate { WebKitWebContext* webContext; WKRetainPtr<WKSoupRequestManagerRef> wkRequestManager; + WKRetainPtr<WKPageRef> wkInitiatingPage; uint64_t requestID; CString uri; GOwnPtr<SoupURI> soupURI; @@ -68,12 +71,13 @@ static void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass* re g_type_class_add_private(requestClass, sizeof(WebKitURISchemeRequestPrivate)); } -WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext* webContext, WKSoupRequestManagerRef wkRequestManager, WKURLRef wkURL, uint64_t requestID) +WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext* webContext, WKSoupRequestManagerRef wkRequestManager, WKURLRef wkURL, WKPageRef wkInitiatingPage, uint64_t requestID) { WebKitURISchemeRequest* request = WEBKIT_URI_SCHEME_REQUEST(g_object_new(WEBKIT_TYPE_URI_SCHEME_REQUEST, NULL)); request->priv->webContext = webContext; request->priv->wkRequestManager = wkRequestManager; request->priv->uri = toImpl(wkURL)->string().utf8(); + request->priv->wkInitiatingPage = wkInitiatingPage; request->priv->requestID = requestID; return request; } @@ -138,6 +142,21 @@ const char* webkit_uri_scheme_request_get_path(WebKitURISchemeRequest* request) return request->priv->soupURI->path; } +/** + * webkit_uri_scheme_request_get_web_view: + * @request: a #WebKitURISchemeRequest + * + * Get the #WebKitWebView that initiated the request. + * + * Returns: (transfer none): the #WebKitWebView that initiated @request. + */ +WebKitWebView* webkit_uri_scheme_request_get_web_view(WebKitURISchemeRequest* request) +{ + g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), 0); + + return WEBKIT_WEB_VIEW(toImpl(request->priv->wkInitiatingPage.get())->viewWidget()); +} + static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest) { GRefPtr<WebKitURISchemeRequest> request = adoptGRef(schemeRequest); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h index 34f214489..9ead50709 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.h @@ -51,22 +51,25 @@ struct _WebKitURISchemeRequestClass { }; WEBKIT_API GType -webkit_uri_scheme_request_get_type (void); +webkit_uri_scheme_request_get_type (void); WEBKIT_API const gchar * -webkit_uri_scheme_request_get_scheme (WebKitURISchemeRequest *request); +webkit_uri_scheme_request_get_scheme (WebKitURISchemeRequest *request); WEBKIT_API const gchar * -webkit_uri_scheme_request_get_uri (WebKitURISchemeRequest *request); +webkit_uri_scheme_request_get_uri (WebKitURISchemeRequest *request); WEBKIT_API const gchar * -webkit_uri_scheme_request_get_path (WebKitURISchemeRequest *request); +webkit_uri_scheme_request_get_path (WebKitURISchemeRequest *request); + +WEBKIT_API WebKitWebView * +webkit_uri_scheme_request_get_web_view (WebKitURISchemeRequest *request); WEBKIT_API void -webkit_uri_scheme_request_finish (WebKitURISchemeRequest *request, - GInputStream *stream, - gint64 stream_length, - const gchar *mime_type); +webkit_uri_scheme_request_finish (WebKitURISchemeRequest *request, + GInputStream *stream, + gint64 stream_length, + const gchar *mime_type); G_END_DECLS diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h index 149813def..b7c011f66 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequestPrivate.h @@ -25,7 +25,7 @@ #include "WebKitWebContext.h" #include <WebKit2/WKSoupRequestManager.h> -WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext*, WKSoupRequestManagerRef, WKURLRef, uint64_t requestID); +WebKitURISchemeRequest* webkitURISchemeRequestCreate(WebKitWebContext*, WKSoupRequestManagerRef, WKURLRef, WKPageRef, uint64_t requestID); uint64_t webkitURISchemeRequestGetID(WebKitURISchemeRequest*); void webkitURISchemeRequestCancel(WebKitURISchemeRequest*); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp index 5b2c26697..dab18a87d 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp @@ -20,10 +20,10 @@ #include "config.h" #include "WebKitWebContext.h" -#include "WebContext.h" #include "WebKitCookieManagerPrivate.h" #include "WebKitDownloadClient.h" #include "WebKitDownloadPrivate.h" +#include "WebKitFaviconDatabasePrivate.h" #include "WebKitGeolocationProvider.h" #include "WebKitPluginPrivate.h" #include "WebKitPrivate.h" @@ -32,7 +32,9 @@ #include "WebKitTextChecker.h" #include "WebKitURISchemeRequestPrivate.h" #include "WebKitWebContextPrivate.h" +#include "WebResourceCacheManagerProxy.h" #include <WebCore/FileSystem.h> +#include <WebCore/IconDatabase.h> #include <WebCore/Language.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> @@ -42,8 +44,6 @@ #include <wtf/gobject/GRefPtr.h> #include <wtf/text/CString.h> -using namespace WebKit; - enum { DOWNLOAD_STARTED, @@ -93,11 +93,12 @@ typedef HashMap<String, RefPtr<WebKitURISchemeHandler> > URISchemeHandlerMap; typedef HashMap<uint64_t, GRefPtr<WebKitURISchemeRequest> > URISchemeRequestMap; struct _WebKitWebContextPrivate { - WKRetainPtr<WKContextRef> context; + RefPtr<WebContext> context; GRefPtr<WebKitCookieManager> cookieManager; + GRefPtr<WebKitFaviconDatabase> faviconDatabase; GRefPtr<WebKitSecurityManager> securityManager; - WKRetainPtr<WKSoupRequestManagerRef> requestManager; + RefPtr<WebSoupRequestManagerProxy> requestManager; URISchemeHandlerMap uriSchemeHandlers; URISchemeRequestMap uriSchemeRequests; #if ENABLE(GEOLOCATION) @@ -106,6 +107,7 @@ struct _WebKitWebContextPrivate { #if ENABLE(SPELLCHECK) OwnPtr<WebKitTextChecker> textChecker; #endif + CString faviconDatabaseDirectory; }; static guint signals[LAST_SIGNAL] = { 0, }; @@ -152,17 +154,20 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass static gpointer createDefaultWebContext(gpointer) { static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL))); - webContext->priv->context = WKContextCreate(); - webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get()); - WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser); + WebKitWebContextPrivate* priv = webContext->priv; + + priv->context = WebContext::create(String()); + priv->requestManager = webContext->priv->context->soupRequestManagerProxy(); + priv->context->setCacheModel(CacheModelPrimaryWebBrowser); + attachDownloadClientToContext(webContext.get()); attachRequestManagerClientToContext(webContext.get()); + #if ENABLE(GEOLOCATION) - WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); - webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager); + priv->geolocationProvider = WebKitGeolocationProvider::create(toAPI(priv->context->geolocationManagerProxy())); #endif #if ENABLE(SPELLCHECK) - webContext->priv->textChecker = WebKitTextChecker::create(); + priv->textChecker = WebKitTextChecker::create(); #endif return webContext.get(); } @@ -206,26 +211,26 @@ WebKitWebContext* webkit_web_context_get_default(void) */ void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model) { - WKCacheModel cacheModel; + CacheModel cacheModel; g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); switch (model) { case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: - cacheModel = kWKCacheModelDocumentViewer; + cacheModel = CacheModelDocumentViewer; break; case WEBKIT_CACHE_MODEL_WEB_BROWSER: - cacheModel = kWKCacheModelPrimaryWebBrowser; + cacheModel = CacheModelPrimaryWebBrowser; break; case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: - cacheModel = kWKCacheModelDocumentBrowser; + cacheModel = CacheModelDocumentBrowser; break; default: g_assert_not_reached(); } - WebKitWebContextPrivate* priv = context->priv; - if (cacheModel != WKContextGetCacheModel(priv->context.get())) - WKContextSetCacheModel(priv->context.get(), cacheModel); + + if (cacheModel != context->priv->context->cacheModel()) + context->priv->context->setCacheModel(cacheModel); } /** @@ -242,13 +247,12 @@ WebKitCacheModel webkit_web_context_get_cache_model(WebKitWebContext* context) { g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER); - WebKitWebContextPrivate* priv = context->priv; - switch (WKContextGetCacheModel(priv->context.get())) { - case kWKCacheModelDocumentViewer: + switch (context->priv->context->cacheModel()) { + case CacheModelDocumentViewer: return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER; - case kWKCacheModelPrimaryWebBrowser: + case CacheModelPrimaryWebBrowser: return WEBKIT_CACHE_MODEL_WEB_BROWSER; - case kWKCacheModelDocumentBrowser: + case CacheModelDocumentBrowser: return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER; default: g_assert_not_reached(); @@ -268,11 +272,10 @@ void webkit_web_context_clear_cache(WebKitWebContext* context) { g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); - WebKitWebContextPrivate* priv = context->priv; - WKResourceCacheManagerClearCacheForAllOrigins(WKContextGetResourceCacheManager(priv->context.get()), WKResourceCachesToClearAll); + context->priv->context->resourceCacheManagerProxy()->clearCacheForAllOrigins(AllResourceCaches); } -typedef HashMap<WKDownloadRef, GRefPtr<WebKitDownload> > DownloadsMap; +typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap; static DownloadsMap& downloadsMap() { @@ -295,12 +298,9 @@ 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); - WebKitWebContextPrivate* priv = context->priv; - WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKURLCreateWithUTF8CString(uri)); - WKRetainPtr<WKURLRequestRef> wkRequest(AdoptWK, WKURLRequestCreateWithWKURL(wkURL.get())); - WKRetainPtr<WKDownloadRef> wkDownload = WKContextDownloadURLRequest(priv->context.get(), wkRequest.get()); - WebKitDownload* download = webkitDownloadCreate(wkDownload.get()); - downloadsMap().set(wkDownload.get(), download); + DownloadProxy* downloadProxy = context->priv->context->download(0, WebCore::ResourceRequest(String::fromUTF8(uri))); + WebKitDownload* download = webkitDownloadCreate(toAPI(downloadProxy)); + downloadsMap().set(downloadProxy, download); return download; } @@ -318,11 +318,107 @@ WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* con WebKitWebContextPrivate* priv = context->priv; if (!priv->cookieManager) - priv->cookieManager = adoptGRef(webkitCookieManagerCreate(WKContextGetCookieManager(priv->context.get()))); + priv->cookieManager = adoptGRef(webkitCookieManagerCreate(toAPI(priv->context->cookieManagerProxy()))); return priv->cookieManager.get(); } +static void ensureFaviconDatabase(WebKitWebContext* context) +{ + WebKitWebContextPrivate* priv = context->priv; + if (priv->faviconDatabase) + return; + + priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->context->iconDatabase())); +} + +/** + * webkit_web_context_set_favicon_database_directory: + * @context: a #WebKitWebContext + * @path: (allow-none): an absolute path to the icon database + * directory or %NULL to use the defaults + * + * Set the directory path to be used to store the favicons database + * for @context on disk. Passing %NULL as @path means using the + * default directory for the platform (see g_get_user_data_dir()). + * + * Calling this method also means enabling the favicons database for + * its use from the applications, so that's why it's expected to be + * called only once. Further calls for the same instance of + * #WebKitWebContext won't cause any effect. + */ +void webkit_web_context_set_favicon_database_directory(WebKitWebContext* context, const gchar* path) +{ + g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); + + WebKitWebContextPrivate* priv = context->priv; + WebIconDatabase* iconDatabase = priv->context->iconDatabase(); + if (iconDatabase->isOpen()) + return; + + ensureFaviconDatabase(context); + + // Use default if 0 is passed as parameter. + String directoryPath = WebCore::filenameToString(path); + priv->faviconDatabaseDirectory = directoryPath.isEmpty() + ? priv->context->iconDatabasePath().utf8() + : directoryPath.utf8(); + + // Build the full path to the icon database file on disk. + GOwnPtr<gchar> faviconDatabasePath(g_build_filename(priv->faviconDatabaseDirectory.data(), + WebCore::IconDatabase::defaultDatabaseFilename().utf8().data(), + NULL)); + + // Setting the path will cause the icon database to be opened. + priv->context->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get())); +} + +/** + * webkit_web_context_get_favicon_database_directory: + * @context: a #WebKitWebContext + * + * Get the directory path being used to store the favicons database + * for @context, or %NULL if + * webkit_web_context_set_favicon_database_directory() hasn't been + * called yet. + * + * This function will always return the same path after having called + * webkit_web_context_set_favicon_database_directory() for the first + * time. + * + * Returns: (transfer none): the path of the directory of the favicons + * database associated with @context, or %NULL. + */ +const gchar* webkit_web_context_get_favicon_database_directory(WebKitWebContext *context) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); + + WebKitWebContextPrivate* priv = context->priv; + if (priv->faviconDatabaseDirectory.isNull()) + return 0; + + return priv->faviconDatabaseDirectory.data(); +} + +/** + * webkit_web_context_get_favicon_database: + * @context: a #WebKitWebContext + * + * Get the #WebKitFaviconDatabase associated with @context. + * + * To initialize the database you need to call + * webkit_web_context_set_favicon_database_directory(). + * + * Returns: (transfer none): the #WebKitFaviconDatabase of @context. + */ +WebKitFaviconDatabase* webkit_web_context_get_favicon_database(WebKitWebContext* context) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); + + ensureFaviconDatabase(context); + return context->priv->faviconDatabase.get(); +} + /** * webkit_web_context_get_security_manager: * @context: a #WebKitWebContext @@ -354,7 +450,7 @@ void webkit_web_context_set_additional_plugins_directory(WebKitWebContext* conte g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); g_return_if_fail(directory); - toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); + context->priv->context->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); } struct GetPluginsAsyncData { @@ -365,7 +461,7 @@ WEBKIT_DEFINE_ASYNC_DATA_STRUCT(GetPluginsAsyncData) static void webkitWebContextGetPluginThread(GSimpleAsyncResult* result, GObject* object, GCancellable*) { GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(result)); - data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins(); + data->plugins = WEBKIT_WEB_CONTEXT(object)->priv->context->pluginInfoStore().plugins(); } /** @@ -472,8 +568,7 @@ void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const cha RefPtr<WebKitURISchemeHandler> handler = adoptRef(new WebKitURISchemeHandler(callback, userData, destroyNotify)); context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), handler.get()); - WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme)); - WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get()); + context->priv->requestManager->registerURIScheme(String::fromUTF8(scheme)); } /** @@ -587,20 +682,20 @@ void webkit_web_context_set_preferred_languages(WebKitWebContext* context, const WebCore::languageDidChange(); } -WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) +WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy) { - GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload); + GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy); if (download) return download.get(); - download = adoptGRef(webkitDownloadCreate(wkDownload)); - downloadsMap().set(wkDownload, download.get()); + download = adoptGRef(webkitDownloadCreate(toAPI(downloadProxy))); + downloadsMap().set(downloadProxy, download.get()); return download.get(); } -void webkitWebContextRemoveDownload(WKDownloadRef wkDownload) +void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy) { - downloadsMap().remove(wkDownload); + downloadsMap().remove(downloadProxy); } void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* download) @@ -608,14 +703,14 @@ void webkitWebContextDownloadStarted(WebKitWebContext* context, WebKitDownload* g_signal_emit(context, signals[DOWNLOAD_STARTED], 0, download); } -WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context) +WebContext* webkitWebContextGetContext(WebKitWebContext* context) { g_assert(WEBKIT_IS_WEB_CONTEXT(context)); return context->priv->context.get(); } -WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext* context) +WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context) { return context->priv->requestManager.get(); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h index f77086f4d..ae79bec87 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h @@ -28,6 +28,7 @@ #include <webkit2/WebKitCookieManager.h> #include <webkit2/WebKitDefines.h> #include <webkit2/WebKitDownload.h> +#include <webkit2/WebKitFaviconDatabase.h> #include <webkit2/WebKitSecurityManager.h> #include <webkit2/WebKitURISchemeRequest.h> @@ -114,6 +115,15 @@ webkit_web_context_download_uri (WebKitWebContext WEBKIT_API WebKitCookieManager * webkit_web_context_get_cookie_manager (WebKitWebContext *context); +WEBKIT_API WebKitFaviconDatabase * +webkit_web_context_get_favicon_database (WebKitWebContext *context); + +WEBKIT_API void +webkit_web_context_set_favicon_database_directory (WebKitWebContext *context, + const gchar *path); +WEBKIT_API const gchar * +webkit_web_context_get_favicon_database_directory (WebKitWebContext *context); + WEBKIT_API WebKitSecurityManager * webkit_web_context_get_security_manager (WebKitWebContext *context); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h index 9e5536b3a..67be48d5c 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h @@ -26,15 +26,20 @@ #ifndef WebKitWebContextPrivate_h #define WebKitWebContextPrivate_h +#include "DownloadProxy.h" +#include "WebContext.h" #include "WebKitPrivate.h" #include "WebKitURISchemeRequest.h" #include "WebKitWebContext.h" +#include "WebSoupRequestManagerProxy.h" -WKContextRef webkitWebContextGetWKContext(WebKitWebContext*); -WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef); -void webkitWebContextRemoveDownload(WKDownloadRef); +using namespace WebKit; + +WebContext* webkitWebContextGetContext(WebKitWebContext*); +WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy*); +void webkitWebContextRemoveDownload(DownloadProxy*); void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*); -WKSoupRequestManagerRef webkitWebContextGetRequestManager(WebKitWebContext*); +WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*); void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*); void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID); void webkitWebContextDidFinishURIRequest(WebKitWebContext*, uint64_t requestID); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index 301be899c..236a4f304 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -30,6 +30,7 @@ #include "WebKitContextMenuPrivate.h" #include "WebKitEnumTypes.h" #include "WebKitError.h" +#include "WebKitFaviconDatabasePrivate.h" #include "WebKitFormClient.h" #include "WebKitFullscreenClient.h" #include "WebKitHitTestResultPrivate.h" @@ -56,6 +57,7 @@ #include <WebCore/DragIcon.h> #include <WebCore/GOwnPtrGtk.h> #include <WebCore/GtkUtilities.h> +#include <WebCore/RefPtrCairo.h> #include <glib/gi18n-lib.h> #include <wtf/gobject/GOwnPtr.h> #include <wtf/gobject/GRefPtr.h> @@ -102,6 +104,7 @@ enum { PROP_WEB_CONTEXT, PROP_TITLE, PROP_ESTIMATED_LOAD_PROGRESS, + PROP_FAVICON, PROP_URI, PROP_ZOOM_LEVEL, PROP_IS_LOADING @@ -120,6 +123,7 @@ struct _WebKitWebViewPrivate { bool waitingForMainResource; gulong mainResourceResponseHandlerID; + gulong watchForChangesInFaviconHandlerID; WebKitLoadEvent lastDelayedEvent; GRefPtr<WebKitBackForwardList> backForwardList; @@ -139,6 +143,9 @@ struct _WebKitWebViewPrivate { ResourcesMap subresourcesMap; GRefPtr<WebKitWebInspector> inspector; + + RefPtr<cairo_surface_t> favicon; + GRefPtr<GCancellable> faviconCancellable; }; static guint signals[LAST_SIGNAL] = { 0, }; @@ -260,6 +267,37 @@ static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebVie getPage(webView)->setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings))); } +static void webkitWebViewCancelFaviconRequest(WebKitWebView* webView) +{ + if (!webView->priv->faviconCancellable) + return; + + g_cancellable_cancel(webView->priv->faviconCancellable.get()); + webView->priv->faviconCancellable = 0; +} + +static void webkitWebViewUpdateFavicon(WebKitWebView* webView, cairo_surface_t* favicon) +{ + if (webView->priv->favicon.get() == favicon) + return; + + webView->priv->favicon = favicon; + g_object_notify(G_OBJECT(webView), "favicon"); +} + +static void iconReadyCallback(WebKitFaviconDatabase* database, const char* uri, WebKitWebView* webView) +{ + // Consider only the icon matching the active URI for this webview. + if (webView->priv->activeURI != uri) + return; + + // Update the favicon only if we don't have one already. + if (!webView->priv->favicon) { + RefPtr<cairo_surface_t> favicon = adoptRef(webkitFaviconDatabaseGetFavicon(database, webView->priv->activeURI)); + webkitWebViewUpdateFavicon(webView, favicon.get()); + } +} + static void webkitWebViewSetSettings(WebKitWebView* webView, WebKitSettings* settings) { webView->priv->settings = settings; @@ -285,6 +323,29 @@ static void webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(WebK priv->mainResourceResponseHandlerID = 0; } +static void webkitWebViewWatchForChangesInFavicon(WebKitWebView* webView) +{ + WebKitWebViewPrivate* priv = webView->priv; + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); + + // Make sure we only connect to this signal once per view. + if (priv->watchForChangesInFaviconHandlerID) + return; + + priv->watchForChangesInFaviconHandlerID = + g_signal_connect(database, "favicon-ready", G_CALLBACK(iconReadyCallback), webView); +} + +static void webkitWebViewDisconnectFaviconDatabaseSignalHandlers(WebKitWebView* webView) +{ + WebKitWebViewPrivate* priv = webView->priv; + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); + + if (priv->watchForChangesInFaviconHandlerID) + g_signal_handler_disconnect(database, priv->watchForChangesInFaviconHandlerID); + priv->watchForChangesInFaviconHandlerID = 0; +} + static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request) { GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request); @@ -337,7 +398,7 @@ static void webkitWebViewConstructed(GObject* object) WebKitWebViewPrivate* priv = webView->priv; WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView); - webkitWebViewBaseCreateWebPage(webViewBase, toImpl(webkitWebContextGetWKContext(priv->context)), 0); + webkitWebViewBaseCreateWebPage(webViewBase, webkitWebContextGetContext(priv->context), 0); attachLoaderClientToView(webView); attachUIClientToView(webView); @@ -385,6 +446,9 @@ static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* valu case PROP_ESTIMATED_LOAD_PROGRESS: g_value_set_double(value, webkit_web_view_get_estimated_load_progress(webView)); break; + case PROP_FAVICON: + g_value_set_pointer(value, webkit_web_view_get_favicon(webView)); + break; case PROP_URI: g_value_set_string(value, webkit_web_view_get_uri(webView)); break; @@ -411,8 +475,10 @@ static void webkitWebViewFinalize(GObject* object) if (priv->modalLoop && g_main_loop_is_running(priv->modalLoop.get())) g_main_loop_quit(priv->modalLoop.get()); + webkitWebViewCancelFaviconRequest(webView); webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); webkitWebViewDisconnectSettingsSignalHandlers(webView); + webkitWebViewDisconnectFaviconDatabaseSignalHandlers(webView); priv->~WebKitWebViewPrivate(); G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object); @@ -500,6 +566,18 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) 0.0, 1.0, 0.0, WEBKIT_PARAM_READABLE)); /** + * WebKitWebView:favicon: + * + * The favicon currently associated to the #WebKitWebView. + * See webkit_web_view_get_favicon() for more details. + */ + g_object_class_install_property(gObjectClass, + PROP_FAVICON, + g_param_spec_pointer("favicon", + _("Favicon"), + _("The favicon associated to the view, if any"), + WEBKIT_PARAM_READABLE)); + /** * WebKitWebView:uri: * * The current active URI of the #WebKitWebView. @@ -1158,9 +1236,10 @@ static void setCertificateToMainResource(WebKitWebView* webView) static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) { - if (loadEvent == WEBKIT_LOAD_STARTED) + if (loadEvent == WEBKIT_LOAD_STARTED) { webkitWebViewSetIsLoading(webView, true); - else if (loadEvent == WEBKIT_LOAD_FINISHED) { + webkitWebViewWatchForChangesInFavicon(webView); + } else if (loadEvent == WEBKIT_LOAD_FINISHED) { webkitWebViewSetIsLoading(webView, false); webView->priv->waitingForMainResource = false; webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView); @@ -1182,29 +1261,52 @@ static void webkitWebViewEmitDelayedLoadEvents(WebKitWebView* webView) priv->waitingForMainResource = false; } +static void getFaviconReadyCallback(GObject* object, GAsyncResult* result, gpointer userData) +{ + GOwnPtr<GError> error; + RefPtr<cairo_surface_t> favicon = adoptRef(webkit_favicon_database_get_favicon_finish(WEBKIT_FAVICON_DATABASE(object), result, &error.outPtr())); + if (!g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + WebKitWebView* webView = WEBKIT_WEB_VIEW(userData); + webkitWebViewUpdateFavicon(webView, favicon.get()); + webView->priv->faviconCancellable = 0; + } +} + +static void webkitWebViewRequestFavicon(WebKitWebView* webView) +{ + WebKitWebViewPrivate* priv = webView->priv; + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context); + priv->faviconCancellable = adoptGRef(g_cancellable_new()); + webkit_favicon_database_get_favicon(database, priv->activeURI.data(), priv->faviconCancellable.get(), getFaviconReadyCallback, webView); +} + void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) { + WebKitWebViewPrivate* priv = webView->priv; if (loadEvent == WEBKIT_LOAD_STARTED) { // Finish a possible previous load waiting for main resource. webkitWebViewEmitDelayedLoadEvents(webView); - webView->priv->loadingResourcesMap.clear(); - webView->priv->mainResource = 0; - webView->priv->waitingForMainResource = false; + webkitWebViewCancelFaviconRequest(webView); + priv->loadingResourcesMap.clear(); + priv->mainResource = 0; + priv->waitingForMainResource = false; } else if (loadEvent == WEBKIT_LOAD_COMMITTED) { - webView->priv->subresourcesMap.clear(); - if (!webView->priv->mainResource) { + webkitWebViewRequestFavicon(webView); + + priv->subresourcesMap.clear(); + if (!priv->mainResource) { // When a page is loaded from the history cache, the main resource load callbacks // are called when the main frame load is finished. We want to make sure there's a // main resource available when load has been committed, so we delay the emission of // load-changed signal until main resource object has been created. - webView->priv->waitingForMainResource = true; + priv->waitingForMainResource = true; } else setCertificateToMainResource(webView); } - if (webView->priv->waitingForMainResource) - webView->priv->lastDelayedEvent = loadEvent; + if (priv->waitingForMainResource) + priv->lastDelayedEvent = loadEvent; else webkitWebViewEmitLoadChanged(webView, loadEvent); } @@ -1850,6 +1952,26 @@ const gchar* webkit_web_view_get_uri(WebKitWebView* webView) } /** + * webkit_web_view_get_favicon: + * @web_view: a #WebKitWebView + * + * Returns favicon currently associated to @web_view, if any. You can + * connect to notify::favicon signal of @web_view to be notified when + * the favicon is available. + * + * Returns: (transfer none): a pointer to a #cairo_surface_t with the + * favicon or %NULL if there's no icon associated with @web_view. + */ +cairo_surface_t* webkit_web_view_get_favicon(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + if (webView->priv->activeURI.isNull()) + return 0; + + return webView->priv->favicon.get(); +} + +/** * webkit_web_view_get_custom_charset: * @web_view: a #WebKitWebView * @@ -2192,7 +2314,7 @@ static void webkitWebViewRunJavaScriptCallback(WKSerializedScriptValueRef wkSeri g_simple_async_result_take_error(result.get(), error); else if (wkSerializedScriptValue) { GRefPtr<WebKitWebView> webView = adoptGRef(WEBKIT_WEB_VIEW(g_async_result_get_source_object(G_ASYNC_RESULT(result.get())))); - data->scriptResult = webkitJavascriptResultCreate(webView.get(), wkSerializedScriptValue); + data->scriptResult = webkitJavascriptResultCreate(webView.get(), toImpl(wkSerializedScriptValue)); } else { g_set_error_literal(&error, WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED, _("An exception was raised in JavaScript")); g_simple_async_result_take_error(result.get(), error); @@ -2307,6 +2429,94 @@ WebKitJavascriptResult* webkit_web_view_run_javascript_finish(WebKitWebView* web return data->scriptResult ? webkit_javascript_result_ref(data->scriptResult) : 0; } +static void resourcesStreamReadCallback(GObject* object, GAsyncResult* result, gpointer userData) +{ + GOutputStream* outputStream = G_OUTPUT_STREAM(object); + GRefPtr<GSimpleAsyncResult> runJavascriptResult = adoptGRef(G_SIMPLE_ASYNC_RESULT(userData)); + + GError* error = 0; + g_output_stream_splice_finish(outputStream, result, &error); + if (error) { + g_simple_async_result_take_error(runJavascriptResult.get(), error); + g_simple_async_result_complete(runJavascriptResult.get()); + return; + } + + GRefPtr<WebKitWebView> webView = adoptGRef(WEBKIT_WEB_VIEW(g_async_result_get_source_object(G_ASYNC_RESULT(runJavascriptResult.get())))); + gpointer outputStreamData = g_memory_output_stream_get_data(G_MEMORY_OUTPUT_STREAM(outputStream)); + getPage(webView.get())->runJavaScriptInMainFrame(String::fromUTF8(reinterpret_cast<const gchar*>(outputStreamData)), + ScriptValueCallback::create(runJavascriptResult.leakRef(), webkitWebViewRunJavaScriptCallback)); +} + +/** + * webkit_web_view_run_javascript_from_gresource: + * @web_view: a #WebKitWebView + * @resource: the location of the resource to load + * @cancellable: (allow-none): a #GCancellable or %NULL to ignore + * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished + * @user_data: (closure): the data to pass to callback function + * + * Asynchronously run the script from @resource in the context of the + * current page in @web_view. + * + * When the operation is finished, @callback will be called. You can + * then call webkit_web_view_run_javascript_from_gresource_finish() to get the result + * of the operation. + */ +void webkit_web_view_run_javascript_from_gresource(WebKitWebView* webView, const gchar* resource, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + g_return_if_fail(resource); + + GRefPtr<GSimpleAsyncResult> result = adoptGRef(g_simple_async_result_new(G_OBJECT(webView), callback, userData, + reinterpret_cast<gpointer>(webkit_web_view_run_javascript_from_gresource))); + RunJavaScriptAsyncData* data = createRunJavaScriptAsyncData(); + data->cancellable = cancellable; + g_simple_async_result_set_op_res_gpointer(result.get(), data, reinterpret_cast<GDestroyNotify>(destroyRunJavaScriptAsyncData)); + + GError* error = 0; + GRefPtr<GInputStream> inputStream = adoptGRef(g_resources_open_stream(resource, G_RESOURCE_LOOKUP_FLAGS_NONE, &error)); + if (error) { + g_simple_async_result_take_error(result.get(), error); + g_simple_async_result_complete_in_idle(result.get()); + return; + } + + GRefPtr<GOutputStream> outputStream = adoptGRef(g_memory_output_stream_new(0, 0, fastRealloc, fastFree)); + g_output_stream_splice_async(outputStream.get(), inputStream.get(), + static_cast<GOutputStreamSpliceFlags>(G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET), + G_PRIORITY_DEFAULT, + cancellable, resourcesStreamReadCallback, result.leakRef()); +} + +/** + * webkit_web_view_run_javascript_from_gresource_finish: + * @web_view: a #WebKitWebView + * @result: a #GAsyncResult + * @error: return location for error or %NULL to ignore + * + * Finish an asynchronous operation started with webkit_web_view_run_javascript_from_gresource(). + * + * Check webkit_web_view_run_javascript_finish() for a usage example. + * + * Returns: (transfer full): a #WebKitJavascriptResult with the result of the last executed statement in @script + * or %NULL in case of error + */ +WebKitJavascriptResult* webkit_web_view_run_javascript_from_gresource_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + g_return_val_if_fail(G_IS_ASYNC_RESULT(result), 0); + + GSimpleAsyncResult* simpleResult = G_SIMPLE_ASYNC_RESULT(result); + g_warn_if_fail(g_simple_async_result_get_source_tag(simpleResult) == webkit_web_view_run_javascript_from_gresource); + + if (g_simple_async_result_propagate_error(simpleResult, error)) + return 0; + + RunJavaScriptAsyncData* data = static_cast<RunJavaScriptAsyncData*>(g_simple_async_result_get_op_res_gpointer(simpleResult)); + return data->scriptResult ? webkit_javascript_result_ref(data->scriptResult) : 0; +} + /** * webkit_web_view_get_main_resource: * @web_view: a #WebKitWebView @@ -2341,7 +2551,7 @@ GList* webkit_web_view_get_subresources(WebKitWebView* webView) WebKitWebViewPrivate* priv = webView->priv; ResourcesMap::const_iterator end = priv->subresourcesMap.end(); for (ResourcesMap::const_iterator it = priv->subresourcesMap.begin(); it != end; ++it) - subresources = g_list_prepend(subresources, it->second.get()); + subresources = g_list_prepend(subresources, it->value.get()); return g_list_reverse(subresources); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h index 8a397b752..ac2e2813f 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h @@ -191,170 +191,185 @@ struct _WebKitWebViewClass { }; WEBKIT_API GType -webkit_web_view_get_type (void); +webkit_web_view_get_type (void); WEBKIT_API GtkWidget * -webkit_web_view_new (void); +webkit_web_view_new (void); WEBKIT_API GtkWidget * -webkit_web_view_new_with_context (WebKitWebContext *context); +webkit_web_view_new_with_context (WebKitWebContext *context); WEBKIT_API WebKitWebContext * -webkit_web_view_get_context (WebKitWebView *web_view); +webkit_web_view_get_context (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_load_uri (WebKitWebView *web_view, - const gchar *uri); +webkit_web_view_load_uri (WebKitWebView *web_view, + const gchar *uri); WEBKIT_API void -webkit_web_view_load_html (WebKitWebView *web_view, - const gchar *content, - const gchar *base_uri); +webkit_web_view_load_html (WebKitWebView *web_view, + const gchar *content, + const gchar *base_uri); WEBKIT_API void -webkit_web_view_load_alternate_html (WebKitWebView *web_view, - const gchar *content, - const gchar *content_uri, - const gchar *base_uri); +webkit_web_view_load_alternate_html (WebKitWebView *web_view, + const gchar *content, + const gchar *content_uri, + const gchar *base_uri); WEBKIT_API void -webkit_web_view_load_plain_text (WebKitWebView *web_view, - const gchar *plain_text); +webkit_web_view_load_plain_text (WebKitWebView *web_view, + const gchar *plain_text); WEBKIT_API void -webkit_web_view_load_request (WebKitWebView *web_view, - WebKitURIRequest *request); +webkit_web_view_load_request (WebKitWebView *web_view, + WebKitURIRequest *request); WEBKIT_API void -webkit_web_view_stop_loading (WebKitWebView *web_view); +webkit_web_view_stop_loading (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_is_loading (WebKitWebView *web_view); +webkit_web_view_is_loading (WebKitWebView *web_view); WEBKIT_API const gchar * -webkit_web_view_get_title (WebKitWebView *web_view); +webkit_web_view_get_title (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_reload (WebKitWebView *web_view); +webkit_web_view_reload (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); +webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); WEBKIT_API gdouble -webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); +webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_back (WebKitWebView *web_view); +webkit_web_view_go_back (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_go_back (WebKitWebView *web_view); +webkit_web_view_can_go_back (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_forward (WebKitWebView *web_view); +webkit_web_view_go_forward (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_go_forward (WebKitWebView *web_view); +webkit_web_view_can_go_forward (WebKitWebView *web_view); WEBKIT_API WebKitBackForwardList * -webkit_web_view_get_back_forward_list (WebKitWebView *web_view); +webkit_web_view_get_back_forward_list (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, - WebKitBackForwardListItem *list_item); +webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, + WebKitBackForwardListItem *list_item); WEBKIT_API const gchar * -webkit_web_view_get_uri (WebKitWebView *web_view); +webkit_web_view_get_uri (WebKitWebView *web_view); + +WEBKIT_API cairo_surface_t * +webkit_web_view_get_favicon (WebKitWebView *web_view); WEBKIT_API const gchar * -webkit_web_view_get_custom_charset (WebKitWebView *web_view); +webkit_web_view_get_custom_charset (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_custom_charset (WebKitWebView *web_view, - const gchar *charset); +webkit_web_view_set_custom_charset (WebKitWebView *web_view, + const gchar *charset); WEBKIT_API void -webkit_web_view_set_settings (WebKitWebView *web_view, - WebKitSettings *settings); +webkit_web_view_set_settings (WebKitWebView *web_view, + WebKitSettings *settings); WEBKIT_API WebKitSettings * -webkit_web_view_get_settings (WebKitWebView *web_view); +webkit_web_view_get_settings (WebKitWebView *web_view); WEBKIT_API WebKitWindowProperties * -webkit_web_view_get_window_properties (WebKitWebView *web_view); +webkit_web_view_get_window_properties (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_zoom_level (WebKitWebView *web_view, - gdouble zoom_level); +webkit_web_view_set_zoom_level (WebKitWebView *web_view, + gdouble zoom_level); WEBKIT_API gdouble -webkit_web_view_get_zoom_level (WebKitWebView *web_view); +webkit_web_view_get_zoom_level (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, - const gchar *command, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, + const gchar *command, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); WEBKIT_API gboolean -webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); +webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); WEBKIT_API void -webkit_web_view_execute_editing_command (WebKitWebView *web_view, - const gchar *command); +webkit_web_view_execute_editing_command (WebKitWebView *web_view, + const gchar *command); WEBKIT_API WebKitFindController * -webkit_web_view_get_find_controller (WebKitWebView *web_view); +webkit_web_view_get_find_controller (WebKitWebView *web_view); WEBKIT_API JSGlobalContextRef -webkit_web_view_get_javascript_global_context (WebKitWebView *web_view); +webkit_web_view_get_javascript_global_context (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_run_javascript (WebKitWebView *web_view, - const gchar *script, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +webkit_web_view_run_javascript (WebKitWebView *web_view, + const gchar *script, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +WEBKIT_API WebKitJavascriptResult * +webkit_web_view_run_javascript_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); + +WEBKIT_API void +webkit_web_view_run_javascript_from_gresource (WebKitWebView *web_view, + const gchar *resource, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + WEBKIT_API WebKitJavascriptResult * -webkit_web_view_run_javascript_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); +webkit_web_view_run_javascript_from_gresource_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); WEBKIT_API WebKitWebResource * -webkit_web_view_get_main_resource (WebKitWebView *web_view); +webkit_web_view_get_main_resource (WebKitWebView *web_view); WEBKIT_API GList * -webkit_web_view_get_subresources (WebKitWebView *web_view); +webkit_web_view_get_subresources (WebKitWebView *web_view); WEBKIT_API WebKitWebInspector * -webkit_web_view_get_inspector (WebKitWebView *web_view); +webkit_web_view_get_inspector (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_show_mime_type (WebKitWebView *web_view, - const gchar *mime_type); +webkit_web_view_can_show_mime_type (WebKitWebView *web_view, + const gchar *mime_type); WEBKIT_API void -webkit_web_view_save (WebKitWebView *web_view, - WebKitSaveMode save_mode, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +webkit_web_view_save (WebKitWebView *web_view, + WebKitSaveMode save_mode, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); WEBKIT_API GInputStream * -webkit_web_view_save_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); +webkit_web_view_save_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); WEBKIT_API void -webkit_web_view_save_to_file (WebKitWebView *web_view, - GFile *file, - WebKitSaveMode save_mode, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +webkit_web_view_save_to_file (WebKitWebView *web_view, + GFile *file, + WebKitSaveMode save_mode, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); WEBKIT_API gboolean -webkit_web_view_save_to_file_finish (WebKitWebView *web_view, - GAsyncResult *result, - GError **error); +webkit_web_view_save_to_file_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp index b42b2ee8f..e5bac671e 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -75,6 +75,10 @@ using namespace WebCore; typedef HashMap<GtkWidget*, IntRect> WebKitWebViewChildrenMap; +#if USE(TEXTURE_MAPPER_GL) +void redirectedWindowDamagedCallback(void* data); +#endif + struct _WebKitWebViewBasePrivate { WebKitWebViewChildrenMap children; OwnPtr<PageClientImpl> pageClient; @@ -111,7 +115,6 @@ struct _WebKitWebViewBasePrivate { #if USE(TEXTURE_MAPPER_GL) OwnPtr<RedirectedXCompositeWindow> redirectedWindow; - bool readyToRenderAcceleratedCompositingResults; #endif }; @@ -300,7 +303,7 @@ static void webkitWebViewBaseContainerForall(GtkContainer* container, gboolean i WebKitWebViewChildrenMap children = priv->children; WebKitWebViewChildrenMap::const_iterator end = children.end(); for (WebKitWebViewChildrenMap::const_iterator current = children.begin(); current != end; ++current) - (*callback)(current->first, callbackData); + (*callback)(current->key, callbackData); if (includeInternals && priv->inspectorView) (*callback)(priv->inspectorView, callbackData); @@ -351,7 +354,8 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase) #if USE(TEXTURE_MAPPER_GL) priv->redirectedWindow = RedirectedXCompositeWindow::create(IntSize(1, 1)); - priv->readyToRenderAcceleratedCompositingResults = false; + if (priv->redirectedWindow) + priv->redirectedWindow->setDamageNotifyCallback(redirectedWindowDamagedCallback, webkitWebViewBase); #endif } @@ -364,10 +368,9 @@ static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* // To avoid flashes when initializing accelerated compositing for the first // time, we wait until we know there's a frame ready before rendering. WebKitWebViewBasePrivate* priv = webViewBase->priv; - if (!priv->readyToRenderAcceleratedCompositingResults) + if (!priv->redirectedWindow) return false; - ASSERT(priv->redirectedWindow); cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height); cairo_surface_t* surface = priv->redirectedWindow->cairoSurfaceForWidget(GTK_WIDGET(webViewBase)); cairo_set_source_surface(cr, surface, 0, 0); @@ -430,7 +433,7 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase } #if USE(TEXTURE_MAPPER_GL) - if (sizeChanged) + if (sizeChanged && webViewBase->priv->redirectedWindow) webViewBase->priv->redirectedWindow->resize(viewRect.size()); #endif @@ -801,7 +804,8 @@ void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebCon #endif #if USE(TEXTURE_MAPPER_GL) - priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId()); + if (priv->redirectedWindow) + priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId()); #endif } @@ -928,37 +932,9 @@ GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase* webkitWebView } #if USE(TEXTURE_MAPPER_GL) -static gboolean queueAnotherDrawOfAcceleratedCompositingResults(gpointer* webViewBasePointer) +void redirectedWindowDamagedCallback(void* data) { - // The WebViewBase may have been destroyed in the time since we queued this - // draw and the time we are actually executing. - if (!*webViewBasePointer) { - fastFree(webViewBasePointer); - return FALSE; - } - - WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(*webViewBasePointer); - gtk_widget_queue_draw(GTK_WIDGET(webViewBase)); - webViewBase->priv->readyToRenderAcceleratedCompositingResults = true; - - g_object_remove_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer); - fastFree(webViewBasePointer); - - return FALSE; -} - -void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase* webViewBase) -{ - gtk_widget_queue_draw(GTK_WIDGET(webViewBase)); - - // Redraw again, one frame later, as it might take some time for the new GL frame to be available. - // This prevents the display from always being one frame behind in the case GL hasn't yet finished - // rendering to the window. - // TODO: Add XDamage support to RedirectedXCompositeWindow to accomplish this. - gpointer* webViewBasePointer = static_cast<gpointer*>(fastMalloc(sizeof(gpointer))); - g_object_add_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer); - *webViewBasePointer = webViewBase; - g_timeout_add(1000 / 60, reinterpret_cast<GSourceFunc>(queueAnotherDrawOfAcceleratedCompositingResults), webViewBasePointer); + gtk_widget_queue_draw(GTK_WIDGET(data)); } #endif diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml index a7f34e6d1..8623af33e 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml @@ -30,6 +30,7 @@ <xi:include href="xml/WebKitPrintOperation.xml"/> <xi:include href="xml/WebKitWebResource.xml"/> <xi:include href="xml/WebKitError.xml"/> + <xi:include href="xml/WebKitFaviconDatabase.xml"/> <xi:include href="xml/WebKitFileChooserRequest.xml"/> <xi:include href="xml/WebKitFindController.xml"/> <xi:include href="xml/WebKitCookieManager.xml"/> diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt index 1827b6b16..f56267b9a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt @@ -30,6 +30,9 @@ webkit_web_context_set_cache_model webkit_web_context_clear_cache webkit_web_context_download_uri webkit_web_context_get_cookie_manager +webkit_web_context_get_favicon_database +webkit_web_context_set_favicon_database_directory +webkit_web_context_get_favicon_database_directory webkit_web_context_get_security_manager webkit_web_context_set_additional_plugins_directory webkit_web_context_get_plugins @@ -98,6 +101,7 @@ webkit_web_view_set_custom_charset webkit_web_view_get_back_forward_list webkit_web_view_go_to_back_forward_list_item webkit_web_view_get_uri +webkit_web_view_get_favicon webkit_web_view_set_settings webkit_web_view_get_settings webkit_web_view_get_window_properties @@ -111,6 +115,8 @@ webkit_web_view_get_inspector webkit_web_view_get_javascript_global_context webkit_web_view_run_javascript webkit_web_view_run_javascript_finish +webkit_web_view_run_javascript_from_gresource +webkit_web_view_run_javascript_from_gresource_finish webkit_web_view_can_show_mime_type webkit_web_view_save webkit_web_view_save_finish @@ -291,6 +297,8 @@ webkit_settings_set_enable_page_cache webkit_settings_get_user_agent webkit_settings_set_user_agent webkit_settings_set_user_agent_with_application_details +webkit_settings_get_enable_smooth_scrolling +webkit_settings_set_enable_smooth_scrolling <SUBSECTION Standard> WebKitSettingsClass @@ -602,6 +610,31 @@ webkit_javascript_error_quark </SECTION> <SECTION> +<FILE>WebKitFaviconDatabase</FILE> +WebKitFaviconDatabase +WEBKIT_FAVICON_DATABASE_ERROR +WebKitFaviconDatabaseError +webkit_favicon_database_get_favicon +webkit_favicon_database_get_favicon_finish +webkit_favicon_database_get_favicon_uri +webkit_favicon_database_clear + +<SUBSECTION Standard> +WebKitFaviconDatabaseClass +WEBKIT_TYPE_FAVICON_DATABASE +WEBKIT_FAVICON_DATABASE +WEBKIT_IS_FAVICON_DATABASE +WEBKIT_FAVICON_DATABASE_CLASS +WEBKIT_IS_FAVICON_DATABASE_CLASS +WEBKIT_FAVICON_DATABASE_GET_CLASS + +<SUBSECTION Private> +WebKitFaviconDatabasePrivate +webkit_favicon_database_get_type +webkit_favicon_database_error_quark +</SECTION> + +<SECTION> <FILE>WebKitFileChooserRequest</FILE> WebKitFileChooserRequest webkit_file_chooser_request_get_mime_types @@ -745,6 +778,7 @@ WebKitURISchemeRequest webkit_uri_scheme_request_get_scheme webkit_uri_scheme_request_get_uri webkit_uri_scheme_request_get_path +webkit_uri_scheme_request_get_web_view webkit_uri_scheme_request_finish <SUBSECTION Standard> diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am index 3fadf40b4..06ea1af7c 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am +++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am @@ -11,6 +11,7 @@ TEST_PROGS += \ Programs/WebKit2APITests/TestResources \ Programs/WebKit2APITests/TestSSL \ Programs/WebKit2APITests/TestWebKitVersion \ + Programs/WebKit2APITests/TestWebKitFaviconDatabase \ Programs/WebKit2APITests/TestWebKitFindController \ Programs/WebKit2APITests/TestWebKitPolicyClient \ Programs/WebKit2APITests/TestWebKitSettings \ @@ -29,6 +30,7 @@ endif webkit2_tests_cppflags = \ -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs\" \ -DWEBKIT_SRC_DIR=\"${shell pwd}/${srcdir}\" \ + -DWEBKIT_DERIVED_SRC_DIR=\"${shell pwd}/${top_builddir}/DerivedSources\" \ $(javascriptcore_cppflags) \ -I$(srcdir)/Source/JavaScriptCore \ -I$(srcdir)/Source \ @@ -55,6 +57,12 @@ 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) --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 + noinst_LTLIBRARIES += Libraries/libWebKit2APITestCore.la Libraries_libWebKit2APITestCore_la_SOURCES = \ Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp \ @@ -69,7 +77,9 @@ Libraries_libWebKit2APITestCore_la_CPPFLAGS = $(webkit2_tests_cppflags) EXTRA_DIST += \ Source/WebKit2/UIProcess/API/gtk/tests/resources/test-cert.pem \ - Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem + Source/WebKit2/UIProcess/API/gtk/tests/resources/test-key.pem \ + Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml \ + Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp @@ -141,6 +151,12 @@ Programs_WebKit2APITests_TestPrinting_CPPFLAGS = $(webkit2_tests_cppflags) $(GTK Programs_WebKit2APITests_TestPrinting_LDADD = $(webkit2_tests_ldadd) $(GTK_UNIX_PRINTING_LIBS) Programs_WebKit2APITests_TestPrinting_LDFLAGS = $(webkit2_tests_ldflags) +Programs_WebKit2APITests_TestWebKitFaviconDatabase_SOURCES = \ + Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp +Programs_WebKit2APITests_TestWebKitFaviconDatabase_CPPFLAGS = $(webkit2_tests_cppflags) +Programs_WebKit2APITests_TestWebKitFaviconDatabase_LDADD = $(webkit2_tests_ldadd) +Programs_WebKit2APITests_TestWebKitFaviconDatabase_LDFLAGS = $(webkit2_tests_ldflags) + Programs_WebKit2APITests_TestWebKitFindController_SOURCES = \ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFindController.cpp Programs_WebKit2APITests_TestWebKitFindController_CPPFLAGS = $(webkit2_tests_cppflags) diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp index e70e391ff..b479366a4 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp @@ -38,6 +38,11 @@ static void serverCallback(SoupServer* server, SoupMessage* msg, const char* pat return; } + if (g_str_has_suffix(path, "favicon.ico")) { + soup_message_set_status(msg, SOUP_STATUS_NOT_FOUND); + return; + } + soup_message_set_status(msg, SOUP_STATUS_OK); char* body = g_strdup_printf("<html><title>%s</title><body>%s</body></html>", path + 1, path + 1); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp index 2fe8998b5..94aeef6e1 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestCookieManager.cpp @@ -295,7 +295,7 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* } else if (g_str_equal(path, "/image.png")) soup_message_headers_replace(message->response_headers, "Set-Cookie", "baz=qux; Max-Age=60"); else - g_assert_not_reached(); + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); soup_message_body_complete(message->response_body); } diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp index c3a14193d..8fcf33009 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestLoaderClient.cpp @@ -312,7 +312,8 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); soup_server_unpause_message(server, message); return; - } + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); soup_message_body_complete(message->response_body); } diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp index 8622af19c..9db47f82b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp @@ -25,12 +25,24 @@ void beforeAll(); void afterAll(); +static void registerGResource(void) +{ + GOwnPtr<char> resourcesPath(g_build_filename(WEBKIT_DERIVED_SRC_DIR, "WebKit2", "webkit2gtk-tests-resources.gresource", NULL)); + GResource* resource = g_resource_load(resourcesPath.get(), 0); + g_assert(resource); + + g_resources_register(resource); + g_resource_unref(resource); +} + int main(int argc, char** argv) { gtk_test_init(&argc, &argv, 0); g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE); g_test_bug_base("https://bugs.webkit.org/"); + registerGResource(); + beforeAll(); int returnValue = g_test_run(); afterAll(); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp index 7e2e5de61..20b90b0b4 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp @@ -80,6 +80,11 @@ public: { test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(resource)); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); + + // Ignore favicons. + if (g_str_has_suffix(webkit_uri_request_get_uri(request), "favicon.ico")) + return; + test->resourceLoadStarted(resource, request); g_signal_connect(resource, "sent-request", G_CALLBACK(resourceSentRequestCallback), test); g_signal_connect(resource, "notify::response", G_CALLBACK(resourceReceivedResponseCallback), test); @@ -507,21 +512,31 @@ static void testWebResourceGetData(ResourcesTest* test, gconstpointer) static void testWebViewResourcesHistoryCache(SingleResourceLoadTest* test, gconstpointer) { - test->loadURI(kServer->getURIForPath("/").data()); + CString javascriptURI = kServer->getURIForPath("/javascript.html"); + test->loadURI(javascriptURI.data()); test->waitUntilResourceLoadFinished(); - g_assert(webkit_web_view_get_main_resource(test->m_webView)); + WebKitWebResource* resource = webkit_web_view_get_main_resource(test->m_webView); + g_assert(resource); + g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data()); - test->loadURI(kServer->getURIForPath("/javascript.html").data()); + CString simpleStyleCSSURI = kServer->getURIForPath("/simple-style-css.html"); + test->loadURI(simpleStyleCSSURI.data()); test->waitUntilResourceLoadFinished(); - g_assert(webkit_web_view_get_main_resource(test->m_webView)); + resource = webkit_web_view_get_main_resource(test->m_webView); + g_assert(resource); + g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data()); test->goBack(); test->waitUntilResourceLoadFinished(); - g_assert(webkit_web_view_get_main_resource(test->m_webView)); + resource = webkit_web_view_get_main_resource(test->m_webView); + g_assert(resource); + g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, javascriptURI.data()); test->goForward(); test->waitUntilResourceLoadFinished(); - g_assert(webkit_web_view_get_main_resource(test->m_webView)); + resource = webkit_web_view_get_main_resource(test->m_webView); + g_assert(resource); + g_assert_cmpstr(webkit_web_resource_get_uri(resource), ==, simpleStyleCSSURI.data()); } static void addCacheHTTPHeadersToResponse(SoupMessage* message) @@ -567,6 +582,9 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* } else if (g_str_equal(path, "/invalid-css.html")) { static const char* invalidCSSHtml = "<html><head><link rel='stylesheet' href='/invalid.css' type='text/css'></head><body></html>"; soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, invalidCSSHtml, strlen(invalidCSSHtml)); + } else if (g_str_equal(path, "/simple-style-css.html")) { + static const char* simpleStyleCSSHtml = "<html><head><link rel='stylesheet' href='/simple-style.css' type='text/css'></head><body></html>"; + soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, simpleStyleCSSHtml, strlen(simpleStyleCSSHtml)); } else if (g_str_equal(path, "/style.css")) { soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleCSS, strlen(kStyleCSS)); addCacheHTTPHeadersToResponse(message); @@ -594,6 +612,8 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* soup_message_headers_append(message->response_headers, "Location", "/simple-style.css"); } else if (g_str_equal(path, "/invalid.css")) soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT); + else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); soup_message_body_complete(message->response_body); } diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp index 40e9fbeee..8fa013dc4 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp @@ -82,9 +82,12 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* return; } - soup_message_set_status(message, SOUP_STATUS_OK); - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, indexHTML, strlen(indexHTML)); - soup_message_body_complete(message->response_body); + if (g_str_equal(path, "/")) { + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, indexHTML, strlen(indexHTML)); + soup_message_body_complete(message->response_body); + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); } void beforeAll() diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp new file mode 100644 index 000000000..40fb5a17a --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitFaviconDatabase.cpp @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * 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 + * 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 "WebKitTestServer.h" +#include "WebViewTest.h" +#include <glib/gstdio.h> +#include <libsoup/soup.h> +#include <wtf/gobject/GOwnPtr.h> + +static WebKitTestServer* kServer; +static char* kTempDirectory; + +class FaviconDatabaseTest: public WebViewTest { +public: + MAKE_GLIB_TEST_FIXTURE(FaviconDatabaseTest); + + FaviconDatabaseTest() + : m_webContext(webkit_web_context_get_default()) + , m_favicon(0) + , m_error(0) + , m_iconReadySignalReceived(false) + , m_faviconNotificationReceived(false) + { + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); + g_signal_connect(database, "favicon-ready", G_CALLBACK(iconReadyCallback), this); + } + + ~FaviconDatabaseTest() + { + if (m_favicon) + cairo_surface_destroy(m_favicon); + + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); + g_signal_handlers_disconnect_matched(database, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this); + } + + static void iconReadyCallback(WebKitFaviconDatabase* database, const char* pageURI, FaviconDatabaseTest* test) + { + g_assert_cmpstr(webkit_web_view_get_uri(test->m_webView), ==, pageURI); + test->m_iconReadySignalReceived = true; + } + + static void faviconChangedCallback(WebKitWebView* webView, GParamSpec* pspec, gpointer data) + { + FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data); + g_assert(test->m_webView == webView); + test->m_faviconNotificationReceived = true; + test->quitMainLoop(); + } + + static void getFaviconCallback(GObject* sourceObject, GAsyncResult* result, void* data) + { + FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data); + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); + test->m_favicon = webkit_favicon_database_get_favicon_finish(database, result, &test->m_error.outPtr()); + test->quitMainLoop(); + } + + void waitUntilFaviconChanged() + { + m_faviconNotificationReceived = false; + unsigned long handlerID = g_signal_connect(m_webView, "notify::favicon", G_CALLBACK(faviconChangedCallback), this); + g_main_loop_run(m_mainLoop); + g_signal_handler_disconnect(m_webView, handlerID); + } + + void getFaviconForPageURIAndWaitUntilReady(const char* pageURI) + { + m_error.clear(); + if (m_favicon) { + cairo_surface_destroy(m_favicon); + m_favicon = 0; + } + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext); + webkit_favicon_database_get_favicon(database, pageURI, 0, getFaviconCallback, this); + g_main_loop_run(m_mainLoop); + } + + WebKitWebContext* m_webContext; + cairo_surface_t* m_favicon; + GOwnPtr<GError> m_error; + bool m_iconReadySignalReceived; + bool m_faviconNotificationReceived; +}; + +static void +serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable* query, SoupClientContext* context, void* data) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + char* contents; + gsize length; + if (g_str_equal(path, "/favicon.ico")) { + GOwnPtr<char> pathToFavicon(g_build_filename(Test::getWebKit1TestResoucesDir().data(), "blank.ico", NULL)); + g_file_get_contents(pathToFavicon.get(), &contents, &length, 0); + } else if (g_str_equal(path, "/nofavicon/favicon.ico")) { + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); + soup_message_body_complete(message->response_body); + return; + } else { + contents = g_strdup("<html><body>test</body></html>"); + length = strlen(contents); + } + + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length); + soup_message_body_complete(message->response_body); +} + +static void testNotInitialized(FaviconDatabaseTest* test, gconstpointer) +{ + // Try to retrieve a valid favicon from a not initialized database. + test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/").data()); + g_assert(!test->m_favicon); + g_assert(test->m_error); + g_assert_cmpint(test->m_error->code, ==, WEBKIT_FAVICON_DATABASE_ERROR_NOT_INITIALIZED); +} + +static void testSetDirectory(FaviconDatabaseTest* test, gconstpointer) +{ + webkit_web_context_set_favicon_database_directory(test->m_webContext, kTempDirectory); + g_assert_cmpstr(kTempDirectory, ==, webkit_web_context_get_favicon_database_directory(test->m_webContext)); +} + +static void testClearDatabase(FaviconDatabaseTest* test, gconstpointer) +{ + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); + webkit_favicon_database_clear(database); + + GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, kServer->getURIForPath("/").data())); + g_assert(!iconURI); +} + +static void testGetFavicon(FaviconDatabaseTest* test, gconstpointer) +{ + // We need to load the page first to ensure the icon data will be + // in the database in case there's an associated favicon. + test->loadURI(kServer->getURIForPath("/").data()); + test->waitUntilFaviconChanged(); + g_assert(test->m_iconReadySignalReceived); + + // Check the API retrieving a valid favicon. + test->m_iconReadySignalReceived = false; + test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/").data()); + g_assert(test->m_favicon); + g_assert(!test->m_error); + g_assert(!test->m_iconReadySignalReceived); + + // Check that width and height match those from blank.ico (16x16 favicon). + g_assert_cmpint(cairo_image_surface_get_width(test->m_favicon), ==, 16); + g_assert_cmpint(cairo_image_surface_get_height(test->m_favicon), ==, 16); + + // Check the API retrieving an invalid favicon. + test->loadURI(kServer->getURIForPath("/nofavicon").data()); + test->waitUntilFaviconChanged(); + g_assert(!test->m_iconReadySignalReceived); + + test->getFaviconForPageURIAndWaitUntilReady(kServer->getURIForPath("/nofavicon/").data()); + g_assert(!test->m_favicon); + g_assert(test->m_error); + g_assert(!test->m_iconReadySignalReceived); +} + +static void testGetFaviconURI(FaviconDatabaseTest* test, gconstpointer) +{ + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext); + + const char* baseURI = kServer->getURIForPath("/").data(); + GOwnPtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI)); + g_assert_cmpstr(iconURI.get(), ==, kServer->getURIForPath("/favicon.ico").data()); +} + +static void testWebViewFavicon(FaviconDatabaseTest* test, gconstpointer) +{ + cairo_surface_t* iconFromWebView = webkit_web_view_get_favicon(test->m_webView); + g_assert(!iconFromWebView); + + test->loadURI(kServer->getURIForPath("/").data()); + test->waitUntilFaviconChanged(); + g_assert(test->m_faviconNotificationReceived); + + iconFromWebView = webkit_web_view_get_favicon(test->m_webView); + g_assert(iconFromWebView); + g_assert_cmpuint(cairo_image_surface_get_width(iconFromWebView), ==, 16); + g_assert_cmpuint(cairo_image_surface_get_height(iconFromWebView), ==, 16); +} + +void beforeAll() +{ + // Start a soup server for testing. + kServer = new WebKitTestServer(); + kServer->run(serverCallback); + + kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0); + g_assert(kTempDirectory); + + // Add tests to the suite. + FaviconDatabaseTest::add("WebKitFaviconDatabase", "not-initialized", testNotInitialized); + FaviconDatabaseTest::add("WebKitFaviconDatabase", "set-directory", testSetDirectory); + FaviconDatabaseTest::add("WebKitFaviconDatabase", "get-favicon", testGetFavicon); + FaviconDatabaseTest::add("WebKitFaviconDatabase", "get-favicon-uri", testGetFaviconURI); + FaviconDatabaseTest::add("WebKitFaviconDatabase", "clear-database", testClearDatabase); + FaviconDatabaseTest::add("WebKitWebView", "favicon", testWebViewFavicon); +} + +static void webkitFaviconDatabaseFinalizedCallback(gpointer, GObject*) +{ + if (!g_file_test(kTempDirectory, G_FILE_TEST_IS_DIR)) + return; + + GOwnPtr<char> filename(g_build_filename(kTempDirectory, "WebpageIcons.db", NULL)); + g_unlink(filename.get()); + + g_rmdir(kTempDirectory); +} + +void afterAll() +{ + delete kServer; + + // Delete the temporary files after the IconDatabase has been + // closed, that is, once WebKitFaviconDatabase is being destroyed. + WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webkit_web_context_get_default()); + g_object_weak_ref(G_OBJECT(database), webkitFaviconDatabaseFinalizedCallback, 0); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp index 9f6ce7819..abbfd652a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp @@ -232,11 +232,13 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* return; } - soup_message_set_status(message, SOUP_STATUS_OK); - - static const char* responseString = "<html><body>Testing!</body></html>"; - soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); - soup_message_body_complete(message->response_body); + if (g_str_equal(path, "/")) { + static const char* responseString = "<html><body>Testing!</body></html>"; + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); + soup_message_body_complete(message->response_body); + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); } void beforeAll() diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp index d8e355472..c7a0dc259 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp @@ -243,6 +243,11 @@ static void testWebKitSettings(Test*, gconstpointer) webkit_settings_set_enable_page_cache(settings, FALSE); g_assert(!webkit_settings_get_enable_page_cache(settings)); + // By default, smooth scrolling is disabled. + g_assert(!webkit_settings_get_enable_smooth_scrolling(settings)); + webkit_settings_set_enable_smooth_scrolling(settings, TRUE); + g_assert(webkit_settings_get_enable_smooth_scrolling(settings)); + g_object_unref(G_OBJECT(settings)); } @@ -315,10 +320,13 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* return; } - soup_message_set_status(message, SOUP_STATUS_OK); - const char* userAgent = soup_message_headers_get_one(message->request_headers, "User-Agent"); - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, userAgent, strlen(userAgent)); - soup_message_body_complete(message->response_body); + if (g_str_equal(path, "/")) { + const char* userAgent = soup_message_headers_get_one(message->request_headers, "User-Agent"); + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, userAgent, strlen(userAgent)); + soup_message_body_complete(message->response_body); + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); } void beforeAll() diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp index 7a13d285d..185c06cfe 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp @@ -146,6 +146,8 @@ public: test->m_uriSchemeRequest = request; test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request)); + g_assert(webkit_uri_scheme_request_get_web_view(request) == test->m_webView); + GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new()); test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(inputStream.get())); @@ -291,10 +293,13 @@ static void serverCallback(SoupServer* server, SoupMessage* message, const char* return; } - soup_message_set_status(message, SOUP_STATUS_OK); - const char* acceptLanguage = soup_message_headers_get_one(message->request_headers, "Accept-Language"); - soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, acceptLanguage, strlen(acceptLanguage)); - soup_message_body_complete(message->response_body); + if (g_str_equal(path, "/")) { + const char* acceptLanguage = soup_message_headers_get_one(message->request_headers, "Accept-Language"); + soup_message_set_status(message, SOUP_STATUS_OK); + soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, acceptLanguage, strlen(acceptLanguage)); + soup_message_body_complete(message->response_body); + } else + soup_message_set_status(message, SOUP_STATUS_NOT_FOUND); } class SecurityPolicyTest: public Test { diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp index 02e8138de..f5197b936 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp @@ -643,6 +643,17 @@ static void testWebViewRunJavaScript(WebViewTest* test, gconstpointer) g_assert(!error.get()); g_assert(WebViewTest::javascriptResultIsUndefined(javascriptResult)); + javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/org/webkit/webkit2gtk/tests/link-title.js", &error.outPtr()); + g_assert(javascriptResult); + g_assert(!error.get()); + valueString.set(WebViewTest::javascriptResultToCString(javascriptResult)); + g_assert_cmpstr(valueString.get(), ==, "WebKitGTK+ Title"); + + javascriptResult = test->runJavaScriptFromGResourceAndWaitUntilFinished("/wrong/path/to/resource.js", &error.outPtr()); + g_assert(!javascriptResult); + g_assert_error(error.get(), G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND); + error.clear(); + javascriptResult = test->runJavaScriptAndWaitUntilFinished("foo();", &error.outPtr()); g_assert(!javascriptResult); g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp index 04747480e..7e7eb0167 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp @@ -313,6 +313,12 @@ static void runJavaScriptReadyCallback(GObject*, GAsyncResult* result, WebViewTe g_main_loop_quit(test->m_mainLoop); } +static void runJavaScriptFromGResourceReadyCallback(GObject*, GAsyncResult* result, WebViewTest* test) +{ + test->m_javascriptResult = webkit_web_view_run_javascript_from_gresource_finish(test->m_webView, result, test->m_javascriptError); + g_main_loop_quit(test->m_mainLoop); +} + WebKitJavascriptResult* WebViewTest::runJavaScriptAndWaitUntilFinished(const char* javascript, GError** error) { if (m_javascriptResult) @@ -325,6 +331,18 @@ WebKitJavascriptResult* WebViewTest::runJavaScriptAndWaitUntilFinished(const cha return m_javascriptResult; } +WebKitJavascriptResult* WebViewTest::runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError** error) +{ + if (m_javascriptResult) + webkit_javascript_result_unref(m_javascriptResult); + m_javascriptResult = 0; + m_javascriptError = error; + webkit_web_view_run_javascript_from_gresource(m_webView, resource, 0, reinterpret_cast<GAsyncReadyCallback>(runJavaScriptFromGResourceReadyCallback), this); + g_main_loop_run(m_mainLoop); + + return m_javascriptResult; +} + static char* jsValueToCString(JSGlobalContextRef context, JSValueRef value) { g_assert(value); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h index 25209caa3..06f398f96 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h +++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h @@ -55,6 +55,7 @@ public: void keyStroke(unsigned int keyVal, unsigned int keyModifiers = 0); WebKitJavascriptResult* runJavaScriptAndWaitUntilFinished(const char* javascript, GError**); + WebKitJavascriptResult* runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError**); // Javascript result helpers. static char* javascriptResultToCString(WebKitJavascriptResult*); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js b/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js new file mode 100644 index 000000000..2c824da38 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js @@ -0,0 +1 @@ +window.document.getElementById('WebKitLink').title; diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml b/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml new file mode 100644 index 000000000..4f1e5a654 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/tests/resources/webkit2gtk-tests.gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/webkit/webkit2gtk/tests/"> + <file alias="link-title.js">Source/WebKit2/UIProcess/API/gtk/tests/resources/link-title.js</file> + </gresource> +</gresources> diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h index e1f3ba04a..1b4fa86a1 100644 --- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h +++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h @@ -34,6 +34,7 @@ #include <webkit2/WebKitEditingCommands.h> #include <webkit2/WebKitEnumTypes.h> #include <webkit2/WebKitError.h> +#include <webkit2/WebKitFaviconDatabase.h> #include <webkit2/WebKitFileChooserRequest.h> #include <webkit2/WebKitFindController.h> #include <webkit2/WebKitFormSubmissionRequest.h> diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h index f3428fc93..e8d2bdab9 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h +++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h @@ -36,6 +36,14 @@ WK_EXPORT - (id)initWithIdentifier:(NSString *)identifier; +/* User Content */ + +- (void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelistedURLPatterns:(NSArray *)whitelist blacklistedURLPatterns:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly; +- (void)removeAllUserStyleSheets; + +- (void)addUserScript:(NSString *)source baseURL:(NSURL *)baseURL whitelistedURLPatterns:(NSArray *)whitelist blacklistedURLPatterns:(NSArray *)blacklist injectionTime:(WKUserScriptInjectionTime)injectionTime mainFrameOnly:(BOOL)mainFrameOnly; +- (void)removeAllUserScripts; + /* Settings */ diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm index 338d390ca..5704dd72a 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm @@ -27,10 +27,14 @@ #import "WKBrowsingContextGroup.h" #import "WKBrowsingContextGroupInternal.h" +#import "WKArray.h" #import "WKPageGroup.h" #import "WKPreferences.h" #import "WKRetainPtr.h" #import "WKStringCF.h" +#import "WKURL.h" +#import "WKURLCF.h" +#import <wtf/Vector.h> @interface WKBrowsingContextGroupData : NSObject { @public @@ -81,6 +85,62 @@ WKPreferencesSetPluginsEnabled(WKPageGroupGetPreferences(self._pageGroupRef), allowsPlugIns); } +static WKArrayRef createWKArray(NSArray *array) +{ + NSUInteger count = [array count]; + if (count == 0) + return WKArrayRef(); + + Vector<WKTypeRef> stringVector; + stringVector.reserveInitialCapacity(count); + for (NSUInteger i = 0; i < count; ++i) { + id entry = [array objectAtIndex:i]; + if ([entry isKindOfClass:[NSString class]]) + stringVector.uncheckedAppend(WKStringCreateWithCFString((CFStringRef)entry)); + + } + + return WKArrayCreateAdoptingValues(stringVector.data(), stringVector.size()); +} + +-(void)addUserStyleSheet:(NSString *)source baseURL:(NSURL *)baseURL whitelistedURLPatterns:(NSArray *)whitelist blacklistedURLPatterns:(NSArray *)blacklist mainFrameOnly:(BOOL)mainFrameOnly +{ + if (!source) + CRASH(); + + WKRetainPtr<WKStringRef> wkSource = adoptWK(WKStringCreateWithCFString((CFStringRef)source)); + WKRetainPtr<WKURLRef> wkBaseURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)baseURL)); + WKRetainPtr<WKArrayRef> wkWhitelist = adoptWK(createWKArray(whitelist)); + WKRetainPtr<WKArrayRef> wkBlacklist = adoptWK(createWKArray(blacklist)); + WKUserContentInjectedFrames injectedFrames = mainFrameOnly ? kWKInjectInTopFrameOnly : kWKInjectInAllFrames; + + WKPageGroupAddUserStyleSheet(self._pageGroupRef, wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames); +} + +- (void)removeAllUserStyleSheets +{ + WKPageGroupRemoveAllUserStyleSheets(self._pageGroupRef); +} + +- (void)addUserScript:(NSString *)source baseURL:(NSURL *)baseURL whitelistedURLPatterns:(NSArray *)whitelist blacklistedURLPatterns:(NSArray *)blacklist injectionTime:(WKUserScriptInjectionTime)injectionTime mainFrameOnly:(BOOL)mainFrameOnly +{ + if (!source) + CRASH(); + + WKRetainPtr<WKStringRef> wkSource = adoptWK(WKStringCreateWithCFString((CFStringRef)source)); + WKRetainPtr<WKURLRef> wkBaseURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)baseURL)); + WKRetainPtr<WKArrayRef> wkWhitelist = adoptWK(createWKArray(whitelist)); + WKRetainPtr<WKArrayRef> wkBlacklist = adoptWK(createWKArray(blacklist)); + WKUserContentInjectedFrames injectedFrames = mainFrameOnly ? kWKInjectInTopFrameOnly : kWKInjectInAllFrames; + + WKPageGroupAddUserScript(self._pageGroupRef, wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames, injectionTime); +} + +- (void)removeAllUserScripts +{ + WKPageGroupRemoveAllUserScripts(self._pageGroupRef); +} + @end @implementation WKBrowsingContextGroup (Internal) diff --git a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm index 63c58895f..ca1cad582 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm @@ -194,8 +194,8 @@ static BOOL isForcingPreviewUpdate; - (uint64_t)_expectedPreviewCallbackForRect:(const IntRect&)rect { for (HashMap<uint64_t, WebCore::IntRect>::iterator iter = _expectedPreviewCallbacks.begin(); iter != _expectedPreviewCallbacks.end(); ++iter) { - if (iter->second == rect) - return iter->first; + if (iter->value == rect) + return iter->key; } return 0; } @@ -229,8 +229,8 @@ static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext ASSERT([view _isPrintingPreview]); if (data) { - HashMap<WebCore::IntRect, Vector<uint8_t> >::AddResult entry = view->_pagePreviews.add(iter->second, Vector<uint8_t>()); - entry.iterator->second.append(data->bytes(), data->size()); + HashMap<WebCore::IntRect, Vector<uint8_t> >::AddResult entry = view->_pagePreviews.add(iter->value, Vector<uint8_t>()); + entry.iterator->value.append(data->bytes(), data->size()); } view->_expectedPreviewCallbacks.remove(context->callbackID); bool receivedResponseToLatestRequest = view->_latestExpectedPreviewCallback == context->callbackID; @@ -494,7 +494,7 @@ static void prepareDataForPrintingOnSecondaryThread(void* untypedContext) return; } - const Vector<uint8_t>& pdfDataBytes = pagePreviewIterator->second; + const Vector<uint8_t>& pdfDataBytes = pagePreviewIterator->value; RetainPtr<NSData> pdfData(AdoptNS, [[NSData alloc] initWithBytes:pdfDataBytes.data() length:pdfDataBytes.size()]); RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:pdfData.get()]); diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 9d69399d4..d4b301298 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -428,7 +428,7 @@ static String commandNameForSelector(SEL selector) static const SelectorNameMap* exceptionMap = createSelectorExceptionMap(); SelectorNameMap::const_iterator it = exceptionMap->find(selector); if (it != exceptionMap->end()) - return it->second; + return it->value; // Remove the trailing colon. // No need to capitalize the command name since Editor command names are @@ -742,7 +742,7 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int // Add this item to the vector of items for a given command that are awaiting validation. ValidationMap::AddResult addResult = _data->_validationMap.add(commandName, ValidationVector()); - addResult.iterator->second.append(item); + addResult.iterator->value.append(item); if (addResult.isNewEntry) { // If we are not already awaiting validation for this command, start the asynchronous validation process. // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index db51b85dd..71688cbe6 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -158,7 +158,7 @@ void QQuickWebPagePrivate::updateSize() DrawingAreaProxy* drawingArea = webPageProxy->drawingArea(); if (drawingArea && drawingArea->layerTreeCoordinatorProxy()) - drawingArea->layerTreeCoordinatorProxy()->setContentsSize(contentsSize); + drawingArea->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(contentsSize)); q->setSize(scaledSize); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index b78cae0f3..07ed832ce 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -268,6 +268,7 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) , filePicker(0) , databaseQuotaDialog(0) , colorChooser(0) + , m_betweenLoadCommitAndFirstFrame(false) , m_useDefaultContentItemSize(true) , m_navigatorQtObjectEnabled(false) , m_renderToOffscreenBuffer(false) @@ -330,14 +331,6 @@ void QQuickWebViewPrivate::loadDidStop() emit q->loadingChanged(&loadRequest); } -void QQuickWebViewPrivate::onComponentComplete() -{ - Q_Q(QQuickWebView); - m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data())); - m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), m_pageViewportControllerClient.data())); - pageView->eventHandler()->setViewportController(m_pageViewportControllerClient.data()); -} - void QQuickWebViewPrivate::setTransparentBackground(bool enable) { webPageProxy->setDrawsTransparentBackground(enable); @@ -370,6 +363,7 @@ void QQuickWebViewPrivate::loadDidCommit() Q_Q(QQuickWebView); ASSERT(q->loading()); + m_betweenLoadCommitAndFirstFrame = true; emit q->navigationHistoryChanged(); emit q->titleChanged(); } @@ -452,10 +446,18 @@ void QQuickWebViewPrivate::setNeedsDisplay() q->page()->d->paint(&painter); return; } - q->page()->update(); } +void QQuickWebViewPrivate::didRenderFrame() +{ + Q_Q(QQuickWebView); + if (m_betweenLoadCommitAndFirstFrame) { + emit q->experimental()->loadVisuallyCommitted(); + m_betweenLoadCommitAndFirstFrame = false; + } +} + void QQuickWebViewPrivate::processDidCrash() { Q_Q(QQuickWebView); @@ -478,8 +480,6 @@ void QQuickWebViewPrivate::didRelaunchProcess() { qWarning("WARNING: The web process has been successfully restarted."); - // Reset to default so that the later update can reach the web process. - webPageProxy->setCustomDeviceScaleFactor(0); webPageProxy->drawingArea()->setSize(viewSize(), IntSize()); updateViewportSize(); @@ -820,12 +820,17 @@ void QQuickWebViewLegacyPrivate::updateViewportSize() QSizeF viewportSize = q->boundingRect().size(); if (viewportSize.isEmpty()) return; + + float devicePixelRatio = webPageProxy->deviceScaleFactor(); pageView->setContentsSize(viewportSize); + // Make sure that our scale matches the one passed to setVisibleContentsRect. + pageView->setContentsScale(devicePixelRatio); + // The fixed layout is handled by the FrameView and the drawing area doesn't behave differently // whether its fixed or not. We still need to tell the drawing area which part of it // has to be rendered on tiles, and in desktop mode it's all of it. - webPageProxy->drawingArea()->setSize(viewportSize.toSize(), IntSize()); - webPageProxy->drawingArea()->setVisibleContentsRect(FloatRect(FloatPoint(), viewportSize), 1, FloatPoint()); + webPageProxy->drawingArea()->setSize((viewportSize / devicePixelRatio).toSize(), IntSize()); + webPageProxy->drawingArea()->setVisibleContentsRect(FloatRect(FloatPoint(), FloatSize(viewportSize / devicePixelRatio)), devicePixelRatio, FloatPoint()); } qreal QQuickWebViewLegacyPrivate::zoomFactor() const @@ -853,6 +858,11 @@ void QQuickWebViewFlickablePrivate::onComponentComplete() { QQuickWebViewPrivate::onComponentComplete(); + Q_Q(QQuickWebView); + m_pageViewportControllerClient.reset(new PageViewportControllerClientQt(q, pageView.data())); + m_pageViewportController.reset(new PageViewportController(webPageProxy.get(), m_pageViewportControllerClient.data())); + pageView->eventHandler()->setViewportController(m_pageViewportControllerClient.data()); + // Trigger setting of correct visibility flags after everything was allocated and initialized. _q_onVisibleChanged(); } @@ -868,7 +878,7 @@ void QQuickWebViewFlickablePrivate::updateViewportSize() Q_Q(QQuickWebView); if (m_pageViewportController) - m_pageViewportController->didChangeViewportSize(QSizeF(q->width(), q->height())); + m_pageViewportController->didChangeViewportSize(FloatSize(q->width(), q->height())); } void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos) @@ -877,13 +887,6 @@ void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos) m_pageViewportController->pageDidRequestScroll(pos); } -void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize) -{ - QQuickWebViewPrivate::didChangeContentsSize(newSize); - pageView->setContentsSize(newSize); // emits contentsSizeChanged() - m_pageViewportController->didChangeContentsSize(newSize); -} - void QQuickWebViewFlickablePrivate::handleMouseEvent(QMouseEvent* event) { if (!pageView->eventHandler()) @@ -1233,7 +1236,7 @@ void QQuickWebViewExperimental::setDevicePixelRatio(qreal devicePixelRatio) if (0 >= devicePixelRatio || devicePixelRatio == this->devicePixelRatio()) return; - d->webPageProxy->setCustomDeviceScaleFactor(devicePixelRatio); + d->webPageProxy->setIntrinsicDeviceScaleFactor(devicePixelRatio); emit devicePixelRatioChanged(); } diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index e8b1bf7a1..89e7fbc99 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -355,6 +355,7 @@ public Q_SLOTS: void evaluateJavaScript(const QString& script, const QJSValue& value = QJSValue()); Q_SIGNALS: + void loadVisuallyCommitted(); void alertDialogChanged(); void confirmDialogChanged(); void promptDialogChanged(); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index f172ad68f..15bf818d7 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -70,7 +70,7 @@ public: virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); - virtual void onComponentComplete(); + virtual void onComponentComplete() { } virtual void provisionalLoadDidStart(const WTF::String& url); virtual void didReceiveServerRedirectForProvisionalLoad(const WTF::String& url); @@ -88,8 +88,9 @@ public: int loadProgress() const { return m_loadProgress; } void setNeedsDisplay(); + void didRenderFrame(); - WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); } + virtual WebKit::PageViewportController* viewportController() const { return 0; } virtual void updateViewportSize() { } void updateTouchViewportSize(); @@ -130,7 +131,6 @@ public: WebCore::IntSize viewSize() const; void didReceiveMessageFromNavigatorQtObject(const String& message); virtual void pageDidRequestScroll(const QPoint& pos) { } - virtual void didChangeContentsSize(const QSize& newSize) { } void processDidCrash(); void didRelaunchProcess(); PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy(); @@ -172,9 +172,6 @@ protected: QScopedPointer<QQuickWebPage> pageView; QQuickWebView* q_ptr; - QScopedPointer<WebKit::PageViewportController> m_pageViewportController; - QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient; - FlickableAxisLocker axisLocker; QQmlComponent* alertDialog; @@ -190,6 +187,7 @@ protected: QList<QUrl> userScripts; + bool m_betweenLoadCommitAndFirstFrame; bool m_useDefaultContentItemSize; bool m_navigatorQtObjectEnabled; bool m_renderToOffscreenBuffer; @@ -220,11 +218,15 @@ public: virtual void onComponentComplete(); virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&); + virtual WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); } virtual void updateViewportSize(); virtual void pageDidRequestScroll(const QPoint& pos); - virtual void didChangeContentsSize(const QSize& newSize); virtual void handleMouseEvent(QMouseEvent*); + +private: + QScopedPointer<WebKit::PageViewportController> m_pageViewportController; + QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient; }; #endif // qquickwebview_p_p_h diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp index 0a7a684cf..5f6c16d56 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp @@ -167,6 +167,11 @@ void QRawWebViewPrivate::toolTipChanged(const String&, const String& newTooltip) notImplemented(); } +void QRawWebViewPrivate::pageTransitionViewportReady() +{ + m_webPageProxy->commitPageTransitionViewport(); +} + void QRawWebViewPrivate::startDrag(const WebCore::DragData& dragData, PassRefPtr<WebKit::ShareableBitmap> dragImage) { notImplemented(); @@ -319,6 +324,7 @@ void QRawWebView::setActive(bool active) { d->m_active = active; d->m_webPageProxy->viewStateDidChange(WebKit::WebPageProxy::ViewWindowIsActive); + layerTreeRenderer()->setActive(active); } QSize QRawWebView::size() const @@ -352,17 +358,20 @@ WKPageRef QRawWebView::pageRef() return toAPI(d->m_webPageProxy.get()); } -void QRawWebView::paint(const QMatrix4x4& transform, float opacity, unsigned paintFlags) +WebKit::LayerTreeRenderer* QRawWebView::layerTreeRenderer() const { WebKit::DrawingAreaProxy* drawingArea = d->m_webPageProxy->drawingArea(); if (!drawingArea) - return; - - WebKit::LayerTreeCoordinatorProxy* coordinatorProxy = drawingArea->layerTreeCoordinatorProxy(); - if (!coordinatorProxy) - return; + return 0; + WebKit::LayerTreeCoordinatorProxy* layerTreeCoordinatorProxy = drawingArea->layerTreeCoordinatorProxy(); + if (!layerTreeCoordinatorProxy) + return 0; + return layerTreeCoordinatorProxy->layerTreeRenderer(); +} - WebKit::LayerTreeRenderer* renderer = coordinatorProxy->layerTreeRenderer(); +void QRawWebView::paint(const QMatrix4x4& transform, float opacity, unsigned paintFlags) +{ + WebKit::LayerTreeRenderer* renderer = layerTreeRenderer(); if (!renderer) return; diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h index f8f15b06d..015815ad8 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p.h @@ -47,6 +47,10 @@ QT_END_NAMESPACE class QRawWebViewPrivate; +namespace WebKit { +class LayerTreeRenderer; +} + class QRawWebViewClient { public: virtual ~QRawWebViewClient() { } @@ -97,6 +101,8 @@ public: void sendTouchEvent(QTouchEvent*); private: + WebKit::LayerTreeRenderer* layerTreeRenderer() const; + QRawWebViewPrivate* d; }; diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h index 55bc85ba0..545096d02 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h @@ -82,6 +82,7 @@ public: virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves); virtual void toolTipChanged(const String&, const String& newTooltip); + virtual void pageTransitionViewportReady(); virtual void startDrag(const WebCore::DragData& dragData, PassRefPtr<WebKit::ShareableBitmap> dragImage); @@ -104,6 +105,7 @@ public: virtual void didRelaunchProcess(); virtual void setViewNeedsDisplay(const WebCore::IntRect& rect); virtual void didChangeContentsSize(const WebCore::IntSize& newSize); + virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) { } virtual void setCursor(const WebCore::Cursor&); virtual bool isViewFocused() { return m_focused; } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro index 4a8d86f80..bc5307f2d 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro @@ -1,4 +1,4 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkit-private +QT += webkitwidgets-private DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro index 02dc197c7..ba8f4cea3 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro @@ -1,3 +1,3 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkit-private +QT += webkitwidgets-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro index 3fd3d4583..7c72fd2f1 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro @@ -3,7 +3,7 @@ SOURCES += tst_qmltests.cpp TARGET = tst_qmltests_DesktopBehavior OBJECTS_DIR = obj_DesktopBehavior/$$activeBuildConfig() -QT += webkit-private +QT += webkitwidgets-private CONFIG += warn_on testcase QT += qmltest diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro index b340235e4..3e217b369 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro @@ -3,7 +3,7 @@ SOURCES += tst_qmltests.cpp TARGET = tst_qmltests_WebView OBJECTS_DIR = obj_WebView/$$activeBuildConfig() -QT += webkit-private +QT += webkitwidgets-private CONFIG += warn_on testcase QT += qmltest diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_doubleTapToZoom.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_doubleTapToZoom.qml index 691455708..d21ef211a 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_doubleTapToZoom.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_doubleTapToZoom.qml @@ -40,6 +40,7 @@ Item { TestCase { name: "DoubleTapToZoom" + when: windowShown property variant test: webView.experimental.test @@ -78,7 +79,7 @@ Item { function test_basic() { webView.url = webView.content - verify(webView.waitForLoadSucceeded()) + verify(webView.waitForViewportReady()) compare(documentSize(), "480x720") 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 f12da5de8..fcd3d9301 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 @@ -38,6 +38,7 @@ Item { TestCase { name: "FitToView" + when: windowShown property variant test: webView.experimental.test @@ -69,7 +70,7 @@ Item { function test_basic() { webView.url = webView.content - verify(webView.waitForLoadSucceeded()) + verify(webView.waitForViewportReady()) compare(documentSize(), "480x720") compare(test.contentsScale, 1.0) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_wheelEventHandling.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_wheelEventHandling.qml index 1fc1559ab..aa6d711a1 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_wheelEventHandling.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_wheelEventHandling.qml @@ -21,12 +21,13 @@ Item { TestCase { name: "WheelEventHandling" + when: windowShown property variant test: webView.experimental.test function init() { webView.url = Qt.resolvedUrl("../common/test4.html") - verify(webView.waitForLoadSucceeded()) + verify(webView.waitForViewportReady()) webView.contentY = 0 } @@ -38,7 +39,7 @@ Item { scrollSpy.wait() var position = webView.contentY webView.reload() - verify(webView.waitForLoadSucceeded()) + verify(webView.waitForViewportReady()) // The check below will fail if the previous position was not restored after reload. verify(position == webView.contentY) } @@ -46,7 +47,7 @@ Item { function test_wheelScrollEventAfterReload() { scrollSpy.clear() webView.reload() - verify(webView.waitForLoadSucceeded()) + verify(webView.waitForViewportReady()) var centerPoint = Qt.point(webView.width / 2, webView.height / 2) test.wheelEvent(webView, centerPoint.x, centerPoint.y, -500); // The signal spy below will time out if the wheel event did not scroll the content. diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/TestWebView.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/TestWebView.qml index 0dd7bccee..5a05f9b3e 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/TestWebView.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/TestWebView.qml @@ -5,43 +5,47 @@ import QtWebKit.experimental 1.0 WebView { property var loadStatus: null + property var viewportReady: false function waitForLoadSucceeded() { - var timeout = 5000 - var i = 0 - while (i < timeout && loadStatus != WebView.LoadSucceededStatus) { - testResult.wait(50) - i += 50 - } - var success = loadStatus == WebView.LoadSucceededStatus + var success = _waitFor(function() { return loadStatus == WebView.LoadSucceededStatus }) loadStatus = null return success } + function waitForViewportReady() { + // Note: You need to have "when: windowShown" in your TestCase for this to work. + // The viewport is locked until the first frame is rendered, and the rendering isn't + // activated until the WebView is visible in a mapped QQuickView. + return _waitFor(function() { return viewportReady }) + } function waitForLoadFailed() { - var timeout = 5000 - var i = 0 - while (i < timeout && loadStatus != WebView.LoadFailedStatus) { - testResult.wait(50) - i += 50 - } - var failure = loadStatus == WebView.LoadFailedStatus + var failure = _waitFor(function() { return loadStatus == WebView.LoadFailedStatus }) loadStatus = null return failure } function waitForLoadStopped() { + var stop = _waitFor(function() { return loadStatus == WebView.LoadStoppedStatus }) + loadStatus = null + return stop + } + function _waitFor(predicate) { var timeout = 5000 var i = 0 - while (i < timeout && loadStatus != WebView.LoadStoppedStatus) { + while (i < timeout && !predicate()) { testResult.wait(50) i += 50 } - var stop = loadStatus == WebView.LoadStoppedStatus - loadStatus = null - return stop + return predicate() } TestResult { id: testResult } - onLoadingChanged: loadStatus = loadRequest.status + experimental.onLoadVisuallyCommitted: viewportReady = true + onLoadingChanged: { + loadStatus = loadRequest.status + if (loadRequest.status == WebView.LoadStartedStatus) + viewportReady = false + } + } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro index 4a8d86f80..bc5307f2d 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro @@ -1,4 +1,4 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkit-private +QT += webkitwidgets-private DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" 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 5b98ae7b7..558053729 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp @@ -440,10 +440,11 @@ void tst_QQuickWebView::inputMethodHints() void tst_QQuickWebView::scrollRequest() { - webView()->setSize(QSizeF(300, 400)); + m_window->setGeometry(0, 0, 300, 400); + m_window->show(); webView()->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html"))); - QVERIFY(waitForLoadSucceeded(webView())); + QVERIFY(waitForViewportReady(webView())); // COMPARE with the position requested in the html // Use qRound as that is also used when calculating the position diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro index 02dc197c7..ba8f4cea3 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro @@ -1,3 +1,3 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkit-private +QT += webkitwidgets-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp index 31102b876..208288d1e 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp @@ -27,6 +27,7 @@ #include <WebKit2/WKContext.h> #include <WebKit2/WKPageGroup.h> +#include <WebKit2/WKPageLoadTypes.h> #include <WebKit2/WKPreferences.h> #include <WebKit2/WKPreferencesPrivate.h> #include <WebKit2/WKStringQt.h> @@ -60,15 +61,18 @@ class WebView : public QObject, public QRawWebViewClient { public: WebView(const QSize& size, bool transparent = false) { + m_webView = new QRawWebView(webContext(), webPageGroup(QString()), this); + m_webView->setTransparentBackground(transparent); + m_webView->create(); + WKPageLoaderClient loaderClient; memset(&loaderClient, 0, sizeof(WKPageLoaderClient)); + loaderClient.version = kWKPageLoaderClientCurrentVersion; loaderClient.clientInfo = this; - loaderClient.didFirstVisuallyNonEmptyLayoutForFrame = WebView::finishFirstLayoutForFrame; + loaderClient.didLayout = WebView::didLayout; - m_webView = new QRawWebView(webContext(), webPageGroup(QString()), this); WKPageSetPageLoaderClient(m_webView->pageRef(), &loaderClient); - m_webView->setTransparentBackground(transparent); - m_webView->create(); + WKPageListenForLayoutMilestones(m_webView->pageRef(), kWKDidFirstVisuallyNonEmptyLayout); WKPageSetUseFixedLayout(m_webView->pageRef(), true); m_webView->setSize(size); @@ -118,7 +122,7 @@ public: static_cast<WebView*>(context)->onRepaintDone(); } - static void finishFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo) + static void didLayout(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef userData, const void *clientInfo) { static_cast<WebView*>(const_cast<void*>(clientInfo))->frameLoaded(); } @@ -152,7 +156,9 @@ public: tst_qrawwebview() : m_resourceDir(QString::fromLatin1(TESTS_SOURCE_DIR "/html/resources")) , m_baseUrl(QUrl::fromLocalFile(TESTS_SOURCE_DIR "/html").toString()) - { } + { + addQtWebProcessToPath(); + } private Q_SLOTS: void paint() { run(&tst_qrawwebview::doPaint, m_resourceDir + "/qwkview_paint.png"); } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri index a1133530d..123b25ce2 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -6,7 +6,7 @@ TARGET = tst_$$TARGET INCLUDEPATH += $$PWD SOURCES += ../util.cpp -QT += testlib webkit +QT += testlib webkitwidgets have?(QTQUICK) { QT += qml quick quick-private HEADERS += ../bytearraytestdata.h \ diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp index c65fae305..fce3cc7f6 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp @@ -126,6 +126,13 @@ bool waitForLoadFailed(QQuickWebView* webView, int timeout) return timeoutSpy.isEmpty(); } +bool waitForViewportReady(QQuickWebView* webView, int timeout) +{ + // The viewport is locked until the first frame of a page load is rendered. + // The QQuickView needs to be shown for this to succeed. + return waitForSignal(webView->experimental(), SIGNAL(loadVisuallyCommitted()), timeout); +} + LoadStartedCatcher::LoadStartedCatcher(QQuickWebView* webView) : m_webView(webView) { diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h index 0c14a1ff4..4834029b4 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/util.h +++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h @@ -36,6 +36,7 @@ void suppressDebugOutput(); #if defined(HAVE_QTQUICK) && HAVE_QTQUICK bool waitForLoadSucceeded(QQuickWebView* webView, int timeout = 10000); bool waitForLoadFailed(QQuickWebView* webView, int timeout = 10000); +bool waitForViewportReady(QQuickWebView* webView, int timeout = 10000); class LoadStartedCatcher : public QObject { Q_OBJECT diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp index 84f6ebd2f..77fdc0a26 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp @@ -80,15 +80,15 @@ void CoordinatedBackingStore::updateTile(int id, const IntRect& sourceRect, cons { HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.find(id); ASSERT(it != m_tiles.end()); - it->second.incrementRepaintCount(); - it->second.setBackBuffer(targetRect, sourceRect, backBuffer, offset); + it->value.incrementRepaintCount(); + it->value.setBackBuffer(targetRect, sourceRect, backBuffer, offset); } PassRefPtr<BitmapTexture> CoordinatedBackingStore::texture() const { HashMap<int, CoordinatedBackingStoreTile>::const_iterator end = m_tiles.end(); for (HashMap<int, CoordinatedBackingStoreTile>::const_iterator it = m_tiles.begin(); it != end; ++it) { - RefPtr<BitmapTexture> texture = it->second.texture(); + RefPtr<BitmapTexture> texture = it->value.texture(); if (texture) return texture; } @@ -112,7 +112,7 @@ void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, HashMap<int, CoordinatedBackingStoreTile>::iterator end = m_tiles.end(); FloatRect coveredRect; for (HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.begin(); it != end; ++it) { - CoordinatedBackingStoreTile& tile = it->second; + CoordinatedBackingStoreTile& tile = it->value; if (!tile.texture()) continue; @@ -156,7 +156,7 @@ void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper) HashMap<int, CoordinatedBackingStoreTile>::iterator tilesEnd = m_tiles.end(); for (HashMap<int, CoordinatedBackingStoreTile>::iterator it = m_tiles.begin(); it != tilesEnd; ++it) - it->second.swapBuffers(textureMapper); + it->value.swapBuffers(textureMapper); } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp index e6f582f22..1953afb61 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp @@ -66,14 +66,14 @@ void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, cons { RefPtr<ShareableSurface> surface; #if USE(GRAPHICS_SURFACE) - uint64_t token = updateInfo.surfaceHandle.graphicsSurfaceToken(); - if (token) { - HashMap<uint64_t, RefPtr<ShareableSurface> >::iterator it = m_surfaces.find(token); + GraphicsSurfaceToken token = updateInfo.surfaceHandle.graphicsSurfaceToken(); + if (token.isValid()) { + HashMap<GraphicsSurfaceToken::BufferHandle, RefPtr<ShareableSurface> >::iterator it = m_surfaces.find(token.frontBufferHandle); if (it == m_surfaces.end()) { surface = ShareableSurface::create(updateInfo.surfaceHandle); - m_surfaces.add(token, surface); + m_surfaces.add(token.frontBufferHandle, surface); } else - surface = it->second; + surface = it->value; } else surface = ShareableSurface::create(updateInfo.surfaceHandle); #else @@ -116,10 +116,16 @@ void LayerTreeCoordinatorProxy::setCompositingLayerFilters(WebLayerID id, const } #endif -void LayerTreeCoordinatorProxy::didRenderFrame() +void LayerTreeCoordinatorProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) { dispatchUpdate(bind(&LayerTreeRenderer::flushLayerChanges, m_renderer.get())); updateViewport(); +#if PLATFORM(QT) + m_drawingAreaProxy->page()->didRenderFrame(contentsSize, coveredRect); +#else + UNUSED_PARAM(contentsSize); + UNUSED_PARAM(coveredRect); +#endif } void LayerTreeCoordinatorProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle) @@ -174,10 +180,12 @@ void LayerTreeCoordinatorProxy::didChangeScrollPosition(const IntPoint& position dispatchUpdate(bind(&LayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position)); } -void LayerTreeCoordinatorProxy::syncCanvas(uint32_t id, const IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) +#if USE(GRAPHICS_SURFACE) +void LayerTreeCoordinatorProxy::syncCanvas(uint32_t id, const IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer) { - dispatchUpdate(bind(&LayerTreeRenderer::syncCanvas, m_renderer.get(), id, canvasSize, graphicsSurfaceToken, frontBuffer)); + dispatchUpdate(bind(&LayerTreeRenderer::syncCanvas, m_renderer.get(), id, canvasSize, token, frontBuffer)); } +#endif void LayerTreeCoordinatorProxy::purgeBackingStores() { diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h index 65a9f5e99..b1ef401a4 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h @@ -29,6 +29,7 @@ #include "WebLayerTreeInfo.h" #include <WebCore/GraphicsContext.h> #include <WebCore/GraphicsLayer.h> +#include <WebCore/GraphicsSurfaceToken.h> #include <WebCore/IntRect.h> #include <WebCore/IntSize.h> #include <WebCore/RunLoop.h> @@ -63,7 +64,7 @@ public: void purgeGLResources(); void setContentsSize(const WebCore::FloatSize&); void setVisibleContentsRect(const WebCore::FloatRect&, float scale, const WebCore::FloatPoint& trajectoryVector); - void didRenderFrame(); + void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect); void createTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&); void updateTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&); void removeTileForLayer(int layerID, int tileID); @@ -73,7 +74,9 @@ public: void updateViewport(); void renderNextFrame(); void didChangeScrollPosition(const WebCore::IntPoint& position); - void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer); +#if USE(GRAPHICS_SURFACE) + void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer); +#endif void purgeBackingStores(); LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); } void setLayerAnimatedOpacity(uint32_t, float); @@ -88,7 +91,7 @@ protected: float m_lastSentScale; WebCore::FloatPoint m_lastSentTrajectoryVector; #if USE(GRAPHICS_SURFACE) - HashMap<uint64_t, RefPtr<ShareableSurface> > m_surfaces; + HashMap<WebCore::GraphicsSurfaceToken::BufferHandle, RefPtr<ShareableSurface> > m_surfaces; #endif }; diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in index 23869233c..b73960021 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in @@ -31,9 +31,11 @@ messages -> LayerTreeCoordinatorProxy { RemoveTileForLayer(uint32_t layerID, int tileID) CreateDirectlyCompositedImage(int64_t key, WebKit::ShareableBitmap::Handle handle) DestroyDirectlyCompositedImage(int64_t key) - DidRenderFrame() + DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect) DidChangeScrollPosition(WebCore::IntPoint position) - SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) +#if USE(GRAPHICS_SURFACE) + SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token, uint32_t frontBuffer) +#endif SetLayerAnimatedOpacity(uint32_t id, float opacity) SetLayerAnimatedTransform(uint32_t id, WebCore::TransformationMatrix transform) } diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp index b94c66b9d..f053a57a6 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp @@ -126,7 +126,7 @@ void LayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matr if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { currentRootLayer->setOpacity(opacity); currentRootLayer->setTransform(matrix); - currentRootLayer->syncCompositingStateForThisLayerOnly(); + currentRootLayer->flushCompositingStateForThisLayerOnly(); } layer->paint(); @@ -183,7 +183,7 @@ void LayerTreeRenderer::adjustPositionForFixedLayers() LayerMap::iterator end = m_fixedLayers.end(); for (LayerMap::iterator it = m_fixedLayers.begin(); it != end; ++it) - toTextureMapperLayer(it->second)->setScrollPositionDeltaIfNeeded(delta); + toTextureMapperLayer(it->value)->setScrollPositionDeltaIfNeeded(delta); } void LayerTreeRenderer::didChangeScrollPosition(const IntPoint& position) @@ -191,12 +191,12 @@ void LayerTreeRenderer::didChangeScrollPosition(const IntPoint& position) m_pendingRenderedContentsScrollPosition = position; } -void LayerTreeRenderer::syncCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer) +#if USE(GRAPHICS_SURFACE) +void LayerTreeRenderer::syncCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer) { if (canvasSize.isEmpty() || !m_textureMapper) return; -#if USE(GRAPHICS_SURFACE) ensureLayer(id); GraphicsLayer* layer = layerByID(id); @@ -206,18 +206,18 @@ void LayerTreeRenderer::syncCanvas(WebLayerID id, const WebCore::IntSize& canvas canvasBackingStore = TextureMapperSurfaceBackingStore::create(); m_surfaceBackingStores.set(id, canvasBackingStore); } else - canvasBackingStore = it->second; + canvasBackingStore = it->value; - canvasBackingStore->setGraphicsSurface(graphicsSurfaceToken, canvasSize, frontBuffer); + canvasBackingStore->setGraphicsSurface(token, canvasSize, frontBuffer); layer->setContentsToMedia(canvasBackingStore.get()); -#endif } +#endif void LayerTreeRenderer::setLayerChildren(WebLayerID id, const Vector<WebLayerID>& childIDs) { ensureLayer(id); LayerMap::iterator it = m_layers.find(id); - GraphicsLayer* layer = it->second; + GraphicsLayer* layer = it->value; Vector<GraphicsLayer*> children; for (size_t i = 0; i < childIDs.size(); ++i) { @@ -239,7 +239,7 @@ void LayerTreeRenderer::setLayerFilters(WebLayerID id, const FilterOperations& f LayerMap::iterator it = m_layers.find(id); ASSERT(it != m_layers.end()); - GraphicsLayer* layer = it->second; + GraphicsLayer* layer = it->value; layer->setFilters(filters); } #endif @@ -250,7 +250,7 @@ void LayerTreeRenderer::setLayerState(WebLayerID id, const WebLayerInfo& layerIn LayerMap::iterator it = m_layers.find(id); ASSERT(it != m_layers.end()); - GraphicsLayer* layer = it->second; + GraphicsLayer* layer = it->value; layer->setReplicatedByLayer(layerByID(layerInfo.replica)); layer->setMaskLayer(layerByID(layerInfo.mask)); @@ -377,7 +377,7 @@ void LayerTreeRenderer::assignImageToLayer(GraphicsLayer* layer, int64_t imageID HashMap<int64_t, RefPtr<TextureMapperBackingStore> >::iterator it = m_directlyCompositedImages.find(imageID); ASSERT(it != m_directlyCompositedImages.end()); - layer->setContentsToMedia(it->second.get()); + layer->setContentsToMedia(it->value.get()); } void LayerTreeRenderer::commitTileOperations() @@ -393,7 +393,7 @@ void LayerTreeRenderer::flushLayerChanges() { m_renderedContentsScrollPosition = m_pendingRenderedContentsScrollPosition; - m_rootLayer->syncCompositingState(FloatRect()); + m_rootLayer->flushCompositingState(FloatRect()); commitTileOperations(); // The pending tiles state is on its way for the screen, tell the web process to render the next one. diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h index 4e45678e6..0a6ae3b88 100644 --- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h +++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h @@ -22,13 +22,13 @@ #if USE(COORDINATED_GRAPHICS) #include "BackingStore.h" -#include "GraphicsSurface.h" #include "ShareableSurface.h" #include "TextureMapper.h" #include "TextureMapperBackingStore.h" #include "WebLayerTreeInfo.h" #include <WebCore/GraphicsContext.h> #include <WebCore/GraphicsLayer.h> +#include <WebCore/GraphicsSurface.h> #include <WebCore/IntRect.h> #include <WebCore/IntSize.h> #include <WebCore/RunLoop.h> @@ -68,7 +68,9 @@ public: void setContentsSize(const WebCore::FloatSize&); void setVisibleContentsRect(const WebCore::FloatRect&); void didChangeScrollPosition(const WebCore::IntPoint& position); - void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, uint64_t graphicsSurfaceToken, uint32_t frontBuffer); +#if USE(GRAPHICS_SURFACE) + void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer); +#endif void detach(); void appendUpdate(const Function<void()>&); @@ -100,7 +102,7 @@ private: // Reimplementations from WebCore::GraphicsLayerClient. virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double) { } - virtual void notifySyncRequired(const WebCore::GraphicsLayer*) { } + virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) { } virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; } virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; } void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { } diff --git a/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp index eb06c29d8..b26395736 100644 --- a/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp @@ -42,7 +42,7 @@ void GeolocationPermissionRequestManagerProxy::invalidateRequests() PendingRequestMap::const_iterator it = m_pendingRequests.begin(); PendingRequestMap::const_iterator end = m_pendingRequests.end(); for (; it != end; ++it) - it->second->invalidate(); + it->value->invalidate(); m_pendingRequests.clear(); } diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp index 66d644734..bc585e94d 100644 --- a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp +++ b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp @@ -67,7 +67,7 @@ WebInspectorServer::~WebInspectorServer() // Close any remaining open connections. HashMap<unsigned, WebSocketServerConnection*>::iterator end = m_connectionMap.end(); for (HashMap<unsigned, WebSocketServerConnection*>::iterator it = m_connectionMap.begin(); it != end; ++it) { - WebSocketServerConnection* connection = it->second; + WebSocketServerConnection* connection = it->value; WebInspectorProxy* client = m_clientMap.get(connection->identifier()); closeConnection(client, connection); } @@ -78,7 +78,7 @@ int WebInspectorServer::registerPage(WebInspectorProxy* client) #ifndef ASSERT_DISABLED ClientMap::iterator end = m_clientMap.end(); for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) - ASSERT(it->second != client); + ASSERT(it->value != client); #endif int pageId = m_nextAvailablePageId++; diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp index abc805fd7..6317c62c2 100644 --- a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp +++ b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp @@ -106,9 +106,9 @@ void WebSocketServerConnection::sendHTTPResponseHeader(int statusCode, const Str builder.appendLiteral("\r\n"); HTTPHeaderMap::const_iterator end = headerFields.end(); for (HTTPHeaderMap::const_iterator it = headerFields.begin(); it != end; ++it) { - builder.append(it->first); + builder.append(it->key); builder.appendLiteral(": "); - builder.append(it->second); + builder.append(it->value); builder.appendLiteral("\r\n"); } builder.appendLiteral("\r\n"); diff --git a/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp b/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp index 1882586af..11e57cfd5 100644 --- a/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp +++ b/Source/WebKit2/UIProcess/InspectorServer/qt/WebInspectorServerQt.cpp @@ -83,18 +83,18 @@ void WebInspectorServer::buildPageList(Vector<char>& data, String& contentType) builder.appendLiteral("[ "); ClientMap::iterator end = m_clientMap.end(); for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) { - WebPageProxy* webPage = it->second->page(); + WebPageProxy* webPage = it->value->page(); if (it != m_clientMap.begin()) builder.appendLiteral(", "); builder.appendLiteral("{ \"id\": "); - builder.appendNumber(it->first); + builder.appendNumber(it->key); builder.appendLiteral(", \"title\": \""); builder.append(webPage->pageTitle()); builder.appendLiteral("\", \"url\": \""); builder.append(webPage->activeURL()); builder.appendLiteral("\", \"inspectorUrl\": \""); builder.append(remoteInspectorPagePath()); - builder.appendNumber(it->first); + builder.appendNumber(it->key); builder.appendLiteral("\" }"); } builder.appendLiteral(" ]"); diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp index ba22dda2d..771a6eef7 100644 --- a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp +++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp @@ -75,6 +75,10 @@ const char* ProcessLauncher::processTypeAsString(ProcessType processType) return "webprocess"; case PluginProcess: return "pluginprocess"; + case NetworkProcess: + return "networkprocess"; + case SharedWorkerProcess: + return "sharedworkerprocess"; } ASSERT_NOT_REACHED(); @@ -93,6 +97,16 @@ bool ProcessLauncher::getProcessTypeFromString(const char* string, ProcessType& return true; } + if (!strcmp(string, "networkprocess")) { + processType = NetworkProcess; + return true; + } + + if (!strcmp(string, "sharedworkerprocess")) { + processType = SharedWorkerProcess; + return true; + } + return false; } diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h index 5945e1e28..5983a76a7 100644 --- a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h +++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h @@ -48,7 +48,9 @@ public: enum ProcessType { WebProcess, - PluginProcess + PluginProcess, + NetworkProcess, + SharedWorkerProcess }; struct LaunchOptions { diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm index 560ceb773..a9c20da32 100644 --- a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm +++ b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm @@ -82,7 +82,7 @@ struct UUIDHolder : public RefCounted<UUIDHolder> { static void setUpTerminationNotificationHandler(pid_t pid) { #if HAVE(DISPATCH_H) - dispatch_source_t processDiedSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, pid, DISPATCH_PROC_EXIT, dispatch_get_current_queue()); + dispatch_source_t processDiedSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, pid, DISPATCH_PROC_EXIT, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); dispatch_source_set_event_handler(processDiedSource, ^{ int status; waitpid(dispatch_source_get_handle(processDiedSource), &status, 0); @@ -366,7 +366,25 @@ static void createProcess(const ProcessLauncher::LaunchOptions& launchOptions, b CString localization = String(cfLocalization.get()).utf8(); NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"]; - NSString *processPath = [webKit2Bundle pathForAuxiliaryExecutable:(launchOptions.processType == ProcessLauncher::PluginProcess ? @"PluginProcess.app" : @"WebProcess.app")]; + + NSString *processPath = nil; + switch(launchOptions.processType) { + case ProcessLauncher::WebProcess: + processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"WebProcess.app"]; + break; + case ProcessLauncher::PluginProcess: + processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"PluginProcess.app"]; + break; +#if ENABLE(NETWORK_PROCESS) + case ProcessLauncher::NetworkProcess: + processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"NetworkProcess.app"]; + break; +#endif + case ProcessLauncher::SharedWorkerProcess: + processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"SharedWorkerProcess.app"]; + break; + } + NSString *frameworkExecutablePath = [webKit2Bundle executablePath]; NSString *processAppExecutablePath = [[NSBundle bundleWithPath:processPath] executablePath]; diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp index 3cacf04db..60cde5fa0 100644 --- a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp +++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp @@ -128,7 +128,7 @@ void ProcessLauncher::launchProcess() mach_port_insert_right(mach_task_self(), connector, connector, MACH_MSG_TYPE_MAKE_SEND); // Register port with a service name to the system. - QString serviceName = QString("com.nokia.Qt.WebKit.QtWebProcess-%1-%2"); + QString serviceName = QStringLiteral("com.nokia.Qt.WebKit.QtWebProcess-%1-%2"); serviceName = serviceName.arg(QString().setNum(getpid()), QString().setNum((size_t)this)); kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.toUtf8().data()), connector, 0); ASSERT_UNUSED(kr, kr == KERN_SUCCESS); diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp new file mode 100644 index 000000000..fe528351a --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "NetworkProcessProxy.h" + +#include "NetworkProcessCreationParameters.h" +#include "NetworkProcessMessages.h" +#include <WebCore/RunLoop.h> + +#if ENABLE(NETWORK_PROCESS) + +using namespace WebCore; + +namespace WebKit { + +PassRefPtr<NetworkProcessProxy> NetworkProcessProxy::create() +{ + return adoptRef(new NetworkProcessProxy); +} + +NetworkProcessProxy::NetworkProcessProxy() +{ + ProcessLauncher::LaunchOptions launchOptions; + launchOptions.processType = ProcessLauncher::NetworkProcess; + +#if PLATFORM(MAC) + launchOptions.architecture = ProcessLauncher::LaunchOptions::MatchCurrentArchitecture; + launchOptions.executableHeap = false; +#if HAVE(XPC) + launchOptions.useXPC = false; +#endif +#endif + + m_processLauncher = ProcessLauncher::create(this, launchOptions); +} + +NetworkProcessProxy::~NetworkProcessProxy() +{ + +} + +void NetworkProcessProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) +{ + +} + +void NetworkProcessProxy::didClose(CoreIPC::Connection*) +{ + +} + +void NetworkProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID) +{ + +} + +void NetworkProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*) +{ + +} + +void NetworkProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier) +{ + ASSERT(!m_connection); + + if (CoreIPC::Connection::identifierIsNull(connectionIdentifier)) { + // FIXME: Do better cleanup here. + return; + } + + m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main()); +#if PLATFORM(MAC) + m_connection->setShouldCloseConnectionOnMachExceptions(); +#endif + + m_connection->open(); + + NetworkProcessCreationParameters parameters; + platformInitializeNetworkProcess(parameters); + + // Initialize the network host process. + m_connection->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0); +} + +} // namespace WebKit + +#endif // ENABLE(NETWORK_PROCESS) diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h new file mode 100644 index 000000000..57e37e653 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef NetworkProcessProxy_h +#define NetworkProcessProxy_h + +#if ENABLE(NETWORK_PROCESS) + +#include "Connection.h" +#include "ProcessLauncher.h" +#include "WebProcessProxyMessages.h" +#include <wtf/Deque.h> + +namespace WebKit { + +struct NetworkProcessCreationParameters; + +class NetworkProcessProxy : public RefCounted<NetworkProcessProxy>, CoreIPC::Connection::Client, ProcessLauncher::Client { +public: + static PassRefPtr<NetworkProcessProxy> create(); + ~NetworkProcessProxy(); + +private: + NetworkProcessProxy(); + + void platformInitializeNetworkProcess(NetworkProcessCreationParameters&); + + // CoreIPC::Connection::Client + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + virtual void didClose(CoreIPC::Connection*); + virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + virtual void syncMessageSendTimedOut(CoreIPC::Connection*); + + // ProcessLauncher::Client + virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier); + + // The connection to the network process. + RefPtr<CoreIPC::Connection> m_connection; + + // The process launcher for the network process. + RefPtr<ProcessLauncher> m_processLauncher; + +}; + +} // namespace WebKit + +#endif // ENABLE(NETWORK_PROCESS) + +#endif // NetworkProcessProxy_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_web_error_private.h b/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm index c9a31e50a..440cc429f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_web_error_private.h +++ b/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,13 +23,22 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ewk_web_error_private_h -#define ewk_web_error_private_h +#import "config.h" +#import "NetworkProcessProxy.h" -#include <WKError.h> +#import "NetworkProcessCreationParameters.h" -typedef struct _Ewk_Web_Error Ewk_Web_Error; +#if ENABLE(NETWORK_PROCESS) -Ewk_Web_Error* ewk_web_error_new(WKErrorRef error); +using namespace WebCore; -#endif // ewk_web_error_private_h +namespace WebKit { + +void NetworkProcessProxy::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters) +{ + parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; +} + +} // namespace WebKit + +#endif // ENABLE(NETWORK_PROCESS) diff --git a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp index 07922985e..4a0c47529 100644 --- a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp @@ -43,7 +43,7 @@ void NotificationPermissionRequestManagerProxy::invalidateRequests() PendingRequestMap::const_iterator it = m_pendingRequests.begin(); PendingRequestMap::const_iterator end = m_pendingRequests.end(); for (; it != end; ++it) - it->second->invalidate(); + it->value->invalidate(); m_pendingRequests.clear(); } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp index 88e2cf1aa..07e1f8497 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp @@ -47,6 +47,7 @@ PassRefPtr<WebNotificationManagerProxy> WebNotificationManagerProxy::create(WebC WebNotificationManagerProxy::WebNotificationManagerProxy(WebContext* context) : m_context(context) { + m_context->addMessageReceiver(CoreIPC::MessageClassWebNotificationManagerProxy, this); } void WebNotificationManagerProxy::invalidate() diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h index d61b6f661..620915d14 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h @@ -27,7 +27,7 @@ #define WebNotificationManagerProxy_h #include "APIObject.h" -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebNotificationProvider.h" #include <WebCore/NotificationClient.h> #include <wtf/HashMap.h> @@ -35,12 +35,6 @@ #include <wtf/PassRefPtr.h> #include <wtf/text/StringHash.h> -namespace CoreIPC { -class ArgumentDecoder; -class ArgumentEncoder; -class Connection; -} - namespace WebKit { class ImmutableArray; @@ -48,7 +42,7 @@ class WebContext; class WebPageProxy; class WebSecurityOrigin; -class WebNotificationManagerProxy : public APIObject { +class WebNotificationManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeNotificationManager; @@ -68,13 +62,13 @@ public: void providerDidUpdateNotificationPolicy(const WebSecurityOrigin*, bool allowed); void providerDidRemoveNotificationPolicies(ImmutableArray* origins); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - private: explicit WebNotificationManagerProxy(WebContext*); virtual Type type() const { return APIType; } - + + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); // Message handlers diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h index ebf5cd16f..c6fb91882 100644 --- a/Source/WebKit2/UIProcess/PageClient.h +++ b/Source/WebKit2/UIProcess/PageClient.h @@ -118,6 +118,8 @@ public: virtual void pageDidRequestScroll(const WebCore::IntPoint&) = 0; #endif #if PLATFORM(QT) + virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) = 0; + virtual void pageTransitionViewportReady() = 0; virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0; virtual void didReceiveMessageFromNavigatorQtObject(const String&) = 0; virtual void updateTextInputState() = 0; diff --git a/Source/WebKit2/UIProcess/PageViewportController.cpp b/Source/WebKit2/UIProcess/PageViewportController.cpp index e42006a14..02fd3b699 100644 --- a/Source/WebKit2/UIProcess/PageViewportController.cpp +++ b/Source/WebKit2/UIProcess/PageViewportController.cpp @@ -54,9 +54,6 @@ ViewportUpdateDeferrer::~ViewportUpdateDeferrer() return; m_controller->resumeContent(); - - // Make sure that tiles all around the viewport will be requested. - m_controller->syncVisibleContents(); } PageViewportController::PageViewportController(WebKit::WebPageProxy* proxy, PageViewportControllerClient* client) @@ -109,15 +106,65 @@ FloatPoint PageViewportController::clampViewportToContents(const WebCore::FloatP return FloatPoint(clampTo(viewportPos.x(), 0.f, horizontalRange), clampTo(viewportPos.y(), 0.f, verticalRange)); } -void PageViewportController::didChangeContentsSize(const IntSize& newSize) +void PageViewportController::didCommitLoad() { - if (m_viewportSize.isEmpty() || newSize.isEmpty()) - return; + // Do not count the previous committed page contents as covered. + m_lastFrameCoveredRect = FloatRect(); + + // Reset the position to the top, page/history scroll requests may override this before we re-enable rendering. + applyPositionAfterRenderingContents(FloatPoint()); +} +void PageViewportController::didChangeContentsSize(const IntSize& newSize) +{ m_contentsSize = newSize; updateMinimumScaleToFit(); +} + +void PageViewportController::didRenderFrame(const IntSize& contentsSize, const IntRect& coveredRect) +{ + if (m_clientContentsSize != contentsSize) { + m_clientContentsSize = contentsSize; + // Only update the viewport's contents dimensions along with its render if the + // size actually changed since animations on the page trigger DidRenderFrame + // messages without causing dimension changes. + m_client->didChangeContentsSize(contentsSize); + } + + m_lastFrameCoveredRect = coveredRect; + + // Apply any scale or scroll position we locked to be set on the viewport + // only when there is something to display there. The scale goes first to + // avoid offsetting our deferred position by scaling at the viewport center. + // All position and scale changes resulting from a web process event should + // go through here to be applied on the viewport to avoid showing incomplete + // tiles to the user during a few milliseconds. + if (m_effectiveScaleIsLocked) { + m_client->setContentsScale(m_effectiveScale, false); + m_effectiveScaleIsLocked = false; + } + if (m_viewportPosIsLocked) { + FloatPoint clampedPos = clampViewportToContents(m_viewportPos, m_effectiveScale); + // There might be rendered frames not covering our requested position yet, wait for it. + if (FloatRect(clampedPos, viewportSizeInContentsCoordinates()).intersects(coveredRect)) { + m_client->setViewportPosition(clampedPos); + m_viewportPosIsLocked = false; + } + } +} + +void PageViewportController::pageTransitionViewportReady() +{ + if (!m_rawAttributes.layoutSize.isEmpty()) { + m_hadUserInteraction = false; + applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale))); + } - m_client->didChangeContentsSize(); + // At this point we should already have received the first viewport arguments and the requested scroll + // position for the newly loaded page and sent our reactions to the web process. It's now safe to tell + // the web process to start rendering the new page contents and possibly re-use the current tiles. + // This assumes that all messages have been handled in order and that nothing has been pushed back on the event loop. + m_webPageProxy->commitPageTransitionViewport(); } void PageViewportController::pageDidRequestScroll(const IntPoint& cssPosition) @@ -126,7 +173,12 @@ void PageViewportController::pageDidRequestScroll(const IntPoint& cssPosition) if (m_activeDeferrerCount) return; - m_client->setViewportPosition(clampViewportToContents(cssPosition, m_effectiveScale)); + FloatRect endVisibleContentRect(clampViewportToContents(cssPosition, m_effectiveScale), viewportSizeInContentsCoordinates()); + if (m_lastFrameCoveredRect.intersects(endVisibleContentRect)) + m_client->setViewportPosition(endVisibleContentRect.location()); + else + // Keep the unclamped position in case the contents size is changed later on. + applyPositionAfterRenderingContents(cssPosition); } void PageViewportController::didChangeViewportSize(const FloatSize& newSize) @@ -145,8 +197,11 @@ void PageViewportController::didChangeViewportSize(const FloatSize& newSize) void PageViewportController::didChangeContentsVisibility(const FloatPoint& viewportPos, float viewportScale, const FloatPoint& trajectoryVector) { - m_viewportPos = viewportPos; - m_effectiveScale = viewportScale; + if (!m_viewportPosIsLocked) + m_viewportPos = viewportPos; + if (!m_effectiveScaleIsLocked) + m_effectiveScale = viewportScale; + syncVisibleContents(trajectoryVector); } @@ -156,7 +211,7 @@ void PageViewportController::syncVisibleContents(const FloatPoint& trajectoryVec if (!drawingArea || m_viewportSize.isEmpty() || m_contentsSize.isEmpty()) return; - FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_effectiveScale), m_viewportSize / m_effectiveScale); + FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_effectiveScale), viewportSizeInContentsCoordinates()); visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize)); drawingArea->setVisibleContentsRect(visibleContentsRect, m_effectiveScale, trajectoryVector); @@ -177,6 +232,11 @@ void PageViewportController::didChangeViewportAttributes(const WebCore::Viewport m_client->didChangeViewportAttributes(); } +WebCore::FloatSize PageViewportController::viewportSizeInContentsCoordinates() const +{ + return WebCore::FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale); +} + void PageViewportController::suspendContent() { if (m_hasSuspendedContent) @@ -188,12 +248,6 @@ void PageViewportController::suspendContent() void PageViewportController::resumeContent() { - if (!m_rawAttributes.layoutSize.isEmpty() && m_rawAttributes.initialScale > 0) { - m_hadUserInteraction = false; - m_client->setContentsScale(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale)), /* isInitialScale */ true); - m_rawAttributes.initialScale = -1; // Mark used. - } - m_client->didResumeContent(); if (!m_hasSuspendedContent) @@ -203,15 +257,32 @@ void PageViewportController::resumeContent() m_webPageProxy->resumeActiveDOMObjectsAndAnimations(); } +void PageViewportController::applyScaleAfterRenderingContents(float scale) +{ + m_effectiveScale = scale; + m_effectiveScaleIsLocked = true; + syncVisibleContents(); +} + +void PageViewportController::applyPositionAfterRenderingContents(const FloatPoint& pos) +{ + m_viewportPos = pos; + m_viewportPosIsLocked = true; + syncVisibleContents(); +} + void PageViewportController::updateMinimumScaleToFit() { + if (m_viewportSize.isEmpty()) + return; + float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize)); if (!fuzzyCompare(minimumScale, m_minimumScaleToFit, 0.001)) { m_minimumScaleToFit = minimumScale; if (!m_hadUserInteraction && !hasSuspendedContent()) - m_client->setContentsScale(toViewportScale(minimumScale), true /* isInitialScale */); + applyScaleAfterRenderingContents(toViewportScale(minimumScale)); m_client->didChangeViewportAttributes(); } diff --git a/Source/WebKit2/UIProcess/PageViewportController.h b/Source/WebKit2/UIProcess/PageViewportController.h index acbb22a58..d38ddb914 100644 --- a/Source/WebKit2/UIProcess/PageViewportController.h +++ b/Source/WebKit2/UIProcess/PageViewportController.h @@ -95,15 +95,21 @@ public: void didChangeContentsVisibility(const WebCore::FloatPoint& viewportPos, float viewportScale, const WebCore::FloatPoint& trajectoryVector = WebCore::FloatPoint::zero()); // Notifications from the WebProcess. + void didCommitLoad(); void didChangeContentsSize(const WebCore::IntSize& newSize); void didChangeViewportAttributes(const WebCore::ViewportAttributes&); + void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect); + void pageTransitionViewportReady(); void pageDidRequestScroll(const WebCore::IntPoint& cssPosition); private: float fromViewportScale(float scale) const { return scale / devicePixelRatio(); } float toViewportScale(float scale) const { return scale * devicePixelRatio(); } void syncVisibleContents(const WebCore::FloatPoint &trajectoryVector = WebCore::FloatPoint::zero()); + void applyScaleAfterRenderingContents(float scale); + void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos); void updateMinimumScaleToFit(); + WebCore::FloatSize viewportSizeInContentsCoordinates() const; WebPageProxy* const m_webPageProxy; PageViewportControllerClient* m_client; @@ -120,8 +126,13 @@ private: WebCore::FloatPoint m_viewportPos; WebCore::FloatSize m_viewportSize; WebCore::FloatSize m_contentsSize; + WebCore::IntSize m_clientContentsSize; float m_effectiveScale; // Should always be cssScale * devicePixelRatio. + bool m_viewportPosIsLocked; + bool m_effectiveScaleIsLocked; + WebCore::FloatRect m_lastFrameCoveredRect; + friend class ViewportUpdateDeferrer; }; diff --git a/Source/WebKit2/UIProcess/PageViewportControllerClient.h b/Source/WebKit2/UIProcess/PageViewportControllerClient.h index 3d91b9aac..7b05ea854 100644 --- a/Source/WebKit2/UIProcess/PageViewportControllerClient.h +++ b/Source/WebKit2/UIProcess/PageViewportControllerClient.h @@ -23,6 +23,11 @@ #include <wtf/Noncopyable.h> +namespace WebCore { +class FloatPoint; +class IntSize; +} + namespace WebKit { class PageViewportController; @@ -37,7 +42,7 @@ public: virtual void setContentsScale(float, bool treatAsInitialValue) = 0; virtual void didResumeContent() = 0; - virtual void didChangeContentsSize() = 0; + virtual void didChangeContentsSize(const WebCore::IntSize&) = 0; virtual void didChangeVisibleContents() = 0; virtual void didChangeViewportAttributes() = 0; diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp index cebf4f7b2..f497895db 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp @@ -74,15 +74,6 @@ void PluginProcessManager::clearSiteData(const PluginModuleInfo& plugin, WebPlug pluginProcess->clearSiteData(webPluginSiteDataManager, sites, flags, maxAgeInSeconds, callbackID); } -void PluginProcessManager::pluginSyncMessageSendTimedOut(const String& pluginPath) -{ - PluginProcessProxy* pluginProcess = pluginProcessWithPath(pluginPath); - if (!pluginProcess) - return; - - pluginProcess->terminate(); -} - PluginProcessProxy* PluginProcessManager::pluginProcessWithPath(const String& pluginPath) { for (size_t i = 0; i < m_pluginProcesses.size(); ++i) { diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h index 19aafe860..37824c4aa 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h @@ -56,8 +56,6 @@ public: void getSitesWithData(const PluginModuleInfo&, WebPluginSiteDataManager*, uint64_t callbackID); void clearSiteData(const PluginModuleInfo&, WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); - void pluginSyncMessageSendTimedOut(const String& pluginPath); - private: PluginProcessManager(); diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp index cfdff9efb..7796cfe97 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp @@ -152,10 +152,10 @@ void PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch() } while (!m_pendingGetSitesReplies.isEmpty()) - didGetSitesWithData(Vector<String>(), m_pendingGetSitesReplies.begin()->first); + didGetSitesWithData(Vector<String>(), m_pendingGetSitesReplies.begin()->key); while (!m_pendingClearSiteDataReplies.isEmpty()) - didClearSiteData(m_pendingClearSiteDataReplies.begin()->first); + didClearSiteData(m_pendingClearSiteDataReplies.begin()->key); // Tell the plug-in process manager to forget about this plug-in process proxy. This may cause us to be deleted. m_pluginProcessManager->removePluginProcessProxy(this); @@ -188,10 +188,6 @@ void PluginProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC: { } -void PluginProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*) -{ -} - void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier) { ASSERT(!m_connection); diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h index e0fe15ff0..4b50e6b80 100644 --- a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h +++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h @@ -101,7 +101,6 @@ private: virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); // ProcessLauncher::Client virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier); diff --git a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp index a26bbbdb8..246eeb447 100644 --- a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp +++ b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp @@ -163,8 +163,6 @@ void WebPluginSiteDataManager::getSitesWithData(PassRefPtr<ArrayCallback> prpCal m_pendingGetSitesWithData.set(callbackID, state); state->getSitesWithDataForNextPlugin(); #else - m_webContext->relaunchProcessIfNecessary(); - Vector<PluginModuleInfo> plugins = m_webContext->pluginInfoStore().plugins(); Vector<String> pluginPaths; for (size_t i = 0; i < plugins.size(); ++i) @@ -225,8 +223,6 @@ void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t fla m_pendingClearSiteData.set(callbackID, state); state->clearSiteDataForNextPlugin(); #else - m_webContext->relaunchProcessIfNecessary(); - Vector<PluginModuleInfo> plugins = m_webContext->pluginInfoStore().plugins(); Vector<String> pluginPaths; for (size_t i = 0; i < plugins.size(); ++i) diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm index 5137968e6..2150c06f2 100644 --- a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm @@ -145,7 +145,14 @@ void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationPa bool PluginProcessProxy::getPluginProcessSerialNumber(ProcessSerialNumber& pluginProcessSerialNumber) { pid_t pluginProcessPID = m_processLauncher->processIdentifier(); +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif return GetProcessForPID(pluginProcessPID, &pluginProcessSerialNumber) == noErr; +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif } void PluginProcessProxy::makePluginProcessTheFrontProcess() @@ -154,14 +161,28 @@ void PluginProcessProxy::makePluginProcessTheFrontProcess() if (!getPluginProcessSerialNumber(pluginProcessSerialNumber)) return; +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif SetFrontProcess(&pluginProcessSerialNumber); +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif } void PluginProcessProxy::makeUIProcessTheFrontProcess() { ProcessSerialNumber processSerialNumber; +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif GetCurrentProcess(&processSerialNumber); SetFrontProcess(&processSerialNumber); +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif } void PluginProcessProxy::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing) @@ -193,7 +214,14 @@ void PluginProcessProxy::exitFullscreen() { // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode. ProcessSerialNumber frontProcessSerialNumber; +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif GetFrontProcess(&frontProcessSerialNumber); +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif // The UI process must be the front process in order to change the presentation mode. makeUIProcessTheFrontProcess(); @@ -206,9 +234,24 @@ void PluginProcessProxy::exitFullscreen() // If the plug-in process was not the front process, switch back to the previous front process. // (Otherwise we'll keep the UI process as the front process). Boolean isPluginProcessFrontProcess; +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif SameProcess(&frontProcessSerialNumber, &pluginProcessSerialNumber, &isPluginProcessFrontProcess); - if (!isPluginProcessFrontProcess) +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif + if (!isPluginProcessFrontProcess) { +#if COMPILER(CLANG) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif SetFrontProcess(&frontProcessSerialNumber); +#if COMPILER(CLANG) +#pragma clang diagnostic pop +#endif + } } void PluginProcessProxy::setModalWindowIsShowing(bool modalWindowIsShowing) diff --git a/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp b/Source/WebKit2/UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp index fa9339d09..3febb069a 100644 --- a/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp +++ b/Source/WebKit2/UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp @@ -1,5 +1,7 @@ /* * Copyright (C) 2011 Igalia S.L. + * Copyright (C) 2011 Apple Inc. + * Copyright (C) 2012 Samsung Electronics * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +12,10 @@ * 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'' + * 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 APPLE INC. OR ITS CONTRIBUTORS + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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 @@ -31,10 +33,11 @@ #include "PluginProcessCreationParameters.h" #include "ProcessExecutablePath.h" #include <WebCore/FileSystem.h> -#include <WebCore/GOwnPtrGtk.h> -#include <glib.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> +#if PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT)) +#include <glib.h> +#endif using namespace WebCore; @@ -46,6 +49,7 @@ void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationPa bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& result) { +#if PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT)) CString binaryPath = fileSystemRepresentation(executablePathOfPluginProcess()); CString pluginPathCString = fileSystemRepresentation(pluginPath); char* argv[4]; @@ -54,27 +58,39 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& argv[2] = const_cast<char*>(pluginPathCString.data()); argv[3] = 0; - gint status; - GOwnPtr<gchar> stdOut; - if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut.outPtr(), 0, &status, 0)) + int status; + char* stdOut = 0; + + if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut, 0, &status, 0)) return false; - if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS) + + if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS) { + free(stdOut); return false; + } const unsigned kNumLinesExpected = 3; String lines[kNumLinesExpected]; unsigned lineIndex = 0; - const UChar* current = reinterpret_cast<const UChar*>(stdOut.get()); + + const UChar* current = reinterpret_cast<const UChar*>(stdOut); + while (lineIndex < kNumLinesExpected) { const UChar* start = current; while (*current++ != UChar('\n')) { } lines[lineIndex++] = String(start, current - start - 1); } + if (stdOut) + free(stdOut); + result.name.swap(lines[0]); result.description.swap(lines[1]); result.mimeDescription.swap(lines[2]); return !result.mimeDescription.isEmpty(); +#else // PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT)) + return false; +#endif // PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT)) } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.cpp b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.cpp new file mode 100644 index 000000000..4e2fe1617 --- /dev/null +++ b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedWorkerProcessManager.h" + +#include "SharedWorkerProcessProxy.h" +#include "WebContext.h" +#include <wtf/StdLibExtras.h> +#include <wtf/text/WTFString.h> + +namespace WebKit { + +SharedWorkerProcessManager& SharedWorkerProcessManager::shared() +{ + DEFINE_STATIC_LOCAL(SharedWorkerProcessManager, manager, ()); + return manager; +} + +SharedWorkerProcessManager::SharedWorkerProcessManager() +{ +} + +void SharedWorkerProcessManager::getSharedWorkerProcessConnection(const String& url, const String& name, PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply> reply) +{ + SharedWorkerProcessProxy* sharedWorkerProcess = getOrCreateSharedWorkerProcess(url, name); + sharedWorkerProcess->getSharedWorkerProcessConnection(reply); +} + +void SharedWorkerProcessManager::removeSharedWorkerProcessProxy(SharedWorkerProcessProxy* sharedWorkerProcessProxy) +{ + size_t vectorIndex = m_sharedWorkerProcesses.find(sharedWorkerProcessProxy); + ASSERT(vectorIndex != notFound); + + m_sharedWorkerProcesses.remove(vectorIndex); +} + +SharedWorkerProcessProxy* SharedWorkerProcessManager::getOrCreateSharedWorkerProcess(const String& url, const String& name) +{ + // FIXME: Find an existing shared worker that matches. + + RefPtr<SharedWorkerProcessProxy> sharedWorkerProcess = SharedWorkerProcessProxy::create(this, url, name); + SharedWorkerProcessProxy* sharedWorkerProcessPtr = sharedWorkerProcess.get(); + + m_sharedWorkerProcesses.append(sharedWorkerProcess.release()); + + return sharedWorkerProcessPtr; +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.h b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.h new file mode 100644 index 000000000..c0bc66210 --- /dev/null +++ b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessManager.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SharedWorkerProcessManager_h +#define SharedWorkerProcessManager_h + +#include "PluginModuleInfo.h" +#include "WebProcessProxyMessages.h" +#include <wtf/Forward.h> +#include <wtf/Noncopyable.h> +#include <wtf/Vector.h> + +namespace CoreIPC { + class ArgumentEncoder; +} + +namespace WebKit { + +class PluginInfoStore; +class SharedWorkerProcessProxy; +class WebProcessProxy; +class WebPluginSiteDataManager; + +class SharedWorkerProcessManager { + WTF_MAKE_NONCOPYABLE(SharedWorkerProcessManager); +public: + static SharedWorkerProcessManager& shared(); + + void getSharedWorkerProcessConnection(const String& url, const String& name, PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply>); + void removeSharedWorkerProcessProxy(SharedWorkerProcessProxy*); + +private: + SharedWorkerProcessManager(); + + SharedWorkerProcessProxy* getOrCreateSharedWorkerProcess(const String& url, const String& name); + + Vector<RefPtr<SharedWorkerProcessProxy> > m_sharedWorkerProcesses; +}; + +} // namespace WebKit + +#endif // SharedWorkerProcessManager_h diff --git a/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.cpp b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.cpp new file mode 100644 index 000000000..5a7967572 --- /dev/null +++ b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.cpp @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedWorkerProcessProxy.h" + +#include "SharedWorkerProcessCreationParameters.h" +#include "SharedWorkerProcessManager.h" +#include "SharedWorkerProcessMessages.h" +#include "WebContext.h" +#include "WebCoreArgumentCoders.h" +#include "WebProcessMessages.h" +#include "WebProcessProxy.h" +#include <WebCore/NotImplemented.h> +#include <WebCore/RunLoop.h> + +#if PLATFORM(MAC) +#include "MachPort.h" +#endif + +using namespace WebCore; + +namespace WebKit { + +// FIXME: Are these relevant to shared worker process at all? +static const double minimumLifetime = 30 * 60; +static const double shutdownTimeout = 10 * 60; + +PassRefPtr<SharedWorkerProcessProxy> SharedWorkerProcessProxy::create(SharedWorkerProcessManager* sharedWorkerProcessManager, const String& url, const String& name) +{ + return adoptRef(new SharedWorkerProcessProxy(sharedWorkerProcessManager, url, name)); +} + +SharedWorkerProcessProxy::SharedWorkerProcessProxy(SharedWorkerProcessManager* sharedWorkerProcessManager, const String& url, const String& name) + : m_sharedWorkerProcessManager(sharedWorkerProcessManager) + , m_numPendingConnectionRequests(0) +{ + ProcessLauncher::LaunchOptions launchOptions; + launchOptions.processType = ProcessLauncher::SharedWorkerProcess; + // FIXME: Pass URL down to the process to load. +#if PLATFORM(MAC) +#if HAVE(XPC) + launchOptions.useXPC = false; +#endif +#endif + + m_processLauncher = ProcessLauncher::create(this, launchOptions); +} + +SharedWorkerProcessProxy::~SharedWorkerProcessProxy() +{ +} + +// Asks the shared worker process to create a new connection to a web process. The connection identifier will be +// encoded in the given argument encoder and sent back to the connection of the given web process. +void SharedWorkerProcessProxy::getSharedWorkerProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply> reply) +{ + m_pendingConnectionReplies.append(reply); + + if (m_processLauncher->isLaunching()) { + m_numPendingConnectionRequests++; + return; + } + + // Ask the shared worker process to create a connection. Since the shared worker can be waiting for a synchronous reply + // we need to make sure that this message is always processed, even when the shared worker is waiting for a synchronus reply. + m_connection->send(Messages::SharedWorkerProcess::CreateWebProcessConnection(), 0, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply); +} + +void SharedWorkerProcessProxy::terminate() +{ + m_processLauncher->terminateProcess(); +} + +void SharedWorkerProcessProxy::sharedWorkerProcessCrashedOrFailedToLaunch() +{ + // The shared worker process must have crashed or exited, send any pending sync replies we might have. + while (!m_pendingConnectionReplies.isEmpty()) { + RefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); + +#if PLATFORM(MAC) + reply->send(CoreIPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND)); +#elif USE(UNIX_DOMAIN_SOCKETS) + reply->send(CoreIPC::Attachment()); +#else + notImplemented(); +#endif + } + + // Tell the shared worker process manager to forget about this shared worker process proxy. This may cause us to be deleted. + m_sharedWorkerProcessManager->removeSharedWorkerProcessProxy(this); +} + +void SharedWorkerProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveSharedWorkerProcessProxyMessage(connection, messageID, arguments); +} + +void SharedWorkerProcessProxy::didClose(CoreIPC::Connection*) +{ + // FIXME: Notify web processes. + + // This will cause us to be deleted. + sharedWorkerProcessCrashedOrFailedToLaunch(); +} + +void SharedWorkerProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID) +{ +} + +void SharedWorkerProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier) +{ + ASSERT(!m_connection); + + if (CoreIPC::Connection::identifierIsNull(connectionIdentifier)) { + sharedWorkerProcessCrashedOrFailedToLaunch(); + return; + } + + m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main()); +#if PLATFORM(MAC) + m_connection->setShouldCloseConnectionOnMachExceptions(); +#elif PLATFORM(QT) + m_connection->setShouldCloseConnectionOnProcessTermination(m_processLauncher->processIdentifier()); +#endif + + m_connection->open(); + + SharedWorkerProcessCreationParameters parameters; + + parameters.minimumLifetime = minimumLifetime; + parameters.terminationTimeout = shutdownTimeout; + + platformInitializeSharedWorkerProcess(parameters); + + // Initialize the shared worker host process. + m_connection->send(Messages::SharedWorkerProcess::InitializeSharedWorkerProcess(parameters), 0); + + for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i) + m_connection->send(Messages::SharedWorkerProcess::CreateWebProcessConnection(), 0); + + m_numPendingConnectionRequests = 0; +} + +void SharedWorkerProcessProxy::didCreateWebProcessConnection(const CoreIPC::Attachment& connectionIdentifier) +{ + ASSERT(!m_pendingConnectionReplies.isEmpty()); + + // Grab the first pending connection reply. + RefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); + +#if PLATFORM(MAC) + reply->send(CoreIPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND)); +#elif USE(UNIX_DOMAIN_SOCKETS) + reply->send(connectionIdentifier); +#else + notImplemented(); +#endif +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.h b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.h new file mode 100644 index 000000000..477482f9e --- /dev/null +++ b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2010, 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SharedWorkerProcessProxy_h +#define SharedWorkerProcessProxy_h + +#include "Connection.h" +#include "ProcessLauncher.h" +#include "WebProcessProxyMessages.h" +#include <wtf/Deque.h> + +// FIXME: This is platform specific. +namespace CoreIPC { + class MachPort; +} + +namespace WebKit { + +class SharedWorkerProcessManager; +class WebProcessProxy; +struct SharedWorkerProcessCreationParameters; + +class SharedWorkerProcessProxy : public RefCounted<SharedWorkerProcessProxy>, CoreIPC::Connection::Client, ProcessLauncher::Client { +public: + static PassRefPtr<SharedWorkerProcessProxy> create(SharedWorkerProcessManager*, const String& url, const String& name); + ~SharedWorkerProcessProxy(); + + // Asks the shared worker process to create a new connection to a web process. The connection identifier will be + // encoded in the given argument encoder and sent back to the connection of the given web process. + void getSharedWorkerProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply>); + + // Terminates the shared worker process. + void terminate(); + +private: + SharedWorkerProcessProxy(SharedWorkerProcessManager*, const String& url, const String& name); + + void sharedWorkerProcessCrashedOrFailedToLaunch(); + + // CoreIPC::Connection::Client + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + virtual void didClose(CoreIPC::Connection*); + virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); + + // ProcessLauncher::Client + virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier); + + // Message handlers + void didReceiveSharedWorkerProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + void didCreateWebProcessConnection(const CoreIPC::Attachment&); + + void platformInitializeSharedWorkerProcess(SharedWorkerProcessCreationParameters&); + + // The shared worker host process manager. + SharedWorkerProcessManager* m_sharedWorkerProcessManager; + + // The connection to the plug-in host process. + RefPtr<CoreIPC::Connection> m_connection; + + // The process launcher for the plug-in host process. + RefPtr<ProcessLauncher> m_processLauncher; + + Deque<RefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply> > m_pendingConnectionReplies; + + // If createPluginConnection is called while the process is still launching we'll keep count of it and send a bunch of requests + // when the process finishes launching. + unsigned m_numPendingConnectionRequests; +}; + +} // namespace WebKit + +#endif // SharedWorkerProcessProxy_h diff --git a/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.messages.in b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.messages.in new file mode 100644 index 000000000..e55c8c044 --- /dev/null +++ b/Source/WebKit2/UIProcess/SharedWorkers/SharedWorkerProcessProxy.messages.in @@ -0,0 +1,25 @@ +# Copyright (C) 2010, 2012 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +messages -> SharedWorkerProcessProxy { + DidCreateWebProcessConnection(CoreIPC::Attachment connectionIdentifier) +} diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp index f43c819fd..4fc41ba21 100644 --- a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp @@ -41,6 +41,7 @@ PassRefPtr<WebApplicationCacheManagerProxy> WebApplicationCacheManagerProxy::cre WebApplicationCacheManagerProxy::WebApplicationCacheManagerProxy(WebContext* context) : m_webContext(context) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebApplicationCacheManagerProxy, this); } WebApplicationCacheManagerProxy::~WebApplicationCacheManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h index 597f8d7e1..464621856 100644 --- a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h @@ -29,7 +29,7 @@ #include "APIObject.h" #include "GenericCallback.h" #include "ImmutableArray.h" - +#include "MessageReceiver.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> @@ -49,7 +49,7 @@ class WebSecurityOrigin; typedef GenericCallback<WKArrayRef> ArrayCallback; -class WebApplicationCacheManagerProxy : public APIObject { +class WebApplicationCacheManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeApplicationCacheManager; @@ -63,8 +63,6 @@ public: void deleteEntriesForOrigin(WebSecurityOrigin*); void deleteAllEntries(); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -73,7 +71,9 @@ private: virtual Type type() const { return APIType; } void didGetApplicationCacheOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID); - + + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebApplicationCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); WebContext* m_webContext; diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp index c3897e81c..b42b7b021 100644 --- a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.cpp @@ -42,6 +42,7 @@ WebBatteryManagerProxy::WebBatteryManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { + m_context->addMessageReceiver(CoreIPC::MessageClassWebBatteryManagerProxy, this); } WebBatteryManagerProxy::~WebBatteryManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h index 9fa5bdc43..65c6614da 100644 --- a/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebBatteryManagerProxy.h @@ -29,21 +29,16 @@ #if ENABLE(BATTERY_STATUS) #include "APIObject.h" -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebBatteryProvider.h" #include <wtf/Forward.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -} - namespace WebKit { class WebContext; class WebBatteryStatus; +class WebBatteryManagerProxy : public APIObject, private CoreIPC::MessageReceiver { -class WebBatteryManagerProxy : public APIObject { public: static const Type APIType = TypeBatteryManager; @@ -58,13 +53,14 @@ public: void providerDidChangeBatteryStatus(const WTF::AtomicString&, WebBatteryStatus*); void providerUpdateBatteryStatus(WebBatteryStatus*); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - private: explicit WebBatteryManagerProxy(WebContext*); virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + // Implemented in generated WebBatteryManagerProxyMessageReceiver.cpp void didReceiveWebBatteryManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp index dbf12ccf0..86ba91c08 100644 --- a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp +++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp @@ -40,8 +40,8 @@ PassRefPtr<WebConnectionToWebProcess> WebConnectionToWebProcess::create(WebProce } WebConnectionToWebProcess::WebConnectionToWebProcess(WebProcessProxy* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop) - : m_process(process) - , m_connection(CoreIPC::Connection::createServerConnection(connectionIdentifier, this, runLoop)) + : WebConnection(CoreIPC::Connection::createServerConnection(connectionIdentifier, this, runLoop)) + , m_process(process) { #if OS(DARWIN) m_connection->setShouldCloseConnectionOnMachExceptions(); @@ -50,42 +50,27 @@ WebConnectionToWebProcess::WebConnectionToWebProcess(WebProcessProxy* process, C #endif } -void WebConnectionToWebProcess::invalidate() +// WebConnection + +void WebConnectionToWebProcess::encodeMessageBody(CoreIPC::ArgumentEncoder* argumentEncoder, APIObject* messageBody) { - m_connection->invalidate(); - m_connection = nullptr; - m_process = 0; + argumentEncoder->encode(WebContextUserMessageEncoder(messageBody)); } -// WebConnection - -void WebConnectionToWebProcess::postMessage(const String& messageName, APIObject* messageBody) +bool WebConnectionToWebProcess::decodeMessageBody(CoreIPC::ArgumentDecoder* argumentDecoder, RefPtr<APIObject>& messageBody) { - // We need to check if we have an underlying process here since a user of the API can hold - // onto us and call postMessage even after the process has been invalidated. - if (!m_process) - return; + if (!argumentDecoder->decode(WebContextUserMessageDecoder(messageBody, m_process))) + return false; - m_process->deprecatedSend(WebConnectionLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody))); + return true; } // CoreIPC::Connection::Client void WebConnectionToWebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { - if (messageID.is<CoreIPC::MessageClassWebConnectionLegacy>()) { - switch (messageID.get<WebConnectionLegacyMessage::Kind>()) { - case WebConnectionLegacyMessage::PostMessage: { - String messageName; - RefPtr<APIObject> messageBody; - WebContextUserMessageDecoder messageDecoder(messageBody, m_process); - if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) - return; - - forwardDidReceiveMessageToClient(messageName, messageBody.get()); - return; - } - } + if (messageID.is<CoreIPC::MessageClassWebConnection>()) { + didReceiveWebConnectionMessage(connection, messageID, arguments); return; } @@ -124,11 +109,6 @@ void WebConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection* co m_client.didClose(this); } -void WebConnectionToWebProcess::syncMessageSendTimedOut(CoreIPC::Connection* connection) -{ - m_process->syncMessageSendTimedOut(connection); -} - #if PLATFORM(WIN) Vector<HWND> WebConnectionToWebProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply() { diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h index f4962e26c..160813247 100644 --- a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h +++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h @@ -33,32 +33,28 @@ namespace WebKit { class WebProcessProxy; -class WebConnectionToWebProcess : public WebConnection, CoreIPC::Connection::Client { +class WebConnectionToWebProcess : public WebConnection, public CoreIPC::Connection::Client { public: static PassRefPtr<WebConnectionToWebProcess> create(WebProcessProxy*, CoreIPC::Connection::Identifier, WebCore::RunLoop*); - CoreIPC::Connection* connection() { return m_connection.get(); } - - void invalidate(); - + WebProcessProxy* webProcessProxy() const { return m_process; } private: WebConnectionToWebProcess(WebProcessProxy*, CoreIPC::Connection::Identifier, WebCore::RunLoop*); // WebConnection - virtual void postMessage(const String&, APIObject*); + virtual void encodeMessageBody(CoreIPC::ArgumentEncoder*, APIObject*) OVERRIDE; + virtual bool decodeMessageBody(CoreIPC::ArgumentDecoder*, RefPtr<APIObject>&) OVERRIDE; // CoreIPC::Connection::Client virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); #if PLATFORM(WIN) virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); #endif WebProcessProxy* m_process; - RefPtr<CoreIPC::Connection> m_connection; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp index f0c3580c1..040416283 100644 --- a/Source/WebKit2/UIProcess/WebContext.cpp +++ b/Source/WebKit2/UIProcess/WebContext.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,7 +28,6 @@ #include "DownloadProxy.h" #include "ImmutableArray.h" -#include "InjectedBundleMessageKinds.h" #include "Logging.h" #include "MutableDictionary.h" #include "SandboxExtension.h" @@ -121,36 +120,45 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa , m_cacheModel(CacheModelDocumentViewer) , m_memorySamplerEnabled(false) , m_memorySamplerInterval(1400.0) - , m_applicationCacheManagerProxy(WebApplicationCacheManagerProxy::create(this)) +#if PLATFORM(WIN) + , m_shouldPaintNativeControls(true) + , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways) +#endif + , m_processTerminationEnabled(true) +#if ENABLE(NETWORK_PROCESS) + , m_usesNetworkProcess(false) +#endif +{ + addMessageReceiver(CoreIPC::MessageClassWebContext, this); + addMessageReceiver(CoreIPC::MessageClassDownloadProxy, this); + addMessageReceiver(CoreIPC::MessageClassWebContextLegacy, this); + + // NOTE: These sub-objects must be initialized after m_messageReceiverMap.. + m_applicationCacheManagerProxy = WebApplicationCacheManagerProxy::create(this); #if ENABLE(BATTERY_STATUS) - , m_batteryManagerProxy(WebBatteryManagerProxy::create(this)) + m_batteryManagerProxy = WebBatteryManagerProxy::create(this); #endif - , m_cookieManagerProxy(WebCookieManagerProxy::create(this)) + m_cookieManagerProxy = WebCookieManagerProxy::create(this); #if ENABLE(SQL_DATABASE) - , m_databaseManagerProxy(WebDatabaseManagerProxy::create(this)) + m_databaseManagerProxy = WebDatabaseManagerProxy::create(this); #endif - , m_geolocationManagerProxy(WebGeolocationManagerProxy::create(this)) - , m_iconDatabase(WebIconDatabase::create(this)) - , m_keyValueStorageManagerProxy(WebKeyValueStorageManagerProxy::create(this)) - , m_mediaCacheManagerProxy(WebMediaCacheManagerProxy::create(this)) + m_geolocationManagerProxy = WebGeolocationManagerProxy::create(this); + m_iconDatabase = WebIconDatabase::create(this); + m_keyValueStorageManagerProxy = WebKeyValueStorageManagerProxy::create(this); + m_mediaCacheManagerProxy = WebMediaCacheManagerProxy::create(this); #if ENABLE(NETWORK_INFO) - , m_networkInfoManagerProxy(WebNetworkInfoManagerProxy::create(this)) + m_networkInfoManagerProxy = WebNetworkInfoManagerProxy::create(this); #endif - , m_notificationManagerProxy(WebNotificationManagerProxy::create(this)) - , m_pluginSiteDataManager(WebPluginSiteDataManager::create(this)) - , m_resourceCacheManagerProxy(WebResourceCacheManagerProxy::create(this)) + m_notificationManagerProxy = WebNotificationManagerProxy::create(this); + m_pluginSiteDataManager = WebPluginSiteDataManager::create(this); + m_resourceCacheManagerProxy = WebResourceCacheManagerProxy::create(this); #if USE(SOUP) - , m_soupRequestManagerProxy(WebSoupRequestManagerProxy::create(this)) + m_soupRequestManagerProxy = WebSoupRequestManagerProxy::create(this); #endif #if ENABLE(VIBRATION) - , m_vibrationProxy(WebVibrationProxy::create(this)) + m_vibrationProxy = WebVibrationProxy::create(this); #endif -#if PLATFORM(WIN) - , m_shouldPaintNativeControls(true) - , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways) -#endif - , m_processTerminationEnabled(true) -{ + #if !LOG_DISABLED WebKit::initializeLogChannelsIfNecessary(); #endif @@ -175,6 +183,8 @@ WebContext::~WebContext() removeLanguageChangeObserver(this); + m_messageReceiverMap.invalidate(); + m_applicationCacheManagerProxy->invalidate(); m_applicationCacheManagerProxy->clearContext(); @@ -263,6 +273,8 @@ void WebContext::setProcessModel(ProcessModel processModel) // Guard against API misuse. if (!m_processes.isEmpty()) CRASH(); + if (processModel != ProcessModelSharedSecondaryProcess && !m_messagesToInjectedBundlePostedToEmptyContext.isEmpty()) + CRASH(); #if !ENABLE(PLUGIN_PROCESS) // Plugin process is required for multiple web process mode. @@ -301,14 +313,28 @@ void WebContext::textCheckerStateChanged() sendToAllProcesses(Messages::WebProcess::SetTextCheckerState(TextChecker::state())); } +void WebContext::setUsesNetworkProcess(bool usesNetworkProcess) +{ +#if ENABLE(NETWORK_PROCESS) + m_usesNetworkProcess = usesNetworkProcess; +#else + UNUSED_PARAM(usesNetworkProcess); +#endif +} + void WebContext::ensureSharedWebProcess() { if (m_processes.isEmpty()) - m_processes.append(createNewWebProcess()); + createNewWebProcess(); } PassRefPtr<WebProcessProxy> WebContext::createNewWebProcess() { +#if ENABLE(NETWORK_PROCESS) + if (m_usesNetworkProcess) + ensureNetworkProcess(); +#endif + RefPtr<WebProcessProxy> process = WebProcessProxy::create(this); WebProcessCreationParameters parameters; @@ -329,6 +355,14 @@ PassRefPtr<WebProcessProxy> WebContext::createNewWebProcess() if (!parameters.localStorageDirectory.isEmpty()) SandboxExtension::createHandleForReadWriteDirectory(parameters.localStorageDirectory, parameters.localStorageDirectoryExtensionHandle); + parameters.diskCacheDirectory = diskCacheDirectory(); + if (!parameters.diskCacheDirectory.isEmpty()) + SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle); + + parameters.cookieStorageDirectory = cookieStorageDirectory(); + if (!parameters.cookieStorageDirectory.isEmpty()) + SandboxExtension::createHandle(parameters.cookieStorageDirectory, SandboxExtension::ReadWrite, parameters.cookieStorageDirectoryExtensionHandle); + parameters.shouldTrackVisitedLinks = m_historyClient.shouldTrackVisitedLinks(); parameters.cacheModel = m_cacheModel; parameters.languages = userPreferredLanguages(); @@ -366,6 +400,23 @@ PassRefPtr<WebProcessProxy> WebContext::createNewWebProcess() injectedBundleInitializationUserData = m_injectedBundleInitializationUserData; process->send(Messages::WebProcess::InitializeWebProcess(parameters, WebContextUserMessageEncoder(injectedBundleInitializationUserData.get())), 0); + m_processes.append(process); + + if (m_processModel == ProcessModelSharedSecondaryProcess) { + for (size_t i = 0; i != m_messagesToInjectedBundlePostedToEmptyContext.size(); ++i) { + pair<String, RefPtr<APIObject> >& message = m_messagesToInjectedBundlePostedToEmptyContext[i]; + + OwnPtr<CoreIPC::ArgumentEncoder> messageData = CoreIPC::ArgumentEncoder::create(0); + + messageData->encode(message.first); + messageData->encode(WebContextUserMessageEncoder(message.second.get())); + process->send(Messages::WebProcess::PostInjectedBundleMessage(CoreIPC::DataReference(messageData->buffer(), messageData->bufferSize())), 0); + } + m_messagesToInjectedBundlePostedToEmptyContext.clear(); + } else + ASSERT(m_messagesToInjectedBundlePostedToEmptyContext.isEmpty()); + + return process.release(); } @@ -376,10 +427,20 @@ void WebContext::warmInitialProcess() return; } - m_processes.append(createNewWebProcess()); + createNewWebProcess(); m_haveInitialEmptyProcess = true; } +#if ENABLE(NETWORK_PROCESS) +void WebContext::ensureNetworkProcess() +{ + if (m_networkProcess) + return; + + m_networkProcess = NetworkProcessProxy::create(); +} +#endif + void WebContext::enableProcessTermination() { m_processTerminationEnabled = true; @@ -446,6 +507,9 @@ void WebContext::disconnectProcess(WebProcessProxy* process) m_visitedLinkProvider.processDidClose(process); + if (m_haveInitialEmptyProcess && process == m_processes.last()) + m_haveInitialEmptyProcess = false; + // FIXME (Multi-WebProcess): <rdar://problem/12239765> All the invalidation calls below are still necessary in multi-process mode, but they should only affect data structures pertaining to the process being disconnected. // Clearing everything causes assertion failures, so it's less trouble to skip that for now. if (m_processModel != ProcessModelSharedSecondaryProcess) { @@ -514,7 +578,6 @@ PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient* pageClient, WebPa } else { // FIXME (Multi-WebProcess): <rdar://problem/12239661> Consider limiting the number of web processes in per-tab process model. process = createNewWebProcess(); - m_processes.append(process); } } @@ -529,10 +592,10 @@ WebProcessProxy* WebContext::relaunchProcessIfNecessary() if (m_processModel == ProcessModelSharedSecondaryProcess) { ensureSharedWebProcess(); return m_processes[0].get(); - } else { - // FIXME (Multi-WebProcess): What should this do in this model? - return 0; } + + ASSERT_NOT_REACHED(); + return 0; } DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request) @@ -559,15 +622,20 @@ DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const Resource void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody) { - if (m_processes.isEmpty()) + if (m_processes.isEmpty()) { + if (m_processModel == ProcessModelSharedSecondaryProcess) + m_messagesToInjectedBundlePostedToEmptyContext.append(std::make_pair(messageName, messageBody)); return; + } // FIXME: Return early if the message body contains any references to WKPageRefs/WKFrameRefs etc. since they're local to a process. + OwnPtr<CoreIPC::ArgumentEncoder> messageData = CoreIPC::ArgumentEncoder::create(0); + messageData->encode(messageName); + messageData->encode(WebContextUserMessageEncoder(messageBody)); + for (size_t i = 0; i < m_processes.size(); ++i) { - // FIXME: We should consider returning false from this function if the messageBody cannot be encoded. - // FIXME: Can we encode the message body outside the loop for all the processes? - m_processes[i]->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody))); + m_processes[i]->send(Messages::WebProcess::PostInjectedBundleMessage(CoreIPC::DataReference(messageData->buffer(), messageData->bufferSize())), 0); } } @@ -709,100 +777,40 @@ HashSet<String, CaseFoldingHash> WebContext::pdfAndPostScriptMIMETypes() return mimeTypes; } -void WebContext::didReceiveMessage(WebProcessProxy* process, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +void WebContext::addMessageReceiver(CoreIPC::MessageClass messageClass, CoreIPC::MessageReceiver* messageReceiver) +{ + m_messageReceiverMap.addMessageReceiver(messageClass, messageReceiver); +} + +bool WebContext::dispatchMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* argumentDecoder) +{ + return m_messageReceiverMap.dispatchMessage(connection, messageID, argumentDecoder); +} + +bool WebContext::dispatchSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* argumentDecoder, OwnPtr<CoreIPC::ArgumentEncoder>& reply) +{ + return m_messageReceiverMap.dispatchSyncMessage(connection, messageID, argumentDecoder, reply); +} + +void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { if (messageID.is<CoreIPC::MessageClassWebContext>()) { - didReceiveWebContextMessage(process->connection(), messageID, arguments); + didReceiveWebContextMessage(connection, messageID, arguments); return; } if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) { if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get()) - downloadProxy->didReceiveDownloadProxyMessage(process->connection(), messageID, arguments); + downloadProxy->didReceiveDownloadProxyMessage(connection, messageID, arguments); return; } - if (messageID.is<CoreIPC::MessageClassWebApplicationCacheManagerProxy>()) { - m_applicationCacheManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - -#if ENABLE(BATTERY_STATUS) - if (messageID.is<CoreIPC::MessageClassWebBatteryManagerProxy>()) { - m_batteryManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } -#endif - - if (messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>()) { - m_cookieManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - -#if ENABLE(SQL_DATABASE) - if (messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>()) { - m_databaseManagerProxy->didReceiveWebDatabaseManagerProxyMessage(process->connection(), messageID, arguments); - return; - } -#endif - - if (messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()) { - m_geolocationManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - - if (messageID.is<CoreIPC::MessageClassWebIconDatabase>()) { - m_iconDatabase->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - - if (messageID.is<CoreIPC::MessageClassWebKeyValueStorageManagerProxy>()) { - m_keyValueStorageManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - - if (messageID.is<CoreIPC::MessageClassWebMediaCacheManagerProxy>()) { - m_mediaCacheManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - -#if ENABLE(NETWORK_INFO) - if (messageID.is<CoreIPC::MessageClassWebNetworkInfoManagerProxy>()) { - m_networkInfoManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } -#endif - - if (messageID.is<CoreIPC::MessageClassWebNotificationManagerProxy>()) { - m_notificationManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } - - if (messageID.is<CoreIPC::MessageClassWebResourceCacheManagerProxy>()) { - m_resourceCacheManagerProxy->didReceiveWebResourceCacheManagerProxyMessage(process->connection(), messageID, arguments); - return; - } - -#if USE(SOUP) - if (messageID.is<CoreIPC::MessageClassWebSoupRequestManagerProxy>()) { - m_soupRequestManagerProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } -#endif - -#if ENABLE(VIBRATION) - if (messageID.is<CoreIPC::MessageClassWebVibrationProxy>()) { - m_vibrationProxy->didReceiveMessage(process->connection(), messageID, arguments); - return; - } -#endif - switch (messageID.get<WebContextLegacyMessage::Kind>()) { case WebContextLegacyMessage::PostMessage: { String messageName; RefPtr<APIObject> messageBody; - WebContextUserMessageDecoder messageDecoder(messageBody, process); + WebContextUserMessageDecoder messageDecoder(messageBody, WebProcessProxy::fromConnection(connection)); if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) return; @@ -816,38 +824,26 @@ void WebContext::didReceiveMessage(WebProcessProxy* process, CoreIPC::MessageID ASSERT_NOT_REACHED(); } -void WebContext::didReceiveSyncMessage(WebProcessProxy* process, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply) +void WebContext::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply) { if (messageID.is<CoreIPC::MessageClassWebContext>()) { - didReceiveSyncWebContextMessage(process->connection(), messageID, arguments, reply); + didReceiveSyncWebContextMessage(connection, messageID, arguments, reply); return; } if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) { if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get()) - downloadProxy->didReceiveSyncDownloadProxyMessage(process->connection(), messageID, arguments, reply); - return; - } - - if (messageID.is<CoreIPC::MessageClassWebIconDatabase>()) { - m_iconDatabase->didReceiveSyncMessage(process->connection(), messageID, arguments, reply); + downloadProxy->didReceiveSyncDownloadProxyMessage(connection, messageID, arguments, reply); return; } -#if ENABLE(NETWORK_INFO) - if (messageID.is<CoreIPC::MessageClassWebNetworkInfoManagerProxy>()) { - m_networkInfoManagerProxy->didReceiveSyncMessage(process->connection(), messageID, arguments, reply); - return; - } -#endif - switch (messageID.get<WebContextLegacyMessage::Kind>()) { case WebContextLegacyMessage::PostSynchronousMessage: { // FIXME: We should probably encode something in the case that the arguments do not decode correctly. String messageName; RefPtr<APIObject> messageBody; - WebContextUserMessageDecoder messageDecoder(messageBody, process); + WebContextUserMessageDecoder messageDecoder(messageBody, WebProcessProxy::fromConnection(connection)); if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder))) return; @@ -929,6 +925,22 @@ String WebContext::localStorageDirectory() const return platformDefaultLocalStorageDirectory(); } +String WebContext::diskCacheDirectory() const +{ + if (!m_overrideDiskCacheDirectory.isEmpty()) + return m_overrideDiskCacheDirectory; + + return platformDefaultDiskCacheDirectory(); +} + +String WebContext::cookieStorageDirectory() const +{ + if (!m_overrideCookieStorageDirectory.isEmpty()) + return m_overrideCookieStorageDirectory; + + return platformDefaultCookieStorageDirectory(); +} + void WebContext::setHTTPPipeliningEnabled(bool enabled) { #if PLATFORM(MAC) @@ -970,7 +982,7 @@ static PassRefPtr<MutableDictionary> createDictionaryFromHashMap(const HashMap<S RefPtr<MutableDictionary> result = MutableDictionary::create(); HashMap<String, uint64_t>::const_iterator end = map.end(); for (HashMap<String, uint64_t>::const_iterator it = map.begin(); it != end; ++it) - result->set(it->first, RefPtr<WebUInt64>(WebUInt64::create(it->second)).get()); + result->set(it->key, RefPtr<WebUInt64>(WebUInt64::create(it->value)).get()); return result; } diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h index 2de4a71c6..9e8d8054a 100644 --- a/Source/WebKit2/UIProcess/WebContext.h +++ b/Source/WebKit2/UIProcess/WebContext.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,11 +28,13 @@ #include "APIObject.h" #include "GenericCallback.h" +#include "MessageReceiver.h" +#include "MessageReceiverMap.h" #include "PluginInfoStore.h" #include "ProcessModel.h" #include "VisitedLinkProvider.h" -#include "WebContextInjectedBundleClient.h" #include "WebContextConnectionClient.h" +#include "WebContextInjectedBundleClient.h" #include "WebDownloadClient.h" #include "WebHistoryClient.h" #include "WebProcessProxy.h" @@ -44,6 +46,10 @@ #include <wtf/text/StringHash.h> #include <wtf/text/WTFString.h> +#if ENABLE(NETWORK_PROCESS) +#include "NetworkProcessProxy.h" +#endif + namespace WebKit { class DownloadProxy; @@ -75,7 +81,7 @@ struct WebProcessCreationParameters; typedef GenericCallback<WKDictionaryRef> DictionaryCallback; -class WebContext : public APIObject { +class WebContext : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeContext; @@ -84,6 +90,10 @@ public: static const Vector<WebContext*>& allContexts(); + void addMessageReceiver(CoreIPC::MessageClass, CoreIPC::MessageReceiver*); + bool dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + bool dispatchSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); + void initializeInjectedBundleClient(const WKContextInjectedBundleClient*); void initializeConnectionClient(const WKContextConnectionClient*); void initializeHistoryClient(const WKContextHistoryClient*); @@ -140,8 +150,9 @@ public: void addVisitedLink(const String&); void addVisitedLinkHash(WebCore::LinkHash); - void didReceiveMessage(WebProcessProxy*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncMessage(WebProcessProxy*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); + // MessageReceiver. + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&) OVERRIDE; void setCacheModel(CacheModel); CacheModel cacheModel() const { return m_cacheModel; } @@ -204,6 +215,8 @@ public: void setIconDatabasePath(const String&); String iconDatabasePath() const; void setLocalStorageDirectory(const String& dir) { m_overrideLocalStorageDirectory = dir; } + void setDiskCacheDirectory(const String& dir) { m_overrideDiskCacheDirectory = dir; } + void setCookieStorageDirectory(const String& dir) { m_overrideCookieStorageDirectory = dir; } void ensureSharedWebProcess(); PassRefPtr<WebProcessProxy> createNewWebProcess(); @@ -230,6 +243,8 @@ public: void textCheckerStateChanged(); + void setUsesNetworkProcess(bool); + private: WebContext(ProcessModel, const String& injectedBundlePath); @@ -237,7 +252,11 @@ private: void platformInitializeWebProcess(WebProcessCreationParameters&); void platformInvalidateContext(); - + +#if ENABLE(NETWORK_PROCESS) + void ensureNetworkProcess(); +#endif + #if PLATFORM(MAC) void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes); void getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames); @@ -278,6 +297,12 @@ private: String localStorageDirectory() const; String platformDefaultLocalStorageDirectory() const; + String diskCacheDirectory() const; + String platformDefaultDiskCacheDirectory() const; + + String cookieStorageDirectory() const; + String platformDefaultCookieStorageDirectory() const; + ProcessModel m_processModel; Vector<RefPtr<WebProcessProxy> > m_processes; @@ -307,6 +332,10 @@ private: bool m_alwaysUsesComplexTextCodePath; bool m_shouldUseFontSmoothing; + // Messages that were posted before any pages were created. + // The client should use initialization messages instead, so that a restarted process would get the same state. + Vector<pair<String, RefPtr<APIObject> > > m_messagesToInjectedBundlePostedToEmptyContext; + CacheModel m_cacheModel; WebDownloadClient m_downloadClient; @@ -352,10 +381,19 @@ private: String m_overrideDatabaseDirectory; String m_overrideIconDatabasePath; String m_overrideLocalStorageDirectory; + String m_overrideDiskCacheDirectory; + String m_overrideCookieStorageDirectory; bool m_processTerminationEnabled; + +#if ENABLE(NETWORK_PROCESS) + RefPtr<NetworkProcessProxy> m_networkProcess; + bool m_usesNetworkProcess; +#endif HashMap<uint64_t, RefPtr<DictionaryCallback> > m_dictionaryCallbacks; + + CoreIPC::MessageReceiverMap m_messageReceiverMap; }; template<typename U> inline void WebContext::sendToAllProcesses(const U& message) @@ -370,7 +408,9 @@ template<typename U> inline void WebContext::sendToAllProcesses(const U& message template<typename U> void WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message) { - relaunchProcessIfNecessary(); +// FIXME (Multi-WebProcess): WebContext doesn't track processes that have exited, so it cannot relaunch these. Perhaps this functionality won't be needed in this mode. + if (m_processModel == ProcessModelSharedSecondaryProcess) + relaunchProcessIfNecessary(); sendToAllProcesses(message); } diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp index cc9b23eb6..aa33ce62f 100644 --- a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp @@ -41,6 +41,7 @@ PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* cont WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context) : m_webContext(context) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebCookieManagerProxy, this); } WebCookieManagerProxy::~WebCookieManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.h b/Source/WebKit2/UIProcess/WebCookieManagerProxy.h index cf1c15b05..6981c0d06 100644 --- a/Source/WebKit2/UIProcess/WebCookieManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.h @@ -29,6 +29,7 @@ #include "APIObject.h" #include "GenericCallback.h" #include "ImmutableArray.h" +#include "MessageReceiver.h" #include "WebCookieManagerProxyClient.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -48,7 +49,7 @@ class WebProcessProxy; typedef GenericCallback<WKArrayRef> ArrayCallback; typedef GenericCallback<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback; -class WebCookieManagerProxy : public APIObject { +class WebCookieManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeCookieManager; @@ -74,8 +75,6 @@ public: void setCookiePersistentStorage(const String& storagePath, uint32_t storageType); #endif - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -88,6 +87,8 @@ private: void cookiesDidChange(); + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebCookieManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); #if PLATFORM(MAC) diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp index b4331d45c..a3fda6556 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp @@ -94,6 +94,7 @@ PassRefPtr<WebDatabaseManagerProxy> WebDatabaseManagerProxy::create(WebContext* WebDatabaseManagerProxy::WebDatabaseManagerProxy(WebContext* webContext) : m_webContext(webContext) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebDatabaseManagerProxy, this); } WebDatabaseManagerProxy::~WebDatabaseManagerProxy() @@ -231,6 +232,11 @@ void WebDatabaseManagerProxy::didModifyDatabase(const String& originIdentifier, m_client.didModifyDatabase(this, origin.get(), databaseIdentifier); } +void WebDatabaseManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebDatabaseManagerProxyMessage(connection, messageID, arguments); +} + } // namespace WebKit #endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h index fe920bb03..b724a847d 100644 --- a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h @@ -31,17 +31,12 @@ #include "APIObject.h" #include "Arguments.h" #include "GenericCallback.h" +#include "MessageReceiver.h" #include "OriginAndDatabases.h" #include "WebDatabaseManagerProxyClient.h" #include <wtf/HashMap.h> #include <wtf/PassRefPtr.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -class MessageID; -} - namespace WebKit { class WebContext; @@ -50,7 +45,7 @@ class WebSecurityOrigin; typedef GenericCallback<WKArrayRef> ArrayCallback; -class WebDatabaseManagerProxy : public APIObject { +class WebDatabaseManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeDatabaseManager; @@ -78,8 +73,6 @@ public: static String databaseDetailsExpectedUsageKey(); static String databaseDetailsCurrentUsageKey(); - void didReceiveWebDatabaseManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -87,6 +80,10 @@ private: virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + void didReceiveWebDatabaseManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + // Message handlers. void didGetDatabasesByOrigin(const Vector<OriginAndDatabases>& originAndDatabases, uint64_t callbackID); void didGetDatabaseOrigins(const Vector<String>& originIdentifiers, uint64_t callbackID); diff --git a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp index 9dc13bcc9..fe71ecaa4 100644 --- a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp @@ -94,9 +94,9 @@ void WebFullScreenManagerProxy::requestExitFullScreen() m_page->process()->send(Messages::WebFullScreenManager::RequestExitFullScreen(), m_page->pageID()); } -void WebFullScreenManagerProxy::supportsFullScreen(bool /*withKeyboard*/, bool& supports) +void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, bool& supports) { - supports = true; + supports = !withKeyboard; } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp index af49f9bc1..e20d1eebd 100644 --- a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp @@ -40,6 +40,7 @@ WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { + m_context->addMessageReceiver(CoreIPC::MessageClassWebGeolocationManagerProxy, this); } WebGeolocationManagerProxy::~WebGeolocationManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h index 65d7b7a7e..8f4102b61 100644 --- a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h @@ -27,21 +27,16 @@ #define WebGeolocationManagerProxy_h #include "APIObject.h" -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebGeolocationProvider.h" #include <wtf/text/WTFString.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -} - namespace WebKit { class WebContext; class WebGeolocationPosition; -class WebGeolocationManagerProxy : public APIObject { +class WebGeolocationManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeGeolocationManager; @@ -56,13 +51,14 @@ public: void providerDidChangePosition(WebGeolocationPosition*); void providerDidFailToDeterminePosition(const String& errorMessage = String()); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - private: explicit WebGeolocationManagerProxy(WebContext*); virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + // Implemented in generated WebGeolocationManagerProxyMessageReceiver.cpp void didReceiveWebGeolocationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.cpp b/Source/WebKit2/UIProcess/WebIconDatabase.cpp index 41c2617bf..8b71e89e0 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.cpp +++ b/Source/WebKit2/UIProcess/WebIconDatabase.cpp @@ -54,6 +54,7 @@ WebIconDatabase::WebIconDatabase(WebContext* context) , m_urlImportCompleted(false) , m_databaseCleanupDisabled(false) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebIconDatabase, this); } void WebIconDatabase::invalidate() @@ -180,6 +181,11 @@ void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision((int)decision, callbackID)); } +void WebIconDatabase::didReceiveIconForPageURL(const String& pageURL) +{ + notifyIconDataReadyForPageURL(pageURL); +} + Image* WebIconDatabase::imageForPageURL(const String& pageURL, const WebCore::IntSize& iconSize) { if (!m_webContext || !m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || pageURL.isEmpty()) @@ -203,6 +209,11 @@ bool WebIconDatabase::isOpen() return m_iconDatabaseImpl && m_iconDatabaseImpl->isOpen(); } +bool WebIconDatabase::isUrlImportCompleted() +{ + return m_urlImportCompleted; +} + void WebIconDatabase::removeAllIcons() { m_iconDatabaseImpl->removeAllIcons(); @@ -224,11 +235,6 @@ void WebIconDatabase::initializeIconDatabaseClient(const WKIconDatabaseClient* c } // WebCore::IconDatabaseClient -bool WebIconDatabase::performImport() -{ - // WebKit2 icon database doesn't currently support importing any old icon database formats. - return true; -} void WebIconDatabase::didImportIconURLForPageURL(const String& pageURL) { @@ -237,7 +243,7 @@ void WebIconDatabase::didImportIconURLForPageURL(const String& pageURL) void WebIconDatabase::didImportIconDataForPageURL(const String& pageURL) { - didChangeIconForPageURL(pageURL); + notifyIconDataReadyForPageURL(pageURL); } void WebIconDatabase::didChangeIconForPageURL(const String& pageURL) @@ -263,14 +269,14 @@ void WebIconDatabase::didFinishURLImport() HashMap<uint64_t, String>::iterator end = m_pendingLoadDecisionURLMap.end(); for (; i != end; ++i) { - LOG(IconDatabase, "WK2 UIProcess performing delayed callback on callback ID %i for page url %s", (int)i->first, i->second.ascii().data()); - IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(i->second, 0); + LOG(IconDatabase, "WK2 UIProcess performing delayed callback on callback ID %i for page url %s", (int)i->key, i->value.ascii().data()); + IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(i->value, 0); // Decisions should never be unknown after the inital import is complete ASSERT(decision != IconLoadUnknown); // FIXME (Multi-WebProcess): <rdar://problem/12240223> We need to know which connection to send this message to. - m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->first)); + m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->key)); } m_pendingLoadDecisionURLMap.clear(); @@ -288,4 +294,10 @@ void WebIconDatabase::didReceiveSyncMessage(CoreIPC::Connection* connection, Cor didReceiveSyncWebIconDatabaseMessage(connection, messageID, decoder, reply); } +void WebIconDatabase::notifyIconDataReadyForPageURL(const String& pageURL) +{ + m_iconDatabaseClient.iconDataReadyForPageURL(this, WebURL::create(pageURL).get()); + didChangeIconForPageURL(pageURL); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.h b/Source/WebKit2/UIProcess/WebIconDatabase.h index d808ef0d9..8643a481d 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.h +++ b/Source/WebKit2/UIProcess/WebIconDatabase.h @@ -54,7 +54,7 @@ namespace WebKit { class WebContext; -class WebIconDatabase : public APIObject, public WebCore::IconDatabaseClient { +class WebIconDatabase : public APIObject, public WebCore::IconDatabaseClient, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeIconDatabase; @@ -77,10 +77,12 @@ public: void synchronousLoadDecisionForIconURL(const String&, int&) const; void getLoadDecisionForIconURL(const String&, uint64_t callbackID); + void didReceiveIconForPageURL(const String&); WebCore::Image* imageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32)); WebCore::NativeImagePtr nativeImageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32)); bool isOpen(); + bool isUrlImportCompleted(); void removeAllIcons(); void checkIntegrityBeforeOpening(); @@ -88,25 +90,27 @@ public: void initializeIconDatabaseClient(const WKIconDatabaseClient*); +private: + WebIconDatabase(WebContext*); + + virtual Type type() const { return APIType; } + // WebCore::IconDatabaseClient - virtual bool performImport(); virtual void didImportIconURLForPageURL(const String&); virtual void didImportIconDataForPageURL(const String&); virtual void didChangeIconForPageURL(const String&); virtual void didRemoveAllIcons(); virtual void didFinishURLImport(); - - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); -private: - WebIconDatabase(WebContext*); - - virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&) OVERRIDE; void didReceiveWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void didReceiveSyncWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); + void notifyIconDataReadyForPageURL(const String&); + WebContext* m_webContext; OwnPtr<WebCore::IconDatabase> m_iconDatabaseImpl; diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.messages.in b/Source/WebKit2/UIProcess/WebIconDatabase.messages.in index b68a0a742..400adb081 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabase.messages.in +++ b/Source/WebKit2/UIProcess/WebIconDatabase.messages.in @@ -32,4 +32,5 @@ messages -> WebIconDatabase { SynchronousLoadDecisionForIconURL(WTF::String iconURL) -> (int loadDecision) GetLoadDecisionForIconURL(WTF::String iconURL, uint64_t callbackID) + DidReceiveIconForPageURL(WTF::String pageURL) } diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp index e0de3664e..4fbfd3ccd 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp +++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp @@ -47,4 +47,12 @@ void WebIconDatabaseClient::didRemoveAllIcons(WebIconDatabase* iconDatabase) m_client.didRemoveAllIcons(toAPI(iconDatabase), m_client.clientInfo); } +void WebIconDatabaseClient::iconDataReadyForPageURL(WebIconDatabase* iconDatabase, WebURL* url) +{ + if (!m_client.iconDataReadyForPageURL) + return; + + m_client.iconDataReadyForPageURL(toAPI(iconDatabase), toAPI(url), m_client.clientInfo); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.h b/Source/WebKit2/UIProcess/WebIconDatabaseClient.h index 801ec12a8..5fe2fea43 100644 --- a/Source/WebKit2/UIProcess/WebIconDatabaseClient.h +++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.h @@ -39,6 +39,7 @@ class WebIconDatabaseClient : public APIClient<WKIconDatabaseClient, kWKIconData public: void didChangeIconForPageURL(WebIconDatabase*, WebURL*); void didRemoveAllIcons(WebIconDatabase*); + void iconDataReadyForPageURL(WebIconDatabase*, WebURL*); }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.h b/Source/WebKit2/UIProcess/WebInspectorProxy.h index b80700429..6922b7d73 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.h +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.h @@ -189,7 +189,7 @@ private: virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); #endif -#if PLATFORM(GTK) +#if PLATFORM(GTK) || PLATFORM(EFL) void createInspectorWindow(); #endif diff --git a/Source/WebKit2/UIProcess/WebIntentData.cpp b/Source/WebKit2/UIProcess/WebIntentData.cpp index 632aa3b75..c6d8c64ba 100644 --- a/Source/WebKit2/UIProcess/WebIntentData.cpp +++ b/Source/WebKit2/UIProcess/WebIntentData.cpp @@ -78,7 +78,7 @@ PassRefPtr<ImmutableDictionary> WebIntentData::extras() const ImmutableDictionary::MapType wkExtras; HashMap<String, String>::const_iterator end = m_store.extras.end(); for (HashMap<String, String>::const_iterator it = m_store.extras.begin(); it != end; ++it) - wkExtras.set(it->first, WebString::create(it->second)); + wkExtras.set(it->key, WebString::create(it->value)); return ImmutableDictionary::adopt(wkExtras); } diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp index 8b3332aa5..454d082f5 100644 --- a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp @@ -41,6 +41,7 @@ PassRefPtr<WebKeyValueStorageManagerProxy> WebKeyValueStorageManagerProxy::creat WebKeyValueStorageManagerProxy::WebKeyValueStorageManagerProxy(WebContext* context) : m_webContext(context) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebKeyValueStorageManagerProxy, this); } WebKeyValueStorageManagerProxy::~WebKeyValueStorageManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h index 2be77c351..9c63142f6 100644 --- a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h @@ -29,17 +29,11 @@ #include "APIObject.h" #include "GenericCallback.h" #include "ImmutableArray.h" - +#include "MessageReceiver.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> -namespace CoreIPC { - class ArgumentDecoder; - class Connection; - class MessageID; -} - namespace WebKit { struct SecurityOriginData; @@ -49,7 +43,7 @@ class WebSecurityOrigin; typedef GenericCallback<WKArrayRef> ArrayCallback; -class WebKeyValueStorageManagerProxy : public APIObject { +class WebKeyValueStorageManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeKeyValueStorageManager; @@ -63,8 +57,6 @@ public: void deleteEntriesForOrigin(WebSecurityOrigin*); void deleteAllEntries(); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -73,7 +65,9 @@ private: virtual Type type() const { return APIType; } void didGetKeyValueStorageOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID); - + + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebKeyValueStorageManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); WebContext* m_webContext; diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp index ce4a78c64..81cf98f56 100644 --- a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp @@ -40,6 +40,7 @@ PassRefPtr<WebMediaCacheManagerProxy> WebMediaCacheManagerProxy::create(WebConte WebMediaCacheManagerProxy::WebMediaCacheManagerProxy(WebContext* context) : m_webContext(context) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebMediaCacheManagerProxy, this); } WebMediaCacheManagerProxy::~WebMediaCacheManagerProxy() diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h index adc68c4ab..48e88e0fc 100644 --- a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h @@ -29,17 +29,11 @@ #include "APIObject.h" #include "GenericCallback.h" #include "ImmutableArray.h" - +#include "MessageReceiver.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Vector.h> -namespace CoreIPC { - class ArgumentDecoder; - class Connection; - class MessageID; -} - namespace WebKit { class WebContext; @@ -47,7 +41,7 @@ class WebProcessProxy; typedef GenericCallback<WKArrayRef> ArrayCallback; -class WebMediaCacheManagerProxy : public APIObject { +class WebMediaCacheManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeMediaCacheManager; @@ -61,8 +55,6 @@ public: void clearCacheForHostname(const String&); void clearCacheForAllHostnames(); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -71,7 +63,9 @@ private: virtual Type type() const { return APIType; } void didGetHostnamesWithMediaCache(const Vector<String>&, uint64_t callbackID); - + + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebMediaCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); WebContext* m_webContext; diff --git a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp index 9bacced06..21a399bc0 100644 --- a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp @@ -43,6 +43,7 @@ WebNetworkInfoManagerProxy::WebNetworkInfoManagerProxy(WebContext* context) : m_isUpdating(false) , m_context(context) { + m_context->addMessageReceiver(CoreIPC::MessageClassWebNetworkInfoManagerProxy, this); } WebNetworkInfoManagerProxy::~WebNetworkInfoManagerProxy() @@ -72,7 +73,7 @@ void WebNetworkInfoManagerProxy::didReceiveMessage(CoreIPC::Connection* connecti didReceiveWebNetworkInfoManagerProxyMessage(connection, messageID, arguments); } -void WebNetworkInfoManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, WTF::OwnPtr<CoreIPC::ArgumentEncoder>& reply) +void WebNetworkInfoManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply) { didReceiveSyncWebNetworkInfoManagerProxyMessage(connection, messageID, arguments, reply); } diff --git a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h index b7298553c..2c4ef7c67 100644 --- a/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h @@ -29,22 +29,16 @@ #if ENABLE(NETWORK_INFO) #include "APIObject.h" -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebNetworkInfoProvider.h" #include <wtf/Forward.h> -namespace CoreIPC { -class ArgumentDecoder; -class ArgumentEncoder; -class Connection; -} - namespace WebKit { class WebContext; class WebNetworkInfo; -class WebNetworkInfoManagerProxy : public APIObject { +class WebNetworkInfoManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeNetworkInfoManager; @@ -58,17 +52,18 @@ public: void providerDidChangeNetworkInformation(const WTF::AtomicString& eventType, WebNetworkInfo*); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, WTF::OwnPtr<CoreIPC::ArgumentEncoder>&); - private: explicit WebNetworkInfoManagerProxy(WebContext*); virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&) OVERRIDE; + // Implemented in generated WebNetworkInfoManagerProxyMessageReceiver.cpp void didReceiveWebNetworkInfoManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - void didReceiveSyncWebNetworkInfoManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, WTF::OwnPtr<CoreIPC::ArgumentEncoder>&); + void didReceiveSyncWebNetworkInfoManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); void startUpdating(); void stopUpdating(); diff --git a/Source/WebKit2/UIProcess/WebPageGroup.cpp b/Source/WebKit2/UIProcess/WebPageGroup.cpp index 72588d4d7..0cdbf817d 100644 --- a/Source/WebKit2/UIProcess/WebPageGroup.cpp +++ b/Source/WebKit2/UIProcess/WebPageGroup.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "WebPageGroup.h" +#include "WebPageGroupProxyMessages.h" #include "WebPageProxy.h" #include "WebPreferences.h" #include <wtf/HashMap.h> @@ -128,4 +129,65 @@ void WebPageGroup::preferencesDidChange() } } +static Vector<String> toStringVector(ImmutableArray* array) +{ + Vector<String> patternVector; + if (!array) + return patternVector; + + size_t size = array->size(); + if (!size) + return patternVector; + + patternVector.reserveInitialCapacity(size); + for (size_t i = 0; i < size; ++i) { + WebString* webString = array->at<WebString>(i); + ASSERT(webString); + patternVector.uncheckedAppend(webString->string()); + } + + return patternVector; +} + +void WebPageGroup::addUserStyleSheet(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserStyleLevel level) +{ + if (source.isEmpty()) + return; + + WebCore::UserStyleSheet userStyleSheet = WebCore::UserStyleSheet(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::KURL(WebCore::KURL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectedFrames, level); + + m_data.userStyleSheets.append(userStyleSheet); + sendToAllProcessesInGroup(Messages::WebPageGroupProxy::AddUserStyleSheet(userStyleSheet), m_data.pageGroupID); +} + +void WebPageGroup::addUserScript(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserScriptInjectionTime injectionTime) +{ + if (source.isEmpty()) + return; + + WebCore::UserScript userScript = WebCore::UserScript(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::KURL(WebCore::KURL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectionTime, injectedFrames); + + m_data.userScripts.append(userScript); + sendToAllProcessesInGroup(Messages::WebPageGroupProxy::AddUserScript(userScript), m_data.pageGroupID); +} + +void WebPageGroup::removeAllUserStyleSheets() +{ + m_data.userStyleSheets.clear(); + sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserStyleSheets(), m_data.pageGroupID); +} + +void WebPageGroup::removeAllUserScripts() +{ + m_data.userScripts.clear(); + sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserScripts(), m_data.pageGroupID); +} + +void WebPageGroup::removeAllUserContent() +{ + m_data.userStyleSheets.clear(); + m_data.userScripts.clear(); + sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserContent(), m_data.pageGroupID); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageGroup.h b/Source/WebKit2/UIProcess/WebPageGroup.h index ccc14bd91..176b9ee46 100644 --- a/Source/WebKit2/UIProcess/WebPageGroup.h +++ b/Source/WebKit2/UIProcess/WebPageGroup.h @@ -28,6 +28,8 @@ #include "APIObject.h" #include "WebPageGroupData.h" +#include "WebPageProxy.h" +#include "WebProcessProxy.h" #include <wtf/Forward.h> #include <wtf/HashSet.h> @@ -56,16 +58,37 @@ public: void setPreferences(WebPreferences*); WebPreferences* preferences() const; void preferencesDidChange(); + + void addUserStyleSheet(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames, WebCore::UserStyleLevel); + void addUserScript(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames, WebCore::UserScriptInjectionTime); + void removeAllUserStyleSheets(); + void removeAllUserScripts(); + void removeAllUserContent(); private: WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient); virtual Type type() const { return APIType; } + + template<typename MessageType> void sendToAllProcessesInGroup(const MessageType&, uint64_t destinationID); WebPageGroupData m_data; mutable RefPtr<WebPreferences> m_preferences; HashSet<WebPageProxy*> m_pages; }; + +template<typename MessageType> inline void WebPageGroup::sendToAllProcessesInGroup(const MessageType& message, uint64_t destinationID) +{ + HashSet<WebProcessProxy*> processesSeen; + for (HashSet<WebPageProxy*>::const_iterator it = m_pages.begin(), end = m_pages.end(); it != end; ++it) { + WebProcessProxy* webProcessProxy = (*it)->process(); + ASSERT(webProcessProxy); + if (!processesSeen.add(webProcessProxy).isNewEntry) + continue; + if (webProcessProxy->canSendMessage()) + webProcessProxy->send(message, destinationID); + } +} } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index a0e9ee7f7..7ef4a249f 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -34,7 +34,6 @@ #include "DrawingAreaProxy.h" #include "EventDispatcherMessages.h" #include "FindIndicator.h" -#include "InjectedBundleMessageKinds.h" #include "Logging.h" #include "MessageID.h" #include "NativeWebKeyboardEvent.h" @@ -108,6 +107,10 @@ #include "ArgumentCodersGtk.h" #endif +#if USE(SOUP) +#include "WebSoupRequestManagerProxy.h" +#endif + #ifndef NDEBUG #include <wtf/RefCountedLeakCounter.h> #endif @@ -220,6 +223,8 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p , m_canShortCircuitHorizontalWheelEvents(true) , m_mainFrameIsPinnedToLeftSide(false) , m_mainFrameIsPinnedToRightSide(false) + , m_mainFrameIsPinnedToTopSide(false) + , m_mainFrameIsPinnedToBottomSide(false) , m_pageCount(0) , m_renderTreeSize(0) , m_shouldSendEventsSynchronously(false) @@ -229,6 +234,10 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p , m_visibilityState(PageVisibilityStateVisible) #endif { +#if ENABLE(PAGE_VISIBILITY_API) + if (!m_isVisible) + m_visibilityState = PageVisibilityStateHidden; +#endif #ifndef NDEBUG webPageProxyCounter.increment(); #endif @@ -277,6 +286,21 @@ bool WebPageProxy::isValid() return m_isValid; } +PassRefPtr<ImmutableArray> WebPageProxy::relatedPages() const +{ + Vector<WebPageProxy*> pages = m_process->pages(); + ASSERT(pages.contains(this)); + + Vector<RefPtr<APIObject> > result; + result.reserveCapacity(pages.size() - 1); + for (size_t i = 0; i < pages.size(); ++i) { + if (pages[i] != this) + result.append(pages[i]); + } + + return ImmutableArray::adopt(result); +} + void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient) { m_loaderClient.initialize(loadClient); @@ -342,10 +366,13 @@ void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* cl void WebPageProxy::reattachToWebProcess() { ASSERT(!isValid()); + ASSERT(m_process); + ASSERT(!m_process->isValid()); + ASSERT(!m_process->isLaunching()); m_isValid = true; - m_process = m_process->context()->relaunchProcessIfNecessary(); + m_process = m_process->context()->createNewWebProcess(); m_process->addExistingWebPage(this, m_pageID); initializeWebPage(); @@ -388,6 +415,8 @@ void WebPageProxy::initializeWebPage() #if ENABLE(PAGE_VISIBILITY_API) m_process->send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID); +#elif ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) + m_process->send(Messages::WebPage::SetVisibilityState(m_isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden, /* isInitialState */ true), m_pageID); #endif } @@ -448,6 +477,8 @@ void WebPageProxy::close() m_mainFrameIsPinnedToLeftSide = false; m_mainFrameIsPinnedToRightSide = false; + m_mainFrameIsPinnedToTopSide = false; + m_mainFrameIsPinnedToBottomSide = false; m_visibleScrollerThumbRect = IntRect(); @@ -745,18 +776,9 @@ String WebPageProxy::committedURL() const bool WebPageProxy::canShowMIMEType(const String& mimeType) const { - if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) + if (MIMETypeRegistry::canShowMIMEType(mimeType)) return true; - if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) - return true; - - if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType)) - return true; - - if (mimeType.startsWith("text/", false)) - return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType); - String newMimeType = mimeType; PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL()); if (!plugin.path.isNull()) @@ -839,6 +861,11 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags) // stop the unresponsiveness timer here. m_process->responsivenessTimer()->stop(); } + +#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) && !ENABLE(PAGE_VISIBILITY_API) + PageVisibilityState visibilityState = m_isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden; + m_process->send(Messages::WebPage::SetVisibilityState(visibilityState, false), m_pageID); +#endif } } @@ -861,7 +888,7 @@ void WebPageProxy::viewStateDidChange(ViewStateFlags flags) #if ENABLE(PAGE_VISIBILITY_API) PageVisibilityState visibilityState = PageVisibilityStateHidden; - if (m_pageClient->isViewVisible()) + if (m_isVisible) visibilityState = PageVisibilityStateVisible; if (visibilityState != m_visibilityState) { @@ -936,6 +963,14 @@ void WebPageProxy::setViewportSize(const IntSize& size) m_process->send(Messages::WebPage::SetViewportSize(size), m_pageID); } + +void WebPageProxy::commitPageTransitionViewport() +{ + if (!isValid()) + return; + + process()->send(Messages::WebPage::CommitPageTransitionViewport(), m_pageID); +} #endif #if ENABLE(DRAG_SUPPORT) @@ -2066,6 +2101,8 @@ void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeTyp // any wheel events and dispatch them to the WKView when necessary. m_mainFrameIsPinnedToLeftSide = true; m_mainFrameIsPinnedToRightSide = true; + m_mainFrameIsPinnedToTopSide = true; + m_mainFrameIsPinnedToBottomSide = true; } m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation); } @@ -2704,41 +2741,6 @@ void WebPageProxy::setMediaVolume(float volume) m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID); } -#if PLATFORM(QT) -void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area) -{ - m_pageClient->didFindZoomableArea(target, area); -} - -void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area) -{ - if (!isValid()) - return; - - m_process->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID); -} - -void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents) -{ - m_pageClient->didReceiveMessageFromNavigatorQtObject(contents); -} - -void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) -{ - m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password); -} - -void WebPageProxy::proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) -{ - m_pageClient->handleProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername, username, password); -} - -void WebPageProxy::certificateVerificationRequest(const String& hostname, bool& ignoreErrors) -{ - m_pageClient->handleCertificateVerificationRequest(hostname, ignoreErrors); -} -#endif // PLATFORM(QT). - #if PLATFORM(QT) || PLATFORM(EFL) void WebPageProxy::handleDownloadRequest(DownloadProxy* download) { @@ -2962,8 +2964,7 @@ NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent() void WebPageProxy::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody) { - // FIXME: We should consider returning false from this function if the messageBody cannot be encoded. - process()->deprecatedSend(InjectedBundleMessage::PostMessageToPage, m_pageID, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody))); + process()->send(Messages::WebPage::PostInjectedBundleMessage(messageName, WebContextUserMessageEncoder(messageBody)), m_pageID); } #if PLATFORM(GTK) @@ -3615,6 +3616,8 @@ void WebPageProxy::processDidCrash() m_mainFrameIsPinnedToLeftSide = false; m_mainFrameIsPinnedToRightSide = false; + m_mainFrameIsPinnedToTopSide = false; + m_mainFrameIsPinnedToBottomSide = false; m_visibleScrollerThumbRect = IntRect(); @@ -3863,10 +3866,12 @@ void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, m_pageClient->didChangeScrollbarsForMainFrame(); } -void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide) +void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide) { m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide; m_mainFrameIsPinnedToRightSide = pinnedToRightSide; + m_mainFrameIsPinnedToTopSide = pinnedToTopSide; + m_mainFrameIsPinnedToBottomSide = pinnedToBottomSide; } void WebPageProxy::didChangePageCount(unsigned pageCount) @@ -4103,4 +4108,11 @@ void WebPageProxy::dictationAlternatives(uint64_t dictationContext, Vector<Strin #endif // PLATFORM(MAC) +#if USE(SOUP) +void WebPageProxy::didReceiveURIRequest(String uriString, uint64_t requestID) +{ + m_process->context()->soupRequestManagerProxy()->didReceiveURIRequest(uriString, this, requestID); +} +#endif + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index 4cbafa3a9..eede6b96f 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -356,6 +356,7 @@ public: bool maintainsInactiveSelection() const { return m_maintainsInactiveSelection; } void setMaintainsInactiveSelection(bool); #if PLATFORM(QT) + void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect); void registerApplicationScheme(const String& scheme); void resolveApplicationSchemeRequest(QtNetworkRequestData); void sendApplicationSchemeReply(const QQuickNetworkReply*); @@ -418,6 +419,7 @@ public: #endif #if USE(TILED_BACKING_STORE) void setViewportSize(const WebCore::IntSize&); + void commitPageTransitionViewport(); #endif void handleMouseEvent(const NativeWebMouseEvent&); @@ -494,6 +496,8 @@ public: bool isPinnedToLeftSide() const { return m_mainFrameIsPinnedToLeftSide; } bool isPinnedToRightSide() const { return m_mainFrameIsPinnedToRightSide; } + bool isPinnedToTopSide() const { return m_mainFrameIsPinnedToTopSide; } + bool isPinnedToBottomSide() const { return m_mainFrameIsPinnedToBottomSide; } void setPaginationMode(WebCore::Pagination::Mode); WebCore::Pagination::Mode paginationMode() const { return m_paginationMode; } @@ -621,6 +625,8 @@ public: bool isValid(); + PassRefPtr<ImmutableArray> relatedPages() const; + const String& urlAtProcessExit() const { return m_urlAtProcessExit; } WebFrameProxy::LoadState loadStateAtProcessExit() const { return m_loadStateAtProcessExit; } @@ -717,7 +723,6 @@ public: #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL) void setAcceleratedCompositingWindowId(uint64_t nativeWindowId); - void invalidateWidget(); #endif void setSuppressVisibilityUpdates(bool flag) { m_suppressVisibilityUpdates = flag; } @@ -833,7 +838,7 @@ private: void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&); void recommendedScrollbarStyleDidChange(int32_t newStyle); void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar); - void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide); + void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide); void didChangePageCount(unsigned); void didFailToInitializePlugin(const String& mimeType); void didBlockInsecurePluginVersion(const String& mimeType, const String& urlString); @@ -850,6 +855,7 @@ private: #endif #if PLATFORM(QT) + void pageTransitionViewportReady(); void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&); #endif @@ -995,6 +1001,10 @@ private: #endif #endif // PLATFORM(MAC) +#if USE(SOUP) + void didReceiveURIRequest(String uriString, uint64_t requestID); +#endif + void clearLoadDependentCallbacks(); void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&); @@ -1188,6 +1198,8 @@ private: bool m_mainFrameIsPinnedToLeftSide; bool m_mainFrameIsPinnedToRightSide; + bool m_mainFrameIsPinnedToTopSide; + bool m_mainFrameIsPinnedToBottomSide; unsigned m_pageCount; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 3a755e1dd..77ac830f2 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -29,7 +29,7 @@ messages -> WebPageProxy { RunJavaScriptConfirm(uint64_t frameID, WTF::String message) -> (bool result) RunJavaScriptPrompt(uint64_t frameID, WTF::String message, WTF::String defaultValue) -> (WTF::String result) ShouldInterruptJavaScript() -> (bool shouldInterupt) - MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData); + MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData) Variadic UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, WTF::String mimeType, WTF::String url, WTF::String pluginsPageURL) DidChangeViewportProperties(WebCore::ViewportAttributes attributes) DidReceiveEvent(uint32_t type, bool handled) @@ -63,7 +63,7 @@ messages -> WebPageProxy { NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb) RecommendedScrollbarStyleDidChange(int32_t newStyle) DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar) - DidChangeScrollOffsetPinningForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar) + DidChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide) DidChangePageCount(unsigned pageCount); DidFailToInitializePlugin(WTF::String mimeType) DidBlockInsecurePluginVersion(WTF::String mimeType, WTF::String urlString) @@ -73,6 +73,7 @@ messages -> WebPageProxy { PageDidRequestScroll(WebCore::IntPoint point) #endif #if PLATFORM(QT) + PageTransitionViewportReady() DidFindZoomableArea(WebCore::IntPoint target, WebCore::IntRect area) AuthenticationRequiredRequest(WTF::String hostname, WTF::String realm, WTF::String prefilledUsername) -> (WTF::String username, WTF::String password) CertificateVerificationRequest(WTF::String hostname) -> (bool ignoreErrors) @@ -94,17 +95,17 @@ messages -> WebPageProxy { #endif # Policy messages - DecidePolicyForResponse(uint64_t frameID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) - DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) - DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, WTF::String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) - UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) + DecidePolicyForResponse(uint64_t frameID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) Variadic + DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) Variadic + DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, WTF::String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic # Intent messages #if ENABLE(WEB_INTENTS) - DidReceiveIntentForFrame(uint64_t frameID, WebKit::IntentData intent, WebKit::InjectedBundleUserMessageEncoder userData) + DidReceiveIntentForFrame(uint64_t frameID, WebKit::IntentData intent, WebKit::InjectedBundleUserMessageEncoder userData) Variadic #endif #if ENABLE(WEB_INTENTS_TAG) - RegisterIntentServiceForFrame(uint64_t frameID, WebKit::IntentServiceInfo serviceInfo, WebKit::InjectedBundleUserMessageEncoder userData); + RegisterIntentServiceForFrame(uint64_t frameID, WebKit::IntentServiceInfo serviceInfo, WebKit::InjectedBundleUserMessageEncoder userData) Variadic #endif # Progress messages @@ -119,23 +120,23 @@ messages -> WebPageProxy { DidRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID); # Frame load messages - DidCommitLoadForFrame(uint64_t frameID, WTF::String mimeType, bool hasCustomRepresentation, WebKit::PlatformCertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) - DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) - DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) - DidFinishDocumentLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidFinishLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidFirstLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidNewFirstVisuallyNonEmptyLayout(WebKit::InjectedBundleUserMessageEncoder userData) - DidLayout(uint32_t type, WebKit::InjectedBundleUserMessageEncoder userData) - DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData) - DidRemoveFrameFromHierarchy(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidStartProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WTF::String unreachableURL, WebKit::InjectedBundleUserMessageEncoder userData) - DidReceiveTitleForFrame(uint64_t frameID, WTF::String title, WebKit::InjectedBundleUserMessageEncoder userData) - DidDisplayInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidRunInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidDetectXSSForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) - DidSameDocumentNavigationForFrame(uint64_t frameID, uint32_t type, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData) + DidCommitLoadForFrame(uint64_t frameID, WTF::String mimeType, bool hasCustomRepresentation, WebKit::PlatformCertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFinishDocumentLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFinishLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFirstLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidNewFirstVisuallyNonEmptyLayout(WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidLayout(uint32_t type, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidRemoveFrameFromHierarchy(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidStartProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WTF::String unreachableURL, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidReceiveTitleForFrame(uint64_t frameID, WTF::String title, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidDisplayInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidRunInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidDetectXSSForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic + DidSameDocumentNavigationForFrame(uint64_t frameID, uint32_t type, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData) Variadic FrameDidBecomeFrameSet(uint64_t frameID, bool value) @@ -155,7 +156,7 @@ messages -> WebPageProxy { DidFinishLoadingDataForCustomRepresentation(WTF::String suggestedFilename, CoreIPC::DataReference data) # Forms messages - WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) + WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic # Callback messages VoidCallback(uint64_t callbackID) @@ -178,10 +179,6 @@ messages -> WebPageProxy { BindAccessibilityTree(WTF::String plugID) #endif -#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL) - InvalidateWidget() -#endif - # BackForward messages BackForwardAddItem(uint64_t itemID) BackForwardGoToItem(uint64_t itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle) @@ -190,7 +187,7 @@ messages -> WebPageProxy { BackForwardForwardListCount() -> (int32_t count) BackForwardClear() ShouldGoToBackForwardListItem(uint64_t itemID) -> (bool shouldGoToBackForwardListItem) - WillGoToBackForwardListItem(uint64_t itemID, WebKit::InjectedBundleUserMessageEncoder userData) + WillGoToBackForwardListItem(uint64_t itemID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic # Undo/Redo messages RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction) @@ -222,7 +219,7 @@ messages -> WebPageProxy { #if ENABLE(CONTEXT_MENUS) # ContextMenu messages - ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::WebHitTestResult::Data hitTestResultData, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) + ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::WebHitTestResult::Data hitTestResultData, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) Variadic #endif # Authentication messages @@ -328,4 +325,9 @@ messages -> WebPageProxy { # Search popup menus SaveRecentSearches(WTF::String name, Vector<String> searchItems) LoadRecentSearches(WTF::String name) -> (Vector<String> result) + +#if USE(SOUP) + # Soup custom URI request messages + DidReceiveURIRequest(WTF::String uriString, uint64_t requestID); +#endif } diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.cpp b/Source/WebKit2/UIProcess/WebProcessProxy.cpp index 579783eed..e8929f9e9 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.cpp +++ b/Source/WebKit2/UIProcess/WebProcessProxy.cpp @@ -46,7 +46,10 @@ #include <wtf/text/WTFString.h> #if PLATFORM(MAC) -#include "BuiltInPDFView.h" +#include "SimplePDFPlugin.h" +#if ENABLE(PDFKIT_PLUGIN) +#include "PDFPlugin.h" +#endif #endif using namespace WebCore; @@ -102,6 +105,16 @@ WebProcessProxy::~WebProcessProxy() } } +WebProcessProxy* WebProcessProxy::fromConnection(CoreIPC::Connection* connection) +{ + ASSERT(connection); + WebConnectionToWebProcess* webConnection = static_cast<WebConnectionToWebProcess*>(connection->client()); + + WebProcessProxy* webProcessProxy = webConnection->webProcessProxy(); + ASSERT(webProcessProxy->connection() == connection); + return webProcessProxy; +} + void WebProcessProxy::connect() { ASSERT(!m_processLauncher); @@ -186,6 +199,13 @@ void WebProcessProxy::removeWebPage(uint64_t pageID) m_pageMap.remove(pageID); } +Vector<WebPageProxy*> WebProcessProxy::pages() const +{ + Vector<WebPageProxy*> result; + copyValuesToVector(m_pageMap, result); + return result; +} + #if ENABLE(WEB_INTENTS) void WebProcessProxy::removeMessagePortChannel(uint64_t channelID) { @@ -253,9 +273,9 @@ bool WebProcessProxy::checkURLReceivedFromWebProcess(const KURL& url) // Items in back/forward list have been already checked. // One case where we don't have sandbox extensions for file URLs in b/f list is if the list has been reinstated after a crash or a browser restart. for (WebBackForwardListItemMap::iterator iter = m_backForwardListItemMap.begin(), end = m_backForwardListItemMap.end(); iter != end; ++iter) { - if (KURL(KURL(), iter->second->url()).fileSystemPath() == path) + if (KURL(KURL(), iter->value->url()).fileSystemPath() == path) return true; - if (KURL(KURL(), iter->second->originalURL()).fileSystemPath() == path) + if (KURL(KURL(), iter->value->originalURL()).fileSystemPath() == path) return true; } @@ -278,15 +298,15 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& original WebBackForwardListItemMap::AddResult result = m_backForwardListItemMap.add(itemID, 0); if (result.isNewEntry) { - result.iterator->second = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID); + result.iterator->value = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID); return; } // Update existing item. - result.iterator->second->setOriginalURL(originalURL); - result.iterator->second->setURL(url); - result.iterator->second->setTitle(title); - result.iterator->second->setBackForwardData(backForwardData.data(), backForwardData.size()); + result.iterator->value->setOriginalURL(originalURL); + result.iterator->value->setURL(url); + result.iterator->value->setTitle(title); + result.iterator->value->setBackForwardData(backForwardData.data(), backForwardData.size()); } void WebProcessProxy::sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<PluginInfo> > pluginInfos) @@ -298,8 +318,12 @@ void WebProcessProxy::sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<Pl #if PLATFORM(MAC) // Add built-in PDF last, so that it's not used when a real plug-in is installed. // NOTE: This has to be done on the main thread as it calls localizedString(). - if (!m_context->omitPDFSupport()) - plugins->append(BuiltInPDFView::pluginInfo()); + if (!m_context->omitPDFSupport()) { +#if ENABLE(PDFKIT_PLUGIN) + plugins->append(PDFPlugin::pluginInfo()); +#endif + plugins->append(SimplePDFPlugin::pluginInfo()); + } #endif send(Messages::WebProcess::DidGetPlugins(requestID, *plugins), 0); @@ -352,11 +376,6 @@ void WebProcessProxy::getPluginProcessConnection(const String& pluginPath, PassR PluginProcessManager::shared().getPluginProcessConnection(m_context->pluginInfoStore(), pluginPath, reply); } -void WebProcessProxy::pluginSyncMessageSendTimedOut(const String& pluginPath) -{ - PluginProcessManager::shared().pluginSyncMessageSendTimedOut(pluginPath); -} - #else void WebProcessProxy::didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID) @@ -371,38 +390,18 @@ void WebProcessProxy::didClearPluginSiteData(uint64_t callbackID) #endif +void WebProcessProxy::getSharedWorkerProcessConnection(const String& /* url */, const String& /* name */, PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply>) +{ + // FIXME: Implement +} + void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { - if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { - didReceiveWebProcessProxyMessage(connection, messageID, arguments); + if (m_context->dispatchMessage(connection, messageID, arguments)) return; - } - if (messageID.is<CoreIPC::MessageClassWebContext>() - || messageID.is<CoreIPC::MessageClassWebContextLegacy>() - || messageID.is<CoreIPC::MessageClassDownloadProxy>() - || messageID.is<CoreIPC::MessageClassWebApplicationCacheManagerProxy>() -#if ENABLE(BATTERY_STATUS) - || messageID.is<CoreIPC::MessageClassWebBatteryManagerProxy>() -#endif - || messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>() - || messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>() - || messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>() - || messageID.is<CoreIPC::MessageClassWebIconDatabase>() - || messageID.is<CoreIPC::MessageClassWebKeyValueStorageManagerProxy>() - || messageID.is<CoreIPC::MessageClassWebMediaCacheManagerProxy>() -#if ENABLE(NETWORK_INFO) - || messageID.is<CoreIPC::MessageClassWebNetworkInfoManagerProxy>() -#endif - || messageID.is<CoreIPC::MessageClassWebNotificationManagerProxy>() -#if USE(SOUP) - || messageID.is<CoreIPC::MessageClassWebSoupRequestManagerProxy>() -#endif -#if ENABLE(VIBRATION) - || messageID.is<CoreIPC::MessageClassWebVibrationProxy>() -#endif - || messageID.is<CoreIPC::MessageClassWebResourceCacheManagerProxy>()) { - m_context->didReceiveMessage(this, messageID, arguments); + if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { + didReceiveWebProcessProxyMessage(connection, messageID, arguments); return; } @@ -419,17 +418,11 @@ void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply) { - if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { - didReceiveSyncWebProcessProxyMessage(connection, messageID, arguments, reply); + if (m_context->dispatchSyncMessage(connection, messageID, arguments, reply)) return; - } - if (messageID.is<CoreIPC::MessageClassWebContext>() || messageID.is<CoreIPC::MessageClassWebContextLegacy>() -#if ENABLE(NETWORK_INFO) - || messageID.is<CoreIPC::MessageClassWebNetworkInfoManagerProxy>() -#endif - || messageID.is<CoreIPC::MessageClassDownloadProxy>() || messageID.is<CoreIPC::MessageClassWebIconDatabase>()) { - m_context->didReceiveSyncMessage(this, messageID, arguments, reply); + if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { + didReceiveSyncWebProcessProxyMessage(connection, messageID, arguments, reply); return; } @@ -473,10 +466,6 @@ void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::Me terminate(); } -void WebProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*) -{ -} - void WebProcessProxy::didBecomeUnresponsive(ResponsivenessTimer*) { Vector<RefPtr<WebPageProxy> > pages; @@ -565,7 +554,7 @@ size_t WebProcessProxy::frameCountInPage(WebPageProxy* page) const { size_t result = 0; for (HashMap<uint64_t, RefPtr<WebFrameProxy> >::const_iterator iter = m_frameMap.begin(); iter != m_frameMap.end(); ++iter) { - if (iter->second->page() == page) + if (iter->value->page() == page) ++result; } return result; diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.h b/Source/WebKit2/UIProcess/WebProcessProxy.h index c4fd3c929..57486c7da 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.h +++ b/Source/WebKit2/UIProcess/WebProcessProxy.h @@ -63,6 +63,8 @@ public: static PassRefPtr<WebProcessProxy> create(PassRefPtr<WebContext>); ~WebProcessProxy(); + static WebProcessProxy* fromConnection(CoreIPC::Connection*); + void terminate(); template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0); @@ -84,6 +86,7 @@ public: PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebContext*, WebPageGroup*); void addExistingWebPage(WebPageProxy*, uint64_t pageID); void removeWebPage(uint64_t pageID); + Vector<WebPageProxy*> pages() const; #if ENABLE(WEB_INTENTS) void removeMessagePortChannel(uint64_t channelID); @@ -142,7 +145,6 @@ private: void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, bool& blocked); #if ENABLE(PLUGIN_PROCESS) void getPluginProcessConnection(const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>); - void pluginSyncMessageSendTimedOut(const String& pluginPath); #else void didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID); void didClearPluginSiteData(uint64_t callbackID); @@ -151,6 +153,8 @@ private: void handleGetPlugins(uint64_t requestID, bool refresh); void sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<WebCore::PluginInfo> >); + void getSharedWorkerProcessConnection(const String& url, const String& name, PassRefPtr<Messages::WebProcessProxy::GetSharedWorkerProcessConnection::DelayedReply>); + #if USE(SECURITY_FRAMEWORK) void secItemRequest(CoreIPC::Connection*, uint64_t requestID, const SecItemRequestData&); void secKeychainItemRequest(CoreIPC::Connection*, uint64_t requestID, const SecKeychainItemRequestData&); @@ -162,7 +166,6 @@ private: virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&); virtual void didClose(CoreIPC::Connection*); virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID); - virtual void syncMessageSendTimedOut(CoreIPC::Connection*); #if PLATFORM(WIN) virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply(); #endif diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.messages.in b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in index 2c3d58b93..67e7b2dde 100644 --- a/Source/WebKit2/UIProcess/WebProcessProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in @@ -38,12 +38,12 @@ messages -> WebProcessProxy { GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, bool blocked) #if ENABLE(PLUGIN_PROCESS) GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Delayed - PluginSyncMessageSendTimedOut(WTF::String pluginPath) #endif #if !ENABLE(PLUGIN_PROCESS) void DidGetSitesWithPluginData(Vector<WTF::String> sites, uint64_t callbackID) void DidClearPluginSiteData(uint64_t callbackID) #endif + GetSharedWorkerProcessConnection(WTF::String url, WTF::String name) -> (CoreIPC::Attachment connectionHandle) Delayed #if USE(SECURITY_FRAMEWORK) SecItemRequest(uint64_t requestID, WebKit::SecItemRequestData request) DispatchOnConnectionQueue diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp index 60bf1a1ba..3c2980797 100644 --- a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp @@ -45,6 +45,7 @@ PassRefPtr<WebResourceCacheManagerProxy> WebResourceCacheManagerProxy::create(We WebResourceCacheManagerProxy::WebResourceCacheManagerProxy(WebContext* webContext) : m_webContext(webContext) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebResourceCacheManagerProxy, this); } WebResourceCacheManagerProxy::~WebResourceCacheManagerProxy() @@ -64,7 +65,6 @@ bool WebResourceCacheManagerProxy::shouldTerminate(WebProcessProxy*) const void WebResourceCacheManagerProxy::getCacheOrigins(PassRefPtr<ArrayCallback> prpCallback) { RefPtr<ArrayCallback> callback = prpCallback; - m_webContext->relaunchProcessIfNecessary(); uint64_t callbackID = callback->callbackID(); m_arrayCallbacks.set(callbackID, callback.release()); @@ -95,4 +95,9 @@ void WebResourceCacheManagerProxy::clearCacheForAllOrigins(ResourceCachesToClear m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::ClearCacheForAllOrigins(cachesToClear)); } +void WebResourceCacheManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) +{ + didReceiveWebResourceCacheManagerProxyMessage(connection, messageID, arguments); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h index f0c7bb549..9e59b641f 100644 --- a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h +++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h @@ -29,16 +29,11 @@ #include "APIObject.h" #include "Arguments.h" #include "GenericCallback.h" +#include "MessageReceiver.h" #include "ResourceCachesToClear.h" #include <wtf/HashMap.h> #include <wtf/PassRefPtr.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -class MessageID; -} - namespace WebKit { struct SecurityOriginData; @@ -48,7 +43,7 @@ class WebSecurityOrigin; typedef GenericCallback<WKArrayRef> ArrayCallback; -class WebResourceCacheManagerProxy : public APIObject { +class WebResourceCacheManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeCacheManager; @@ -62,8 +57,6 @@ public: void clearCacheForOrigin(WebSecurityOrigin*, ResourceCachesToClear); void clearCacheForAllOrigins(ResourceCachesToClear); - void didReceiveWebResourceCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - bool shouldTerminate(WebProcessProxy*) const; private: @@ -71,6 +64,10 @@ private: virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + void didReceiveWebResourceCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + // Message handlers. void didGetCacheOrigins(const Vector<SecurityOriginData>& originIdentifiers, uint64_t callbackID); diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.cpp b/Source/WebKit2/UIProcess/WebVibrationProxy.cpp index 9a5f7f264..0590f30cc 100644 --- a/Source/WebKit2/UIProcess/WebVibrationProxy.cpp +++ b/Source/WebKit2/UIProcess/WebVibrationProxy.cpp @@ -40,6 +40,7 @@ PassRefPtr<WebVibrationProxy> WebVibrationProxy::create(WebContext* context) WebVibrationProxy::WebVibrationProxy(WebContext* context) : m_context(context) { + m_context->addMessageReceiver(CoreIPC::MessageClassWebVibrationProxy, this); } WebVibrationProxy::~WebVibrationProxy() diff --git a/Source/WebKit2/UIProcess/WebVibrationProxy.h b/Source/WebKit2/UIProcess/WebVibrationProxy.h index 4e69e96fa..676d3a497 100644 --- a/Source/WebKit2/UIProcess/WebVibrationProxy.h +++ b/Source/WebKit2/UIProcess/WebVibrationProxy.h @@ -29,20 +29,15 @@ #if ENABLE(VIBRATION) #include "APIObject.h" -#include "MessageID.h" +#include "MessageReceiver.h" #include "WebVibrationProvider.h" #include <wtf/Forward.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -} - namespace WebKit { class WebContext; -class WebVibrationProxy : public APIObject { +class WebVibrationProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeVibration; @@ -54,13 +49,14 @@ public: void initializeProvider(const WKVibrationProvider*); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); - private: explicit WebVibrationProxy(WebContext*); virtual Type type() const { return APIType; } + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; + // Implemented in generated WebVibrationProxyMessageReceiver.cpp void didReceiveWebVibrationProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); diff --git a/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp b/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp index 75a8a99a5..9ec3cc141 100644 --- a/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp @@ -1,5 +1,7 @@ /* - * Copyright (C) 2011 Samsung Electronics + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. + * Copyright (C) 2011-2012 Samsung Electronics * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,7 +29,10 @@ #include "TextChecker.h" #include "TextCheckerState.h" -#include <WebCore/NotImplemented.h> + +#if ENABLE(SPELLCHECK) +#include "WebTextChecker.h" +#endif using namespace WebCore; @@ -37,91 +42,185 @@ static TextCheckerState textCheckerState; const TextCheckerState& TextChecker::state() { - notImplemented(); +#if ENABLE(SPELLCHECK) + static bool didInitializeState = false; + if (didInitializeState) + return textCheckerState; + + WebTextCheckerClient& client = WebTextChecker::shared()->client(); + textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled(); + textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled(); + + didInitializeState = true; +#endif return textCheckerState; } bool TextChecker::isContinuousSpellCheckingAllowed() { - notImplemented(); +#if ENABLE(SPELLCHECK) + return WebTextChecker::shared()->client().continuousSpellCheckingAllowed(); +#else return false; +#endif } -void TextChecker::setContinuousSpellCheckingEnabled(bool) +void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled) { - notImplemented(); +#if ENABLE(SPELLCHECK) + if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled) + return; + + textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled; + WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled); +#else + UNUSED_PARAM(isContinuousSpellCheckingEnabled); +#endif } -void TextChecker::setGrammarCheckingEnabled(bool) +void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled) { - notImplemented(); +#if ENABLE(SPELLCHECK) + if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled) + return; + + textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled; + WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled); +#else + UNUSED_PARAM(isGrammarCheckingEnabled); +#endif } -void TextChecker::continuousSpellCheckingEnabledStateChanged(bool /*enabled*/) +void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled) { - notImplemented(); +#if ENABLE(SPELLCHECK) + textCheckerState.isContinuousSpellCheckingEnabled = enabled; +#else + UNUSED_PARAM(enabled); +#endif } -void TextChecker::grammarCheckingEnabledStateChanged(bool /*enabled*/) +void TextChecker::grammarCheckingEnabledStateChanged(bool enabled) { - notImplemented(); +#if ENABLE(SPELLCHECK) + textCheckerState.isGrammarCheckingEnabled = enabled; +#else + UNUSED_PARAM(enabled); +#endif } -int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*) +int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page) { - notImplemented(); +#if ENABLE(SPELLCHECK) + return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page); +#else + UNUSED_PARAM(page); return 0; +#endif } -void TextChecker::closeSpellDocumentWithTag(int64_t) +void TextChecker::closeSpellDocumentWithTag(int64_t tag) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag); +#else + UNUSED_PARAM(tag); +#endif } -void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&) +void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(text); + UNUSED_PARAM(length); + UNUSED_PARAM(misspellingLocation); + UNUSED_PARAM(misspellingLength); +#endif } -void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&) +void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(text); + UNUSED_PARAM(length); + UNUSED_PARAM(grammarDetails); + UNUSED_PARAM(badGrammarLocation); + UNUSED_PARAM(badGrammarLength); +#endif } bool TextChecker::spellingUIIsShowing() { - notImplemented(); +#if ENABLE(SPELLCHECK) + return WebTextChecker::shared()->client().spellingUIIsShowing(); +#else return false; +#endif } void TextChecker::toggleSpellingUIIsShowing() { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().toggleSpellingUIIsShowing(); +#endif } -void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&) +void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(misspelledWord); +#endif } -void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&) +void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(badGrammarPhrase); + UNUSED_PARAM(grammarDetail); +#endif } -void TextChecker::getGuessesForWord(int64_t, const String&, const String&, Vector<String>&) +void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& , Vector<String>& guesses) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(word); + UNUSED_PARAM(guesses); +#endif } -void TextChecker::learnWord(int64_t, const String&) +void TextChecker::learnWord(int64_t spellDocumentTag, const String& word) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().learnWord(spellDocumentTag, word); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(word); +#endif } -void TextChecker::ignoreWord(int64_t, const String&) +void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word) { - notImplemented(); +#if ENABLE(SPELLCHECK) + WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word); +#else + UNUSED_PARAM(spellDocumentTag); + UNUSED_PARAM(word); +#endif } } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp index 8a479d29e..d53f83560 100644 --- a/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp @@ -54,8 +54,7 @@ String WebContext::platformDefaultDatabaseDirectory() const String WebContext::platformDefaultIconDatabasePath() const { - notImplemented(); - return ""; + return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IconDatabase"; } String WebContext::platformDefaultLocalStorageDirectory() const @@ -63,4 +62,16 @@ String WebContext::platformDefaultLocalStorageDirectory() const return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/LocalStorage"; } +String WebContext::platformDefaultDiskCacheDirectory() const +{ + notImplemented(); + return String(); +} + +String WebContext::platformDefaultCookieStorageDirectory() const +{ + notImplemented(); + return String(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp index 538356610..a24dc3430 100644 --- a/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp @@ -29,31 +29,84 @@ #if ENABLE(INSPECTOR) #include "WebProcessProxy.h" +#include "ewk_settings.h" #include "ewk_view.h" #include "ewk_view_private.h" #include <WebCore/NotImplemented.h> #include <unistd.h> #include <wtf/text/CString.h> +#include <wtf/text/StringBuilder.h> #include <wtf/text/WTFString.h> namespace WebKit { +static void resizeInspectorWindow(Ecore_Evas* inspectorWindow) +{ + Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector"); + if (!inspectorView) + return; + + int width, height; + ecore_evas_geometry_get(inspectorWindow, 0, 0, &width, &height); + + evas_object_move(inspectorView, 0, 0); + evas_object_resize(inspectorView, width, height); +} + +static void destroyInspectorWindow(Ecore_Evas* inspectorWindow) +{ + Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector"); + if (inspectorView) + evas_object_smart_callback_call(inspectorView, "inspector,view,close", 0); +} + +static void closeInspectorWindow(void* userData, Evas_Object*, void*) +{ + WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData); + + inspectorProxy->close(); +} + +void WebInspectorProxy::createInspectorWindow() +{ + ecore_evas_title_set(m_inspectorWindow, "Web Inspector"); + ecore_evas_callback_resize_set(m_inspectorWindow, resizeInspectorWindow); + ecore_evas_callback_delete_request_set(m_inspectorWindow, destroyInspectorWindow); + ecore_evas_show(m_inspectorWindow); + + evas_object_name_set(m_inspectorView, "inspector"); + evas_object_move(m_inspectorView, 0, 0); + evas_object_resize(m_inspectorView, initialWindowWidth, initialWindowHeight); + evas_object_show(m_inspectorView); + + evas_object_focus_set(m_inspectorView, true); +} + WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() { ASSERT(m_page); - m_inspectorWindow = ecore_evas_buffer_new(initialWindowWidth, initialWindowHeight); + m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0); if (!m_inspectorWindow) return 0; m_inspectorView = ewk_view_base_add(ecore_evas_get(m_inspectorWindow), toAPI(page()->process()->context()), toAPI(inspectorPageGroup())); ewk_view_theme_set(m_inspectorView, TEST_THEME_DIR"/default.edj"); + + Ewk_Settings* settings = ewk_view_settings_get(m_inspectorView); + ewk_settings_file_access_from_file_urls_allowed_set(settings, true); + return ewk_view_page_get(m_inspectorView); } void WebInspectorProxy::platformOpen() { - notImplemented(); + if (m_isAttached) + platformAttach(); + else + createInspectorWindow(); + + evas_object_smart_callback_add(m_inspectorView, "inspector,view,close", closeInspectorWindow, this); } void WebInspectorProxy::platformDidClose() @@ -87,14 +140,18 @@ void WebInspectorProxy::platformInspectedURLChanged(const String&) String WebInspectorProxy::inspectorPageURL() const { - return makeString(inspectorBaseURL(), "/inspector.html"); + StringBuilder builder; + builder.append(inspectorBaseURL()); + builder.appendLiteral("/inspector.html"); + + return builder.toString(); } String WebInspectorProxy::inspectorBaseURL() const { - String inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_INSTALL_DIR); + String inspectorFilesPath = ASCIILiteral("file://" WEB_INSPECTOR_INSTALL_DIR); if (access(inspectorFilesPath.utf8().data(), R_OK)) - inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_DIR); + inspectorFilesPath = ASCIILiteral("file://" WEB_INSPECTOR_DIR); return inspectorFilesPath; } diff --git a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp index 2a3b3078d..8981ceeb1 100644 --- a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp @@ -83,4 +83,14 @@ void WebPageProxy::setThemePath(const String& themePath) process()->send(Messages::WebPage::SetThemePath(themePath), m_pageID, 0); } +void WebPageProxy::createPluginContainer(uint64_t&) +{ + notImplemented(); +} + +void WebPageProxy::windowedPluginGeometryDidChange(const WebCore::IntRect&, const WebCore::IntRect&, uint64_t) +{ + notImplemented(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp index 71c7bbe3c..afeb1723e 100644 --- a/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp +++ b/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "WebContext.h" #include <WebCore/FileSystem.h> +#include <WebCore/NotImplemented.h> #include <wtf/gobject/GOwnPtr.h> namespace WebKit { @@ -53,8 +54,8 @@ String WebContext::platformDefaultDatabaseDirectory() const String WebContext::platformDefaultIconDatabasePath() const { - // FIXME: Implement. - return WTF::String(); + GOwnPtr<gchar> databaseDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "icondatabase", NULL)); + return WebCore::filenameToString(databaseDirectory.get()); } String WebContext::platformDefaultLocalStorageDirectory() const @@ -63,4 +64,16 @@ String WebContext::platformDefaultLocalStorageDirectory() const return WebCore::filenameToString(storageDirectory.get()); } +String WebContext::platformDefaultDiskCacheDirectory() const +{ + notImplemented(); + return String(); +} + +String WebContext::platformDefaultCookieStorageDirectory() const +{ + notImplemented(); + return String(); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp index 80881bfe7..6b01bb027 100644 --- a/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp +++ b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp @@ -114,11 +114,6 @@ void WebPageProxy::setAcceleratedCompositingWindowId(uint64_t nativeWindowId) { process()->send(Messages::WebPage::SetAcceleratedCompositingWindowId(nativeWindowId), m_pageID); } - -void WebPageProxy::invalidateWidget() -{ - webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WEBKIT_WEB_VIEW_BASE(static_cast<PageClientImpl*>(m_pageClient)->viewWidget())); -} #endif } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm index 68c8e1125..9a9232cb0 100644 --- a/Source/WebKit2/UIProcess/mac/WebContextMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm @@ -30,6 +30,7 @@ #import "WebProcessCreationParameters.h" #import <WebCore/Color.h> #import <WebCore/FileSystem.h> +#include <WebCore/NotImplemented.h> #import <WebCore/PlatformPasteboard.h> #import <sys/param.h> @@ -77,22 +78,8 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para { parameters.presenterApplicationPid = getpid(); - if (!omitPDFSupport()) { - // We want to use a PDF view in the UI process for PDF MIME types. - HashSet<String, CaseFoldingHash> mimeType = pdfAndPostScriptMIMETypes(); - parameters.mimeTypesWithCustomRepresentation.appendRange(mimeType.begin(), mimeType.end()); - } - parameters.parentProcessName = [[NSProcessInfo processInfo] processName]; - RetainPtr<CFStringRef> cachePath(AdoptCF, WKCopyFoundationCacheDirectory()); - if (!cachePath) - cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory()); - - parameters.nsURLCachePath = [(NSString *)cachePath.get() stringByStandardizingPath]; - SandboxExtension::createHandleForReadWriteDirectory(parameters.nsURLCachePath, parameters.nsURLCachePathExtensionHandle); - ASSERT(!parameters.nsURLCachePath.isEmpty()); - NSURLCache *urlCache = [NSURLCache sharedURLCache]; parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity]; parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity]; @@ -100,10 +87,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 parameters.shouldForceScreenFontSubstitution = [[NSUserDefaults standardUserDefaults] boolForKey:@"NSFontDefaultScreenFontSubstitutionEnabled"]; #endif - -#if ENABLE(PLUGIN_PROCESS) - parameters.disablePluginProcessMessageTimeout = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitDisablePluginProcessMessageTimeout"]; -#endif + parameters.shouldEnableKerningAndLigaturesByDefault = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitKerningAndLigaturesEnabledByDefault"]; #if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION) #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @@ -131,7 +115,22 @@ void WebContext::platformInvalidateContext() { [[NSNotificationCenter defaultCenter] removeObserver:(id)m_enhancedAccessibilityObserver.get()]; } - + +String WebContext::platformDefaultDiskCacheDirectory() const +{ + RetainPtr<NSString> cachePath(AdoptNS, (NSString *)WKCopyFoundationCacheDirectory()); + if (!cachePath) + cachePath = @"~/Library/Caches/com.apple.WebKit2.WebProcess"; + + return [cachePath.get() stringByStandardizingPath]; +} + +String WebContext::platformDefaultCookieStorageDirectory() const +{ + notImplemented(); + return [@"" stringByStandardizingPath]; +} + String WebContext::platformDefaultDatabaseDirectory() const { NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebDatabaseDirectoryDefaultsKey]; diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm index eb442fde5..530a2f587 100644 --- a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm @@ -96,7 +96,7 @@ static const CGFloat windowContentBorderThickness = 55; // depend on this for enforcing the height constraints, so a small delay isn't terrible. Most // of the time the views will already have the correct frames because of autoresizing masks. - dispatch_after(DISPATCH_TIME_NOW, dispatch_get_current_queue(), ^{ + dispatch_after(DISPATCH_TIME_NOW, dispatch_get_main_queue(), ^{ if (!_inspectorProxy) return; static_cast<WebInspectorProxy*>(_inspectorProxy)->inspectedViewFrameDidChange(); diff --git a/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm index 73f3ddc02..a182faa42 100644 --- a/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm @@ -149,6 +149,20 @@ bool WebProcessProxy::fullKeyboardAccessEnabled() return [WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled]; } +#if HAVE(XPC) +static bool shouldUseXPC() +{ + if (id value = [[NSUserDefaults standardUserDefaults] objectForKey:@"WebKit2UseXPCServiceForWebProcess"]) + return [value boolValue]; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 + return true; +#else + return false; +#endif +} +#endif + void WebProcessProxy::platformConnect(ProcessLauncher::LaunchOptions& launchOptions) { // We want the web process to match the architecture of the UI process. @@ -156,7 +170,7 @@ void WebProcessProxy::platformConnect(ProcessLauncher::LaunchOptions& launchOpti launchOptions.executableHeap = false; #if HAVE(XPC) - launchOptions.useXPC = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKit2UseXPCServiceForWebProcess"]; + launchOptions.useXPC = shouldUseXPC(); #endif } diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp index 9e2531f57..cbc26e68b 100644 --- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp +++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp @@ -322,8 +322,6 @@ void PageViewportControllerClientQt::setContentsScale(float localScale, bool tre setContentRectVisiblePositionAtScale(QPointF(), localScale); } else scaleContent(localScale); - - updateViewportController(); } void PageViewportControllerClientQt::setContentsRectToNearestValidBounds() @@ -335,6 +333,7 @@ void PageViewportControllerClientQt::setContentsRectToNearestValidBounds() void PageViewportControllerClientQt::didResumeContent() { + // Make sure that tiles all around the viewport will be requested. updateViewportController(); } @@ -468,8 +467,10 @@ void PageViewportControllerClientQt::pinchGestureCancelled() m_scaleUpdateDeferrer.reset(); } -void PageViewportControllerClientQt::didChangeContentsSize() +void PageViewportControllerClientQt::didChangeContentsSize(const IntSize& newSize) { + m_pageItem->setContentsSize(QSizeF(newSize)); + // Emit for testing purposes, so that it can be verified that // we didn't do scale adjustment. emit m_viewportItem->experimental()->test()->contentsScaleCommitted(); @@ -492,18 +493,14 @@ void PageViewportControllerClientQt::didChangeVisibleContents() void PageViewportControllerClientQt::didChangeViewportAttributes() { - // Make sure we apply the new initial scale when deferring ends. - ViewportUpdateDeferrer guard(m_controller); - emit m_viewportItem->experimental()->test()->devicePixelRatioChanged(); emit m_viewportItem->experimental()->test()->viewportChanged(); } -void PageViewportControllerClientQt::updateViewportController(const QPointF& trajectory, qreal scale) +void PageViewportControllerClientQt::updateViewportController(const QPointF& trajectory) { FloatPoint viewportPos = m_viewportItem->mapToWebContent(QPointF()); - float viewportScale = (scale < 0) ? m_pageItem->contentsScale() : scale; - m_controller->didChangeContentsVisibility(viewportPos, viewportScale, trajectory); + m_controller->didChangeContentsVisibility(viewportPos, m_pageItem->contentsScale(), trajectory); } void PageViewportControllerClientQt::scaleContent(qreal itemScale, const QPointF& centerInCSSCoordinates) diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h index bd0e1731b..7c5ceea58 100644 --- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h +++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.h @@ -51,7 +51,7 @@ public: virtual void setContentsScale(float scale, bool treatAsInitialValue); virtual void didResumeContent(); - virtual void didChangeContentsSize(); + virtual void didChangeContentsSize(const WebCore::IntSize&); virtual void didChangeVisibleContents(); virtual void didChangeViewportAttributes(); @@ -124,7 +124,7 @@ private: QRectF nearestValidVisibleContentsRect() const; void setContentsRectToNearestValidBounds(); - void updateViewportController(const QPointF& trajectory = QPointF(), qreal scale = -1); + void updateViewportController(const QPointF& trajectory = QPointF()); void setContentRectVisiblePositionAtScale(const QPointF& location, qreal itemScale); void animateContentRectVisible(const QRectF& contentRect); void scaleContent(qreal itemScale, const QPointF& centerInCSSCoordinates = QPointF()); diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp index d5a5f7ece..7737f6529 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp @@ -73,6 +73,16 @@ void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect) QQuickWebViewPrivate::get(m_webView)->setNeedsDisplay(); } +void QtPageClient::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) +{ + // The viewport has to be notified first so that the viewport position + // is adjusted before the loadVisuallyCommitted() signal. + PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController(); + if (pvc) + pvc->didRenderFrame(contentsSize, coveredRect); + QQuickWebViewPrivate::get(m_webView)->didRenderFrame(); +} + void QtPageClient::pageDidRequestScroll(const IntPoint& pos) { QQuickWebViewPrivate::get(m_webView)->pageDidRequestScroll(pos); @@ -90,7 +100,9 @@ void QtPageClient::didRelaunchProcess() void QtPageClient::didChangeContentsSize(const IntSize& newSize) { - QQuickWebViewPrivate::get(m_webView)->didChangeContentsSize(newSize); + PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController(); + if (pvc) + pvc->didChangeContentsSize(newSize); } void QtPageClient::didChangeViewportProperties(const WebCore::ViewportAttributes& attr) @@ -220,6 +232,13 @@ void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&) notImplemented(); } +void QtPageClient::pageTransitionViewportReady() +{ + PageViewportController* pvc = QQuickWebViewPrivate::get(m_webView)->viewportController(); + if (pvc) + pvc->pageTransitionViewportReady(); +} + void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area) { ASSERT(m_eventHandler); diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.h b/Source/WebKit2/UIProcess/qt/QtPageClient.h index 2e367570a..e493ce8ad 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.h +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.h @@ -43,6 +43,7 @@ public: // QQuickWebView. virtual void setViewNeedsDisplay(const WebCore::IntRect&); + virtual void didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect); virtual WebCore::IntSize viewSize(); virtual bool isViewFocused(); virtual bool isViewVisible(); @@ -99,6 +100,7 @@ public: virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); virtual void findStringInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { } virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { } + virtual void pageTransitionViewportReady(); virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&); virtual void updateTextInputState(); virtual void doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled); diff --git a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp index 0aaa06690..a9c4e7a00 100644 --- a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp @@ -38,9 +38,6 @@ QtPanGestureRecognizer::QtPanGestureRecognizer(QtWebPageEventHandler* eventHandl bool QtPanGestureRecognizer::update(const QTouchEvent::TouchPoint& touchPoint, qint64 eventTimestampMillis) { - if (!viewportController()) - return false; - m_lastPosition = touchPoint.pos(); m_lastEventTimestampMillis = eventTimestampMillis; @@ -48,7 +45,8 @@ bool QtPanGestureRecognizer::update(const QTouchEvent::TouchPoint& touchPoint, q case NoGesture: m_state = GestureRecognitionStarted; m_firstScreenPosition = touchPoint.screenPos(); - viewportController()->cancelScrollAnimation(); + if (viewportController()) + viewportController()->cancelScrollAnimation(); return false; case GestureRecognitionStarted: { // To start the gesture, the delta from start in screen coordinates @@ -58,11 +56,13 @@ bool QtPanGestureRecognizer::update(const QTouchEvent::TouchPoint& touchPoint, q return false; m_state = GestureRecognized; - viewportController()->panGestureStarted(touchPoint.pos(), eventTimestampMillis); + if (viewportController()) + viewportController()->panGestureStarted(touchPoint.pos(), eventTimestampMillis); return true; } case GestureRecognized: - viewportController()->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis); + if (viewportController()) + viewportController()->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis); return true; default: ASSERT_NOT_REACHED(); @@ -75,8 +75,8 @@ void QtPanGestureRecognizer::finish(const QTouchEvent::TouchPoint& touchPoint, q if (m_state == NoGesture) return; - ASSERT(viewportController()); - viewportController()->panGestureEnded(touchPoint.pos(), eventTimestampMillis); + if (viewportController()) + viewportController()->panGestureEnded(touchPoint.pos(), eventTimestampMillis); reset(); } @@ -85,8 +85,10 @@ void QtPanGestureRecognizer::cancel() if (m_state == NoGesture) return; - viewportController()->panGestureEnded(m_lastPosition, m_lastEventTimestampMillis); - viewportController()->panGestureCancelled(); + if (viewportController()) { + viewportController()->panGestureEnded(m_lastPosition, m_lastEventTimestampMillis); + viewportController()->panGestureCancelled(); + } reset(); } diff --git a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp index a10367a40..7fa58014f 100644 --- a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp @@ -48,7 +48,6 @@ QtPinchGestureRecognizer::QtPinchGestureRecognizer(QtWebPageEventHandler* eventH bool QtPinchGestureRecognizer::update(const QTouchEvent::TouchPoint& point1, const QTouchEvent::TouchPoint& point2) { - ASSERT(viewportController()); const qreal currentFingerDistance = QLineF(point1.screenPos(), point2.screenPos()).length(); switch (m_state) { case NoGesture: @@ -60,7 +59,8 @@ bool QtPinchGestureRecognizer::update(const QTouchEvent::TouchPoint& point1, con if (pinchDistance < pinchInitialTriggerDistanceThreshold) return false; m_state = GestureRecognized; - viewportController()->pinchGestureStarted(computePinchCenter(point1, point2)); + if (viewportController()) + viewportController()->pinchGestureStarted(computePinchCenter(point1, point2)); // We reset the initial span distance to the current distance of the // touch points in order to avoid the jump caused by the events which @@ -72,7 +72,8 @@ bool QtPinchGestureRecognizer::update(const QTouchEvent::TouchPoint& point1, con case GestureRecognized: const qreal totalScaleFactor = currentFingerDistance / m_initialFingerDistance; const QPointF touchCenterInViewCoordinates = computePinchCenter(point1, point2); - viewportController()->pinchGestureRequestUpdate(touchCenterInViewCoordinates, totalScaleFactor); + if (viewportController()) + viewportController()->pinchGestureRequestUpdate(touchCenterInViewCoordinates, totalScaleFactor); return true; break; } @@ -86,8 +87,8 @@ void QtPinchGestureRecognizer::finish() if (m_state == NoGesture) return; - ASSERT(viewportController()); - viewportController()->pinchGestureEnded(); + if (viewportController()) + viewportController()->pinchGestureEnded(); reset(); } @@ -96,8 +97,8 @@ void QtPinchGestureRecognizer::cancel() if (m_state == NoGesture) return; - ASSERT(viewportController()); - viewportController()->pinchGestureCancelled(); + if (viewportController()) + viewportController()->pinchGestureCancelled(); reset(); } diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp index afdfa6fcd..592bb371c 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp @@ -90,11 +90,11 @@ QImage QtWebIconDatabaseClient::iconImageForPageURL(const WTF::String& pageURL, WebCore::IntSize size(iconSize.width(), iconSize.height()); - QImage* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size); + QPixmap* nativeImage = m_iconDatabase->nativeImageForPageURL(pageURL, size); if (!nativeImage) return QImage(); - return *nativeImage; + return nativeImage->toImage(); } void QtWebIconDatabaseClient::retainIconForPageURL(const String& pageURL) diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp index 819d4a0a2..fdc92355f 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp @@ -167,18 +167,18 @@ void QtWebPageEventHandler::handleHoverLeaveEvent(QHoverEvent* ev) { // To get the correct behavior of mouseout, we need to turn the Leave event of our webview into a mouse move // to a very far region. - QTransform fromItemTransform = m_webPage->transformFromItem(); - QHoverEvent fakeEvent(QEvent::HoverMove, QPoint(INT_MIN, INT_MIN), fromItemTransform.map(ev->oldPosF())); + QHoverEvent fakeEvent(QEvent::HoverMove, QPoint(INT_MIN, INT_MIN), ev->oldPosF()); fakeEvent.setTimestamp(ev->timestamp()); + // This will apply the transform on the event. handleHoverMoveEvent(&fakeEvent); } void QtWebPageEventHandler::handleHoverMoveEvent(QHoverEvent* ev) { - QTransform fromItemTransform = m_webPage->transformFromItem(); - QMouseEvent me(QEvent::MouseMove, fromItemTransform.map(ev->posF()), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent me(QEvent::MouseMove, ev->posF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); me.setAccepted(ev->isAccepted()); me.setTimestamp(ev->timestamp()); + // This will apply the transform on the event. handleMouseMoveEvent(&me); } @@ -450,7 +450,38 @@ void QtWebPageEventHandler::doneWithGestureEvent(const WebGestureEvent& event, b void QtWebPageEventHandler::handleInputEvent(const QInputEvent* event) { - ASSERT(m_viewportController); + if (m_viewportController) { + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::TouchBegin: + ASSERT(!m_viewportController->panGestureActive()); + ASSERT(!m_viewportController->pinchGestureActive()); + m_viewportController->touchBegin(); + + // The page viewport controller might still be animating kinetic scrolling or a scale animation + // such as double-tap to zoom or the bounce back effect. A touch stops the kinetic scrolling + // where as it does not stop the scale animation. + // The gesture recognizer stops the kinetic scrolling animation if needed. + break; + case QEvent::MouseMove: + case QEvent::TouchUpdate: + // The scale animation can only be interrupted by a pinch gesture, which will then take over. + if (m_viewportController->scaleAnimationActive() && m_pinchGestureRecognizer.isRecognized()) + m_viewportController->interruptScaleAnimation(); + break; + case QEvent::MouseButtonRelease: + case QEvent::TouchEnd: + m_viewportController->touchEnd(); + break; + default: + break; + } + + // If the scale animation is active we don't pass the event to the recognizers. In the future + // we would want to queue the event here and repost then when the animation ends. + if (m_viewportController->scaleAnimationActive()) + return; + } bool isMouseEvent = false; @@ -458,45 +489,22 @@ void QtWebPageEventHandler::handleInputEvent(const QInputEvent* event) case QEvent::MouseButtonPress: isMouseEvent = true; m_isMouseButtonPressed = true; - // Fall through. - case QEvent::TouchBegin: - ASSERT(!m_viewportController->panGestureActive()); - ASSERT(!m_viewportController->pinchGestureActive()); - m_viewportController->touchBegin(); - - // The interaction engine might still be animating kinetic scrolling or a scale animation - // such as double-tap to zoom or the bounce back effect. A touch stops the kinetic scrolling - // where as it does not stop the scale animation. - // The gesture recognizer stops the kinetic scrolling animation if needed. break; case QEvent::MouseMove: if (!m_isMouseButtonPressed) return; - isMouseEvent = true; - // Fall through. - case QEvent::TouchUpdate: - // The scale animation can only be interrupted by a pinch gesture, which will then take over. - if (m_viewportController->scaleAnimationActive() && m_pinchGestureRecognizer.isRecognized()) - m_viewportController->interruptScaleAnimation(); break; case QEvent::MouseButtonRelease: isMouseEvent = true; m_isMouseButtonPressed = false; - // Fall through. - case QEvent::TouchEnd: - m_viewportController->touchEnd(); break; - default: - ASSERT(event->type() == QEvent::MouseButtonDblClick); + case QEvent::MouseButtonDblClick: return; + default: + break; } - // If the scale animation is active we don't pass the event to the recognizers. In the future - // we would want to queue the event here and repost then when the animation ends. - if (m_viewportController->scaleAnimationActive()) - return; - QList<QTouchEvent::TouchPoint> activeTouchPoints; QTouchEvent::TouchPoint currentTouchPoint; qint64 eventTimestampMillis = event->timestamp(); @@ -568,9 +576,6 @@ void QtWebPageEventHandler::handleInputEvent(const QInputEvent* event) #if ENABLE(TOUCH_EVENTS) void QtWebPageEventHandler::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled) { - if (!m_viewportController) - return; - if (wasEventHandled || event.type() == WebEvent::TouchCancel) { m_panGestureRecognizer.cancel(); m_pinchGestureRecognizer.cancel(); diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp index 0e9c5cfb4..b877ca8df 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp @@ -62,6 +62,9 @@ void QtWebPageLoadClient::didReceiveServerRedirectForProvisionalLoad(const WTF:: void QtWebPageLoadClient::didCommitLoad() { + PageViewportController* pvc = m_webView->d_func()->viewportController(); + if (pvc) + pvc->didCommitLoad(); m_webView->d_func()->loadDidCommit(); } diff --git a/Source/WebKit2/UIProcess/qt/WebContextQt.cpp b/Source/WebKit2/UIProcess/qt/WebContextQt.cpp index f6af89d62..45329db44 100644 --- a/Source/WebKit2/UIProcess/qt/WebContextQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebContextQt.cpp @@ -43,8 +43,9 @@ namespace WebKit { static QString s_defaultDatabaseDirectory; static QString s_defaultLocalStorageDirectory; +static QString s_defaultCookieStorageDirectory; -static String defaultDiskCacheDirectory() +String WebContext::platformDefaultDiskCacheDirectory() const { static String s_defaultDiskCacheDirectory; @@ -61,7 +62,7 @@ String WebContext::applicationCacheDirectory() const String cacheDirectory = WebCore::cacheStorage().cacheDirectory(); if (cacheDirectory.isEmpty()) - return defaultDiskCacheDirectory(); + return platformDefaultDiskCacheDirectory(); return cacheDirectory; } @@ -69,8 +70,6 @@ String WebContext::applicationCacheDirectory() void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters) { qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - parameters.cookieStorageDirectory = defaultDataLocation(); - parameters.diskCacheDirectory = defaultDiskCacheDirectory(); #if ENABLE(GEOLOCATION) static WebGeolocationProviderQt* location = WebGeolocationProviderQt::create(toAPI(geolocationManagerProxy())); WKGeolocationManagerSetProvider(toAPI(geolocationManagerProxy()), WebGeolocationProviderQt::provider(location)); @@ -106,4 +105,13 @@ String WebContext::platformDefaultLocalStorageDirectory() const return s_defaultLocalStorageDirectory; } +String WebContext::platformDefaultCookieStorageDirectory() const +{ + if (!s_defaultCookieStorageDirectory.isEmpty()) + return s_defaultCookieStorageDirectory; + + s_defaultCookieStorageDirectory = defaultDataLocation(); + return s_defaultCookieStorageDirectory; +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp index ef6d5477d..e5a7829c0 100644 --- a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp @@ -85,6 +85,11 @@ void WebPageProxy::cancelComposition() process()->send(Messages::WebPage::CancelComposition(), m_pageID); } +void WebPageProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect) +{ + m_pageClient->didRenderFrame(contentsSize, coveredRect); +} + void WebPageProxy::registerApplicationScheme(const String& scheme) { process()->send(Messages::WebPage::RegisterApplicationScheme(scheme), m_pageID); @@ -116,6 +121,44 @@ void WebPageProxy::setUserScripts(const Vector<String>& scripts) process()->send(Messages::WebPage::SetUserScripts(scripts), m_pageID); } +void WebPageProxy::pageTransitionViewportReady() +{ + m_pageClient->pageTransitionViewportReady(); +} + +void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area) +{ + m_pageClient->didFindZoomableArea(target, area); +} + +void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area) +{ + if (!isValid()) + return; + + m_process->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID); +} + +void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents) +{ + m_pageClient->didReceiveMessageFromNavigatorQtObject(contents); +} + +void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) +{ + m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password); +} + +void WebPageProxy::proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) +{ + m_pageClient->handleProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername, username, password); +} + +void WebPageProxy::certificateVerificationRequest(const String& hostname, bool& ignoreErrors) +{ + m_pageClient->handleCertificateVerificationRequest(hostname, ignoreErrors); +} + #if PLUGIN_ARCHITECTURE(X11) void WebPageProxy::createPluginContainer(uint64_t& windowID) { diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.cpp b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.cpp index be2c6cc66..c5d7e3bf7 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.cpp +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.cpp @@ -24,12 +24,12 @@ namespace WebKit { -bool WebSoupRequestManagerClient::didReceiveURIRequest(WebSoupRequestManagerProxy* soupRequestManager, WebURL* url, uint64_t requestID) +bool WebSoupRequestManagerClient::didReceiveURIRequest(WebSoupRequestManagerProxy* soupRequestManager, WebURL* url, WebPageProxy* initiaingPage, uint64_t requestID) { if (!m_client.didReceiveURIRequest) return false; - m_client.didReceiveURIRequest(toAPI(soupRequestManager), toAPI(url), requestID, m_client.clientInfo); + m_client.didReceiveURIRequest(toAPI(soupRequestManager), toAPI(url), toAPI(initiaingPage), requestID, m_client.clientInfo); return true; } diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.h b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.h index dc1755e5a..e247fecd7 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.h +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerClient.h @@ -30,7 +30,7 @@ class WebURL; class WebSoupRequestManagerClient : public APIClient<WKSoupRequestManagerClient, kWKSoupRequestManagerClientCurrentVersion> { public: - bool didReceiveURIRequest(WebSoupRequestManagerProxy*, WebURL*, uint64_t requestID); + bool didReceiveURIRequest(WebSoupRequestManagerProxy*, WebURL*, WebPageProxy*, uint64_t requestID); void didFailToLoadURIRequest(WebSoupRequestManagerProxy*, uint64_t requestID); }; diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp index c766b0adb..e2bf3423d 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.cpp @@ -35,6 +35,7 @@ WebSoupRequestManagerProxy::WebSoupRequestManagerProxy(WebContext* context) : m_webContext(context) , m_loadFailed(false) { + m_webContext->addMessageReceiver(CoreIPC::MessageClassWebSoupRequestManagerProxy, this); } WebSoupRequestManagerProxy::~WebSoupRequestManagerProxy() @@ -76,9 +77,9 @@ void WebSoupRequestManagerProxy::didReceiveURIRequestData(const WebData* request m_webContext->sendToAllProcesses(Messages::WebSoupRequestManager::DidReceiveURIRequestData(requestData->dataReference(), requestID)); } -void WebSoupRequestManagerProxy::didReceiveURIRequest(const String& uriString, uint64_t requestID) +void WebSoupRequestManagerProxy::didReceiveURIRequest(const String& uriString, WebPageProxy* initiaingPage, uint64_t requestID) { - if (!m_client.didReceiveURIRequest(this, WebURL::create(uriString).get(), requestID)) + if (!m_client.didReceiveURIRequest(this, WebURL::create(uriString).get(), initiaingPage, requestID)) didHandleURIRequest(WebData::create(0, 0).get(), 0, String(), requestID); } diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h index 92bd63e1e..6a3d6e826 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.h @@ -21,23 +21,18 @@ #define WebSoupRequestManagerProxy_h #include "APIObject.h" +#include "MessageReceiver.h" #include "WebSoupRequestManagerClient.h" #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/text/WTFString.h> -namespace CoreIPC { -class ArgumentDecoder; -class Connection; -class MessageID; -} - namespace WebKit { class WebContext; class WebData; -class WebSoupRequestManagerProxy : public APIObject { +class WebSoupRequestManagerProxy : public APIObject, private CoreIPC::MessageReceiver { public: static const Type APIType = TypeSoupRequestManager; @@ -54,15 +49,15 @@ public: void didReceiveURIRequestData(const WebData*, uint64_t requestID); void didFailToLoadURIRequest(uint64_t requestID); - void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); + void didReceiveURIRequest(const String& uriString, WebPageProxy*, uint64_t requestID); private: WebSoupRequestManagerProxy(WebContext*); virtual Type type() const { return APIType; } - void didReceiveURIRequest(const String& uriString, uint64_t requestID); - + // CoreIPC::MessageReceiver + virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) OVERRIDE; void didReceiveWebSoupRequestManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); WebContext* m_webContext; diff --git a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.messages.in b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.messages.in index 81591a493..18058f5c7 100644 --- a/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.messages.in +++ b/Source/WebKit2/UIProcess/soup/WebSoupRequestManagerProxy.messages.in @@ -21,6 +21,5 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. messages -> WebSoupRequestManagerProxy { - DidReceiveURIRequest(WTF::String uriString, uint64_t requestID); DidFailToLoadURIRequest(uint64_t requestID); } diff --git a/Source/WebKit2/UIProcess/win/WebContextWin.cpp b/Source/WebKit2/UIProcess/win/WebContextWin.cpp index 9964de06c..9dd056820 100644 --- a/Source/WebKit2/UIProcess/win/WebContextWin.cpp +++ b/Source/WebKit2/UIProcess/win/WebContextWin.cpp @@ -29,6 +29,7 @@ #include "WebProcessCreationParameters.h" #include "WebProcessMessages.h" #include <WebCore/FileSystem.h> +#include <WebCore/NotImplemented.h> #if USE(CFNETWORK) #include <CFNetwork/CFURLCachePriv.h> @@ -61,11 +62,11 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para parameters.cfURLCacheMemoryCapacity = CFURLCacheMemoryCapacity(cfurlCache.get()); RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory(0)); - parameters.cfURLCachePath = String(cfURLCachePath.get()); + parameters.diskCacheDirectory = String(cfURLCachePath.get()); // Remove the ending '\' (necessary to have CFNetwork find the Cache file). - ASSERT(parameters.cfURLCachePath.length()); - if (parameters.cfURLCachePath[parameters.cfURLCachePath.length() - 1] == '\\') - parameters.cfURLCachePath.remove(parameters.cfURLCachePath.length() - 1); + ASSERT(parameters.diskCacheDirectory.length()); + if (parameters.diskCacheDirectory.endsWith(UChar('\\'))) + parameters.diskCacheDirectory.remove(parameters.diskCacheDirectory.length() - 1); #if USE(CFURLSTORAGESESSIONS) parameters.uiProcessBundleIdentifier = String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey))); @@ -97,5 +98,16 @@ String WebContext::platformDefaultLocalStorageDirectory() const return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "LocalStorage"); } +String WebContext::platformDefaultDiskCacheDirectory() const +{ + return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "cache"); +} + +String WebContext::platformDefaultCookieStorageDirectory() const +{ + notImplemented(); + return String(); +} + } // namespace WebKit |