From: David Steele Date: Fri, 29 Jan 2021 12:54:08 +0000 (+0000) Subject: [dali_2.0.11] Merge branch 'devel/master' X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=41c8e6862c377913d579544ee6103a6c8aa482d1;hp=e9075a50279076fa8d070e8ee53b7922779a8b66 [dali_2.0.11] Merge branch 'devel/master' Change-Id: Ib549cf4cc158bdc3dd5443feefad3b60c7a4529a --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index a4b45c9..c6e63e7 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@ -2,7 +2,7 @@ #define DALI_TEST_SUITE_UTILS_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -417,25 +417,25 @@ inline void DALI_TEST_PRINT_ASSERT(DaliException& e) * @param expressions code to execute * @param except the exception expected in the assert */ -#define DALI_TEST_THROWS(expressions, except) \ - try \ - { \ - TestApplication::EnableLogging(false); \ - expressions; \ - TestApplication::EnableLogging(true); \ - fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \ - tet_result(TET_FAIL); \ - throw("TET_FAIL"); \ - } \ - catch(except &) \ - { \ - tet_result(TET_PASS); \ - } \ - catch(...) \ - { \ - fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \ - tet_result(TET_FAIL); \ - throw; \ +#define DALI_TEST_THROWS(expressions, except) \ + try \ + { \ + TestApplication::EnableLogging(false); \ + expressions; \ + TestApplication::EnableLogging(true); \ + fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \ + tet_result(TET_FAIL); \ + throw("TET_FAIL"); \ + } \ + catch(except&) \ + { \ + tet_result(TET_PASS); \ + } \ + catch(...) \ + { \ + fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \ + tet_result(TET_FAIL); \ + throw; \ } // Functor to test whether an Applied signal is emitted diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 9d7a582..d6419ff 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -18,6 +18,12 @@ #include "toolkit-timer.h" #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -58,6 +64,228 @@ static void DisconnectFromGlobalSignal( bool (*func)() ) } } +class MockWebEngineContext : public Dali::WebEngineContext +{ +public: + MockWebEngineContext() + : mockModel( Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER ) + { + } + + Dali::WebEngineContext::CacheModel GetCacheModel() const override + { + return mockModel; + } + + void SetCacheModel( Dali::WebEngineContext::CacheModel cacheModel ) override + { + mockModel = cacheModel; + } + + void SetProxyUri( const std::string& uri ) override + { + } + + void SetDefaultProxyAuth( const std::string& username, const std::string& password ) override + { + } + + void SetCertificateFilePath( const std::string& certificatePath ) override + { + } + + void DeleteWebDatabase() override + { + } + + void DeleteWebStorage() override + { + } + + void DeleteLocalFileSystem() override + { + } + + void DisableCache( bool cacheDisabled ) override + { + } + + void ClearCache() override + { + } + +private: + Dali::WebEngineContext::CacheModel mockModel; +}; + +class MockWebEngineCookieManager : public Dali::WebEngineCookieManager +{ +public: + MockWebEngineCookieManager() + : mockCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY ) + { + } + + void SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy policy ) override + { + mockCookieAcceptPolicy = policy; + } + + Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const override + { + return mockCookieAcceptPolicy; + } + + void ClearCookies() override + { + } + + void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) override + { + } + +private: + Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy; +}; + +class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem +{ +public: + MockWebEngineBackForwardListItem() + : mockUrl( "http://url" ), + mockTitle( "title" ), + mockOriginalUrl( "http://originalurl" ) + { + } + + std::string GetUrl() const override + { + return mockUrl; + } + + std::string GetTitle() const override + { + return mockTitle; + } + + std::string GetOriginalUrl() const override + { + return mockOriginalUrl; + } + +private: + std::string mockUrl; + std::string mockTitle; + std::string mockOriginalUrl; +}; + +class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList +{ +public: + MockWebEngineBackForwardList( ) + : mockItem(), + pMockItem( &mockItem ) + { + } + + Dali::WebEngineBackForwardListItem& GetCurrentItem() const override + { + return *pMockItem; + } + + Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override + { + return *pMockItem; + } + + uint32_t GetItemCount() const override + { + return 1; + } + +private: + MockWebEngineBackForwardListItem mockItem; + WebEngineBackForwardListItem* pMockItem; +}; + +class MockWebEngineSettings : public WebEngineSettings +{ +public: + MockWebEngineSettings() + : mockDefaultFontSize( 16 ), + mockJavaScriptEnabled( true ), + mockImageLoadedAutomatically( true ), + mockDefaultTextEncodingName() + { + } + + uint32_t GetDefaultFontSize() const override + { + return mockDefaultFontSize; + } + + void SetDefaultFontSize( uint32_t size ) override + { + mockDefaultFontSize = size; + } + + bool IsJavaScriptEnabled() const override + { + return mockJavaScriptEnabled; + } + + void EnableJavaScript( bool enabled ) override + { + mockJavaScriptEnabled = enabled; + } + + bool AreImagesLoadedAutomatically() const override + { + return mockImageLoadedAutomatically; + } + + void AllowImagesLoadAutomatically( bool automatic ) override + { + mockImageLoadedAutomatically = automatic; + } + + std::string GetDefaultTextEncodingName() const override + { + return mockDefaultTextEncodingName; + } + + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) override + { + mockDefaultTextEncodingName = defaultTextEncodingName; + } + + void AllowMixedContents( bool allowed ) override + { + } + + void EnableSpatialNavigation( bool enabled ) override + { + } + + void EnableWebSecurity( bool enabled ) override + { + } + + void AllowFileAccessFromExternalUrl( bool allowed ) override + { + } + + void AllowScriptsOpenWindows( bool allowed ) override + { + } + +private: + int mockDefaultFontSize; + bool mockJavaScriptEnabled; + bool mockImageLoadedAutomatically; + std::string mockDefaultTextEncodingName; +}; + class WebEngine: public Dali::BaseObject { public: @@ -65,13 +293,7 @@ public: WebEngine() : mUrl() , mCurrentPlusOnePos( 0 ) - , mCacheModel( Dali::WebEnginePlugin::CacheModel::DOCUMENT_VIEWER ) - , mCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy::NO_THIRD_PARTY ) , mUserAgent() - , mEnableJavaScript( true ) - , mLoadImagesAutomatically( true ) - , mDefaultTextEncodingName() - , mDefaultFontSize( 16 ) , mEvaluating( false ) , mScrollPosition( 0, 0 ) , mScrollSize( 500, 500 ) @@ -79,6 +301,11 @@ public: { gInstanceCount++; gInstance = this; + + mockWebEngineSettings = new MockWebEngineSettings(); + mockWebEngineContext = new MockWebEngineContext(); + mockWebEngineCookieManager = new MockWebEngineCookieManager(); + mockWebEngineBackForwardList = new MockWebEngineBackForwardList(); } virtual ~WebEngine() @@ -88,6 +315,31 @@ public: { gInstance = NULL; } + + delete mockWebEngineSettings; + delete mockWebEngineContext; + delete mockWebEngineCookieManager; + delete mockWebEngineBackForwardList; + } + + Dali::WebEngineSettings& GetSettings() const + { + return *mockWebEngineSettings; + } + + Dali::WebEngineContext& GetContext() const + { + return *mockWebEngineContext; + } + + Dali::WebEngineCookieManager& GetCookieManager() const + { + return *mockWebEngineCookieManager; + } + + Dali::WebEngineBackForwardList& GetBackForwardList() const + { + return *mockWebEngineBackForwardList; } void LoadUrl( const std::string& url ) @@ -101,6 +353,37 @@ public: return mUrl; } + std::string GetTitle() const + { + return std::string("title"); + } + + Dali::PixelData GetFavicon() const + { + uint8_t* faviconData = new uint8_t[ 16 ]; + + faviconData[ 0 ] = 0xff; + faviconData[ 1 ] = 0x00; + faviconData[ 2 ] = 0x00; + faviconData[ 3 ] = 0xff; + faviconData[ 4 ] = 0xff; + faviconData[ 5 ] = 0x00; + faviconData[ 6 ] = 0x00; + faviconData[ 7 ] = 0xff; + faviconData[ 8 ] = 0xff; + faviconData[ 9 ] = 0x00; + faviconData[ 10 ] = 0x00; + faviconData[ 11 ] = 0xff; + faviconData[ 12 ] = 0xff; + faviconData[ 13 ] = 0x00; + faviconData[ 14 ] = 0x00; + faviconData[ 15 ] = 0xff; + + return Dali::PixelData::New( faviconData, 16, 2, 2, + Dali::Pixel::Format::RGBA8888, + Dali::PixelData::ReleaseFunction::DELETE_ARRAY ); + } + bool CanGoForward() const { return mHistory.size() > mCurrentPlusOnePos; @@ -138,26 +421,6 @@ public: ConnectToGlobalSignal( &OnClearHistory ); } - Dali::WebEnginePlugin::CacheModel GetCacheModel() const - { - return mCacheModel; - } - - void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) - { - mCacheModel = cacheModel; - } - - Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const - { - return mCookieAcceptPolicy; - } - - void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) - { - mCookieAcceptPolicy = policy; - } - const std::string& GetUserAgent() const { return mUserAgent; @@ -168,46 +431,6 @@ public: mUserAgent = userAgent; } - bool IsJavaScriptEnabled() const - { - return mEnableJavaScript; - } - - void EnableJavaScript( bool enabled ) - { - mEnableJavaScript = enabled; - } - - bool AreImagesAutomaticallyLoaded() const - { - return mLoadImagesAutomatically; - } - - void LoadImagesAutomatically( bool automatic ) - { - mLoadImagesAutomatically = automatic; - } - - const std::string& GetDefaultTextEncodingName() const - { - return mDefaultTextEncodingName; - } - - void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) - { - mDefaultTextEncodingName = defaultTextEncodingName; - } - - int GetDefaultFontSize() const - { - return mDefaultFontSize; - } - - void SetDefaultFontSize( int defaultFontSize ) - { - mDefaultFontSize = defaultFontSize; - } - void ScrollBy( int dx, int dy ) { mScrollPosition += Dali::Vector2( dx, dy ); @@ -223,22 +446,19 @@ public: mScrollPosition.y = y; } - void GetScrollPosition( int& x, int& y ) const + Dali::Vector2 GetScrollPosition() const { - x = mScrollPosition.x; - y = mScrollPosition.y; + return mScrollPosition; } - void GetScrollSize( int& w, int& h ) const + Dali::Vector2 GetScrollSize() const { - w = mScrollSize.width; - h = mScrollSize.height; + return mScrollSize; } - void GetContentSize( int& w, int& h ) const + Dali::Vector2 GetContentSize() const { - w = mContentSize.width; - h = mContentSize.height; + return mContentSize; } Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal() @@ -264,13 +484,7 @@ public: std::string mUrl; std::vector< std::string > mHistory; size_t mCurrentPlusOnePos; - Dali::WebEnginePlugin::CacheModel mCacheModel; - Dali::WebEnginePlugin::CookieAcceptPolicy mCookieAcceptPolicy; std::string mUserAgent; - bool mEnableJavaScript; - bool mLoadImagesAutomatically; - std::string mDefaultTextEncodingName; - int mDefaultFontSize; Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal; Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal; Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal; @@ -281,6 +495,10 @@ public: Dali::Vector2 mScrollPosition; Dali::Vector2 mScrollSize; Dali::Vector2 mContentSize; + WebEngineBackForwardList* mockWebEngineBackForwardList; + WebEngineContext* mockWebEngineContext; + WebEngineCookieManager* mockWebEngineCookieManager; + WebEngineSettings* mockWebEngineSettings; }; inline WebEngine& GetImplementation( Dali::WebEngine& webEngine ) @@ -415,15 +633,49 @@ void WebEngine::Create( int width, int height, const std::string& locale, const { } +void WebEngine::Create( int width, int height, int argc, char** argv ) +{ +} + void WebEngine::Destroy() { } +WebEngineSettings& WebEngine::GetSettings() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetSettings(); +} + +WebEngineContext& WebEngine::GetContext() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetContext(); +} + +WebEngineCookieManager& WebEngine::GetCookieManager() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetCookieManager(); +} + +WebEngineBackForwardList& WebEngine::GetBackForwardList() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList(); +} + void WebEngine::LoadUrl( const std::string& url ) { return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url ); } +std::string WebEngine::GetTitle() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetTitle(); +} + +Dali::PixelData WebEngine::GetFavicon() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetFavicon(); +} + const std::string& WebEngine::GetUrl() { return Internal::Adaptor::GetImplementation( *this ).GetUrl(); @@ -436,7 +688,7 @@ NativeImageInterfacePtr WebEngine::GetNativeImageSource() return sourcePtr; } -void WebEngine::LoadHTMLString( const std::string& htmlString ) +void WebEngine::LoadHtmlString( const std::string& htmlString ) { } @@ -485,37 +737,13 @@ void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectNam { } -void WebEngine::ClearHistory() -{ - Internal::Adaptor::GetImplementation( *this ).ClearHistory(); -} - -void WebEngine::ClearCache() -{ -} - -void WebEngine::ClearCookies() -{ -} - -Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const +void WebEngine::ClearAllTilesResources() { - return Internal::Adaptor::GetImplementation( *this ).GetCacheModel(); } -void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) -{ - Internal::Adaptor::GetImplementation( *this ).SetCacheModel( cacheModel ); -} - -Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const -{ - return Internal::Adaptor::GetImplementation( *this ).GetCookieAcceptPolicy(); -} - -void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) +void WebEngine::ClearHistory() { - Internal::Adaptor::GetImplementation( *this ).SetCookieAcceptPolicy( policy ); + Internal::Adaptor::GetImplementation( *this ).ClearHistory(); } const std::string& WebEngine::GetUserAgent() const @@ -528,46 +756,6 @@ void WebEngine::SetUserAgent( const std::string& userAgent ) Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent ); } -bool WebEngine::IsJavaScriptEnabled() const -{ - return Internal::Adaptor::GetImplementation( *this ).IsJavaScriptEnabled(); -} - -void WebEngine::EnableJavaScript( bool enabled ) -{ - Internal::Adaptor::GetImplementation( *this ).EnableJavaScript( enabled ); -} - -bool WebEngine::AreImagesAutomaticallyLoaded() const -{ - return Internal::Adaptor::GetImplementation( *this ).AreImagesAutomaticallyLoaded(); -} - -void WebEngine::LoadImagesAutomatically( bool automatic ) -{ - Internal::Adaptor::GetImplementation( *this ).LoadImagesAutomatically( automatic ); -} - -const std::string& WebEngine::GetDefaultTextEncodingName() const -{ - return Internal::Adaptor::GetImplementation( *this ).GetDefaultTextEncodingName(); -} - -void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) -{ - Internal::Adaptor::GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName ); -} - -int WebEngine::GetDefaultFontSize() const -{ - return Internal::Adaptor::GetImplementation( *this ).GetDefaultFontSize(); -} - -void WebEngine::SetDefaultFontSize( int defaultFontSize ) -{ - Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize ); -} - void WebEngine::ScrollBy( int dx, int dy ) { Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy ); @@ -578,19 +766,19 @@ void WebEngine::SetScrollPosition( int x, int y ) Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y ); } -void WebEngine::GetScrollPosition( int& x, int& y ) const +Dali::Vector2 WebEngine::GetScrollPosition() const { - Internal::Adaptor::GetImplementation( *this ).GetScrollPosition( x, y ); + return Internal::Adaptor::GetImplementation( *this ).GetScrollPosition(); } -void WebEngine::GetScrollSize( int& w, int& h ) const +Dali::Vector2 WebEngine::GetScrollSize() const { - Internal::Adaptor::GetImplementation( *this ).GetScrollSize( w, h ); + return Internal::Adaptor::GetImplementation( *this ).GetScrollSize(); } -void WebEngine::GetContentSize( int& w, int& h ) const +Dali::Vector2 WebEngine::GetContentSize() const { - Internal::Adaptor::GetImplementation( *this ).GetContentSize( w, h ); + return Internal::Adaptor::GetImplementation( *this ).GetContentSize(); } void WebEngine::SetSize( int width, int height ) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp index 3d538cd..243a73b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include "dummy-control.h" @@ -74,7 +75,9 @@ int UtcDaliAnimatedImageVisualGetPropertyMap01(void) .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME ) .Add( ImageVisual::Property::PIXEL_AREA, Vector4() ) .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT ) - .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )); + .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT ) + .Add( DevelVisual::Property::CORNER_RADIUS, 22.2f ) + .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE )); Property::Map resultMap; animatedImageVisual.CreatePropertyMap( resultMap ); @@ -87,6 +90,14 @@ int UtcDaliAnimatedImageVisualGetPropertyMap01(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == TEST_GIF_FILE_NAME ); + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), 22.2f, TEST_LOCATION ); + + value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::Transform::Policy::ABSOLUTE ); + // request AnimatedImageVisual with an URL Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() ); resultMap.Clear(); @@ -124,7 +135,9 @@ int UtcDaliAnimatedImageVisualGetPropertyMap02(void) .Add( "frameDelay", 200 ) .Add( "pixelArea", Vector4() ) .Add( "wrapModeU", WrapMode::REPEAT ) - .Add( "wrapModeV", WrapMode::DEFAULT )); + .Add( "wrapModeV", WrapMode::DEFAULT ) + .Add( "cornerRadius", 50.0f ) + .Add( "cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE )); Property::Map resultMap; animatedImageVisual.CreatePropertyMap( resultMap ); @@ -159,6 +172,14 @@ int UtcDaliAnimatedImageVisualGetPropertyMap02(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), 11, TEST_LOCATION ); + value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), 50.0f, TEST_LOCATION ); + + value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::Transform::Policy::RELATIVE ); + END_TEST; } @@ -183,7 +204,8 @@ int UtcDaliAnimatedImageVisualGetPropertyMap03(void) .Add( "frameDelay", 200 ) .Add( "pixelArea", Vector4() ) .Add( "wrapModeU", WrapMode::REPEAT ) - .Add( "wrapModeV", WrapMode::DEFAULT )); + .Add( "wrapModeV", WrapMode::DEFAULT ) + .Add( "cornerRadius", 50.5f )); Property::Map resultMap; animatedImageVisual.CreatePropertyMap( resultMap ); @@ -218,6 +240,14 @@ int UtcDaliAnimatedImageVisualGetPropertyMap03(void) DALI_TEST_CHECK( value ); DALI_TEST_EQUALS( value->Get(), 11, TEST_LOCATION ); + value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get(), 50.5f, TEST_LOCATION ); + + value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get() == Visual::Transform::Policy::ABSOLUTE ); + END_TEST; } @@ -271,12 +301,14 @@ int UtcDaliAnimatedImageVisualSynchronousLoading(void) { Property::Map propertyMap; - propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE ); - propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME ); - propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2); - propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2); - propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20); - propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true); + propertyMap.Insert( Visual::Property::TYPE, Visual::ANIMATED_IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2 ); + propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2 ); + propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20 ); + propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true ); + propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 0.23f ); + propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE ); VisualFactory factory = VisualFactory::Get(); Visual::Base visual = factory.CreateVisual( propertyMap ); @@ -1273,4 +1305,4 @@ int UtcDaliAnimatedImageVisualPlayback(void) } END_TEST; -} \ No newline at end of file +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 534aeb6..42a9e91 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -139,7 +139,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ); + .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ) + .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -170,6 +171,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" ); int startFrame = 1, endFrame = 3; + float cornerRadius = 50.0f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -181,7 +183,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) .Add( "playRange", playRange ) .Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME ) .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE ) - .Add( "redrawInScalingDown", false ); + .Add( "redrawInScalingDown", false ) + .Add( "cornerRadius", cornerRadius ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -237,6 +240,14 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get< bool >() == false ); + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::ABSOLUTE ); + actor.Unparent( ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); @@ -249,6 +260,7 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" ); int startFrame = 1, endFrame = 3; + float cornerRadius = 50.0f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -257,7 +269,9 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ); + .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ) + .Add( DevelVisual::Property::CORNER_RADIUS, cornerRadius ) + .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE); // request AnimatedVectorImageVisual with a property map VisualFactory factory = VisualFactory::Get(); @@ -317,6 +331,14 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get< bool >() == true ); // Check default value + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::RELATIVE ); + // request AnimatedVectorImageVisual with an URL Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 6f3fa6a..761e88e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -3617,6 +3617,8 @@ int UtcDaliVisualRoundedCorner(void) application.Render(); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION ); + // Default corner radius policy is absolute. + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION ); } // color visual 1 @@ -3759,8 +3761,114 @@ int UtcDaliVisualRoundedCorner(void) application.Render(); DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION ); + // Default corner radius policy is absolute. + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION ); } + // animated image visual + { + VisualFactory factory = VisualFactory::Get(); + Property::Map properties; + float cornerRadius = 24.0f; + + properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE; + properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME; + properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius + 10.0f; // Dummy Input + properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius; + properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE; + + Visual::Base visual = factory.CreateVisual( properties ); + + // trigger creation through setting on stage + DummyControl dummy = DummyControl::New( true ); + Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + + dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); + dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + application.GetScene().Add( dummy ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION ); + } + + // vector image visual + { + VisualFactory factory = VisualFactory::Get(); + Property::Map properties; + float cornerRadius = 27.0f; + + properties[Visual::Property::TYPE] = Visual::SVG; + properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME; + properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius; + + Visual::Base visual = factory.CreateVisual( properties ); + + // trigger creation through setting on stage + DummyControl dummy = DummyControl::New( true ); + Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + + dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); + dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + application.GetScene().Add( dummy ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION ); + // Default corner radius policy is absolute. + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION ); + } + + // animated vector image visual + { + VisualFactory factory = VisualFactory::Get(); + Property::Map properties; + float cornerRadius = 1.3f; + + properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE; + properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME; + properties["cornerRadius"] = cornerRadius; + properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE; + + Visual::Base visual = factory.CreateVisual( properties ); + + // trigger creation through setting on stage + DummyControl dummy = DummyControl::New( true ); + Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); + + dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); + dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + application.GetScene().Add( dummy ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION ); + } + + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 0ca47b6..0d02ccf 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -24,10 +24,16 @@ #include #include #include +#include +#include #include +#include +#include +#include +#include +#include #include - using namespace Dali; using namespace Toolkit; @@ -207,8 +213,6 @@ int UtcDaliWebViewPageNavigation(void) view.Reload(); view.StopLoading(); view.ClearHistory(); - view.ClearCache(); - view.ClearCookies(); Test::EmitGlobalTimerSignal(); DALI_TEST_CHECK( !view.CanGoBack() ); DALI_TEST_CHECK( !view.CanGoForward() ); @@ -286,211 +290,95 @@ int UtcDaliWebViewFocusGainedAndLost(void) END_TEST; } -int UtcDaliWebViewProperty1(void) +int UtcDaliWebViewGetWebBackForwardList(void) { - // URL ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); - std::string local; - view.SetProperty( WebView::Property::URL, TEST_URL1 ); - Property::Value val = view.GetProperty( WebView::Property::URL ); - DALI_TEST_CHECK( val.Get( local ) ); - DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION ); + Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList(); + DALI_TEST_CHECK( bfList != 0 ); END_TEST; } -int UtcDaliWebViewProperty2(void) +int UtcDaliWebViewGetWebContext(void) { - // CACHE_MODEL ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); - const std::string kDefaultValue = "DOCUMENT_VIEWER"; - const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER; - const std::string kTestValue = "PRIMARY_WEB_BROWSER"; - - // Check default value - std::string output; - Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum ); - value = view.GetProperty( WebView::Property::CACHE_MODEL ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); - - view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue ); - value = view.GetProperty( WebView::Property::CACHE_MODEL ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + Dali::Toolkit::WebContext* context = view.GetContext(); + DALI_TEST_CHECK( context != 0 ); END_TEST; } -int UtcDaliWebViewProperty3(void) +int UtcDaliWebViewGetWebCookieManager(void) { - // COOKIE_ACCEPT_POLICY ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); - const std::string kDefaultValue = "NO_THIRD_PARTY"; - const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER; - const std::string kTestValue = "NEVER"; - - // Check default value - std::string output; - Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum ); - value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); - - view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue ); - value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + DALI_TEST_CHECK( cookieManager != 0 ); END_TEST; } -int UtcDaliWebViewProperty4(void) +int UtcDaliWebViewGetWebSettings(void) { - // USER_AGENT ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); - const std::string kDefaultValue; - const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; - - // Check default value - std::string output; - Property::Value value = view.GetProperty( WebView::Property::USER_AGENT ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::USER_AGENT, kTestValue ); - value = view.GetProperty( WebView::Property::USER_AGENT ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliWebViewProperty5(void) -{ - // ENABLE_JAVASCRIPT - ToolkitTestApplication application; - - WebView view = WebView::New(); - DALI_TEST_CHECK( view ); - - const bool kDefaultValue = true; - const bool kTestValue = false; - - // Check default value - bool output; - Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue ); - value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + Dali::Toolkit::WebSettings* settings = view.GetSettings(); + DALI_TEST_CHECK( settings != 0 ); END_TEST; } -int UtcDaliWebViewProperty6(void) +int UtcDaliWebViewProperty1(void) { - // LOAD_IMAGES_AUTOMATICALLY + // URL ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); - const bool kDefaultValue = true; - const bool kTestValue = false; - - // Check default value - bool output; - Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue ); - value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + std::string local; + view.SetProperty( WebView::Property::URL, TEST_URL1 ); + Property::Value val = view.GetProperty( WebView::Property::URL ); + DALI_TEST_CHECK( val.Get( local ) ); + DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION ); END_TEST; } -int UtcDaliWebViewProperty7(void) +int UtcDaliWebViewProperty4(void) { - // DEFAULT_TEXT_ENCODING_NAME + // USER_AGENT ToolkitTestApplication application; WebView view = WebView::New(); DALI_TEST_CHECK( view ); const std::string kDefaultValue; - const std::string kTestValue = "UTF-8"; + const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; // Check default value std::string output; - Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); - - // Check Set/GetProperty - view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue ); - value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME ); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliWebViewProperty8(void) -{ - // DEFAULT_FONT_SIZE - ToolkitTestApplication application; - - WebView view = WebView::New(); - DALI_TEST_CHECK( view ); - - const int kDefaultValue = 16; - const int kTestValue = 26; - - // Check default value - int output; - Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE ); + Property::Value value = view.GetProperty( WebView::Property::USER_AGENT ); DALI_TEST_CHECK( value.Get( output ) ); DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); // Check Set/GetProperty - view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue ); - value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE ); + view.SetProperty( WebView::Property::USER_AGENT, kTestValue ); + value = view.GetProperty( WebView::Property::USER_AGENT ); DALI_TEST_CHECK( value.Get( output ) ); DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); @@ -529,6 +417,33 @@ int UtcDaliWebViewProperty9(void) END_TEST; } +int UtcDaliWebViewPropertyTitleFavicon(void) +{ + // SCROLL_POSITION + ToolkitTestApplication application; + + char argv[] = "--test"; + WebView view = WebView::New( 1, (char**)&argv ); + DALI_TEST_CHECK( view ); + + // reset something + view.ClearAllTilesResources(); + + // Check default value of title + std::string testValue("title"); + std::string output; + view.GetProperty( WebView::Property::TITLE ).Get( output ); + DALI_TEST_EQUALS( output, testValue, TEST_LOCATION ); + + // Check default value of favicon + Dali::Toolkit::ImageView* favicon = &view.GetFavicon(); + DALI_TEST_CHECK( favicon ); + Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE ); + DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 ); + + END_TEST; +} + int UtcDaliWebViewScrollBy(void) { ToolkitTestApplication application; @@ -569,7 +484,7 @@ int UtcDaliWebViewEvaluteJavaScript(void) WebView view = WebView::New( "ko-KR", "Asia/Seoul" ); - view.LoadHTMLString( "Hello World!" ); + view.LoadHtmlString( "Hello World!" ); view.EvaluateJavaScript( "jsObject.postMessage('Hello')" ); view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript ); Test::EmitGlobalTimerSignal(); @@ -579,14 +494,13 @@ int UtcDaliWebViewEvaluteJavaScript(void) END_TEST; } - int UtcDaliWebViewMethodsForCoverage(void) { ToolkitTestApplication application; WebView view = WebView::New( "ko-KR", "Asia/Seoul" ); - view.LoadHTMLString( "Hello World!" ); + view.LoadHtmlString( "Hello World!" ); view.AddJavaScriptMessageHandler( "jsObject", []( const std::string& arg ) { } @@ -596,3 +510,227 @@ int UtcDaliWebViewMethodsForCoverage(void) END_TEST; } + +// test cases for web backforward list. + +int UtcDaliWebBackForwardListCheckItem(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList(); + DALI_TEST_CHECK( bfList != 0 ) + + unsigned int itemCount = bfList->GetItemCount(); + DALI_TEST_CHECK( itemCount == 1 ) + + Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem(); + DALI_TEST_CHECK( citem != 0 ); + + const std::string kDefaultUrl( "http://url" ); + std::string testValue = citem->GetUrl(); + DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION ); + + const std::string kDefaultTitle( "title" ); + testValue = citem->GetTitle(); + DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION ); + + const std::string kDefaultOriginalUrl( "http://originalurl" ); + testValue = citem->GetOriginalUrl(); + DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION ); + + Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 ); + DALI_TEST_CHECK( item != 0 ); + + END_TEST; +} + +// test cases for web context. + +int UtcDaliWebContextGetSetCacheModel(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebContext* context = view.GetContext(); + DALI_TEST_CHECK( context != 0 ) + + std::string kDefaultValue; + + // Reset something + context->SetProxyUri( kDefaultValue ); + context->SetCertificateFilePath( kDefaultValue ); + context->DisableCache( false ); + context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue ); + context->DeleteWebDatabase(); + context->DeleteWebStorage(); + context->DeleteLocalFileSystem(); + context->ClearCache(); + + // Check default value + Dali::WebEngineContext::CacheModel value = context->GetCacheModel(); + DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER ); + + // Check Set/GetProperty + context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER ); + value = context->GetCacheModel(); + DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER ); + + END_TEST; +} + +// test cases for web cookie manager. + +int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + DALI_TEST_CHECK( cookieManager != 0 ) + + const std::string kDefaultValue; + + // Reset something + cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE ); + cookieManager->ClearCookies(); + + // Check default value + Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy(); + DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY ); + + // Check Set/GetProperty + cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS ); + value = cookieManager->GetCookieAcceptPolicy(); + DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS ); + + END_TEST; +} + +// test cases for web settings. + +int UtcDaliWebSettingsGetSetDefaultFontSize(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebSettings* settings = view.GetSettings(); + DALI_TEST_CHECK( settings != 0 ) + + // Reset something + settings->AllowMixedContents( false ); + settings->EnableSpatialNavigation( false ); + settings->EnableWebSecurity( false ); + settings->AllowFileAccessFromExternalUrl( false ); + settings->AllowScriptsOpenWindows( false ); + + // Check default value + int value = settings->GetDefaultFontSize(); + DALI_TEST_CHECK( value == 16 ); + + // Check Set/GetProperty + settings->SetDefaultFontSize( 20 ); + value = settings->GetDefaultFontSize(); + DALI_TEST_CHECK( value == 20 ); + + END_TEST; +} + +int UtcDaliWebSettingsCheckEnableJavaScript(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebSettings* settings = view.GetSettings(); + DALI_TEST_CHECK( settings != 0 ) + + // Reset something + settings->AllowMixedContents( false ); + settings->EnableSpatialNavigation( false ); + settings->EnableWebSecurity( false ); + settings->AllowFileAccessFromExternalUrl( false ); + settings->AllowScriptsOpenWindows( false ); + + // Check default value is true or not + bool value = settings->IsJavaScriptEnabled(); + DALI_TEST_CHECK( value ); + + // Check Set/GetProperty + settings->EnableJavaScript( false ); + value = settings->IsJavaScriptEnabled(); + DALI_TEST_CHECK( !value ); + + END_TEST; +} + +int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebSettings* settings = view.GetSettings(); + DALI_TEST_CHECK( settings != 0 ) + + // Reset something + settings->AllowMixedContents( false ); + settings->EnableSpatialNavigation( false ); + settings->EnableWebSecurity( false ); + settings->AllowFileAccessFromExternalUrl( false ); + settings->AllowScriptsOpenWindows( false ); + + // Check default value is true or not + bool value = settings->AreImagesLoadedAutomatically(); + DALI_TEST_CHECK( value ); + + // Check Set/GetProperty + settings->AllowImagesLoadAutomatically( false ); + value = settings->AreImagesLoadedAutomatically(); + DALI_TEST_CHECK( !value ); + + END_TEST; +} + +int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Toolkit::WebSettings* settings = view.GetSettings(); + DALI_TEST_CHECK( settings != 0 ) + + const std::string kDefaultValue; + const std::string kTestValue = "UTF-8"; + + // Reset something + settings->AllowMixedContents( false ); + settings->EnableSpatialNavigation( false ); + settings->EnableWebSecurity( false ); + settings->AllowFileAccessFromExternalUrl( false ); + settings->AllowScriptsOpenWindows( false ); + + // Check default value + std::string value = settings->GetDefaultTextEncodingName(); + DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + settings->SetDefaultTextEncodingName( kTestValue ); + value = settings->GetDefaultTextEncodingName(); + DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION ); + + END_TEST; +} + diff --git a/dali-toolkit/devel-api/builder/builder.h b/dali-toolkit/devel-api/builder/builder.h index f10f037..b255c11 100644 --- a/dali-toolkit/devel-api/builder/builder.h +++ b/dali-toolkit/devel-api/builder/builder.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_UIBUILDER_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,9 +163,23 @@ public: * @brief Adds user defined constants to all future style template or animation expansions * * e.g. - * Property::Map map; - * map["IMAGE_DIRECTORY"] = "/usr/share/images"; - * builder.AddConstants( map ); + * @code + * Property::Map map; + * map["IMAGE_DIRECTORY"] = "/usr/share/images"; + * builder.AddConstants( map ); + * @endcode + * + * The following shows a list of constants available by default: + * + * Constant | Description + * ----------------------------- | ---------------------------------------------------------------------------------------------------- + * DALI_IMAGE_DIR | The Image Directory used by Toolkit. + * DALI_SOUND_DIR | The Sound Directory used by Toolkit. + * DALI_STYLE_DIR | The Style directory that the Toolkit uses. + * DALI_STYLE_IMAGE_DIR | The directory that stores all the images used by Toolkit's style. + * DALI_SHADER_VERSION_PREFIX | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix + * DALI_VERTEX_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix + * DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix() * * @pre The Builder has been initialized. * @param map The user defined constants used in template expansions. @@ -180,6 +194,8 @@ public: * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" ); * @endcode * + * @see AddConstants(const Property::Map&) for builder pre-defined default constants. + * * @pre The Builder has been initialized. * @param key The constant name to add or update * @param value The new value for the constant. diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp new file mode 100755 index 0000000..c8f9aeb --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Toolkit +{ + +const std::string EMPTY_STRING; + +WebBackForwardListItem::WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item ) +: mWebEngineBackForwardListItem( item ) +{ +} + +WebBackForwardListItem::~WebBackForwardListItem() +{ +} + +std::string WebBackForwardListItem::GetUrl() const +{ + return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetUrl() : EMPTY_STRING; +} + +std::string WebBackForwardListItem::GetTitle() const +{ + return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetTitle() : EMPTY_STRING; +} + +std::string WebBackForwardListItem::GetOriginalUrl() const +{ + return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetOriginalUrl() : EMPTY_STRING; +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h new file mode 100755 index 0000000..44a3bc1 --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h @@ -0,0 +1,97 @@ +#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H +#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +class WebEngineBackForwardListItem; + +namespace Toolkit +{ + +/** + * @addtogroup dali_toolkit_controls_web_view + * @{ + */ + +/** + * @brief WebBackForwardListItem is a class for back-forward list item of WebView. + * + * + * For working WebBackForwardListItem, a Dali::WebBackForwardListItem should be provided. + * + */ +class DALI_TOOLKIT_API WebBackForwardListItem +{ +public: + /** + * @brief Creates a WebBackForwardListItem. + */ + WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item ); + + /** + * @brief Destructor. + */ + virtual ~WebBackForwardListItem() final; + + /** + * @brief Returns the URL of the item. + * + * @details The returned URL may differ from the original URL (For example, + * if the page is redirected). + * + * @return The URL of the @a item, otherwise "" in case of an error + */ + std::string GetUrl() const; + + /** + * @brief Returns the title of the item. + * + * @return The title of the @a item, otherwise "" in case of an error + */ + std::string GetTitle() const; + + /** + * @brief Returns the original URL of the item. + * + * @return The original URL of the @a item, otherwise "" in case of an error + */ + std::string GetOriginalUrl() const; + +private: + + const Dali::WebEngineBackForwardListItem* mWebEngineBackForwardListItem; +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp new file mode 100755 index 0000000..fe4e33b --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Toolkit +{ + +WebBackForwardList::WebBackForwardList( const Dali::WebEngineBackForwardList& list ) +: mWebEngineBackForwardList( list ) +, mWebBackForwardListItem( 0 ) +{ +} + +WebBackForwardList::~WebBackForwardList() +{ +} + +WebBackForwardListItem* WebBackForwardList::GetCurrentItem() +{ + mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetCurrentItem() ); + return &mWebBackForwardListItem; +} + +WebBackForwardListItem* WebBackForwardList::GetItemAtIndex( uint32_t index ) +{ + mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetItemAtIndex( index ) ); + return &mWebBackForwardListItem; +} + +uint32_t WebBackForwardList::GetItemCount() const +{ + return mWebEngineBackForwardList.GetItemCount(); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h new file mode 100755 index 0000000..144c02b --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h @@ -0,0 +1,94 @@ +#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H +#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +class WebEngineBackForwardList; + +namespace Toolkit +{ +class WebBackForwardListItem; + +/** + * @addtogroup dali_toolkit_controls_web_view + * @{ + */ + +/** + * @brief WebBackForwardList is a class for back-forward list item of WebView. + * + * + * For working WebBackForwardList, a Dali::WebBackForwardList should be provided. + * + */ +class DALI_TOOLKIT_API WebBackForwardList +{ +public: + /** + * @brief Creates a WebBackForwardList. + */ + WebBackForwardList( const Dali::WebEngineBackForwardList& list ); + + /** + * @brief Destructor. + */ + virtual ~WebBackForwardList() final; + + /** + * @brief Returns the current item in the @a list. + * @return The current item in list. + */ + WebBackForwardListItem* GetCurrentItem(); + + /** + * @brief Returns the item at a given @a index relative to the current item. + * @param[in] index The index of the item + * @return The current item in list. + */ + WebBackForwardListItem* GetItemAtIndex(uint32_t index); + + /** + * @brief Returns the length of the back-forward list including the current + * item. + * @return The length of the back-forward list including the current item, + * otherwise 0 in case of an error + */ + uint32_t GetItemCount() const; + +private: + const Dali::WebEngineBackForwardList& mWebEngineBackForwardList; + Dali::Toolkit::WebBackForwardListItem mWebBackForwardListItem; + +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp new file mode 100755 index 0000000..1e0cbbd --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-context.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ +namespace Toolkit +{ + +WebContext::WebContext( Dali::WebEngineContext& context) +: mWebEngineContext( context ) +{ +} + +WebContext::~WebContext() +{ +} + +Dali::WebEngineContext::CacheModel WebContext::GetCacheModel() const +{ + return mWebEngineContext.GetCacheModel(); +} + +void WebContext::SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel ) +{ + mWebEngineContext.SetCacheModel( cacheModel ); +} + +void WebContext::SetProxyUri( const std::string& uri ) +{ + mWebEngineContext.SetProxyUri( uri ); +} + +void WebContext::SetCertificateFilePath( const std::string& certificatePath ) +{ + mWebEngineContext.SetCertificateFilePath( certificatePath ); +} + +void WebContext::DisableCache( bool cacheDisabled ) +{ + mWebEngineContext.DisableCache( cacheDisabled ); +} + +void WebContext::SetDefaultProxyAuth( const std::string& username, const std::string& password ) +{ + mWebEngineContext.SetDefaultProxyAuth( username, password ); +} + +void WebContext::DeleteWebDatabase() +{ + mWebEngineContext.DeleteWebDatabase(); +} + +void WebContext::DeleteWebStorage() +{ + mWebEngineContext.DeleteWebStorage(); +} + +void WebContext::DeleteLocalFileSystem() +{ + mWebEngineContext.DeleteLocalFileSystem(); +} + +void WebContext::ClearCache() +{ + mWebEngineContext.ClearCache(); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.h b/dali-toolkit/devel-api/controls/web-view/web-context.h new file mode 100755 index 0000000..1640c70 --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-context.h @@ -0,0 +1,148 @@ +#ifndef DALI_TOOLKIT_WEB_CONTEXT_H +#define DALI_TOOLKIT_WEB_CONTEXT_H + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +/** + * @addtogroup dali_toolkit_controls_web_view + * @{ + */ + +/** + * @brief WebContext is a control for settings of WebView. + * + * For working WebContext, a WebView should be provided. + * + */ +class DALI_TOOLKIT_API WebContext +{ +public: + + /** + * @brief Creates a WebContext. + * + * @param[in] context The context of web engine. + */ + WebContext( Dali::WebEngineContext& context ); + + /** + * @brief Destructor. + */ + virtual ~WebContext() final; + + /** + * @brief Returns the cache model type. + * + * @return #Dali::WebEngineContext::CacheModel + */ + Dali::WebEngineContext::CacheModel GetCacheModel() const; + + /** + * @brief Requests to set the cache model. + * + * @param[in] cacheModel The cache model + */ + void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel ); + + /** + * @brief Sets the given proxy URI to network backend of specific context. + * + * @param[in] uri The proxy URI to set + */ + void SetProxyUri( const std::string& uri ); + + /** + * Adds CA certificates to persistent NSS certificate database + * + * Function accepts a path to a CA certificate file, a path to a directory + * containing CA certificate files, or a colon-seprarated list of those. + * Certificate files should have *.crt extension. + * Directories are traversed recursively. + * + * @param[in] certificatePath path to a CA certificate file(s), see above for details + */ + void SetCertificateFilePath( const std::string& certificatePath ); + + /** + * Toggles the cache to be enabled or disabled + * + * Function works asynchronously. + * By default the cache is disabled resulting in not storing network data on disk. + * + * @param[in] cacheDisabled enable or disable cache + */ + void DisableCache( bool cacheDisabled ); + + /** + * @brief Sets a proxy auth credential to network backend of specific context. + * + * @param[in] username username to set + * @param[in] password password to set + */ + void SetDefaultProxyAuth( const std::string& username, const std::string& password ); + + /** + * Requests for deleting all web databases. + */ + void DeleteWebDatabase(); + + /** + * @brief Deletes web storage. + * + * @details This function does not ensure that all data will be removed. + * Should be used to extend free physical memory. + */ + void DeleteWebStorage(); + + /** + * @brief Requests for deleting all local file systems. + */ + void DeleteLocalFileSystem(); + + /** + * @brief Requests to clear cache + */ + void ClearCache(); + +private: + + Dali::WebEngineContext& mWebEngineContext; +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_WEB_CONTEXT_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp new file mode 100755 index 0000000..ef6bd64 --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ +namespace Toolkit +{ + +WebCookieManager::WebCookieManager( Dali::WebEngineCookieManager& manager ) +: mWebEngineCookieManager( manager ) +{ +} + +WebCookieManager::~WebCookieManager() +{ +} + +void WebCookieManager::SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy cookieAcceptPolicy ) +{ + mWebEngineCookieManager.SetCookieAcceptPolicy( cookieAcceptPolicy ); +} + +Dali::WebEngineCookieManager::CookieAcceptPolicy WebCookieManager::GetCookieAcceptPolicy() const +{ + return mWebEngineCookieManager.GetCookieAcceptPolicy(); +} + +void WebCookieManager::ClearCookies() +{ + mWebEngineCookieManager.ClearCookies(); +} + +void WebCookieManager::SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) +{ + mWebEngineCookieManager.SetPersistentStorage( path, storage ); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h new file mode 100755 index 0000000..adb8481 --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h @@ -0,0 +1,111 @@ +#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H +#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class WebEngineCookieManager; + +namespace Toolkit +{ + +/** + * @addtogroup dali_toolkit_controls_web_view + * @{ + */ + +/** + * @brief WebCookieManager is a control for settings of WebView. + * + * + * For working WebCookieManager, a WebView should be provided. + * + */ +class DALI_TOOLKIT_API WebCookieManager +{ +public: + + /** + * @brief Creates a WebCookieManager. + * @param[in] manager A #Dali::WebEngineCookieManager + */ + WebCookieManager( Dali::WebEngineCookieManager& manager ); + + /** + * @brief Destructor. + */ + virtual ~WebCookieManager() final; + + /** + * @brief Sets @a policy as the cookie acceptance policy for @a manager. + * + * @details By default, only cookies set by the main document loaded are + * accepted. + * + * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy + */ + void SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy ); + + /** + * @brief Gets the cookie acceptance policy. The default is Toolkit::WebCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY. + * @see Dali::WebEngineCookieManager::CookieAcceptPolicy + */ + Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const; + + /** + * @brief Deletes all the cookies of @a manager. + */ + void ClearCookies(); + + /** + * @brief Sets the @a path where non-session cookies are stored persistently using + * @a storage as the format to read/write the cookies. + * + * @details Cookies are initially read from @a path/Cookies to create an initial + * set of cookies. Then, non-session cookies will be written to @a path/Cookies. + * By default, @a manager doesn't store the cookies persistently, so you need to + * call this method to keep cookies saved across sessions. + * If @a path does not exist it will be created. + * + * @param[in] path The path where to read/write Cookies + * @param[in] storage The type of storage + */ + void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ); + +private: + + Dali::WebEngineCookieManager& mWebEngineCookieManager; +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_WEB_COOKIE_MANAGER_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-settings.cpp b/dali-toolkit/devel-api/controls/web-view/web-settings.cpp new file mode 100755 index 0000000..7b6dc13 --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-settings.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Toolkit +{ + +WebSettings::WebSettings( Dali::WebEngineSettings& settings ) +: mWebEngineSettings( settings ) +{ +} + +WebSettings::~WebSettings() +{ +} + +void WebSettings::AllowMixedContents( bool allowed ) +{ + mWebEngineSettings.AllowMixedContents( allowed ); +} + +void WebSettings::EnableSpatialNavigation( bool enabled ) +{ + mWebEngineSettings.AllowMixedContents( enabled ); +} + +int WebSettings::GetDefaultFontSize() const +{ + return mWebEngineSettings.GetDefaultFontSize(); +} + +void WebSettings::SetDefaultFontSize( int defaultFontSize ) +{ + mWebEngineSettings.SetDefaultFontSize( defaultFontSize ); +} + +void WebSettings::EnableWebSecurity( bool enabled ) +{ + mWebEngineSettings.EnableWebSecurity( enabled ); +} + +void WebSettings::AllowFileAccessFromExternalUrl( bool allowed ) +{ + mWebEngineSettings.AllowFileAccessFromExternalUrl( allowed ); +} + +bool WebSettings::IsJavaScriptEnabled() const +{ + return mWebEngineSettings.IsJavaScriptEnabled(); +} + +void WebSettings::EnableJavaScript( bool enabled ) +{ + mWebEngineSettings.EnableJavaScript( enabled ); +} + +void WebSettings::AllowScriptsOpenWindows( bool allowed ) +{ + mWebEngineSettings.AllowScriptsOpenWindows( allowed ); +} + +bool WebSettings::AreImagesLoadedAutomatically() const +{ + return mWebEngineSettings.AreImagesLoadedAutomatically(); +} + +void WebSettings::AllowImagesLoadAutomatically( bool automatic ) +{ + mWebEngineSettings.AllowImagesLoadAutomatically( automatic ); +} + +std::string WebSettings::GetDefaultTextEncodingName() const +{ + return mWebEngineSettings.GetDefaultTextEncodingName(); +} + +void WebSettings::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +{ + mWebEngineSettings.SetDefaultTextEncodingName( defaultTextEncodingName ); +} + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-settings.h b/dali-toolkit/devel-api/controls/web-view/web-settings.h new file mode 100755 index 0000000..dc46e7c --- /dev/null +++ b/dali-toolkit/devel-api/controls/web-view/web-settings.h @@ -0,0 +1,169 @@ +#ifndef DALI_TOOLKIT_WEB_SETTINGS_H +#define DALI_TOOLKIT_WEB_SETTINGS_H + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class WebEngineSettings; + +namespace Toolkit +{ + +/** + * @addtogroup dali_toolkit_controls_web_view + * @{ + */ + +/** + * @brief WebEngineSettings is a control for settings of WebView. + * + * + * For working WebEngineSettings, a WebView should be provided. + * + */ +class DALI_TOOLKIT_API WebSettings +{ +public: + /** + * @brief Creates a WebEngineSettings. + * + * @param[in] settings A settings of web engine. + */ + WebSettings( Dali::WebEngineSettings& settings ); + + /** + * @brief Destructor. + */ + virtual ~WebSettings() final; + + /** + *@brief Allow running mixed contents or not. + * + * @param[in] allowed if true, allow to run mixed contents, + * otherwise not allow + */ + void AllowMixedContents( bool allowed ); + + /** + * @brief Enable the spatial navigation or not. + * + * @param[in] enabled if true, use spatial navigation, + * otherwise to disable + */ + void EnableSpatialNavigation( bool enabled ); + + /** + * @brief Returns the default font size in pixel. The default value is 16. + * + * @return The default font size + */ + int GetDefaultFontSize() const; + + /** + * @brief Sets the default font size in pixel. The default value is 16. + * + * @param[in] defaultFontSize A new default font size to set + */ + void SetDefaultFontSize( int defaultFontSize ); + + /** + * @brief Enables/disables web security. + * + * @param[in] enabled if true, to enable the web security + * otherwise to disable + */ + void EnableWebSecurity( bool enabled ); + + /** + * @brief Allow/Disallow file access from external url + * + * @param[in] allowed if true, to allow file access from external url + * otherwise to disallow + */ + void AllowFileAccessFromExternalUrl( bool allowed ); + + /** + * @brief Returns whether JavaScript can be executable. The default is true. + * + * @return true if JavaScript executing is enabled, false otherwise + */ + bool IsJavaScriptEnabled() const; + + /** + * @brief Enables/disables JavaScript executing. The default is enabled. + * + * @param[in] enabled True if JavaScript executing is enabled, false otherwise + */ + void EnableJavaScript( bool enabled ); + + /** + * @brief Allow if the scripts can open new windows. + * + * @param[in] allowed if true, the scripts can open new windows, + * otherwise not + */ + void AllowScriptsOpenWindows( bool allowed ); + + /** + * @brief Returns whether images can be loaded automatically. The default is true. + * + * @return true if images are loaded automatically, false otherwise + */ + bool AreImagesLoadedAutomatically() const; + + /** + * @brief Enables/disables auto loading of images. The default is enabled. + * + * @param[in] automatic True if images are loaded automatically, false otherwise + */ + void AllowImagesLoadAutomatically( bool automatic ); + + /** + * @brief Gets the default text encoding name (e.g. UTF-8). + * + * @return The default text encoding name + */ + std::string GetDefaultTextEncodingName() const; + + /** + * @brief Sets the default text encoding name (e.g. UTF-8). + * + * @param[in] defaultTextEncodingName The default text encoding name + */ + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); + +private: + Dali::WebEngineSettings& mWebEngineSettings; +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_WEB_SETTINGS_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.cpp b/dali-toolkit/devel-api/controls/web-view/web-view.cpp index 338f8b9..a0672ae 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-view.cpp @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -58,19 +59,49 @@ WebView WebView::New(const std::string& locale, const std::string& timezoneId) return Internal::WebView::New(locale, timezoneId); } +WebView WebView::New( int argc, char** argv ) +{ + return Internal::WebView::New( argc, argv ); +} + WebView WebView::DownCast(BaseHandle handle) { return Control::DownCast(handle); } +Dali::Toolkit::WebSettings* WebView::GetSettings() const +{ + return Dali::Toolkit::GetImpl( *this ).GetSettings(); +} + +Dali::Toolkit::WebContext* WebView::GetContext() const +{ + return Dali::Toolkit::GetImpl( *this ).GetContext(); +} + +Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const +{ + return Dali::Toolkit::GetImpl( *this ).GetCookieManager(); +} + +Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const +{ + return Dali::Toolkit::GetImpl( *this ).GetBackForwardList(); +} + +Dali::Toolkit::ImageView& WebView::GetFavicon() +{ + return Dali::Toolkit::GetImpl( *this ).GetFavicon(); +} + void WebView::LoadUrl(const std::string& url) { Dali::Toolkit::GetImpl(*this).LoadUrl(url); } -void WebView::LoadHTMLString(const std::string& htmlString) +void WebView::LoadHtmlString(const std::string& htmlString) { - Dali::Toolkit::GetImpl(*this).LoadHTMLString(htmlString); + Dali::Toolkit::GetImpl(*this).LoadHtmlString(htmlString); } void WebView::Reload() @@ -133,19 +164,14 @@ void WebView::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::Toolkit::GetImpl(*this).AddJavaScriptMessageHandler(exposedObjectName, handler); } -void WebView::ClearHistory() -{ - Dali::Toolkit::GetImpl(*this).ClearHistory(); -} - -void WebView::ClearCache() +void WebView::ClearAllTilesResources() { - Dali::Toolkit::GetImpl(*this).ClearCache(); + Dali::Toolkit::GetImpl( *this ).ClearAllTilesResources(); } -void WebView::ClearCookies() +void WebView::ClearHistory() { - Dali::Toolkit::GetImpl(*this).ClearCookies(); + Dali::Toolkit::GetImpl(*this).ClearHistory(); } WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal() diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index f447eda..0380c26 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -29,6 +29,12 @@ namespace Dali { namespace Toolkit { +class ImageView; +class WebBackForwardList; +class WebContext; +class WebCookieManager; +class WebSettings; + namespace Internal DALI_INTERNAL { class WebView; @@ -50,59 +56,6 @@ class WebView; class DALI_TOOLKIT_API WebView : public Control { public: - /** - * @brief A structure used to contain the cache model enumeration. - */ - struct CacheModel - { - /** - * @brief Enumeration for cache model options. - */ - enum Type - { - /** - * @brief Use the smallest cache capacity. - */ - DOCUMENT_VIEWER, - - /** - * @brief Use the bigger cache capacity than DocumentBrowser. - */ - DOCUMENT_BROWSER, - - /** - * @brief Use the biggest cache capacity. - */ - PRIMARY_WEB_BROWSER - }; - }; - - /** - * @brief A structure used to contain the cookie acceptance policy enumeration. - */ - struct CookieAcceptPolicy - { - /** - * @brief Enumeration for the cookies accept policies. - */ - enum Type - { - /** - * @brief Accepts every cookie sent from any page. - */ - ALWAYS, - - /** - * @brief Rejects all the cookies. - */ - NEVER, - - /** - * @brief Accepts only cookies set by the main document that is loaded. - */ - NO_THIRD_PARTY - }; - }; /** * @brief Enumeration for the start and end property ranges for this control. @@ -127,56 +80,12 @@ public: URL = PROPERTY_START_INDEX, /** - * @brief The cache model. - * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING. - * @note Default is WebView::CacheModel::DOCUMENT_VIEWER. - * @see WebView::CacheModel::Type - */ - CACHE_MODEL, - - /** - * @brief The cookie acceptance policy. - * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING. - * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY. - * @see WebView::CookieAcceptPolicy::Type - */ - COOKIE_ACCEPT_POLICY, - - /** * @brief The user agent string. * @details Name "userAgent", type Property::STRING. */ USER_AGENT, /** - * @brief Whether JavaScript is enabled. - * @details Name "enableJavaScript", type Property::BOOLEAN. - * @note Default is true. - */ - ENABLE_JAVASCRIPT, - - /** - * @brief Whether images can be loaded automatically. - * @details Name "loadImagesAutomatically", type Property::BOOLEAN. - * @note Default is true. - */ - LOAD_IMAGES_AUTOMATICALLY, - - /** - * @brief The default text encoding name. - * @details Name "defaultTextEncodingName", type Property::STRING. - * @note If the value is not set, the web engine detects web page's text encoding. - */ - DEFAULT_TEXT_ENCODING_NAME, - - /** - * @brief The default font size in pixel. - * @details Name "defaultFontSize", type Property::INT. - * @note Default is 16. - */ - DEFAULT_FONT_SIZE, - - /** * @brief The current position of scroll. * @details Name "scrollPosition", type Property::VECTOR2. */ @@ -193,6 +102,13 @@ public: * @details Name "contentSize", type Property::VECTOR2. Read-only. */ CONTENT_SIZE, + + /** + * @brief The title of web page. + * @details Name "title", type Property::STRING. + * @note The value is read-only. + */ + TITLE, }; }; @@ -280,17 +196,17 @@ public: /** * @brief WebView signal type related with page loading. */ - typedef Signal WebViewPageLoadSignalType; + using WebViewPageLoadSignalType = Signal< void( WebView, const std::string& ) >; /** * @brief WebView signal type related with page loading error. */ - typedef Signal WebViewPageLoadErrorSignalType; + using WebViewPageLoadErrorSignalType = Signal< void( WebView, const std::string&, LoadErrorCode ) >; /** * @brief WebView signal type related with scroll edge reached. */ - typedef Signal WebViewScrollEdgeReachedSignalType; + using WebViewScrollEdgeReachedSignalType = Signal< void( WebView, Dali::WebEnginePlugin::ScrollEdge ) >; public: /** @@ -310,6 +226,14 @@ public: static WebView New(const std::string& locale, const std::string& timezoneId); /** + * @brief Creates an initialized WebView. + * + * @param [in] argc The count of arguments of Applications + * @param [in] argv The string array of arguments of Applications + */ + static WebView New( int argc, char** argv ); + + /** * @brief Creates an uninitialized WebView. */ WebView(); @@ -348,6 +272,33 @@ public: static WebView DownCast(BaseHandle handle); /** + * @brief Get WebSettings of WebEngine. + */ + Dali::Toolkit::WebSettings* GetSettings() const; + + /** + * @brief Get WebContext of WebEngine. + */ + Dali::Toolkit::WebContext* GetContext() const; + + /** + * @brief Get CookieManager of WebEngine. + */ + Dali::Toolkit::WebCookieManager* GetCookieManager() const; + + /** + * @brief Get WebBackForwardList of WebEngine. + */ + Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; + + /** + * @brief Get Favicon of web page. + * + * @return Handle to a fav icon + */ + Dali::Toolkit::ImageView& GetFavicon(); + + /** * @brief Loads a web page based on a given URL. * * @param [in] url The URL of the resource to load @@ -359,7 +310,7 @@ public: * * @param [in] htmlString The string to use as the contents of the web page */ - void LoadHTMLString(const std::string& htmlString); + void LoadHtmlString(const std::string& htmlString); /** * @brief Reloads the Web. @@ -454,19 +405,14 @@ public: void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); /** - * @brief Clears the history of Web. - */ - void ClearHistory(); - - /** - * @brief Clears the cache of Web. + * @brief Clears all tiles resources of Web. */ - void ClearCache(); + void ClearAllTilesResources(); /** - * @brief Clears all the cookies of Web. + * @brief Clears the history of Web. */ - void ClearCookies(); + void ClearHistory(); /** * @brief Connects to this signal to be notified when page loading is started. diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index c8445cf..f43ca09 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -36,6 +36,11 @@ SET( devel_api_src_files ${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.cpp ${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp ${devel_api_src_dir}/controls/video-view/video-view-devel.cpp + ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp + ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp + ${devel_api_src_dir}/controls/web-view/web-context.cpp + ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp + ${devel_api_src_dir}/controls/web-view/web-settings.cpp ${devel_api_src_dir}/controls/web-view/web-view.cpp ${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp ${devel_api_src_dir}/focus-manager/keyboard-focus-manager-devel.cpp @@ -245,6 +250,11 @@ SET( devel_api_video_view_header_files ) SET( devel_api_web_view_header_files + ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h + ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h + ${devel_api_src_dir}/controls/web-view/web-context.h + ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h + ${devel_api_src_dir}/controls/web-view/web-settings.h ${devel_api_src_dir}/controls/web-view/web-view.h ) diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 8bcdff1..88c51b6 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -156,13 +157,16 @@ Builder::Builder() { mParser = Dali::Toolkit::JsonParser::New(); - Property::Map defaultDirs; - defaultDirs[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath(); - defaultDirs[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath(); - defaultDirs[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath(); - defaultDirs[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath(); + Property::Map defaultConstants; + defaultConstants[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath(); + defaultConstants[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath(); + defaultConstants[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath(); + defaultConstants[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath(); + defaultConstants[TOKEN_STRING(DALI_SHADER_VERSION_PREFIX)] = Shader::GetShaderVersionPrefix(); + defaultConstants[TOKEN_STRING(DALI_VERTEX_SHADER_PREFIX)] = Shader::GetVertexShaderPrefix(); + defaultConstants[TOKEN_STRING(DALI_FRAGMENT_SHADER_PREFIX)] = Shader::GetFragmentShaderPrefix(); - AddConstants( defaultDirs ); + AddConstants(defaultConstants); } void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format ) diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index db14c27..0cf97a4 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -20,6 +20,10 @@ // EXTERNAL INCLUDES #include +#include +#include +#include +#include #include #include #include @@ -29,8 +33,13 @@ // INTERNAL INCLUDES #include +#include +#include +#include +#include #include #include +#include #include namespace Dali @@ -50,31 +59,14 @@ BaseHandle Create() return Toolkit::WebView::New(); } -DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER ) -DALI_ENUM_TO_STRING_TABLE_END( CacheModel ) - -DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY ) -DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy ) - DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel", STRING, CACHE_MODEL ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy", STRING, COOKIE_ACCEPT_POLICY ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent", STRING, USER_AGENT ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript", BOOLEAN, ENABLE_JAVASCRIPT ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING, DEFAULT_TEXT_ENCODING_NAME ) -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize", INTEGER, DEFAULT_FONT_SIZE ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "title", STRING, TITLE ) DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL ) DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL ) @@ -112,6 +104,25 @@ WebView::WebView( const std::string& locale, const std::string& timezoneId ) } } +WebView::WebView( int argc, char** argv ) +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), + mUrl(), + mVisual(), + mWebViewSize( Stage::GetCurrent().GetSize() ), + mWebEngine(), + mPageLoadStartedSignal(), + mPageLoadFinishedSignal(), + mPageLoadErrorSignal() +{ + mWebEngine = Dali::WebEngine::New(); + + // WebEngine is empty when it is not properly initialized. + if ( mWebEngine ) + { + mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, argc, argv ); + } +} + WebView::WebView() : WebView( "", "" ) { @@ -139,6 +150,15 @@ Toolkit::WebView WebView::New( const std::string& locale, const std::string& tim return handle; } +Toolkit::WebView WebView::New( int argc, char** argv ) +{ + WebView* impl = new WebView( argc, argv ); + Toolkit::WebView handle = Toolkit::WebView( *impl ); + + impl->Initialize(); + return handle; +} + void WebView::OnInitialize() { Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true ); @@ -150,7 +170,45 @@ void WebView::OnInitialize() mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished ); mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError ); mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached ); + + mWebContext = std::unique_ptr( new WebContext( mWebEngine.GetContext() ) ); + mWebCookieManager = std::unique_ptr( new WebCookieManager( mWebEngine.GetCookieManager() ) ); + mWebSettings = std::unique_ptr( new WebSettings( mWebEngine.GetSettings() ) ); + mWebBackForwardList = std::unique_ptr( new WebBackForwardList( mWebEngine.GetBackForwardList() ) ); + } +} + +Dali::Toolkit::WebSettings* WebView::GetSettings() const +{ + return mWebSettings.get(); +} + +Dali::Toolkit::WebContext* WebView::GetContext() const +{ + return mWebContext.get(); +} + +Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const +{ + return mWebCookieManager.get(); +} + +Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const +{ + return mWebBackForwardList.get(); +} + +Dali::Toolkit::ImageView& WebView::GetFavicon() +{ + if ( mWebEngine ) + { + Dali::PixelData pixelData = mWebEngine.GetFavicon(); + std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData ); + mFaviconView = Dali::Toolkit::ImageView::New( url ); + mFaviconView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) ); } + return mFaviconView; } void WebView::LoadUrl( const std::string& url ) @@ -173,7 +231,7 @@ void WebView::LoadUrl( const std::string& url ) } } -void WebView::LoadHTMLString( const std::string& htmlString ) +void WebView::LoadHtmlString( const std::string& htmlString ) { if( mWebEngine ) { @@ -186,7 +244,7 @@ void WebView::LoadHTMLString( const std::string& htmlString ) if( mVisual ) { DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual ); - mWebEngine.LoadHTMLString( htmlString ); + mWebEngine.LoadHtmlString( htmlString ); } } } @@ -273,27 +331,19 @@ void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, } } -void WebView::ClearHistory() -{ - if( mWebEngine ) - { - mWebEngine.ClearHistory(); - } -} - -void WebView::ClearCache() +void WebView::ClearAllTilesResources() { if( mWebEngine ) { - mWebEngine.ClearCache(); + mWebEngine.ClearAllTilesResources(); } } -void WebView::ClearCookies() +void WebView::ClearHistory() { if( mWebEngine ) { - mWebEngine.ClearCookies(); + mWebEngine.ClearHistory(); } } @@ -429,20 +479,6 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop } break; } - case Toolkit::WebView::Property::CACHE_MODEL: - { - Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel(); - GET_ENUM_VALUE( CacheModel, value, output ); - impl.SetCacheModel( output ); - break; - } - case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY: - { - Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy(); - GET_ENUM_VALUE( CookieAcceptPolicy, value, output ); - impl.SetCookieAcceptPolicy( output ); - break; - } case Toolkit::WebView::Property::USER_AGENT: { std::string input; @@ -452,42 +488,6 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop } break; } - case Toolkit::WebView::Property::ENABLE_JAVASCRIPT: - { - bool input; - if( value.Get( input ) ) - { - impl.EnableJavaScript( input ); - } - break; - } - case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY: - { - bool input; - if( value.Get( input ) ) - { - impl.LoadImagesAutomatically( input ); - } - break; - } - case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME: - { - std::string input; - if( value.Get( input ) ) - { - impl.SetDefaultTextEncodingName( input ); - } - break; - } - case Toolkit::WebView::Property::DEFAULT_FONT_SIZE: - { - int input; - if( value.Get( input ) ) - { - impl.SetDefaultFontSize( input ); - } - break; - } case Toolkit::WebView::Property::SCROLL_POSITION: { Vector2 input; @@ -517,60 +517,29 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper value = impl.mUrl; break; } - case Toolkit::WebView::Property::CACHE_MODEL: - { - value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() ); - break; - } - case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY: - { - value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() ); - break; - } case Toolkit::WebView::Property::USER_AGENT: { value = impl.GetUserAgent(); break; } - case Toolkit::WebView::Property::ENABLE_JAVASCRIPT: - { - value = impl.IsJavaScriptEnabled(); - break; - } - case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY: - { - value = impl.AreImagesAutomaticallyLoaded(); - break; - } - case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME: - { - value = impl.GetDefaultTextEncodingName(); - break; - } - case Toolkit::WebView::Property::DEFAULT_FONT_SIZE: - { - value = impl.GetDefaultFontSize(); - break; - } case Toolkit::WebView::Property::SCROLL_POSITION: { - int x, y; - impl.GetScrollPosition( x, y ); - value = Vector2( x, y ); + value = impl.GetScrollPosition(); break; } case Toolkit::WebView::Property::SCROLL_SIZE: { - int width, height; - impl.GetScrollSize( width, height ); - value = Vector2( width, height ); + value = impl.GetScrollSize(); break; } case Toolkit::WebView::Property::CONTENT_SIZE: { - int width, height; - impl.GetContentSize( width, height ); - value = Vector2( width, height ); + value = impl.GetContentSize(); + break; + } + case Toolkit::WebView::Property::TITLE: + { + value = impl.GetTitle(); break; } default: @@ -631,54 +600,24 @@ void WebView::SetScrollPosition( int x, int y ) } } -void WebView::GetScrollPosition( int& x, int& y ) const +Dali::Vector2 WebView::GetScrollPosition() const { - if( mWebEngine ) - { - mWebEngine.GetScrollPosition( x, y ); - } + return mWebEngine ? mWebEngine.GetScrollPosition() : Dali::Vector2::ZERO; } -void WebView::GetScrollSize( int& width, int& height ) const +Dali::Vector2 WebView::GetScrollSize() const { - if( mWebEngine ) - { - mWebEngine.GetScrollSize( width, height ); - } + return mWebEngine ? mWebEngine.GetScrollSize() : Dali::Vector2::ZERO; } -void WebView::GetContentSize( int& width, int& height ) const +Dali::Vector2 WebView::GetContentSize() const { - if( mWebEngine ) - { - mWebEngine.GetContentSize( width, height ); - } + return mWebEngine ? mWebEngine.GetContentSize() : Dali::Vector2::ZERO; } -Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const +std::string WebView::GetTitle() const { - return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER; -} - -void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel ) -{ - if( mWebEngine ) - { - mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) ); - } -} - -Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const -{ - return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY; -} - -void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy ) -{ - if( mWebEngine ) - { - mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) ); - } + return mWebEngine ? mWebEngine.GetTitle() : kEmptyString; } const std::string& WebView::GetUserAgent() const @@ -694,58 +633,6 @@ void WebView::SetUserAgent( const std::string& userAgent ) } } -bool WebView::IsJavaScriptEnabled() const -{ - return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true; -} - -void WebView::EnableJavaScript( bool enabled ) -{ - if( mWebEngine ) - { - mWebEngine.EnableJavaScript( enabled ); - } -} - -bool WebView::AreImagesAutomaticallyLoaded() const -{ - return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true; -} - -void WebView::LoadImagesAutomatically( bool automatic ) -{ - if( mWebEngine ) - { - mWebEngine.LoadImagesAutomatically( automatic ); - } -} - -const std::string& WebView::GetDefaultTextEncodingName() const -{ - return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString; -} - -void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) -{ - if( mWebEngine ) - { - mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName ); - } -} - -int WebView::GetDefaultFontSize() const -{ - return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0; -} - -void WebView::SetDefaultFontSize( int defaultFontSize ) -{ - if( mWebEngine ) - { - mWebEngine.SetDefaultFontSize( defaultFontSize ); - } -} - #undef GET_ENUM_STRING #undef GET_ENUM_VALUE diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index 0769bad..14fb0b5 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -19,13 +19,15 @@ */ // EXTERNAL INCLUDES +#include #include #include // INTERNAL INCLUDES +#include #include #include -#include +#include namespace Dali { @@ -35,6 +37,10 @@ namespace Toolkit class KeyEvent; class TouchEvent; +class WebBackForwardList; +class WebContext; +class WebCookieManager; +class WebSettings; class WebView; namespace Internal @@ -48,6 +54,8 @@ protected: WebView( const std::string& locale, const std::string& timezoneId ); + WebView( int argc, char** argv ); + virtual ~WebView(); public: @@ -63,6 +71,38 @@ public: static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId ); /** + * @brief Get settings of WebEngine. + */ + Dali::Toolkit::WebSettings* GetSettings() const; + + /** + * @brief Get context of WebEngine. + */ + Dali::Toolkit::WebContext* GetContext() const; + + /** + * @brief Get cookie manager of WebEngine. + */ + Dali::Toolkit::WebCookieManager* GetCookieManager() const; + + /** + * @brief Get WebBackForwardList of WebEngine. + */ + Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; + + /** + * @copydoc Dali::Toolkit::WebView::New( int, char** ) + */ + static Toolkit::WebView New( int argc, char** argv ); + + /** + * @brief Get Favicon of web page. + * + * @return Handle to a fav icon + */ + Dali::Toolkit::ImageView& GetFavicon(); + + /** * @copydoc Dali::Toolkit::WebView::LoadUrl() */ void LoadUrl( const std::string& url ); @@ -70,7 +110,7 @@ public: /** * @copydoc Dali::WebEngine::LoadHTMLString() */ - void LoadHTMLString( const std::string& htmlString ); + void LoadHtmlString( const std::string& htmlString ); /** * @copydoc Dali::Toolkit::WebView::Reload() @@ -128,19 +168,14 @@ public: void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ); /** - * @copydoc Dali::Toolkit::WebView::ClearHistory() - */ - void ClearHistory(); - - /** - * @copydoc Dali::Toolkit::WebView::ClearCache() + * @brief Clears all tiles resources of Web. */ - void ClearCache(); + void ClearAllTilesResources(); /** - * @copydoc Dali::Toolkit::WebView::ClearCookies() + * @copydoc Dali::Toolkit::WebView::ClearHistory() */ - void ClearCookies(); + void ClearHistory(); /** * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal() @@ -252,47 +287,28 @@ private: * @param[out] x The coordinate x of scroll * @param[out] y The coordinate y of scroll */ - void GetScrollPosition( int& x, int& y ) const; + Dali::Vector2 GetScrollPosition() const; /** * @brief Gets the possible scroll size of the given view. * @param[out] width The width of scroll size * @param[out] height The height of scroll size */ - void GetScrollSize( int& width, int& height ) const; + Dali::Vector2 GetScrollSize() const; /** * @brief Gets the last known content's size. * @param[out] width The width of content's size * @param[out] height The height of content's size */ - void GetContentSize( int& width, int& height ) const; - - /** - * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER. - * @see Toolkit::WebView::CacheModel::Type - */ - Toolkit::WebView::CacheModel::Type GetCacheModel() const; - - /** - * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER. - * @param[in] cacheModel The cache model option - * @see Toolkit::WebView::CacheModel::Type - */ - void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel ); - - /** - * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY. - * @see Toolkit::WebView::CookieAcceptPolicy::Type - */ - Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const; + Dali::Vector2 GetContentSize() const; /** - * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY. - * @param[in] policy The cookie acceptance policy - * @see Toolkit::WebView::CookieAcceptPolicy::Type + * @brief Returns the title of the Web. + * + * @return The title of web page */ - void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy ); + std::string GetTitle() const; /** * @brief Get user agent string. @@ -307,62 +323,6 @@ private: void SetUserAgent( const std::string& userAgent ); /** - * @brief Returns whether JavaScript can be executable. The default is true. - * - * @return true if JavaScript executing is enabled, false otherwise - */ - bool IsJavaScriptEnabled() const; - - /** - * @brief Enables/disables JavaScript executing. The default is enabled. - * - * @param[in] enabled True if JavaScript executing is enabled, false otherwise - */ - void EnableJavaScript( bool enabled ); - - /** - * @brief Returns whether images can be loaded automatically. The default is true. - * - * @return true if images are loaded automatically, false otherwise - */ - bool AreImagesAutomaticallyLoaded() const; - - /** - * @brief Enables/disables auto loading of images. The default is enabled. - * - * @param[in] automatic True if images are loaded automatically, false otherwise - */ - void LoadImagesAutomatically( bool automatic ); - - /** - * @brief Gets the default text encoding name (e.g. UTF-8). - * - * @return The default text encoding name - */ - const std::string& GetDefaultTextEncodingName() const; - - /** - * @brief Sets the default text encoding name (e.g. UTF-8). - * - * @param[in] defaultTextEncodingName The default text encoding name - */ - void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); - - /** - * @brief Returns the default font size in pixel. The default value is 16. - * - * @return The default font size - */ - int GetDefaultFontSize() const; - - /** - * @brief Sets the default font size in pixel. The default value is 16. - * - * @param[in] defaultFontSize A new default font size to set - */ - void SetDefaultFontSize( int defaultFontSize ); - - /** * @brief Callback function to be called when page load started. * @param[in] url The url currently being loaded */ @@ -398,6 +358,12 @@ private: Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal; + + std::unique_ptr mWebContext; + std::unique_ptr mWebCookieManager; + std::unique_ptr mWebSettings; + std::unique_ptr mWebBackForwardList; + Dali::Toolkit::ImageView mFaviconView; }; } // namespace Internal diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag index d68e66f..4654ab4 100644 --- a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag +++ b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag @@ -7,7 +7,19 @@ uniform lowp vec3 mixColor; void main() { - mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius; OUT_COLOR = vec4(mixColor, 1.0) * uColor; - OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist ); -} \ No newline at end of file + mediump vec2 diff = abs( vPosition ) - vRectSize; + mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius; + if( dist > 1.0 ) + { + OUT_COLOR.a = 0.0; + } + else if( dist > -1.0 ) + { + if( min( diff.x, diff.y ) < 0.0) + { + dist += min( diff.x, diff.y ) / vCornerRadius; + } + OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist ); + } +} diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert index f4bc1ad..33216e5 100644 --- a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert @@ -24,6 +24,7 @@ vec4 ComputeVertexPosition() vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy); vCornerRadius = min( vCornerRadius, minSize * 0.5 ); vRectSize = visualSize / 2.0 - vCornerRadius; + vCornerRadius = max( vCornerRadius, 1.0 ); vPosition = aPosition* visualSize; return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 ); } @@ -31,4 +32,4 @@ vec4 ComputeVertexPosition() void main() { gl_Position = uMvpMatrix * ComputeVertexPosition(); -} \ No newline at end of file +} diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert index 79724e7..144fa81 100644 --- a/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert @@ -24,6 +24,7 @@ vec4 ComputeVertexPosition() vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy); vCornerRadius = min( vCornerRadius, minSize * 0.5 ); vRectSize = visualSize * 0.5 - vCornerRadius; + vCornerRadius = max( vCornerRadius, 1.0 ); vPosition = aPosition * visualSize; return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 ); } diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag index 61984eb..548367c 100644 --- a/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag +++ b/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag @@ -8,7 +8,19 @@ varying mediump float vCornerRadius; void main() { - mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius; gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor; - gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist ); + mediump vec2 diff = abs( vPosition ) - vRectSize; + mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius; + if( dist > 1.0 ) + { + gl_FragColor = vec4( 0.0 ); + } + else if( dist > -1.0 ) + { + if( min( diff.x, diff.y ) < 0.0 ) + { + dist += min( diff.x, diff.y ) / vCornerRadius; + } + gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist ); + } } diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag index 0ae8163..10bf0fe 100644 --- a/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag +++ b/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag @@ -8,7 +8,19 @@ varying mediump float vCornerRadius; void main() { - mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius; gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor; - gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist ); + mediump vec2 diff = abs( vPosition ) - vRectSize; + mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius; + if( dist > 1.0 ) + { + gl_FragColor = vec4( 0.0 ); + } + else if( dist > -1.0 ) + { + if( min( diff.x, diff.y ) < 0.0) + { + dist += min( diff.x, diff.y ) / vCornerRadius; + } + gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist ); + } } diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert index 38f05fb..f383185 100644 --- a/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert @@ -24,6 +24,7 @@ vec4 ComputeVertexPosition() vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy); vCornerRadius = min( vCornerRadius, minSize * 0.5 ); vRectSize = visualSize * 0.5 - vCornerRadius; + vCornerRadius = max( vCornerRadius, 1.0 ); vPosition = aPosition * visualSize; return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 ); } diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag index 1e3a1a7..0e2c1d8 100644 --- a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag +++ b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag @@ -10,10 +10,23 @@ uniform lowp float preMultipliedAlpha; void main() { - mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius; - mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist ); + mediump vec2 diff = abs( vPosition ) - vRectSize; + mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius; + mediump float opacity = 1.0; + if( dist > 1.0 ) + { + opacity = 0.0; + } + else if( dist > -1.0 ) + { + if( min( diff.x, diff.y ) < 0.0 ) + { + dist += min( diff.x, diff.y ) / vCornerRadius; + } + opacity = 1.0 - smoothstep( -1.0, 1.0, dist ); + } OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 ); OUT_COLOR.a *= opacity; OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha ); -} \ No newline at end of file +} diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert index d4b129e..0bd3530 100644 --- a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert @@ -26,6 +26,7 @@ vec4 ComputeVertexPosition() vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy); vCornerRadius = min( vCornerRadius, minSize * 0.5 ); vRectSize = visualSize * 0.5 - vCornerRadius; + vCornerRadius = max( vCornerRadius, 1.0 ); vPosition = aPosition* visualSize; return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 ); } @@ -34,4 +35,4 @@ void main() { gl_Position = uMvpMatrix * ComputeVertexPosition(); vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) ); -} \ No newline at end of file +} diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index a2d102a..db97880 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp @@ -293,7 +293,7 @@ void AnimatedVectorImageVisual::DoSetOnScene( Actor& actor ) } else { - shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, false ); + shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, IsRoundedCornerRequired() ); } Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.cpp b/dali-toolkit/internal/visuals/svg/svg-visual.cpp index 09d8de2..bce5c27 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.cpp +++ b/dali-toolkit/internal/visuals/svg/svg-visual.cpp @@ -141,7 +141,7 @@ void SvgVisual::DoSetOnScene( Actor& actor ) Shader shader; if( !mImpl->mCustomShader ) { - shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, false ); + shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, IsRoundedCornerRequired() ); } else { diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 844fd5d..384c67e 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -29,7 +29,7 @@ namespace Toolkit { const unsigned int TOOLKIT_MAJOR_VERSION = 2; const unsigned int TOOLKIT_MINOR_VERSION = 0; -const unsigned int TOOLKIT_MICRO_VERSION = 10; +const unsigned int TOOLKIT_MICRO_VERSION = 11; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 041c023..e7e130a 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali2-toolkit Summary: Dali 3D engine Toolkit -Version: 2.0.10 +Version: 2.0.11 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT