From 8d56551c7f8808b20aa3f3140e4b932b633d237c Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Fri, 18 Dec 2020 16:08:32 +0800 Subject: [PATCH 1/1] Add some new APIs into web engine. Some new APIs are added, e.g. Create, GetTitle, GetFavicon. Change-Id: I273cb0ee6fe158674b2af65a7968905a67e4194c --- .../adaptor-framework/web-engine-plugin.h | 30 +++++++++++++++++++ dali/devel-api/adaptor-framework/web-engine.cpp | 23 ++++++++++++++ dali/devel-api/adaptor-framework/web-engine.h | 29 ++++++++++++++++++ .../internal/web-engine/common/web-engine-impl.cpp | 35 +++++++++++++++++----- dali/internal/web-engine/common/web-engine-impl.h | 34 ++++++++++++++++----- 5 files changed, 137 insertions(+), 14 deletions(-) diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h index fbf8d1c..eb4a5fe 100755 --- a/dali/devel-api/adaptor-framework/web-engine-plugin.h +++ b/dali/devel-api/adaptor-framework/web-engine-plugin.h @@ -26,6 +26,7 @@ namespace Dali { class KeyEvent; +class PixelData; class TouchEvent; class WebEngineBackForwardList; class WebEngineContext; @@ -89,6 +90,16 @@ public: virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0; /** + * @brief Creates WebEngine instance. + * + * @param [in] width The width of Web + * @param [in] height The height of Web + * @param [in] argc The count of application arguments + * @param [in] argv The string array of application arguments + */ + virtual void Create( int width, int height, int argc, char** argv ) = 0; + + /** * @brief Destroys WebEngine instance. */ virtual void Destroy() = 0; @@ -121,6 +132,20 @@ public: virtual void LoadUrl(const std::string& url) = 0; /** + * @brief Returns the title of the Web. + * + * @return The title of web page + */ + virtual std::string GetTitle() const = 0; + + /** + * @brief Returns the Favicon of the Web. + * + * @return Favicon of Dali::PixelData& type + */ + virtual Dali::PixelData GetFavicon() const = 0; + + /** * @brief Gets image to render. */ virtual NativeImageInterfacePtr GetNativeImageSource() = 0; @@ -225,6 +250,11 @@ public: virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler) = 0; /** + * @brief Clears all tiles resources of Web. + */ + virtual void ClearAllTilesResources() = 0; + + /** * @brief Clears the history of Web. */ virtual void ClearHistory() = 0; diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp index 46130fa..76dfec0 100755 --- a/dali/devel-api/adaptor-framework/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine.cpp @@ -25,6 +25,9 @@ #include #include +// EXTERNAL INCLUDES +#include + namespace Dali { WebEngine::WebEngine() @@ -71,6 +74,11 @@ void WebEngine::Create(int width, int height, const std::string& locale, const s GetImplementation(*this).Create(width, height, locale, timezoneId); } +void WebEngine::Create( int width, int height, int argc, char** argv ) +{ + GetImplementation( *this ).Create( width, height, argc, argv ); +} + void WebEngine::Destroy() { GetImplementation(*this).Destroy(); @@ -106,6 +114,16 @@ void WebEngine::LoadUrl(const std::string& url) return GetImplementation(*this).LoadUrl(url); } +std::string WebEngine::GetTitle() const +{ + return GetImplementation( *this ).GetTitle(); +} + +Dali::PixelData WebEngine::GetFavicon() const +{ + return GetImplementation( *this ).GetFavicon(); +} + const std::string& WebEngine::GetUrl() { return GetImplementation(*this).GetUrl(); @@ -191,6 +209,11 @@ void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler); } +void WebEngine::ClearAllTilesResources() +{ + GetImplementation( *this ).ClearAllTilesResources(); +} + void WebEngine::ClearHistory() { return GetImplementation(*this).ClearHistory(); diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h index a01db89..b733353 100755 --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -97,6 +97,16 @@ public: void Create(int width, int height, const std::string& locale, const std::string& timezoneId); /** + * @brief Creates WebEngine instance. + * + * @param [in] width The width of Web + * @param [in] height The height of Web + * @param [in] argc The count of application arguments + * @param [in] argv The string array of application arguments + */ + void Create( int width, int height, int argc, char** argv ); + + /** * @brief Destroys WebEngine instance. */ void Destroy(); @@ -134,6 +144,20 @@ public: void LoadUrl(const std::string& url); /** + * @brief Returns the title of the Web. + * + * @return The title of web page + */ + std::string GetTitle() const; + + /** + * @brief Returns the Favicon of the Web. + * + * @return FavIcon of Dali::PixelData& type + */ + Dali::PixelData GetFavicon() const; + + /** * @brief Gets the url. */ const std::string& GetUrl(); @@ -231,6 +255,11 @@ public: void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); /** + * @brief Clears all tiles resources of Web. + */ + void ClearAllTilesResources(); + + /** * @brief Clears the history of Web. */ void ClearHistory(); diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp index 3381dac..0943387 100755 --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace Dali { @@ -172,6 +173,11 @@ void WebEngine::Create( int width, int height, const std::string& locale, const mPlugin->Create( width, height, locale, timezoneId ); } +void WebEngine::Create( int width, int height, int argc, char** argv ) +{ + mPlugin->Create( width, height, argc, argv ); +} + void WebEngine::Destroy() { mPlugin->Destroy(); @@ -207,11 +213,31 @@ void WebEngine::LoadUrl( const std::string& url ) mPlugin->LoadUrl( url ); } +std::string WebEngine::GetTitle() const +{ + return mPlugin->GetTitle(); +} + +Dali::PixelData WebEngine::GetFavicon() const +{ + return mPlugin->GetFavicon(); +} + const std::string& WebEngine::GetUrl() { return mPlugin->GetUrl(); } +const std::string& WebEngine::GetUserAgent() const +{ + return mPlugin->GetUserAgent(); +} + +void WebEngine::SetUserAgent( const std::string& userAgent ) +{ + mPlugin->SetUserAgent( userAgent ); +} + void WebEngine::LoadHtmlString( const std::string& htmlString ) { mPlugin->LoadHtmlString( htmlString ); @@ -292,14 +318,9 @@ void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectNam mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler ); } -const std::string& WebEngine::GetUserAgent() const +void WebEngine::ClearAllTilesResources() { - return mPlugin->GetUserAgent(); -} - -void WebEngine::SetUserAgent( const std::string& userAgent ) -{ - mPlugin->SetUserAgent( userAgent ); + mPlugin->ClearAllTilesResources(); } void WebEngine::ClearHistory() diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h index 28cedec..a2a6571 100755 --- a/dali/internal/web-engine/common/web-engine-impl.h +++ b/dali/internal/web-engine/common/web-engine-impl.h @@ -64,6 +64,11 @@ public: void Create( int width, int height, const std::string& locale, const std::string& timezoneId ); /** + * @copydoc Dali::WebEngine::Create() + */ + void Create( int width, int height, int argc, char** argv ); + + /** * @copydoc Dali::WebEngine::Destroy() */ void Destroy(); @@ -99,11 +104,31 @@ public: void LoadUrl( const std::string& url ); /** + * @copydoc Dali::WebEngine::GetTitle() + */ + std::string GetTitle() const; + + /** + * @copydoc Dali::WebEngine::GetFavicon() + */ + Dali::PixelData GetFavicon() const; + + /** * @copydoc Dali::WebEngine::GetUrl() */ const std::string& GetUrl(); /** + * @copydoc Dali::WebEngine::GetUserAgent() + */ + const std::string& GetUserAgent() const; + + /** + * @copydoc Dali::WebEngine::SetUserAgent() + */ + void SetUserAgent( const std::string& userAgent ); + + /** * @copydoc Dali::WebEngine::LoadHtmlString() */ void LoadHtmlString( const std::string& htmlString ); @@ -184,14 +209,9 @@ public: void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler ); /** - * @copydoc Dali::WebEngine::GetUserAgent() + * @copydoc Dali::WebEngine::ClearAllTilesResources() */ - const std::string& GetUserAgent() const; - - /** - * @copydoc Dali::WebEngine::SetUserAgent() - */ - void SetUserAgent( const std::string& userAgent ); + void ClearAllTilesResources(); /** * @copydoc Dali::WebEngine::ClearHistory() -- 2.7.4