diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebKit2/UIProcess/API | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
62 files changed, 2101 insertions, 256 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h index bef294e8a..fe55dd8ac 100644 --- a/Source/WebKit2/UIProcess/API/C/WKAPICast.h +++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h @@ -30,12 +30,14 @@ #include "CacheModel.h" #include "FontSmoothingLevel.h" #include "HTTPCookieAcceptPolicy.h" +#include "ProcessModel.h" #include "ResourceCachesToClear.h" #include "WebGrammarDetail.h" #include "WKContext.h" #include "WKCookieManager.h" #include "WKCredentialTypes.h" #include "WKPage.h" +#include "WKPreferences.h" #include "WKPreferencesPrivate.h" #include "WKProtectionSpaceTypes.h" #include "WKResourceCacheManager.h" @@ -174,6 +176,31 @@ inline WKCacheModel toAPI(CacheModel cacheModel) return kWKCacheModelDocumentViewer; } +inline ProcessModel toProcessModel(WKProcessModel wkProcessModel) +{ + switch (wkProcessModel) { + case kWKProcessModelSharedSecondaryProcess: + return ProcessModelSharedSecondaryProcess; + case kWKProcessModelMultipleSecondaryProcesses: + return ProcessModelMultipleSecondaryProcesses; + } + + ASSERT_NOT_REACHED(); + return ProcessModelSharedSecondaryProcess; +} + +inline WKProcessModel toAPI(ProcessModel processModel) +{ + switch (processModel) { + case ProcessModelSharedSecondaryProcess: + return kWKProcessModelSharedSecondaryProcess; + case ProcessModelMultipleSecondaryProcesses: + return kWKProcessModelMultipleSecondaryProcesses; + } + + return kWKProcessModelSharedSecondaryProcess; +} + inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel) { switch (wkLevel) { @@ -359,6 +386,36 @@ inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy) return kWKHTTPCookieAcceptPolicyAlways; } +inline WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(WKStorageBlockingPolicy policy) +{ + switch (policy) { + case kWKAllowAllStorage: + return WebCore::SecurityOrigin::AllowAllStorage; + case kWKBlockThirdPartyStorage: + return WebCore::SecurityOrigin::BlockThirdPartyStorage; + case kWKBlockAllStorage: + return WebCore::SecurityOrigin::BlockAllStorage; + } + + ASSERT_NOT_REACHED(); + return WebCore::SecurityOrigin::AllowAllStorage; +} + +inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy) +{ + switch (policy) { + case WebCore::SecurityOrigin::AllowAllStorage: + return kWKAllowAllStorage; + case WebCore::SecurityOrigin::BlockThirdPartyStorage: + return kWKBlockThirdPartyStorage; + case WebCore::SecurityOrigin::BlockAllStorage: + return kWKBlockAllStorage; + } + + ASSERT_NOT_REACHED(); + return kWKAllowAllStorage; +} + inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail) { return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail)); @@ -366,7 +423,7 @@ inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& gram } // namespace WebKit -#if defined(WIN32) || defined(_WIN32) +#if (defined(WIN32) || defined(_WIN32)) && !defined(BUILDING_QT__) #include "WKAPICastWin.h" #endif diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp index f802e9374..28a70821b 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp @@ -120,6 +120,16 @@ WKCacheModel WKContextGetCacheModel(WKContextRef contextRef) return toAPI(toImpl(contextRef)->cacheModel()); } +void WKContextSetProcessModel(WKContextRef contextRef, WKProcessModel processModel) +{ + toImpl(contextRef)->setProcessModel(toProcessModel(processModel)); +} + +WKProcessModel WKContextGetProcessModel(WKContextRef contextRef) +{ + return toAPI(toImpl(contextRef)->processModel()); +} + void WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef contextRef, bool alwaysUseComplexTextCodePath) { toImpl(contextRef)->setAlwaysUsesComplexTextCodePath(alwaysUseComplexTextCodePath); diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h index 967daea79..69d129805 100644 --- a/Source/WebKit2/UIProcess/API/C/WKContext.h +++ b/Source/WebKit2/UIProcess/API/C/WKContext.h @@ -123,6 +123,12 @@ typedef struct WKContextConnectionClient WKContextConnectionClient; enum { kWKContextConnectionClientCurrentVersion = 0 }; +enum { + kWKProcessModelSharedSecondaryProcess = 0, + kWKProcessModelMultipleSecondaryProcesses = 1 +}; +typedef uint32_t WKProcessModel; + WK_EXPORT WKTypeID WKContextGetTypeID(); WK_EXPORT WKContextRef WKContextCreate(); @@ -143,6 +149,9 @@ WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visited WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel); WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context); +WK_EXPORT void WKContextSetProcessModel(WKContextRef context, WKProcessModel processModel); +WK_EXPORT WKProcessModel WKContextGetProcessModel(WKContextRef context); + WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval); WK_EXPORT void WKContextStopMemorySampler(WKContextRef context); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 66d4dcd98..862e2d1b0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -817,14 +817,14 @@ bool WKPreferencesGetRequestAnimationFrameEnabled(WKPreferencesRef preferencesRe return toImpl(preferencesRef)->requestAnimationFrameEnabled(); } -void WKPreferencesSetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef, bool flag) +void WKPreferencesSetStorageBlockingPolicy(WKPreferencesRef preferencesRef, WKStorageBlockingPolicy policy) { - toImpl(preferencesRef)->setThirdPartyStorageBlockingEnabled(flag); + toImpl(preferencesRef)->setStorageBlockingPolicy(toStorageBlockingPolicy(policy)); } -bool WKPreferencesGetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef) +WKStorageBlockingPolicy WKPreferencesGetStorageBlockingPolicy(WKPreferencesRef preferencesRef) { - return toImpl(preferencesRef)->thirdPartyStorageBlockingEnabled(); + return toAPI(static_cast<WebCore::SecurityOrigin::StorageBlockingPolicy>(toImpl(preferencesRef)->storageBlockingPolicy())); } void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef) @@ -874,6 +874,26 @@ bool WKPreferencesGetArtificialPluginInitializationDelayEnabled(WKPreferencesRef return toImpl(preferencesRef)->artificialPluginInitializationDelayEnabled(); } +void WKPreferencesSetTabToLinksEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setTabToLinksEnabled(enabled); +} + +bool WKPreferencesGetTabToLinksEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->tabToLinksEnabled(); +} + +void WKPreferencesSetInteractiveFormValidationEnabled(WKPreferencesRef preferencesRef, bool enabled) +{ + toImpl(preferencesRef)->setInteractiveFormValidationEnabled(enabled); +} + +bool WKPreferencesGetInteractiveFormValidationEnabled(WKPreferencesRef preferencesRef) +{ + return toImpl(preferencesRef)->interactiveFormValidationEnabled(); +} + void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled) { toImpl(preferencesRef)->setScrollingPerformanceLoggingEnabled(enabled); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h index 883fbff61..c0fde67fd 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h @@ -36,6 +36,13 @@ extern "C" { #endif +enum WKStorageBlockingPolicy { + kWKAllowAllStorage = 0, + kWKBlockThirdPartyStorage, + kWKBlockAllStorage +}; +typedef enum WKStorageBlockingPolicy WKStorageBlockingPolicy; + WK_EXPORT WKTypeID WKPreferencesGetTypeID(); WK_EXPORT WKPreferencesRef WKPreferencesCreate(); @@ -206,8 +213,8 @@ WK_EXPORT void WKPreferencesSetShouldRespectImageOrientation(WKPreferencesRef pr WK_EXPORT bool WKPreferencesGetShouldRespectImageOrientation(WKPreferencesRef preferencesRef); // Defaults to false -WK_EXPORT void WKPreferencesSetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef, bool enabled); -WK_EXPORT bool WKPreferencesGetThirdPartyStorageBlockingEnabled(WKPreferencesRef preferencesRef); +WK_EXPORT void WKPreferencesSetStorageBlockingPolicy(WKPreferencesRef preferencesRef, WKStorageBlockingPolicy policy); +WK_EXPORT WKStorageBlockingPolicy WKPreferencesGetStorageBlockingPolicy(WKPreferencesRef preferencesRef); #ifdef __cplusplus } diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index b469d7aca..31899d47e 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -204,6 +204,14 @@ WK_EXPORT void WKPreferencesSetArtificialPluginInitializationDelayEnabled(WKPref WK_EXPORT bool WKPreferencesGetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef); // Defaults to false +WK_EXPORT void WKPreferencesSetTabToLinksEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetTabToLinksEnabled(WKPreferencesRef preferencesRef); + +// Defaults to false +WK_EXPORT void WKPreferencesSetInteractiveFormValidationEnabled(WKPreferencesRef preferencesRef, bool enabled); +WK_EXPORT bool WKPreferencesGetInteractiveFormValidationEnabled(WKPreferencesRef preferencesRef); + +// Defaults to false WK_EXPORT void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled); WK_EXPORT bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef); diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index d98023de6..750cb4864 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -38,6 +38,8 @@ #include "ewk_intent_service.h" #include "ewk_main.h" #include "ewk_navigation_policy_decision.h" +#include "ewk_popup_menu_item.h" +#include "ewk_settings.h" #include "ewk_url_request.h" #include "ewk_url_response.h" #include "ewk_url_scheme_request.h" diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp index f5740822e..eb3d007fe 100644 --- a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp @@ -31,22 +31,28 @@ #include "LayerTreeCoordinatorProxy.h" #include "LayerTreeRenderer.h" #include "TransformationMatrix.h" +#include "ewk_view_private.h" using namespace WebCore; namespace WebKit { -EflViewportHandler::EflViewportHandler(PageClientImpl* pageClientImpl) - : m_pageClientImpl(pageClientImpl) +EflViewportHandler::EflViewportHandler(Evas_Object* viewWidget) + : m_viewWidget(viewWidget) , m_scaleFactor(1) { - ASSERT(m_pageClientImpl); + ASSERT(m_viewWidget); } EflViewportHandler::~EflViewportHandler() { } +DrawingAreaProxy* EflViewportHandler::drawingArea() const +{ + return ewk_view_page_get(m_viewWidget)->drawingArea(); +} + void EflViewportHandler::display(const IntRect& rect) { WebCore::TransformationMatrix matrix; @@ -61,7 +67,7 @@ void EflViewportHandler::display(const IntRect& rect) void EflViewportHandler::updateViewportSize(const IntSize& viewportSize) { m_viewportSize = viewportSize; - m_pageClientImpl->page()->setViewportSize(viewportSize); + ewk_view_page_get(m_viewWidget)->setViewportSize(viewportSize); setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint()); } diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h index cc6b3d957..a23f4e147 100644 --- a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h @@ -35,13 +35,13 @@ namespace WebKit { class EflViewportHandler { public: - static PassOwnPtr<EflViewportHandler> create(PageClientImpl* pageClientImpl) + static PassOwnPtr<EflViewportHandler> create(Evas_Object* viewWidget) { - return adoptPtr(new EflViewportHandler(pageClientImpl)); + return adoptPtr(new EflViewportHandler(viewWidget)); } ~EflViewportHandler(); - DrawingAreaProxy* drawingArea() const { return m_pageClientImpl->page()->drawingArea(); } + DrawingAreaProxy* drawingArea() const; WebCore::IntSize viewSize() { return m_viewportSize; } void display(const WebCore::IntRect& rect); @@ -50,9 +50,9 @@ public: void didChangeContentsSize(const WebCore::IntSize& size); private: - explicit EflViewportHandler(PageClientImpl*); + explicit EflViewportHandler(Evas_Object*); - PageClientImpl* m_pageClientImpl; + Evas_Object* m_viewWidget; WebCore::IntRect m_visibleContentRect; WebCore::IntSize m_contentsSize; WebCore::IntSize m_viewportSize; diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 726caaae1..24bda6305 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -33,6 +33,7 @@ #include "WebContextMenuProxy.h" #include "WebPageGroup.h" #include "WebPageProxy.h" +#include "WebPopupMenuProxyEfl.h" #include "WebPreferences.h" #include "ewk_context.h" #include "ewk_context_private.h" @@ -44,18 +45,9 @@ using namespace WebCore; namespace WebKit { -PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget) +PageClientImpl::PageClientImpl(Evas_Object* viewWidget) : m_viewWidget(viewWidget) { - m_page = context->createWebPage(this, pageGroup); - -#if USE(COORDINATED_GRAPHICS) - m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); - m_page->pageGroup()->preferences()->setForceCompositingMode(true); - m_page->setUseFixedLayout(true); -#endif - - m_page->initializeWebPage(); } PageClientImpl::~PageClientImpl() @@ -65,7 +57,7 @@ PageClientImpl::~PageClientImpl() // PageClient PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() { - return DrawingAreaProxyImpl::create(m_page.get()); + return DrawingAreaProxyImpl::create(ewk_view_page_get(m_viewWidget)); } void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) @@ -204,10 +196,9 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEven } #endif -PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy*) +PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) { - notImplemented(); - return 0; + return WebPopupMenuProxyEfl::create(m_viewWidget, page); } PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy*) @@ -217,7 +208,7 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr } #if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&) +PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) { notImplemented(); return 0; diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 861850263..36ee76d7d 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -33,18 +33,17 @@ namespace WebKit { class PageClientImpl : public PageClient { public: - static PassOwnPtr<PageClientImpl> create(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget) + static PassOwnPtr<PageClientImpl> create(Evas_Object* viewWidget) { - return adoptPtr(new PageClientImpl(context, pageGroup, viewWidget)); + return adoptPtr(new PageClientImpl(viewWidget)); } ~PageClientImpl(); Evas_Object* viewWidget() const { return m_viewWidget; } - WebPageProxy* page() const { return m_page.get(); } private: - PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*); + explicit PageClientImpl(Evas_Object*); // PageClient virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); @@ -87,7 +86,7 @@ private: virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); #if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor); + virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&); #endif virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool); @@ -115,7 +114,6 @@ private: virtual void didChangeContentsSize(const WebCore::IntSize&); private: - RefPtr<WebPageProxy> m_page; Evas_Object* m_viewWidget; }; 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 acf8d5645..f6bd0a760 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp @@ -84,6 +84,24 @@ static inline Ewk_Back_Forward_List_Item* addItemToWrapperCache(const Ewk_Back_F return item; } +static inline Eina_List* createEinaList(const Ewk_Back_Forward_List* list, WKArrayRef wkList) +{ + if (!wkList) + return 0; + + Eina_List* result = 0; + + const size_t count = WKArrayGetSize(wkList); + for (size_t i = 0; i < count; ++i) { + WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkList, i)); + Ewk_Back_Forward_List_Item* item = addItemToWrapperCache(list, wkItem); + ewk_back_forward_list_item_ref(item); + result = eina_list_append(result, item); + } + + return result; +} + Ewk_Back_Forward_List_Item* ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List* list) { EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); @@ -121,6 +139,29 @@ unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List* list) return WKBackForwardListGetBackListCount(wkList) + WKBackForwardListGetForwardListCount(wkList) + currentItem; } +Eina_List* ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_List* list, int limit) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + if (limit == -1) + limit = WKBackForwardListGetBackListCount(wkList); + EINA_SAFETY_ON_FALSE_RETURN_VAL(limit >= 0, 0); + WKRetainPtr<WKArrayRef> backList(AdoptWK, WKBackForwardListCopyBackListWithLimit(wkList, limit)); + + return createEinaList(list, backList.get()); +} + +Eina_List* ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forward_List* list, int limit) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + if (limit == -1) + limit = WKBackForwardListGetForwardListCount(wkList); + EINA_SAFETY_ON_FALSE_RETURN_VAL(limit >= 0, 0); + WKRetainPtr<WKArrayRef> forwardList(AdoptWK, WKBackForwardListCopyForwardListWithLimit(wkList, limit)); + + return createEinaList(list, forwardList.get()); +} /** * @internal diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h index 5b9cca726..c58476140 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h @@ -86,6 +86,68 @@ EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_at_index_get(const E */ EAPI unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list); +/** + * Creates the list containing the items preceding the current item limited by @a limit. + * + * The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one. + * if @a limit is equal to @c -1 all the items preceding the current item are returned. + * + * @param list the back-forward list instance + * @param limit the number of items to retrieve + * + * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * to free the items + */ +EAPI Eina_List *ewk_back_forward_list_n_back_items_copy(const Ewk_Back_Forward_List *list, int limit); + +/** + * Creates the list containing the items following the current item limited by @a limit. + * + * The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one. + * if @a limit is equal to @c -1 all the items preceding the current item are returned. + * + * @param list the back-forward list instance + * @param limit the number of items to retrieve + * + * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * to free the items + */ +EAPI Eina_List *ewk_back_forward_list_n_forward_items_copy(const Ewk_Back_Forward_List *list, int limit); + +/** + * Creates the list containing the items preceding the current item. + * + * The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one. + * + * @param list the back-forward list instance + * + * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * to free the items + * + * @see ewk_back_forward_list_n_back_items_copy + */ +#define ewk_back_forward_list_back_items_copy(list) \ + ewk_back_forward_list_n_back_items_copy(list, -1) + +/** + * Creates the list containing the items following the current item. + * + * The @c Ewk_Back_Forward_List_Item elements are located in the result list starting with the oldest one. + * + * @param list the back-forward list instance + * + * @return @c Eina_List containing @c Ewk_Back_Forward_List_Item elements or @c NULL in case of error, + * the Eina_List and its items should be freed after use. Use ewk_back_forward_list_item_unref() + * to free the items + * + * @see ewk_back_forward_list_n_forward_items_copy + */ +#define ewk_back_forward_list_forward_items_copy(list) \ + ewk_back_forward_list_n_forward_items_copy(list, -1) + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index 71504f641..60c79e16e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -25,6 +25,7 @@ #include "VibrationProvider.h" #include "WKAPICast.h" #include "WKContextSoup.h" +#include "WKNumber.h" #include "WKRetainPtr.h" #include "WKString.h" #include "ewk_context_download_client_private.h" @@ -85,6 +86,16 @@ struct _Ewk_Context { vibrationProvider = VibrationProvider::create(wkVibrationRef); #endif +#if ENABLE(MEMORY_SAMPLER) + static bool initializeMemorySampler = false; + static const char environmentVariable[] = "SAMPLE_MEMORY"; + + if (!initializeMemorySampler && getenv(environmentVariable)) { + WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(0.0)); + WKContextStartMemorySampler(context.get(), interval.get()); + initializeMemorySampler = true; + } +#endif ewk_context_request_manager_client_attach(this); ewk_context_download_client_attach(this); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp new file mode 100644 index 000000000..566bbef89 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_popup_menu_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()) + { } +}; + +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); + + return item->type; +} + +const char* ewk_popup_menu_item_text_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->text; +} + +Ewk_Text_Direction ewk_popup_menu_item_text_direction_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, EWK_TEXT_DIRECTION_LEFT_TO_RIGHT); + + return item->textDirection; +} + +Eina_Bool ewk_popup_menu_item_text_direction_override_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, false); + + return item->hasTextDirectionOverride; +} + +const char* ewk_popup_menu_item_tooltip_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->toolTip; +} + +const char* ewk_popup_menu_item_accessibility_text_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->accessibilityText; +} + +Eina_Bool ewk_popup_menu_item_enabled_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, false); + + return item->isEnabled; +} + +Eina_Bool ewk_popup_menu_item_is_label_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, false); + + return item->isLabel; +} + +Eina_Bool ewk_popup_menu_item_selected_get(const Ewk_Popup_Menu_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, false); + + return item->isSelected; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.h b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.h new file mode 100644 index 000000000..b96d4366d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item.h @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_popup_menu_item.h + * @brief Describes the Ewk Popup Menu Item API. + */ + +#ifndef ewk_popup_menu_item_h +#define ewk_popup_menu_item_h + +#include "ewk_view.h" +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Enum values containing type of popup menu item. */ +typedef enum { + EWK_POPUP_MENU_SEPARATOR, + EWK_POPUP_MENU_ITEM, + EWK_POPUP_MENU_UNKNOWN = -1 +} Ewk_Popup_Menu_Item_Type; + +/** Creates a type name for _Ewk_Popup_Menu_Item */ +typedef struct _Ewk_Popup_Menu_Item Ewk_Popup_Menu_Item; + +/** + * Returns type of the popup menu item. + * + * @param item the popup menu item instance + * + * @return the type of the @a item or @c EWK_POPUP_MENU_UNKNOWN in case of error. + */ +EAPI Ewk_Popup_Menu_Item_Type ewk_popup_menu_item_type_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns text of the popup menu item. + * + * @param item the popup menu item instance + * + * @return the text 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_popup_menu_item_text_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns text direction of the popup menu item. + * + * @param item the popup menu item instance + * + * @return the text direction of the @a item. + */ +EAPI Ewk_Text_Direction ewk_popup_menu_item_text_direction_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns whether the popup menu item has text direction override. + * + * @param item the popup menu item instance + * + * @return @c EINA_TRUE if the popup menu item has text direction override, + * @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_popup_menu_item_text_direction_override_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns tooltip of the popup menu item. + * + * @param item the popup menu item instance + * + * @return the tooltip 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_popup_menu_item_tooltip_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns accessibility text of the popup menu item. + * + * @param item the popup menu item instance + * + * @return the accessibility text 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_popup_menu_item_accessibility_text_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns whether the popup menu item is enabled or not. + * + * @param item the popup menu item instance + * + * @return @c EINA_TRUE if ther popup menu item is enabled, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_popup_menu_item_enabled_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns whether the popup menu item is label or not. + * + * @param item the popup menu item instance + * + * @return @c EINA_TRUE if the popup menu item is label, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_popup_menu_item_is_label_get(const Ewk_Popup_Menu_Item *item); + +/** + * Returns whether the popup menu item is selected or not. + * + * @param item the popup menu item instance + * + * @return @c EINA_TRUE if the popup menu item is selected, @c EINA_FALSE otherwise. + */ +EAPI Eina_Bool ewk_popup_menu_item_selected_get(const Ewk_Popup_Menu_Item *item); + +#ifdef __cplusplus +} +#endif +#endif // ewk_popup_menu_item_h 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 new file mode 100644 index 000000000..6a4a435bf --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_popup_menu_item_private.h @@ -0,0 +1,34 @@ +/* + * 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_popup_menu_item_private_h +#define ewk_popup_menu_item_private_h + +#include "WebPopupItem.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); + +#endif // ewk_popup_menu_item_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp new file mode 100644 index 000000000..9055ce7eb --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_settings.h" + +#include "ewk_settings_private.h" +#include <WebKit2/WKPreferences.h> + +using namespace WebKit; + +Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool enable) +{ +#if ENABLE(FULLSCREEN_API) + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + WKPreferencesSetFullScreenEnabled(settings->preferences.get(), enable); + return true; +#else + return false; +#endif +} + +Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings* settings) +{ +#if ENABLE(FULLSCREEN_API) + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + return WKPreferencesGetFullScreenEnabled(settings->preferences.get()); +#else + return false; +#endif +} + +Eina_Bool ewk_settings_javascript_enabled_set(Ewk_Settings* settings, Eina_Bool enable) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + WKPreferencesSetJavaScriptEnabled(settings->preferences.get(), enable); + + return true; +} + +Eina_Bool ewk_settings_javascript_enabled_get(const Ewk_Settings* settings) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + return WKPreferencesGetJavaScriptEnabled(settings->preferences.get()); +} + +Eina_Bool ewk_settings_loads_images_automatically_set(Ewk_Settings* settings, Eina_Bool automatic) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + WKPreferencesSetLoadsImagesAutomatically(settings->preferences.get(), automatic); + + return true; +} + +Eina_Bool ewk_settings_loads_images_automatically_get(const Ewk_Settings* settings) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + + return WKPreferencesGetLoadsImagesAutomatically(settings->preferences.get()); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings.h b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h new file mode 100644 index 000000000..a28d40be2 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_settings.h + * @brief Describes the settings API. + * + * @note The ewk_settings is for setting the preference of specific ewk_view. + * We can get the ewk_settings from ewk_view using ewk_view_settings_get() API. + */ + +#ifndef ewk_settings_h +#define ewk_settings_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Settings */ +typedef struct _Ewk_Settings Ewk_Settings; + +/** + * 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 + * + * Default value for Javascript Fullscreen API setting is @c EINA_TRUE . + * + * @param settings settings object to enable Javascript Fullscreen API + * @param enable @c EINA_TRUE to enable Javascript Fullscreen API or + * @c EINA_FALSE to disable + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings *settings, Eina_Bool enable); + +/** + * Returns whether the Javascript Fullscreen API is enabled or not. + * + * @param settings settings object to query whether Javascript Fullscreen API is enabled + * + * @return @c EINA_TRUE if the Javascript Fullscreen API is enabled + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_settings_fullscreen_enabled_get(const Ewk_Settings *settings); + +/** + * Enables/disables the javascript executing. + * + * @param settings settings object to set javascript executing + * @param enable @c EINA_TRUE to enable javascript executing + * @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. + * + * @param settings settings object to query if the javascript can be executed + * + * @return @c EINA_TRUE if the javascript can be executed + * @c EINA_FALSE if not or on failure + */ +EAPI Eina_Bool ewk_settings_javascript_enabled_get(const Ewk_Settings *settings); + +/** + * Enables/disables auto loading of the images. + * + * @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 + * + * @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. + * + * @param settings settings object to get auto loading of the images + * + * @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); + +#ifdef __cplusplus +} +#endif +#endif // ewk_settings_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h new file mode 100644 index 000000000..2c9da0d7c --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_settings_private.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_settings_private_h +#define ewk_settings_private_h + +#include "ewk_settings.h" +#include <WebKit2/WKPreferences.h> +#include <WebKit2/WKRetainPtr.h> +#include <wtf/PassOwnPtr.h> + +/** Creates a type name for _Ewk_Settings */ +typedef struct _Ewk_Settings Ewk_Settings; + +/** + * \struct _Ewk_Settings + * @brief Contains the settings data. + */ +struct _Ewk_Settings { + WKRetainPtr<WKPreferencesRef> preferences; + + explicit _Ewk_Settings(WKPreferencesRef wkPreferences) + : preferences(wkPreferences) + { } +}; + +#endif // ewk_settings_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index ce7f7b454..9971b1634 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -31,11 +31,19 @@ #include "WKRetainPtr.h" #include "WKString.h" #include "WKURL.h" +#include "WebContext.h" +#include "WebPageGroup.h" +#include "WebPopupItem.h" +#include "WebPopupMenuProxyEfl.h" +#include "WebPreferences.h" #include "ewk_back_forward_list_private.h" #include "ewk_context.h" #include "ewk_context_private.h" #include "ewk_intent_private.h" +#include "ewk_popup_menu_item.h" +#include "ewk_popup_menu_item_private.h" #include "ewk_private.h" +#include "ewk_settings_private.h" #include "ewk_view_find_client_private.h" #include "ewk_view_form_client_private.h" #include "ewk_view_loader_client_private.h" @@ -48,8 +56,13 @@ #include <Edje.h> #include <WebCore/Cursor.h> #include <WebCore/EflScreenUtilities.h> +#include <WebKit2/WKPageGroup.h> #include <wtf/text/CString.h> +#if ENABLE(FULLSCREEN_API) +#include "WebFullScreenManagerProxy.h" +#endif + #if USE(ACCELERATED_COMPOSITING) #include <Evas_GL.h> #endif @@ -73,6 +86,7 @@ struct _Ewk_View_Private_Data { #if USE(COORDINATED_GRAPHICS) OwnPtr<EflViewportHandler> viewportHandler; #endif + RefPtr<WebPageProxy> pageProxy; WKEinaSharedString uri; WKEinaSharedString title; @@ -82,6 +96,11 @@ struct _Ewk_View_Private_Data { Evas_Object* cursorObject; LoadingResourcesMap loadingResourcesMap; Ewk_Back_Forward_List* backForwardList; + OwnPtr<Ewk_Settings> settings; + bool areMouseEventsEnabled; + + WebPopupMenuProxyEfl* popupMenuProxy; + Eina_List* popupMenuItems; #ifdef HAVE_ECORE_X bool isUsingEcoreX; @@ -96,6 +115,9 @@ struct _Ewk_View_Private_Data { _Ewk_View_Private_Data() : cursorObject(0) , backForwardList(0) + , areMouseEventsEnabled(false) + , popupMenuProxy(0) + , popupMenuItems(0) #ifdef HAVE_ECORE_X , isUsingEcoreX(false) #endif @@ -114,6 +136,10 @@ struct _Ewk_View_Private_Data { 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)); } }; @@ -148,15 +174,17 @@ struct _Ewk_View_Private_Data { EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \ Ewk_View_Smart_Data* smartData = 0; \ if (_tmp_result) \ - smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView); + smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView) #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \ EWK_VIEW_SD_GET(ewkView, smartData); \ - if (!smartData) { \ - EINA_LOG_CRIT("no smart data for object %p (%s)", \ - ewkView, evas_object_type_get(ewkView)); \ - return __VA_ARGS__; \ - } + do { \ + if (!smartData) { \ + EINA_LOG_CRIT("no smart data for object %p (%s)", \ + ewkView, evas_object_type_get(ewkView)); \ + return __VA_ARGS__; \ + } \ + } while (0) #define EWK_VIEW_PRIV_GET(smartData, priv) \ Ewk_View_Private_Data* priv = smartData->priv @@ -167,11 +195,13 @@ struct _Ewk_View_Private_Data { return __VA_ARGS__; \ } \ EWK_VIEW_PRIV_GET(smartData, priv); \ - if (!priv) { \ - EINA_LOG_CRIT("no private data for object %p (%s)", \ - smartData->self, evas_object_type_get(smartData->self)); \ - return __VA_ARGS__; \ - } + do { \ + if (!priv) { \ + EINA_LOG_CRIT("no private data for object %p (%s)", \ + smartData->self, evas_object_type_get(smartData->self)); \ + return __VA_ARGS__; \ + } \ + } while (0) static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData) { @@ -184,69 +214,69 @@ static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData) // Default Event Handling. static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); + priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); return true; } static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); + priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive); return true; } static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position)); + priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position)); return true; } static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position)); + priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(downEvent, &position)); return true; } static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position)); + priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(upEvent, &position)); return true; } static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); Evas_Point position = {smartData->view.x, smartData->view.y}; - priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position)); + priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position)); return true; } static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent)); + priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent)); return true; } static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent) { - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent)); + priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent)); return true; } @@ -390,13 +420,12 @@ static void _ewk_view_smart_add(Evas_Object* ewkView) evas_object_smart_member_add(smartData->image, ewkView); evas_object_show(smartData->image); + ewk_view_mouse_events_enabled_set(ewkView, true); + #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData) CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in); CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out); CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel); - CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down); - CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up); - CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move); CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down); CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up); #undef CONNECT @@ -534,8 +563,8 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) priv->viewportHandler->updateViewportSize(IntSize(width, height)); #endif - if (priv->pageClient->page()->drawingArea()) - priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); + if (priv->pageProxy->drawingArea()) + priv->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize()); #if USE(ACCELERATED_COMPOSITING) if (!priv->evasGlSurface) @@ -597,8 +626,8 @@ static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, #undef CHECK_COLOR evas_object_image_alpha_set(smartData->image, alpha < 255); - priv->pageClient->page()->setDrawsBackground(red || green || blue); - priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255); + priv->pageProxy->setDrawsBackground(red || green || blue); + priv->pageProxy->setDrawsTransparentBackground(alpha < 255); g_parentSmartClass.color_set(ewkView, red, green, blue, alpha); } @@ -658,28 +687,43 @@ static inline Evas_Smart* _ewk_view_smart_class_new(void) static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); - EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); EINA_SAFETY_ON_NULL_RETURN(context); if (priv->pageClient) return; - priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView); - priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList())); + priv->pageClient = PageClientImpl::create(ewkView); + if (pageGroupRef) + 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()); #if USE(COORDINATED_GRAPHICS) - priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get()); + priv->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); + priv->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true); + priv->pageProxy->setUseFixedLayout(true); #endif + priv->pageProxy->initializeWebPage(); + + priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageProxy->backForwardList())); + priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get()))))); - WKPageRef wkPage = toAPI(priv->pageClient->page()); +#if USE(COORDINATED_GRAPHICS) + priv->viewportHandler = EflViewportHandler::create(ewkView); +#endif + + WKPageRef wkPage = toAPI(priv->pageProxy.get()); ewk_view_find_client_attach(wkPage, ewkView); ewk_view_form_client_attach(wkPage, ewkView); ewk_view_loader_client_attach(wkPage, ewkView); ewk_view_policy_client_attach(wkPage, ewkView); ewk_view_resource_load_client_attach(wkPage, ewkView); ewk_view_ui_client_attach(wkPage, ewkView); - - ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj"); +#if ENABLE(FULLSCREEN_API) + priv->pageProxy->fullScreenManager()->setWebView(ewkView); + ewk_settings_fullscreen_enabled_set(priv->settings.get(), true); +#endif } static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) @@ -759,7 +803,7 @@ void ewk_view_uri_update(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); - String activeURL = priv->pageClient->page()->activeURL(); + String activeURL = priv->pageProxy->activeURL(); if (activeURL.isEmpty()) return; @@ -777,7 +821,7 @@ Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false); - priv->pageClient->page()->loadURL(uri); + priv->pageProxy->loadURL(uri); ewk_view_uri_update(ewkView); return true; @@ -796,7 +840,7 @@ Eina_Bool ewk_view_reload(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->reload(/*reloadFromOrigin*/ false); + priv->pageProxy->reload(/*reloadFromOrigin*/ false); ewk_view_uri_update(ewkView); return true; @@ -807,7 +851,7 @@ Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->reload(/*reloadFromOrigin*/ true); + priv->pageProxy->reload(/*reloadFromOrigin*/ true); ewk_view_uri_update(ewkView); return true; @@ -818,11 +862,19 @@ Eina_Bool ewk_view_stop(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->stopLoading(); + priv->pageProxy->stopLoading(); return true; } +Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + + return priv->settings.get(); +} + /** * @internal * Load was initiated for a resource in the view. @@ -926,7 +978,7 @@ const char* ewk_view_title_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - CString title = priv->pageClient->page()->pageTitle().utf8(); + CString title = priv->pageProxy->pageTitle().utf8(); priv->title = title.data(); return priv->title; @@ -959,7 +1011,7 @@ double ewk_view_load_progress_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); - return priv->pageClient->page()->estimatedProgress(); + return priv->pageProxy->estimatedProgress(); } Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y) @@ -967,7 +1019,7 @@ Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, in EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y)); + priv->pageProxy->scalePage(scaleFactor, IntPoint(x, y)); return true; } @@ -976,7 +1028,7 @@ double ewk_view_scale_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1); - return priv->pageClient->page()->pageScaleFactor(); + return priv->pageProxy->pageScaleFactor(); } Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio) @@ -984,7 +1036,7 @@ Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - priv->pageClient->page()->setCustomDeviceScaleFactor(ratio); + priv->pageProxy->setCustomDeviceScaleFactor(ratio); return true; } @@ -994,7 +1046,7 @@ float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0); - return priv->pageClient->page()->deviceScaleFactor(); + return priv->pageProxy->deviceScaleFactor(); } /** @@ -1028,7 +1080,7 @@ void ewk_view_theme_set(Evas_Object* ewkView, const char* path) if (priv->theme != path) { priv->theme = path; - priv->pageClient->page()->setThemePath(path); + priv->pageProxy->setThemePath(path); } } @@ -1108,6 +1160,37 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height()); } +#if ENABLE(FULLSCREEN_API) +/** + * @internal + * Calls fullscreen_enter callback or falls back to default behavior and enables fullscreen mode. + */ +void ewk_view_full_screen_enter(Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + + if (!smartData->api->fullscreen_enter || !smartData->api->fullscreen_enter(smartData)) { + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); + ecore_evas_fullscreen_set(ecoreEvas, true); + } +} + +/** + * @internal + * Calls fullscreen_exit callback or falls back to default behavior and disables fullscreen mode. + */ +void ewk_view_full_screen_exit(Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + + if (!smartData->api->fullscreen_exit || !smartData->api->fullscreen_exit(smartData)) { + Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas); + ecore_evas_fullscreen_set(ecoreEvas, false); + } +} +#endif + + /** * @internal * A download for that view was cancelled. @@ -1158,7 +1241,7 @@ Eina_Bool ewk_view_back(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WebPageProxy* page = priv->pageClient->page(); + WebPageProxy* page = priv->pageProxy.get(); if (page->canGoBack()) { page->goBack(); return true; @@ -1172,7 +1255,7 @@ Eina_Bool ewk_view_forward(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - WebPageProxy* page = priv->pageClient->page(); + WebPageProxy* page = priv->pageProxy.get(); if (page->canGoForward()) { page->goForward(); return true; @@ -1188,7 +1271,7 @@ Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent) EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false); - WebPageProxy* page = priv->pageClient->page(); + WebPageProxy* page = priv->pageProxy.get(); page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent))); return true; @@ -1202,7 +1285,7 @@ Eina_Bool ewk_view_back_possible(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - return priv->pageClient->page()->canGoBack(); + return priv->pageProxy->canGoBack(); } Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) @@ -1210,7 +1293,7 @@ Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); - return priv->pageClient->page()->canGoForward(); + return priv->pageProxy->canGoForward(); } Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView) @@ -1337,9 +1420,9 @@ Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, cons EINA_SAFETY_ON_NULL_RETURN_VAL(html, false); if (unreachableUrl && *unreachableUrl) - priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); + priv->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl)); else - priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); + priv->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : ""); ewk_view_uri_update(ewkView); return true; @@ -1363,7 +1446,7 @@ WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - return priv->pageClient->page(); + return priv->pageProxy.get(); } const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView) @@ -1371,7 +1454,7 @@ const char* ewk_view_setting_encoding_custom_get(const Evas_Object* ewkView) EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); - String customEncoding = priv->pageClient->page()->customTextEncodingName(); + String customEncoding = priv->pageProxy->customTextEncodingName(); if (customEncoding.isEmpty()) return 0; @@ -1386,7 +1469,7 @@ Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); priv->customEncoding = encoding; - priv->pageClient->page()->setCustomTextEncodingName(encoding ? encoding : String()); + priv->pageProxy->setCustomTextEncodingName(encoding ? encoding : String()); return true; } @@ -1424,7 +1507,7 @@ Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Op EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text)); - WKPageFindString(toAPI(priv->pageClient->page()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount); + WKPageFindString(toAPI(priv->pageProxy.get()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount); return true; } @@ -1434,7 +1517,7 @@ 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->pageClient->page())); + WKPageHideFindUI(toAPI(priv->pageProxy.get())); return true; } @@ -1448,3 +1531,96 @@ void ewk_view_contents_size_changed(const Evas_Object* ewkView, const IntSize& s priv->viewportHandler->didChangeContentsSize(size); #endif } + +COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, RTL); +COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, LTR); + +void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + EINA_SAFETY_ON_NULL_RETURN(smartData->api); + + ASSERT(popupMenu); + + if (!smartData->api->popup_menu_show) + return; + + if (priv->popupMenuProxy) + ewk_view_popup_menu_close(ewkView); + priv->popupMenuProxy = popupMenu; + + Eina_List* popupItems = 0; + size_t size = items.size(); + for (size_t i = 0; i < size; ++i) + popupItems = eina_list_append(popupItems, ewk_popup_menu_item_new(items[i])); + priv->popupMenuItems = popupItems; + + smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex); +} + +Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false); + + if (!priv->popupMenuProxy) + return false; + + priv->popupMenuProxy = 0; + + if (smartData->api->popup_menu_hide) + smartData->api->popup_menu_hide(smartData); + + void* item; + EINA_LIST_FREE(priv->popupMenuItems, item) + ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item)); + + return true; +} + +Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false); + + if (selectedIndex >= eina_list_count(priv->popupMenuItems)) + return false; + + priv->popupMenuProxy->valueChanged(selectedIndex); + + return true; +} + +Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + enabled = !!enabled; + if (priv->areMouseEventsEnabled == enabled) + return true; + + priv->areMouseEventsEnabled = enabled; + if (enabled) { + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData); + evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData); + } else { + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up); + evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move); + } + + return true; +} + +Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + return priv->areMouseEventsEnabled; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index afa45846f..b040fdf30 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -73,6 +73,7 @@ #include "ewk_context.h" #include "ewk_download_job.h" #include "ewk_intent.h" +#include "ewk_settings.h" #include "ewk_url_request.h" #include "ewk_url_response.h" #include "ewk_web_error.h" @@ -83,6 +84,12 @@ extern "C" { #endif +/// Enum values containing text directionality values. +typedef enum { + EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, + EWK_TEXT_DIRECTION_LEFT_TO_RIGHT +} Ewk_Text_Direction; + typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data; typedef struct _Ewk_View_Smart_Class Ewk_View_Smart_Class; @@ -91,11 +98,16 @@ struct _Ewk_View_Smart_Class { Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */ unsigned long version; + Eina_Bool (*popup_menu_show)(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List *items, int selected_index); + Eina_Bool (*popup_menu_hide)(Ewk_View_Smart_Data *sd); + // event handling: // - returns true if handled // - if overridden, have to call parent method if desired Eina_Bool (*focus_in)(Ewk_View_Smart_Data *sd); Eina_Bool (*focus_out)(Ewk_View_Smart_Data *sd); + Eina_Bool (*fullscreen_enter)(Ewk_View_Smart_Data *sd); + Eina_Bool (*fullscreen_exit)(Ewk_View_Smart_Data *sd); Eina_Bool (*mouse_wheel)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Wheel *ev); Eina_Bool (*mouse_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Down *ev); Eina_Bool (*mouse_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Up *ev); @@ -108,7 +120,7 @@ struct _Ewk_View_Smart_Class { * The version you have to put into the version field * in the @a Ewk_View_Smart_Class structure. */ -#define EWK_VIEW_SMART_CLASS_VERSION 1UL +#define EWK_VIEW_SMART_CLASS_VERSION 3UL /** * Initializer for whole Ewk_View_Smart_Class structure. @@ -120,7 +132,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} +#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} /** * Initializer to zero a whole Ewk_View_Smart_Class structure. @@ -347,6 +359,15 @@ EAPI Eina_Bool ewk_view_reload_bypass_cache(Evas_Object *o); EAPI Eina_Bool ewk_view_stop(Evas_Object *o); /** + * Gets the Ewk_Settings of this view. + * + * @param o view object to get Ewk_Settings + * + * @return the Ewk_Settings of this view or @c NULL on failure + */ +EAPI Ewk_Settings *ewk_view_settings_get(const Evas_Object *o); + +/** * Delivers a Web intent to the view's main frame. * * @param o view object to deliver the intent to @@ -534,7 +555,7 @@ EAPI Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object *o, float ratio); * use this one. * * @param o view object to change theme - * @param path theme path, may be @c NULL to reset to the default theme + * @param path theme path */ EAPI void ewk_view_theme_set(Evas_Object *o, const char *path); @@ -590,6 +611,49 @@ EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Opt */ EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o); +/** + * Selects index of current popup menu. + * + * @param o view object contains popup menu. + * @param index index of item to select + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (probably + * popup menu is not selected or index is out of range) + */ +EAPI Eina_Bool ewk_view_popup_menu_select(Evas_Object *o, unsigned int index); + +/** + * Closes current popup menu. + * + * @param o view object contains popup menu. + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (probably + * popup menu is not selected) + */ +EAPI Eina_Bool ewk_view_popup_menu_close(Evas_Object *o); + +/** + * Sets whether the ewk_view supports the mouse events or not. + * + * The ewk_view will support the mouse events if EINA_TRUE or not support the + * mouse events otherwise. The default value is EINA_TRUE. + * + * @param o view object to enable/disable the mouse events + * @param enabled a state to set + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure + */ +EAPI Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object *o, Eina_Bool enabled); + +/** + * Queries if the ewk_view supports the mouse events. + * + * @param o view object to query if the mouse events are enabled + * + * @return @c EINA_TRUE if the mouse events are enabled or @c EINA_FALSE otherwise + */ +EAPI Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *o); + #ifdef __cplusplus } #endif 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 6e2540f80..cf3b85e09 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_policy_client.cpp @@ -31,6 +31,7 @@ #include "ewk_navigation_policy_decision_private.h" #include "ewk_view_policy_client_private.h" #include "ewk_view_private.h" +#include <WebCore/HTTPStatusCodes.h> #include <wtf/text/CString.h> using namespace WebCore; @@ -58,6 +59,13 @@ static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKF static void decidePolicyForResponseCallback(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo) { const ResourceResponse resourceResponse = toImpl(response)->resourceResponse(); + + // Ignore responses with an HTTP status code of 204 (No Content) + if (resourceResponse.httpStatusCode() == HTTPNoContent) { + WKFramePolicyListenerIgnore(listener); + return; + } + // If the URL Response has "Content-Disposition: attachment;" header, then // we should download it. if (resourceResponse.isAttachment()) { diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index f40298587..fcd65ee0f 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -23,7 +23,9 @@ #include "WebPageProxy.h" #include <Evas.h> +#include <WebCore/TextDirection.h> #include <WebKit2/WKBase.h> +#include <wtf/Vector.h> namespace WebCore { class Cursor; @@ -31,6 +33,11 @@ class IntRect; class IntSize; } +namespace WebKit { +class WebPopupItem; +class WebPopupMenuProxyEfl; +} + typedef struct _Ewk_Download_Job Ewk_Download_Job; typedef struct _Ewk_Form_Submission_Request Ewk_Form_Submission_Request; typedef struct _Ewk_Url_Request Ewk_Url_Request; @@ -52,6 +59,10 @@ void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job*, Ewk_W void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job*); void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job*); void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request*); +#if ENABLE(FULLSCREEN_API) +void ewk_view_full_screen_enter(Evas_Object* ewkView); +void ewk_view_full_screen_exit(Evas_Object* ewkView); +#endif void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const WebCore::IntSize& size); void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error); void ewk_view_load_finished(Evas_Object* ewkView); @@ -89,4 +100,6 @@ bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView); bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView); #endif +void ewk_view_popup_menu_request(Evas_Object* ewkView, WebKit::WebPopupMenuProxyEfl* popupMenu, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex); + #endif // ewk_view_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp index 39bc5a4db..8033e2498 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp @@ -21,7 +21,6 @@ #include "EWK2UnitTestBase.h" #include "EWK2UnitTestEnvironment.h" -#include <EWebKit2.h> #include <Ecore.h> #include <glib-object.h> #include <wtf/UnusedParam.h> @@ -42,7 +41,9 @@ static void onLoadFinished(void* userData, Evas_Object* webView, void* eventInfo EWK2UnitTestBase::EWK2UnitTestBase() : m_ecoreEvas(0) , m_webView(0) + , m_ewkViewClass(EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Browser_View")) { + ewk_view_smart_class_set(&m_ewkViewClass); } void EWK2UnitTestBase::SetUp() @@ -60,7 +61,8 @@ void EWK2UnitTestBase::SetUp() ecore_evas_show(m_ecoreEvas); Evas* evas = ecore_evas_get(m_ecoreEvas); - m_webView = ewk_view_add(evas); + Evas_Smart* smart = evas_smart_class_new(&m_ewkViewClass.sc); + m_webView = ewk_view_smart_add(evas, smart, ewk_context_default_get()); ewk_view_theme_set(m_webView, environment->defaultTheme()); evas_object_resize(m_webView, width, height); @@ -77,10 +79,15 @@ void EWK2UnitTestBase::TearDown() void EWK2UnitTestBase::loadUrlSync(const char* url) { + ewk_view_uri_set(m_webView, url); + waitUntilLoadFinished(); +} + +void EWK2UnitTestBase::waitUntilLoadFinished() +{ bool loadFinished = false; evas_object_smart_callback_add(m_webView, "load,finished", onLoadFinished, &loadFinished); - ewk_view_uri_set(m_webView, url); while (!loadFinished) ecore_main_loop_iterate(); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h index 29d55bee4..fa6abd160 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h @@ -20,6 +20,7 @@ #ifndef EWK2UnitTestBase_h #define EWK2UnitTestBase_h +#include <EWebKit2.h> #include <Ecore_Evas.h> #include <Evas.h> #include <gtest/gtest.h> @@ -29,6 +30,7 @@ namespace EWK2UnitTest { class EWK2UnitTestBase : public ::testing::Test { public: Evas_Object* webView() { return m_webView; } + Ewk_View_Smart_Class* ewkViewClass() { return &m_ewkViewClass; } protected: EWK2UnitTestBase(); @@ -37,12 +39,14 @@ protected: virtual void TearDown(); void loadUrlSync(const char* url); + void waitUntilLoadFinished(); void waitUntilTitleChangedTo(const char* expectedTitle); void mouseClick(int x, int y); private: Evas_Object* m_webView; Ecore_Evas* m_ecoreEvas; + Ewk_View_Smart_Class m_ewkViewClass; }; } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp index fae77242f..814f8c2cb 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.cpp @@ -20,7 +20,9 @@ #include "config.h" #include "EWK2UnitTestEnvironment.h" +#include <wtf/text/StringBuilder.h> #include <wtf/text/StringConcatenate.h> +#include <wtf/text/WTFString.h> namespace EWK2UnitTest { @@ -46,4 +48,12 @@ CString EWK2UnitTestEnvironment::urlForResource(const char* resource) return makeString("file://"TEST_RESOURCES_DIR"/", resource).utf8(); } +CString EWK2UnitTestEnvironment::pathForResource(const char* resource) +{ + StringBuilder builder; + builder.appendLiteral(TEST_RESOURCES_DIR "/"); + builder.append(resource); + return builder.toString().utf8(); +} + } // namespace EWK2UnitTest diff --git a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h index d010b6237..fb3a309f8 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h +++ b/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestEnvironment.h @@ -33,6 +33,7 @@ public: const char* defaultTestPageUrl() const; const char* defaultTheme() const; CString urlForResource(const char* resource); + CString pathForResource(const char* resource); virtual unsigned int defaultWidth() const { return m_defaultWidth; } virtual unsigned int defaultHeight() const { return m_defaultHeight; } diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/big_button_theme.edj b/Source/WebKit2/UIProcess/API/efl/tests/resources/big_button_theme.edj Binary files differnew file mode 100644 index 000000000..60bb40ff9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/big_button_theme.edj diff --git a/Source/WebKit2/UIProcess/API/efl/tests/resources/empty_theme.edj b/Source/WebKit2/UIProcess/API/efl/tests/resources/empty_theme.edj Binary files differnew file mode 100644 index 000000000..2d6cd0485 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/resources/empty_theme.edj 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 af10981ec..68c15dbb8 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 @@ -41,6 +41,7 @@ extern EWK2UnitTestEnvironment* environment; static const char title1[] = "Page1"; static const char title2[] = "Page2"; +static const char title3[] = "Page3"; static void serverCallbackNavigation(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) { @@ -78,6 +79,13 @@ static inline WKEinaSharedString urlFromTitle(EWK2UnitTestServer* httpServer, co return res; } +static inline void freeEinaList(Eina_List* list) +{ + void* data = 0; + EINA_LIST_FREE(list, data) + ewk_back_forward_list_item_unref(static_cast<Ewk_Back_Forward_List_Item*>(data)); +} + TEST_F(EWK2UnitTestBase, ewk_back_forward_list_current_item_get) { const char* url = environment->defaultTestPageUrl(); @@ -181,3 +189,83 @@ TEST_F(EWK2UnitTestBase, ewk_back_forward_list_count) EXPECT_EQ(ewk_back_forward_list_count(backForwardList), 2); } + +TEST_F(EWK2UnitTestBase, ewk_back_forward_list_n_back_items_copy) +{ + OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); + httpServer->run(serverCallbackNavigation); + + WKEinaSharedString url1 = urlFromTitle(httpServer.get(), title1); + loadUrlSync(url1); + ASSERT_STREQ(ewk_view_title_get(webView()), title1); + + WKEinaSharedString url2 = urlFromTitle(httpServer.get(), title2); + loadUrlSync(url2); + ASSERT_STREQ(ewk_view_title_get(webView()), title2); + + loadUrlSync(urlFromTitle(httpServer.get(), title3)); + ASSERT_STREQ(ewk_view_title_get(webView()), title3); + + 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); + checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(backList, 0)), title2, url2, url2); + freeEinaList(backList); + + // Check '0' limit. + backList = ewk_back_forward_list_n_back_items_copy(backForwardList, 0); + ASSERT_FALSE(backList); + + backList = ewk_back_forward_list_n_back_items_copy(backForwardList, -1); + ASSERT_TRUE(backList); + ASSERT_EQ(eina_list_count(backList), 2); + 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); +} + +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); + + WKEinaSharedString url2 = urlFromTitle(httpServer.get(), title2); + loadUrlSync(url2); + ASSERT_STREQ(ewk_view_title_get(webView()), title2); + + WKEinaSharedString url3 = urlFromTitle(httpServer.get(), title3); + loadUrlSync(url3); + ASSERT_STREQ(ewk_view_title_get(webView()), title3); + + // Go back to Page1. + ewk_view_back(webView()); + waitUntilTitleChangedTo(title2); + ewk_view_back(webView()); + waitUntilTitleChangedTo(title1); + + Ewk_Back_Forward_List* backForwardList = ewk_view_back_forward_list_get(webView()); + ASSERT_TRUE(backForwardList); + + Eina_List* forwardList = ewk_back_forward_list_n_forward_items_copy(backForwardList, 1); + ASSERT_TRUE(forwardList); + ASSERT_EQ(eina_list_count(forwardList), 1); + checkItem(static_cast<Ewk_Back_Forward_List_Item*>(eina_list_nth(forwardList, 0)), title2, url2, url2); + freeEinaList(forwardList); + + // Check '0' limit. + forwardList = ewk_back_forward_list_n_forward_items_copy(backForwardList, 0); + ASSERT_FALSE(forwardList); + + forwardList = ewk_back_forward_list_n_forward_items_copy(backForwardList, -1); + ASSERT_TRUE(forwardList); + ASSERT_EQ(eina_list_count(forwardList), 2); + 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_cookie_manager.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp index 10be26cb5..e0319f7ce 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 @@ -258,7 +258,7 @@ TEST_F(EWK2UnitTestBase, ewk_cookie_manager_cookies_delete) ASSERT_EQ(countHostnamesWithCookies(cookieManager), 0); } -TEST_F(EWK2UnitTestBase, ewk_cookie_manager_permanent_storage) +TEST_F(EWK2UnitTestBase, DISABLED_ewk_cookie_manager_permanent_storage) { OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer); httpServer->run(serverCallback); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp new file mode 100644 index 000000000..dd0a6e722 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "UnitTestUtils/EWK2UnitTestBase.h" +#include <EWebKit2.h> +#include <Eina.h> + +using namespace EWK2UnitTest; + +TEST_F(EWK2UnitTestBase, ewk_settings_fullscreen_enabled) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + +#if ENABLE(FULLSCREEN_API) + ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings)); + + ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE)); + ASSERT_TRUE(ewk_settings_fullscreen_enabled_get(settings)); + + ASSERT_TRUE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE)); + ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings)); +#else + ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings)); + + ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_TRUE)); + ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings)); + + ASSERT_FALSE(ewk_settings_fullscreen_enabled_set(settings, EINA_FALSE)); + ASSERT_FALSE(ewk_settings_fullscreen_enabled_get(settings)); +#endif +} + +TEST_F(EWK2UnitTestBase, ewk_settings_javascript_enabled) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + + ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, EINA_TRUE)); + ASSERT_TRUE(ewk_settings_javascript_enabled_get(settings)); + + ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, 2)); + ASSERT_TRUE(ewk_settings_javascript_enabled_get(settings)); + + ASSERT_TRUE(ewk_settings_javascript_enabled_set(settings, EINA_FALSE)); + ASSERT_FALSE(ewk_settings_javascript_enabled_get(settings)); +} + +TEST_F(EWK2UnitTestBase, ewk_settings_loads_images_automatically) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + + ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, EINA_TRUE)); + ASSERT_TRUE(ewk_settings_loads_images_automatically_get(settings)); + + ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, 2)); + ASSERT_TRUE(ewk_settings_loads_images_automatically_get(settings)); + + ASSERT_TRUE(ewk_settings_loads_images_automatically_set(settings, EINA_FALSE)); + ASSERT_FALSE(ewk_settings_loads_images_automatically_get(settings)); +} 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 5edb04379..6e928edd9 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -24,6 +24,7 @@ #include "UnitTestUtils/EWK2UnitTestServer.h" #include <EWebKit2.h> #include <Ecore.h> +#include <Eina.h> #include <gtest/gtest.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -33,6 +34,7 @@ using namespace EWK2UnitTest; extern EWK2UnitTestEnvironment* environment; +bool fullScreenCallbackCalled; static void onLoadFinishedForRedirection(void* userData, Evas_Object*, void*) { @@ -188,3 +190,173 @@ TEST_F(EWK2UnitTestBase, ewk_view_form_submission_request) ASSERT_TRUE(handled); evas_object_smart_callback_del(webView(), "form,submission,request", onFormAboutToBeSubmitted); } + +static inline void checkBasicPopupMenuItem(Ewk_Popup_Menu_Item* item, const char* title, bool enabled) +{ + EXPECT_EQ(ewk_popup_menu_item_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); +} + +static Eina_Bool selectItemAfterDelayed(void* data) +{ + EXPECT_TRUE(ewk_view_popup_menu_select(static_cast<Evas_Object*>(data), 0)); + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool showPopupMenu(Ewk_View_Smart_Data* smartData, Eina_Rectangle, Ewk_Text_Direction, double, Eina_List* list, int selectedIndex) +{ + EXPECT_EQ(selectedIndex, 2); + + 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_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); + + 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_TRUE(ewk_popup_menu_item_selected_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 3)); + checkBasicPopupMenuItem(item, "label", false); + EXPECT_TRUE(ewk_popup_menu_item_is_label_get(item)); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 4)); + checkBasicPopupMenuItem(item, " forth", true); + + item = static_cast<Ewk_Popup_Menu_Item*>(eina_list_nth(list, 5)); + EXPECT_EQ(ewk_popup_menu_item_type_get(item), EWK_POPUP_MENU_UNKNOWN); + EXPECT_STREQ(ewk_popup_menu_item_text_get(item), 0); + + ecore_timer_add(0, selectItemAfterDelayed, smartData->self); + return true; +} + +TEST_F(EWK2UnitTestBase, ewk_view_popup_menu_select) +{ + const char* selectHTML = + "<!doctype html><body><select onchange=\"document.title=this.value;\">" + "<option>first</option><option disabled>second</option><option selected dir=\"rtl\" title=\"tooltip\" aria-label=\"aria\">third</option>" + "<optgroup label=\"label\"><option>forth</option></optgroup>" + "</select></body>"; + + ewkViewClass()->popup_menu_show = showPopupMenu; + + ewk_view_html_string_load(webView(), selectHTML, "file:///", 0); + waitUntilLoadFinished(); + mouseClick(30, 20); + waitUntilTitleChangedTo("first"); + + EXPECT_TRUE(ewk_view_popup_menu_close(webView())); + EXPECT_FALSE(ewk_view_popup_menu_select(webView(), 0)); +} + +TEST_F(EWK2UnitTestBase, ewk_view_settings_get) +{ + Ewk_Settings* settings = ewk_view_settings_get(webView()); + ASSERT_TRUE(settings); + ASSERT_EQ(settings, ewk_view_settings_get(webView())); +} + +TEST_F(EWK2UnitTestBase, ewk_view_theme_set) +{ + const char* buttonHTML = "<html><body><input type='button' id='btn'>" + "<script>document.title=document.getElementById('btn').clientWidth;</script>" + "</body></html>"; + + ewk_view_html_string_load(webView(), buttonHTML, "file:///", 0); + waitUntilTitleChangedTo("30"); // button of default theme has 30px as padding (15 to -16) + + ewk_view_theme_set(webView(), environment->pathForResource("it_does_not_exist.edj").data()); + ewk_view_html_string_load(webView(), buttonHTML, "file:///", 0); + waitUntilTitleChangedTo("30"); // the result should be same as default theme + + ewk_view_theme_set(webView(), environment->pathForResource("empty_theme.edj").data()); + ewk_view_html_string_load(webView(), buttonHTML, "file:///", 0); + waitUntilTitleChangedTo("30"); // the result should be same as default theme + + ewk_view_theme_set(webView(), environment->pathForResource("big_button_theme.edj").data()); + ewk_view_html_string_load(webView(), buttonHTML, "file:///", 0); + waitUntilTitleChangedTo("299"); // button of big button theme has 299px as padding (150 to -150) +} + +TEST_F(EWK2UnitTestBase, ewk_view_mouse_events_enabled) +{ + ASSERT_TRUE(ewk_view_mouse_events_enabled_set(webView(), EINA_TRUE)); + ASSERT_TRUE(ewk_view_mouse_events_enabled_get(webView())); + + ASSERT_TRUE(ewk_view_mouse_events_enabled_set(webView(), 2)); + ASSERT_TRUE(ewk_view_mouse_events_enabled_get(webView())); + + ASSERT_TRUE(ewk_view_mouse_events_enabled_set(webView(), EINA_FALSE)); + ASSERT_FALSE(ewk_view_mouse_events_enabled_get(webView())); +} + +static Eina_Bool fullScreenCallback(Ewk_View_Smart_Data* smartData) +{ + fullScreenCallbackCalled = true; + 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[] = + "<!doctype html><head><script>function makeFullScreen(){" + "var div = document.getElementById(\"fullscreen\");" + "div.webkitRequestFullScreen();" + "document.title = \"fullscreen entered\";" + "}</script></head>" + "<body><div id=\"fullscreen\" style=\"width:100px; height:100px\" onclick=\"makeFullScreen()\"></div></body>"; + + ewkViewClass()->fullscreen_enter = fullScreenCallback; + + ewk_view_html_string_load(webView(), fullscreenHTML, "file:///", 0); + waitUntilLoadFinished(); + mouseClick(50, 50); + waitUntilTitleChangedTo("fullscreen entered"); + ASSERT_TRUE(fullScreenCallbackCalled); + checkFullScreenProperty(webView(), true); +} + +TEST_F(EWK2UnitTestBase, ewk_view_full_screen_exit) +{ + const char fullscreenHTML[] = + "<!doctype html><head><script>function makeFullScreenAndExit(){" + "var div = document.getElementById(\"fullscreen\");" + "div.webkitRequestFullScreen();" + "document.webkitCancelFullScreen();" + "document.title = \"fullscreen exited\";" + "}</script></head>" + "<body><div id=\"fullscreen\" style=\"width:100px; height:100px\" onclick=\"makeFullScreenAndExit()\"></div></body>"; + + ewkViewClass()->fullscreen_exit = fullScreenCallback; + + ewk_view_html_string_load(webView(), fullscreenHTML, "file:///", 0); + waitUntilLoadFinished(); + mouseClick(50, 50); + waitUntilTitleChangedTo("fullscreen exited"); + ASSERT_TRUE(fullScreenCallbackCalled); + checkFullScreenProperty(webView(), false); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp index 5a6adae0a..a1f5d962d 100644 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp @@ -233,7 +233,7 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr } #if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&) +PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) { notImplemented(); return 0; diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h index 72fc34539..f4afd06d9 100644 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h @@ -51,7 +51,7 @@ public: GtkWidget* viewWidget() { return m_viewWidget; } private: - PageClientImpl(GtkWidget*); + explicit PageClientImpl(GtkWidget*); virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); virtual void setViewNeedsDisplay(const WebCore::IntRect&); @@ -82,7 +82,7 @@ private: virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*); virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); #if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor); + virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&); #endif virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate); virtual void didChangeScrollbarsForMainFrame() const; diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp index e0d7a60ea..aa2623783 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp @@ -98,7 +98,9 @@ static gboolean webkitDownloadDecideDestination(WebKitDownload* download, const { if (!download->priv->destinationURI.isNull()) return FALSE; - GOwnPtr<char> destination(g_build_filename(g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD), suggestedFilename, NULL)); + + GOwnPtr<char> filename(g_strdelimit(g_strdup(suggestedFilename), G_DIR_SEPARATOR_S, '_')); + GOwnPtr<char> destination(g_build_filename(g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD), filename.get(), NULL)); GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); download->priv->destinationURI = destinationURI.get(); g_object_notify(G_OBJECT(download), "destination"); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.cpp index 1cd8aaf7f..b38161156 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitResourceLoadClient.cpp @@ -38,7 +38,7 @@ using namespace WebKit; static void didInitiateLoadForResource(WKPageRef, WKFrameRef wkFrame, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, bool pageIsProvisionallyLoading, const void* clientInfo) { GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(wkRequest)->resourceRequest())); - webkitWebViewResourceLoadStarted(WEBKIT_WEB_VIEW(clientInfo), wkFrame, resourceIdentifier, request.get(), pageIsProvisionallyLoading); + webkitWebViewResourceLoadStarted(WEBKIT_WEB_VIEW(clientInfo), wkFrame, resourceIdentifier, request.get()); } static void didSendRequestForResource(WKPageRef, WKFrameRef, uint64_t resourceIdentifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index ee86d448a..6fefb652b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -1311,11 +1311,12 @@ static void waitForMainResourceResponseIfWaitingForResource(WebKitWebView* webVi g_signal_connect(priv->mainResource.get(), "notify::response", G_CALLBACK(mainResourceResponseChangedCallback), webView); } -void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame, uint64_t resourceIdentifier, WebKitURIRequest* request, bool isMainResource) +void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame, uint64_t resourceIdentifier, WebKitURIRequest* request) { WebKitWebViewPrivate* priv = webView->priv; + bool isMainResource = WKFrameIsMainFrame(wkFrame) && !priv->mainResource; WebKitWebResource* resource = webkitWebResourceCreate(wkFrame, request, isMainResource); - if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource)) { + if (isMainResource) { priv->mainResource = resource; waitForMainResourceResponseIfWaitingForResource(webView); } diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp index 4925b5a7c..f5bd2ddcc 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -147,6 +147,9 @@ static void webkitWebViewBaseRealize(GtkWidget* widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK +#if GTK_CHECK_VERSION(3, 3, 18) + | GDK_SMOOTH_SCROLL_MASK +#endif | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h index f2986d1f9..5ad2853bb 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h @@ -47,7 +47,7 @@ void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest* void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*); void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers); void webkitWebViewPrintFrame(WebKitWebView*, WKFrameRef); -void webkitWebViewResourceLoadStarted(WebKitWebView*, WKFrameRef, uint64_t resourceIdentifier, WebKitURIRequest*, bool isMainResource); +void webkitWebViewResourceLoadStarted(WebKitWebView*, WKFrameRef, uint64_t resourceIdentifier, WebKitURIRequest*); void webkitWebViewRunFileChooserRequest(WebKitWebView*, WebKitFileChooserRequest*); WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); void webkitWebViewRemoveLoadingWebResource(WebKitWebView*, uint64_t resourceIdentifier); diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm index 6a02f562d..4df0ef1c4 100644 --- a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm +++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm @@ -36,7 +36,8 @@ #import "WebPreferences.h" #import <PDFKit/PDFKit.h> #import <WebCore/LocalizedStrings.h> -#import <objc/runtime.h> +#import <objc/objc-runtime.h> +#import <wtf/ObjcRuntimeExtras.h> #import <wtf/text/CString.h> #import <wtf/text/WTFString.h> @@ -537,7 +538,7 @@ static void PDFViewScrollView_scrollWheel(NSScrollView* self, SEL _cmd, NSEvent } } - oldPDFViewScrollView_scrollWheel(self, _cmd, wheelEvent); + wtfCallIMP<void>(oldPDFViewScrollView_scrollWheel, self, _cmd, wheelEvent); } #endif diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h index 98da7eceb..18579eee9 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h @@ -48,7 +48,7 @@ public: void viewWillMoveToAnotherWindow(); private: - PageClientImpl(WKView*); + explicit PageClientImpl(WKView*); virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); virtual void setViewNeedsDisplay(const WebCore::IntRect&); @@ -97,7 +97,7 @@ private: virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*); #if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor); + virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&); #endif void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate); diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index b31946b3c..7b54b4bd7 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -366,7 +366,7 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr } #if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&) +PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) { notImplemented(); return 0; diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index eb6b819c5..98e32662a 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -1937,6 +1937,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl [self _accessibilityRegisterUIProcessTokens]; } else { + [self _updateWindowVisibility]; _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h index ad1c6ad3f..c7ac86c3d 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h @@ -26,7 +26,6 @@ namespace WebKit { class WebPageProxy; -class QtViewportHandler; class QtWebPageEventHandler; } diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 921586d1b..490b9ba7c 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -23,9 +23,9 @@ #include "DownloadProxy.h" #include "DrawingAreaProxyImpl.h" +#include "PageViewportControllerClientQt.h" #include "QtDialogRunner.h" #include "QtDownloadManager.h" -#include "QtViewportHandler.h" #include "QtWebContext.h" #include "QtWebError.h" #include "QtWebIconDatabaseClient.h" @@ -272,6 +272,7 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) , m_navigatorQtObjectEnabled(false) , m_renderToOffscreenBuffer(false) , m_allowAnyHTTPSCertificateForLocalHost(false) + , m_customDevicePixelRatio(0) , m_loadProgress(0) { viewport->setClip(true); @@ -325,8 +326,9 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa void QQuickWebViewPrivate::onComponentComplete() { Q_Q(QQuickWebView); - m_viewportHandler.reset(new QtViewportHandler(webPageProxy.get(), q, pageView.data())); - pageView->eventHandler()->setViewportHandler(m_viewportHandler.data()); + 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) @@ -473,7 +475,10 @@ 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(); updateUserScripts(); } @@ -789,6 +794,20 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& emit q_ptr->experimental()->messageReceived(variantMap); } +void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize) +{ + if (newSize.isEmpty() || !m_customDevicePixelRatio || webPageProxy->deviceScaleFactor() == m_customDevicePixelRatio) + return; + + // DrawingAreaProxy returns early if the page size is empty + // and the device pixel ratio property is propagated from QML + // before the QML page item has a valid size yet, thus the + // information would not reach the web process. + // Set the custom device pixel ratio requested from QML as soon + // as the content item has a valid size. + webPageProxy->setCustomDeviceScaleFactor(m_customDevicePixelRatio); +} + QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport) : QQuickWebViewPrivate(viewport) { @@ -836,11 +855,6 @@ QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* view viewport->setAcceptHoverEvents(false); } -QQuickWebViewFlickablePrivate::~QQuickWebViewFlickablePrivate() -{ - m_viewportHandler->disconnect(); -} - void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) { QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); @@ -856,28 +870,29 @@ void QQuickWebViewFlickablePrivate::onComponentComplete() void QQuickWebViewFlickablePrivate::didChangeViewportProperties(const WebCore::ViewportAttributes& newAttributes) { - if (m_viewportHandler) - m_viewportHandler->viewportAttributesChanged(newAttributes); + if (m_pageViewportController) + m_pageViewportController->didChangeViewportAttributes(newAttributes); } void QQuickWebViewFlickablePrivate::updateViewportSize() { - // FIXME: Examine why there is not an viewportHandler here in the beginning. - if (m_viewportHandler) - m_viewportHandler->viewportItemSizeChanged(); + Q_Q(QQuickWebView); + + if (m_pageViewportController) + m_pageViewportController->setViewportSize(QSizeF(q->width(), q->height())); } void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos) { - m_viewportHandler->pageContentPositionRequested(pos); + if (m_pageViewportController) + m_pageViewportController->pageDidRequestScroll(pos); } void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize) { - Q_Q(QQuickWebView); - pageView->setContentsSize(newSize); // emits contentsSizeChanged() - m_viewportHandler->pageContentsSizeChanged(newSize, q->boundingRect().size().toSize()); + QQuickWebViewPrivate::didChangeContentsSize(newSize); + m_pageViewportController->didChangeContentsSize(newSize); } void QQuickWebViewFlickablePrivate::handleMouseEvent(QMouseEvent* event) @@ -889,22 +904,6 @@ void QQuickWebViewFlickablePrivate::handleMouseEvent(QMouseEvent* event) pageView->eventHandler()->handleInputEvent(event); } -/*! - \qmlsignal WebView::onNavigationRequested(WebNavigationRequest request) - - This signal is emitted for every navigation request. The request object contains url, - button and modifiers properties describing the navigation action, e.g. "a middle click - with shift key pressed to 'http://qt-project.org'". - - The navigation will be accepted by default. To change that, one can set the action - property to WebView.IgnoreRequest to reject the request or WebView.DownloadRequest to - trigger a download instead of navigating to the url. - - The request object cannot be used after the signal handler function ends. - - \sa WebNavigationRequest -*/ - QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView) : QObject(webView) , q_ptr(webView) @@ -1233,19 +1232,23 @@ void QQuickWebViewExperimental::setUserAgent(const QString& userAgent) down but still provide a better looking image. */ -double QQuickWebViewExperimental::devicePixelRatio() const +qreal QQuickWebViewExperimental::devicePixelRatio() const { Q_D(const QQuickWebView); + + if (d->m_customDevicePixelRatio) + return d->m_customDevicePixelRatio; + return d->webPageProxy->deviceScaleFactor(); } -void QQuickWebViewExperimental::setDevicePixelRatio(double devicePixelRatio) +void QQuickWebViewExperimental::setDevicePixelRatio(qreal devicePixelRatio) { Q_D(QQuickWebView); - if (devicePixelRatio == this->devicePixelRatio()) + if (0 >= devicePixelRatio || devicePixelRatio == this->devicePixelRatio()) return; - d->webPageProxy->setCustomDeviceScaleFactor(devicePixelRatio); + d->m_customDevicePixelRatio = devicePixelRatio; emit devicePixelRatioChanged(); } @@ -1427,13 +1430,55 @@ QQuickWebPage* QQuickWebViewExperimental::page() } /*! - \qmlclass WebView QWebView - \inqmlmodule QtWebKit 3.0 + \page index.html + + \title QtWebKit: QML WebView version 3.0 + + The WebView API allows QML applications to render regions of dynamic + web content. A \e{WebView} component may share the screen with other + QML components or encompass the full screen as specified within the + QML application. + + QML WebView version 3.0 is incompatible with previous QML WebView API + versions. It allows an application to load pages into the WebView, + either by URL or with an HTML string, and navigate within session + history. By default, links to different pages load within the same + WebView, but applications may intercept requests to delegate links to + other functions. + + This sample QML application loads a web page, responds to session + history context, and intercepts requests for external links: + + \code + import QtQuick 2.0 + import QtWebKit 3.0 + + Page { + WebView { + id: webview + url: "http://qt-project.org" + width: parent.width + height: parent.height + onNavigationRequested: { + // detect URL scheme prefix, most likely an external link + var schemaRE = /^\w+:/; + if (schemaRE.test(request.url)) { + request.action = WebView.AcceptRequest; + } else { + request.action = WebView.IgnoreRequest; + // delegate request.url here + } + } + } + } + \endcode */ + /*! - \qmlmethod WebView(Item parent) - \brief Constructs a WebView with a parent. + \qmltype WebView + \inqmlmodule QtWebKit 3.0 + \brief A WebView renders web content within a QML application */ QQuickWebView::QQuickWebView(QQuickItem* parent) @@ -1464,24 +1509,49 @@ QQuickWebPage* QQuickWebView::page() return d->pageView.data(); } +/*! + \qmlmethod void WebView::goBack() + + Go backward within the browser's session history, if possible. + (Equivalent to the \c{window.history.back()} DOM method.) + + \sa WebView::canGoBack +*/ void QQuickWebView::goBack() { Q_D(QQuickWebView); d->webPageProxy->goBack(); } +/*! + \qmlmethod void WebView::goForward() + + Go forward within the browser's session history, if possible. + (Equivalent to the \c{window.history.forward()} DOM method.) +*/ void QQuickWebView::goForward() { Q_D(QQuickWebView); d->webPageProxy->goForward(); } +/*! + \qmlmethod void WebView::stop() + + Stop loading the current page. +*/ void QQuickWebView::stop() { Q_D(QQuickWebView); d->webPageProxy->stopLoading(); } +/*! + \qmlmethod void WebView::reload() + + Reload the current page. (Equivalent to the + \c{window.location.reload()} DOM method.) +*/ void QQuickWebView::reload() { Q_D(QQuickWebView); @@ -1502,6 +1572,15 @@ void QQuickWebView::reload() d->webPageProxy->reload(reloadFromOrigin); } +/*! + \qmlproperty url WebView::url + + The location of the currently displaying HTML page. This writable + property offers the main interface to load a page into a web view. + It functions the same as the \c{window.location} DOM property. + + \sa WebView::loadHtml() +*/ QUrl QQuickWebView::url() const { Q_D(const QQuickWebView); @@ -1535,6 +1614,24 @@ void QQuickWebView::emitUrlChangeIfNeeded() } } +/*! + \qmlproperty url WebView::icon + + The location of the currently displaying Web site icon, also known as favicon + or shortcut icon. This read-only URL corresponds to the image used within a + mobile browser application to represent a bookmarked page on the device's home + screen. + + This example uses the \c{icon} property to build an \c{Image} element: + + \code + Image { + id: appIcon + source: webView.icon != "" ? webView.icon : "fallbackFavIcon.png"; + ... + } + \endcode +*/ QUrl QQuickWebView::icon() const { Q_D(const QQuickWebView); @@ -1543,23 +1640,34 @@ QUrl QQuickWebView::icon() const /*! \qmlproperty int WebView::loadProgress - \brief The progress of loading the current web page. - The range is from 0 to 100. + The amount of the page that has been loaded, expressed as an integer + percentage in the range from \c{0} to \c{100}. */ - int QQuickWebView::loadProgress() const { Q_D(const QQuickWebView); return d->loadProgress(); } +/*! + \qmlproperty bool WebView::canGoBack + + Returns \c{true} if there are prior session history entries, \c{false} + otherwise. +*/ bool QQuickWebView::canGoBack() const { Q_D(const QQuickWebView); return d->webPageProxy->canGoBack(); } +/*! + \qmlproperty bool WebView::canGoForward + + Returns \c{true} if there are subsequent session history entries, + \c{false} otherwise. +*/ bool QQuickWebView::canGoForward() const { Q_D(const QQuickWebView); @@ -1568,9 +1676,9 @@ bool QQuickWebView::canGoForward() const /*! \qmlproperty bool WebView::loading - \brief True if the web view is currently loading a web page, false otherwise. -*/ + Returns \c{true} if the HTML page is currently loading, \c{false} otherwise. +*/ bool QQuickWebView::loading() const { Q_D(const QQuickWebView); @@ -1619,9 +1727,10 @@ QRectF QQuickWebView::mapRectFromWebContent(const QRectF& rectInCSSCoordinates) /*! \qmlproperty string WebView::title - \brief The title of the loaded page. -*/ + The title of the currently displaying HTML page, a read-only value + that reflects the contents of the \c{<title>} tag. +*/ QString QQuickWebView::title() const { Q_D(const QQuickWebView); @@ -1657,7 +1766,7 @@ QVariant QQuickWebView::inputMethodQuery(Qt::InputMethodQuery property) const } /*! - \preliminary + internal The experimental module consisting on experimental API which will break from version to version. @@ -1901,8 +2010,14 @@ void QQuickWebView::handleFlickableMouseRelease(const QPointF& position, qint64 \qmlmethod void WebView::loadHtml(string html, url baseUrl, url unreachableUrl) \brief Loads the specified \a html as the content of the web view. + (This method offers a lower-level alternative to the \c{url} property, + which references HTML pages via URL.) + External objects such as stylesheets or images referenced in the HTML - document are located relative to \a baseUrl. + document are located relative to \a baseUrl. For example if provided \a html + was originally retrieved from \c http://www.example.com/documents/overview.html + and that was the base url, then an image referenced with the relative url \c diagram.png + would be looked for at \c{http://www.example.com/documents/diagram.png}. If an \a unreachableUrl is passed it is used as the url for the loaded content. This is typically used to display error pages for a failed @@ -1955,5 +2070,201 @@ void QQuickWebView::setAllowAnyHTTPSCertificateForLocalHost(bool allow) d->m_allowAnyHTTPSCertificateForLocalHost = allow; } +/*! + \qmlsignal WebView::onLoadingChanged(loadRequest) + + Occurs when any page load begins, ends, or fails. Various read-only + parameters are available on the \a loadRequest: + + \list + + \li \c{url}: the location of the resource that is loading. + + \li \c{status}: Reflects one of three load states: + \c{LoadStartedStatus}, \c{LoadSucceededStatus}, or + \c{LoadFailedStatus}. See \c{WebView::LoadStatus}. + + \li \c{errorString}: description of load error. + + \li \c{errorCode}: HTTP error code. + + \li \c{errorDomain}: high-level error types, one of + \c{NetworkErrorDomain}, \c{HttpErrorDomain}, \c{InternalErrorDomain}, + \c{DownloadErrorDomain}, or \c{NoErrorDomain}. See + \l{WebView::ErrorDomain}. + + \endlist + + \sa WebView::loading +*/ + +/*! + \qmlsignal WebView::onLinkHovered(hoveredUrl, hoveredTitle) + + Within a mouse-driven interface, this signal is emitted when a mouse + pointer passes over a link, corresponding to the \c{mouseover} DOM + event. (May also occur in touch interfaces for \c{mouseover} events + that are not cancelled with \c{preventDefault()}.) The \a{hoveredUrl} + provides the link's location, and the \a{hoveredTitle} is any avalable + link text. +*/ + +/*! + \qmlsignal WebView::onNavigationRequested(request) + + Occurs for various kinds of navigation. If the application listens + for this signal, it must set the \c{request.action} to either of the + following \l{WebView::NavigationRequestAction} enum values: + + \list + + \li \c{AcceptRequest}: Allow navigation to external pages within the + web view. This represents the default behavior when no listener is + active. + + \li \c{IgnoreRequest}: Suppress navigation to new pages within the web + view. (The listener may then delegate navigation externally to + the browser application.) + + \endlist + + The \a{request} also provides the following read-only values: + + \list + + \li \c{url}: The location of the requested page. + + \li \c{navigationType}: contextual information, one of + \c{LinkClickedNavigation}, \c{BackForwardNavigation}, + \c{ReloadNavigation}, \c{FormSubmittedNavigation}, + \c{FormResubmittedNavigation}, or \c{OtherNavigation} enum values. + See \l{WebView::NavigationType}. + + \li \c{keyboardModifiers}: potential states for \l{Qt::KeyboardModifier}. + + \li \c{mouseButton}: potential states for \l{Qt::MouseButton}. + + \endlist +*/ + +/*! + \qmlproperty enumeration WebView::ErrorDomain + + Details various high-level error types. + + \table + + \header + \li Constant + \li Description + + \row + \li InternalErrorDomain + \li Content fails to be interpreted by QtWebKit. + + \row + \li NetworkErrorDomain + \li Error results from faulty network connection. + + \row + \li HttpErrorDomain + \li Error is produced by server. + + \row + \li DownloadErrorDomain + \li Error in saving file. + + \row + \li NoErrorDomain + \li Unspecified fallback error. + + \endtable +*/ + +/*! + \qmlproperty enumeration WebView::NavigationType + + Distinguishes context for various navigation actions. + + \table + + \header + \li Constant + \li Description + + \row + \li LinkClickedNavigation + \li Navigation via link. + + \row + \li FormSubmittedNavigation + \li Form data is posted. + + \row + \li BackForwardNavigation + \li Navigation back and forth within session history. + + \row + \li ReloadNavigation + \li The current page is reloaded. + + \row + \li FormResubmittedNavigation + \li Form data is re-posted. + + \row + \li OtherNavigation + \li Unspecified fallback method of navigation. + + \endtable +*/ + +/*! + \qmlproperty enumeration WebView::LoadStatus + + Reflects a page's load status. + + \table + + \header + \li Constant + \li Description + + \row + \li LoadStartedStatus + \li Page is currently loading. + + \row + \li LoadSucceededStatus + \li Page has successfully loaded, and is not currently loading. + + \row + \li LoadFailedStatus + \li Page has failed to load, and is not currently loading. + + \endtable +*/ + +/*! + \qmlproperty enumeration WebView::NavigationRequestAction + + Specifies a policy when navigating a link to an external page. + + \table + + \header + \li Constant + \li Description + + \row + \li AcceptRequest + \li Allow navigation to external pages within the web view. + + \row + \li IgnoreRequest + \li Suppress navigation to new pages within the web view. + + \endtable +*/ #include "moc_qquickwebview_p.cpp" diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index 8d0f4ffb9..68e5fca30 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -48,8 +48,8 @@ class PlatformWebView; } namespace WebKit { -class QtRefCountedNetworkRequestData; -class QtViewportHandler; +struct QtRefCountedNetworkRequestData; +class PageViewportControllerClientQt; class QtWebPageLoadClient; class QtWebPagePolicyClient; class QtWebPageUIClient; @@ -217,7 +217,7 @@ private: QQuickWebViewExperimental* m_experimental; friend class QWebKitTest; - friend class WebKit::QtViewportHandler; + friend class WebKit::PageViewportControllerClientQt; friend class WebKit::QtWebPageLoadClient; friend class WebKit::QtWebPagePolicyClient; friend class WebKit::QtWebPageUIClient; @@ -255,7 +255,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { Q_PROPERTY(int preferredMinimumContentsWidth WRITE setPreferredMinimumContentsWidth READ preferredMinimumContentsWidth NOTIFY preferredMinimumContentsWidthChanged) Q_PROPERTY(int deviceWidth WRITE setDeviceWidth READ deviceWidth NOTIFY deviceWidthChanged) Q_PROPERTY(int deviceHeight WRITE setDeviceHeight READ deviceHeight NOTIFY deviceHeightChanged) - Q_PROPERTY(double devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) + Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) Q_PROPERTY(QWebNavigationHistory* navigationHistory READ navigationHistory CONSTANT FINAL) @@ -312,8 +312,8 @@ public: void setDeviceWidth(int); int deviceHeight() const; void setDeviceHeight(int); - double devicePixelRatio() const; - void setDevicePixelRatio(double); + qreal devicePixelRatio() const; + void setDevicePixelRatio(qreal); QList<QUrl> userScripts() const; void setUserScripts(const QList<QUrl>& userScripts); QUrl remoteInspectorUrl() const; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index d8a88f8c9..d1d3d9e88 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -21,13 +21,13 @@ #ifndef qquickwebview_p_p_h #define qquickwebview_p_p_h +#include "PageViewportController.h" +#include "PageViewportControllerClient.h" #include "QtPageClient.h" #include "QtWebPageUIClient.h" #include "QtWebUndoController.h" - #include "qquickwebview_p.h" #include "qquickwebpage_p.h" - #include <QtCore/QElapsedTimer> #include <QtCore/QObject> #include <QtCore/QScopedPointer> @@ -39,7 +39,7 @@ namespace WebKit { class DownloadProxy; class DrawingAreaProxy; class QtDialogRunner; -class QtViewportHandler; +class PageViewportControllerClientQt; class QtWebContext; class QtWebError; class QtWebPageLoadClient; @@ -87,7 +87,7 @@ public: int loadProgress() const { return m_loadProgress; } void setNeedsDisplay(); - virtual WebKit::QtViewportHandler* viewportHandler() { return 0; } + WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); } virtual void updateViewportSize() { } void updateTouchViewportSize(); @@ -128,7 +128,7 @@ public: WebCore::IntSize viewSize() const; void didReceiveMessageFromNavigatorQtObject(const String& message); virtual void pageDidRequestScroll(const QPoint& pos) { } - virtual void didChangeContentsSize(const QSize& newSize) { } + virtual void didChangeContentsSize(const QSize& newSize); void processDidCrash(); void didRelaunchProcess(); PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy(); @@ -170,7 +170,9 @@ protected: QScopedPointer<QQuickWebPage> pageView; QQuickWebView* q_ptr; - QScopedPointer<WebKit::QtViewportHandler> m_viewportHandler; + QScopedPointer<WebKit::PageViewportController> m_pageViewportController; + QScopedPointer<WebKit::PageViewportControllerClientQt> m_pageViewportControllerClient; + FlickableAxisLocker axisLocker; QQmlComponent* alertDialog; @@ -190,6 +192,7 @@ protected: bool m_navigatorQtObjectEnabled; bool m_renderToOffscreenBuffer; bool m_allowAnyHTTPSCertificateForLocalHost; + qreal m_customDevicePixelRatio; WTF::String m_iconUrl; int m_loadProgress; WTF::String m_currentUrl; @@ -211,13 +214,11 @@ class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate { Q_DECLARE_PUBLIC(QQuickWebView) public: QQuickWebViewFlickablePrivate(QQuickWebView* viewport); - virtual ~QQuickWebViewFlickablePrivate(); virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); virtual void onComponentComplete(); virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&); - virtual WebKit::QtViewportHandler* viewportHandler() { return m_viewportHandler.data(); } virtual void updateViewportSize(); virtual void pageDidRequestScroll(const QPoint& pos); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp index 1c39a53cd..a8a9c686b 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebkittest.cpp @@ -21,7 +21,7 @@ #include "config.h" #include "qwebkittest_p.h" -#include "QtViewportHandler.h" +#include "PageViewportControllerClientQt.h" #include "qquickwebview_p_p.h" #include <QMutableListIterator> #include <QTouchEvent> @@ -137,51 +137,42 @@ QSize QWebKitTest::contentsSize() const return QSize(m_webViewPrivate->pageView->contentsSize().toSize()); } -QVariant QWebKitTest::contentsScale() const +static inline QJsonObject toJsonObject(const QSizeF& sizeF) { - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return viewport->currentCSSScale(); - return 1.0; + QJsonObject result; + result.insert(QLatin1String("width"), sizeF.width()); + result.insert(QLatin1String("height"), sizeF.height()); + return result; } -QVariant QWebKitTest::devicePixelRatio() const +QJsonObject QWebKitTest::viewport() const { - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return viewport->m_devicePixelRatio; - return 1.0; -} - -QVariant QWebKitTest::initialScale() const -{ - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return viewport->m_rawAttributes.initialScale; - return 1.0; + QJsonObject viewportData; + if (const PageViewportController* const viewportHandler = m_webViewPrivate->viewportController()) { + viewportData.insert(QLatin1String("layoutSize"), toJsonObject(viewportHandler->contentsLayoutSize())); + viewportData.insert(QLatin1String("isScalable"), viewportHandler->allowsUserScaling()); + viewportData.insert(QLatin1String("minimumScale"), viewportHandler->minimumContentsScale()); + viewportData.insert(QLatin1String("maximumScale"), viewportHandler->maximumContentsScale()); + } else { + viewportData.insert(QLatin1String("initialScale"), 1.0); + viewportData.insert(QLatin1String("layoutSize"), toJsonObject(QSizeF())); + viewportData.insert(QLatin1String("isScalable"), false); + viewportData.insert(QLatin1String("minimumScale"), 1.0); + viewportData.insert(QLatin1String("maximumScale"), 1.0); + } + return viewportData; } -QVariant QWebKitTest::minimumScale() const +QVariant QWebKitTest::devicePixelRatio() const { - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return viewport->m_minimumScale; + if (const PageViewportController* const viewport = m_webViewPrivate->viewportController()) + return viewport->devicePixelRatio(); return 1.0; } -QVariant QWebKitTest::maximumScale() const +QVariant QWebKitTest::contentsScale() const { - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return viewport->m_maximumScale; + if (const PageViewportController* const viewport = m_webViewPrivate->viewportController()) + return viewport->currentContentsScale(); return 1.0; } - -QVariant QWebKitTest::isScalable() const -{ - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return !!viewport->m_rawAttributes.userScalable; - return false; -} - -QVariant QWebKitTest::layoutSize() const -{ - if (QtViewportHandler* viewport = m_webViewPrivate->viewportHandler()) - return QSizeF(viewport->m_rawAttributes.layoutSize); - return QSizeF(); -} diff --git a/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h b/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h index 3754f169a..bfabb69fb 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebkittest_p.h @@ -24,6 +24,7 @@ #include "qwebkitglobal.h" #include "qquickwebview_p.h" +#include <QtCore/QJsonObject> #include <QtCore/QObject> #include <QtCore/QPointer> #include <QtCore/QSize> @@ -40,17 +41,14 @@ class QWEBKIT_EXPORT QWebKitTest : public QObject { Q_PROPERTY(QVariant contentsScale READ contentsScale NOTIFY contentsScaleChanged) - Q_PROPERTY(QVariant devicePixelRatio READ devicePixelRatio NOTIFY viewportChanged) - Q_PROPERTY(QVariant initialScale READ initialScale NOTIFY viewportChanged) - Q_PROPERTY(QVariant isScalable READ isScalable NOTIFY viewportChanged) - Q_PROPERTY(QVariant maximumScale READ maximumScale NOTIFY viewportChanged) - Q_PROPERTY(QVariant minimumScale READ minimumScale NOTIFY viewportChanged) - Q_PROPERTY(QVariant layoutSize READ layoutSize NOTIFY viewportChanged) + Q_PROPERTY(QVariant devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) + Q_PROPERTY(QJsonObject viewport READ viewport NOTIFY viewportChanged) Q_SIGNALS: void contentsSizeChanged(); void contentsScaleChanged(); void contentsScaleCommitted(); + void devicePixelRatioChanged(); void viewportChanged(); public Q_SLOTS: @@ -68,11 +66,7 @@ public: QVariant contentsScale() const; QVariant devicePixelRatio() const; - QVariant initialScale() const; - QVariant isScalable() const; - QVariant layoutSize() const; - QVariant maximumScale() const; - QVariant minimumScale() const; + QJsonObject viewport() const; private: QQuickWebViewPrivate* m_webViewPrivate; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp index e66f368c5..e27f51264 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp @@ -71,6 +71,10 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute return WKPreferencesGetCSSCustomFilterEnabled(preferencesRef()); #endif #endif +#if ENABLE(WEB_AUDIO) + case WebAudioEnabled: + return WKPreferencesGetWebAudioEnabled(preferencesRef()); +#endif default: ASSERT_NOT_REACHED(); return false; @@ -124,6 +128,11 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a break; #endif #endif +#if ENABLE(WEB_AUDIO) + case WebAudioEnabled: + WKPreferencesSetWebAudioEnabled(preferencesRef(), enable); + break; +#endif default: ASSERT_NOT_REACHED(); } @@ -513,6 +522,25 @@ void QWebPreferences::setWebGLEnabled(bool enable) #endif } +bool QWebPreferences::webAudioEnabled() const +{ +#if ENABLE(WEB_AUDIO) + return d->testAttribute(QWebPreferencesPrivate::WebAudioEnabled); +#else + return false; +#endif +} + +void QWebPreferences::setWebAudioEnabled(bool enable) +{ +#if ENABLE(WEB_AUDIO) + d->setAttribute(QWebPreferencesPrivate::WebAudioEnabled, enable); + emit webAudioEnabledChanged(); +#else + UNUSED_PARAM(enable); +#endif +} + WKPreferencesRef QWebPreferencesPrivate::preferencesRef() const { WKPageGroupRef pageGroupRef = toAPI(webViewPrivate->webPageProxy->pageGroup()); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h index 8618f4fc3..373df7504 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h @@ -44,6 +44,7 @@ public: Q_PROPERTY(bool frameFlatteningEnabled READ frameFlatteningEnabled WRITE setFrameFlatteningEnabled NOTIFY frameFlatteningEnabledChanged FINAL) Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled NOTIFY developerExtrasEnabledChanged FINAL) Q_PROPERTY(bool webGLEnabled READ webGLEnabled WRITE setWebGLEnabled NOTIFY webGLEnabledChanged FINAL) + Q_PROPERTY(bool webAudioEnabled READ webAudioEnabled WRITE setWebAudioEnabled NOTIFY webAudioEnabledChanged FINAL) Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL) Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL) @@ -95,6 +96,9 @@ public: bool webGLEnabled() const; void setWebGLEnabled(bool enable); + bool webAudioEnabled() const; + void setWebAudioEnabled(bool enable); + QString standardFontFamily() const; void setStandardFontFamily(const QString& family); @@ -136,6 +140,7 @@ Q_SIGNALS: void frameFlatteningEnabledChanged(); void developerExtrasEnabledChanged(); void webGLEnabledChanged(); + void webAudioEnabledChanged(); void standardFontFamilyChanged(); void fixedFontFamilyChanged(); diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h index 004500c90..c606bbe89 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h @@ -40,7 +40,8 @@ public: DnsPrefetchEnabled, DeveloperExtrasEnabled, WebGLEnabled, - CSSCustomFilterEnabled + CSSCustomFilterEnabled, + WebAudioEnabled }; enum FontFamily { diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp index 6250348a6..0a7a684cf 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp @@ -185,7 +185,7 @@ PassRefPtr<WebKit::WebContextMenuProxy> QRawWebViewPrivate::createContextMenuPro } #if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebKit::WebColorChooserProxy> QRawWebViewPrivate::createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor) +PassRefPtr<WebKit::WebColorChooserProxy> QRawWebViewPrivate::createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&) { notImplemented(); return PassRefPtr<WebKit::WebColorChooserProxy>(); @@ -240,7 +240,10 @@ PassOwnPtr<WebKit::DrawingAreaProxy> QRawWebViewPrivate::createDrawingAreaProxy( } QRawWebViewPrivate::QRawWebViewPrivate(WebKit::WebContext* context, WebKit::WebPageGroup* pageGroup, QRawWebViewClient* client) - : m_client(client) + : m_focused(false) + , m_visible(false) + , m_active(false) + , m_client(client) , m_webPageProxy(context->createWebPage(this, pageGroup)) { m_webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true); @@ -325,14 +328,20 @@ QSize QRawWebView::size() const void QRawWebView::setSize(const QSize& size) { - d->m_size = size; - d->m_webPageProxy->setViewportSize(size); - - WebKit::DrawingAreaProxy* drawingArea = d->m_webPageProxy->drawingArea(); if (!drawingArea) return; + if (d->m_webPageProxy->useFixedLayout()) + d->m_webPageProxy->setViewportSize(size); + else { + WebKit::LayerTreeCoordinatorProxy* coordinator = drawingArea->layerTreeCoordinatorProxy(); + if (!coordinator) + return; + coordinator->setContentsSize(WebCore::FloatSize(size.width(), size.height())); + } + + d->m_size = size; drawingArea->setSize(d->m_size, WebCore::IntSize()); drawingArea->setVisibleContentsRect(WebCore::IntRect(WebCore::IntPoint(), d->m_size), 1 /*scale*/, WebCore::FloatPoint()); 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 0a4bf5a9e..55bc85ba0 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h @@ -25,8 +25,10 @@ #ifndef qrawwebview_p_p_h #define qrawwebview_p_p_h +#include "FindIndicator.h" #include "PageClient.h" #include "WebContextMenuProxy.h" +#include "WebEditCommandProxy.h" #include "WebPopupMenuProxy.h" #include "qrawwebview_p.h" @@ -87,7 +89,7 @@ public: virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy* webPageProxy); #if ENABLE(INPUT_TYPE_COLOR) - virtual PassRefPtr<WebKit::WebColorChooserProxy> createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor); + virtual PassRefPtr<WebKit::WebColorChooserProxy> createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&); #endif QRawWebViewPrivate(WebKit::WebContext*, WebKit::WebPageGroup*, QRawWebViewClient*); diff --git a/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h b/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h index 2262a5f1a..95b005f3a 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h +++ b/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h @@ -30,7 +30,7 @@ #include <QObject> #include <QtQuick/qquickitem.h> -class QWEBKIT_EXPORT ByteArrayTestData : public QObject { +class ByteArrayTestData : public QObject { Q_OBJECT Q_PROPERTY(QVariant latin1Data READ latin1Data) Q_PROPERTY(QVariant utf8Data READ utf8Data) diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml new file mode 100644 index 000000000..0442b53c9 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml @@ -0,0 +1,62 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 1.0 +import "../common" + + +TestWebView { + id: webView + property variant lastResult + width: 400 + height: 300 + focus: true + + SignalSpy { + id: resultSpy + target: webView + signalName: "lastResultChanged" + } + + TestCase { + name: "DevicePixelRatio" + + function init() { + resultSpy.clear() + webView.lastResult = null + } + + function test_devicePixelRatio() { + resultSpy.clear() + webView.url = Qt.resolvedUrl("../common/test1.html"); + webView.experimental.devicePixelRatio = 2.0 + verify(webView.waitForLoadSucceeded()) + + webView.experimental.evaluateJavaScript( + "(function() { return window.devicePixelRatio })()", + function(result) { + webView.lastResult = result + }) + + resultSpy.wait() + compare(webView.lastResult, 2.0) + compare(webView.lastResult, webView.experimental.devicePixelRatio) + } + + function test_devicePixelRatioMediaQuery() { + resultSpy.clear() + webView.url = Qt.resolvedUrl("../common/test2.html"); + webView.experimental.devicePixelRatio = 2.0 + verify(webView.waitForLoadSucceeded()) + + webView.experimental.evaluateJavaScript( + "(function() { return window.matchMedia(\"(-webkit-device-pixel-ratio: 2)\").matches })()", + function(result) { + webView.lastResult = result + }) + + resultSpy.wait() + verify(webView.lastResult) + } + } +} 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 b2a860e73..691455708 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 @@ -13,8 +13,6 @@ Item { property variant result - experimental.test.onContentsScaleCommitted: scaleChanged() - property variant content: "data:text/html," + "<head>" + " <meta name='viewport' content='width=device-width'>" + @@ -26,7 +24,6 @@ Item { "</body>" signal resultReceived - signal scaleChanged } SignalSpy { @@ -37,8 +34,8 @@ Item { SignalSpy { id: scaleSpy - target: webView - signalName: "scaleChanged" + target: webView.experimental.test + signalName: "contentsScaleCommitted" } TestCase { @@ -67,8 +64,8 @@ Item { var result; webView.experimental.evaluateJavaScript( - "document.getElementById('" + id + "').getBoundingClientRect();", - function(rect) { webView.resultReceived(); result = rect }); + "JSON.stringify(document.getElementById('" + id + "').getBoundingClientRect());", + function(rect) { webView.resultReceived(); result = JSON.parse(rect); }); resultSpy.wait(); return result; } 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 febd948b8..f12da5de8 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 @@ -13,8 +13,6 @@ Item { property variant result - experimental.test.onContentsScaleCommitted: scaleChanged() - property variant content: "data:text/html," + "<head>" + " <meta name='viewport' content='width=device-width'>" + @@ -24,7 +22,6 @@ Item { "</body>" signal resultReceived - signal scaleChanged } SignalSpy { @@ -35,8 +32,8 @@ Item { SignalSpy { id: scaleSpy - target: webView - signalName: "scaleChanged" + target: webView.experimental.test + signalName: "contentsScaleCommitted" } TestCase { 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 d24312610..1fc1559ab 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 @@ -42,5 +42,16 @@ Item { // The check below will fail if the previous position was not restored after reload. verify(position == webView.contentY) } + + function test_wheelScrollEventAfterReload() { + scrollSpy.clear() + webView.reload() + verify(webView.waitForLoadSucceeded()) + 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. + scrollSpy.wait() + } } + } 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 93d669cee..0338ecff6 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp @@ -150,7 +150,7 @@ class tst_qrawwebview : public QObject { Q_OBJECT public: tst_qrawwebview() - : m_resourceDir(QString::fromAscii(TESTS_SOURCE_DIR "/html/resources")) + : m_resourceDir(QString::fromLatin1(TESTS_SOURCE_DIR "/html/resources")) , m_baseUrl(QUrl::fromLocalFile(TESTS_SOURCE_DIR "/html").toString()) { } |