X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fweb-view%2Fweb-view-impl.h;h=0a610b525ecf9e70fc92651c41d106362c67e0c1;hb=3890e8d5e0d6c13b7a20538b0de12125946f6d87;hp=14fb0b52fb67b46dbcbdddda7252b6c226d737a3;hpb=06390b11a4bbb71ee3d9a0508ed33cb3aa14d8a3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 14fb0b5..0a610b5 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_WEB_VIEW_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. @@ -19,9 +19,10 @@ */ // EXTERNAL INCLUDES -#include #include #include +#include +#include // INTERNAL INCLUDES #include @@ -31,10 +32,8 @@ namespace Dali { - namespace Toolkit { - class KeyEvent; class TouchEvent; class WebBackForwardList; @@ -45,21 +44,18 @@ class WebView; namespace Internal { - class WebView : public Control { protected: - WebView(); - WebView( const std::string& locale, const std::string& timezoneId ); + WebView(const std::string& locale, const std::string& timezoneId); - WebView( int argc, char** argv ); + WebView(int argc, char** argv); virtual ~WebView(); public: - /** * @copydoc Dali::Toolkit::WebView::New() */ @@ -68,7 +64,7 @@ public: /** * @copydoc Dali::Toolkit::WebView::New( const std::string&, const std::string& ) */ - static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId ); + static Toolkit::WebView New(const std::string& locale, const std::string& timezoneId); /** * @brief Get settings of WebEngine. @@ -93,7 +89,7 @@ public: /** * @copydoc Dali::Toolkit::WebView::New( int, char** ) */ - static Toolkit::WebView New( int argc, char** argv ); + static Toolkit::WebView New(int argc, char** argv); /** * @brief Get Favicon of web page. @@ -105,12 +101,12 @@ public: /** * @copydoc Dali::Toolkit::WebView::LoadUrl() */ - void LoadUrl( const std::string& url ); + void LoadUrl(const std::string& url); /** * @copydoc Dali::WebEngine::LoadHTMLString() */ - void LoadHtmlString( const std::string& htmlString ); + void LoadHtmlString(const std::string& htmlString); /** * @copydoc Dali::Toolkit::WebView::Reload() @@ -135,7 +131,7 @@ public: /** * @copydoc Dali::Toolkit::WebView::ScrollBy() */ - void ScrollBy( int deltaX, int deltaY ); + void ScrollBy(int deltaX, int deltaY); /** * @copydoc Dali::Toolkit::WebView::CanGoForward() @@ -160,17 +156,42 @@ public: /** * @copydoc Dali::Toolkit::WebView::EvaluateJavaScript() */ - void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ); + void EvaluateJavaScript(const std::string& script, std::function resultHandler); /** * @copydoc Dali::Toolkit::WebView::AddJavaScriptMessageHandler() */ - void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ); + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); /** - * @brief Clears all tiles resources of Web. + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptAlertCallback() */ - void ClearAllTilesResources(); + void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback); + + /** + * @copydoc Dali::Toolkit::WebView::JavaScriptAlertReply() + */ + void JavaScriptAlertReply(); + + /** + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptConfirmCallback() + */ + void RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback); + + /** + * @copydoc Dali::Toolkit::WebView::JavaScriptConfirmReply() + */ + void JavaScriptConfirmReply(bool confirmed); + + /** + * @copydoc Dali::Toolkit::WebView::RegisterJavaScriptPromptCallback() + */ + void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback); + + /** + * @copydoc Dali::Toolkit::WebView::JavaScriptPromptReply() + */ + void JavaScriptPromptReply(const std::string& result); /** * @copydoc Dali::Toolkit::WebView::ClearHistory() @@ -178,11 +199,21 @@ public: void ClearHistory(); /** + * @brief Clears all tiles resources of Web. + */ + void ClearAllTilesResources(); + + /** * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal() */ Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal(); /** + * @copydoc Dali::Toolkit::WebView::PageLoadInProgressSignal() + */ + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadInProgressSignal(); + + /** * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal() */ Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadFinishedSignal(); @@ -197,8 +228,12 @@ public: */ Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); -public: // Properties + /** + * @copydoc Dali::Toolkit::WebView::UrlChangedSignal() + */ + Dali::Toolkit::WebView::WebViewUrlChangedSignalType& UrlChangedSignal(); +public: // Properties /** * @brief Called when a property of an object of this type is set. * @@ -206,7 +241,7 @@ public: // Properties * @param[in] index The property index. * @param[in] value The new property value. */ - static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value ); + static void SetProperty(Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value); /** * @brief Called to retrieve a property of an object of this type. @@ -215,7 +250,7 @@ public: // Properties * @param[in] index The property index. * @return The current value of the property. */ - static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex ); + static Dali::Property::Value GetProperty(Dali::BaseObject* object, Dali::Property::Index propertyIndex); /** * Connects a callback function with the object's signals. @@ -226,10 +261,9 @@ public: // Properties * @return True if the signal was connected. * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor); private: // From Control - /** * @copydoc Toolkit::Control::OnInitialize() */ @@ -241,22 +275,9 @@ private: // From Control Vector3 GetNaturalSize() override; /** - * @copydoc Toolkit::Control::OnRelayout() - */ - void OnRelayout( const Vector2& size, RelayoutContainer& container ) override; - - /** - * Signal occurs when the Web View has been touched. - * @param[in] actor The Actor Touched - * @param[in] touch The Touch Data. - * @return Whether to consume event or not. - */ - bool OnTouchEvent( Actor actor, const Dali::TouchEvent& touch ); - - /** * @copydoc Toolkit::Control::OnKeyEvent() */ - bool OnKeyEvent( const Dali::KeyEvent& event ) override; + bool OnKeyEvent(const Dali::KeyEvent& event) override; /** * @copydoc Toolkit::Control::OnKeyInputFocusGained() @@ -268,19 +289,23 @@ private: // From Control */ void OnKeyInputFocusLost() override; -private: + /** + * @copydoc Toolkit::Control::OnSceneConnection() + */ + void OnSceneConnection(int depth) override; +private: // Undefined - WebView( const WebView& webView ); + WebView(const WebView& webView); - WebView& operator=( const WebView& webView ); + WebView& operator=(const WebView& webView); /** * @brief Sets an absolute scroll of the given view. * @param[in] x The coordinate x of scroll * @param[in] y The coordinate y of scroll */ - void SetScrollPosition( int x, int y ); + void SetScrollPosition(int x, int y); /** * @brief Gets the current scroll position of the given view. @@ -311,6 +336,38 @@ private: std::string GetTitle() const; /** + * @brief Sets the background color of web page. + * @param[in] color The value of background color. + */ + void SetDocumentBackgroundColor(Dali::Vector4 color); + + /** + * @brief Clears tiles when hidden. + * + * @param[in] cleared Whether tiles are cleared or not + */ + void ClearTilesWhenHidden(bool cleared); + + /** + * @brief Sets multiplier of cover area of tile. + * + * @param[in] multiplier The multiplier of cover area + */ + void SetTileCoverAreaMultiplier(float multiplier); + + /** + * @brief Enables cursor by client. + * @param[in] enabled Whether cursor is enabled or not. + */ + void EnableCursorByClient(bool enabled); + + /** + * @brief Gets the selected text. + * @return The selected text + */ + std::string GetSelectedText() const; + + /** * @brief Get user agent string. * @return The string value of user agent */ @@ -320,66 +377,143 @@ private: * @brief Set user agent string. * @param[in] userAgent The string value of user agent */ - void SetUserAgent( const std::string& userAgent ); + void SetUserAgent(const std::string& userAgent); + + /** + * @brief Updates display area of web view. + * @param[in] source The soource triggers Notification. + */ + void UpdateDisplayArea(Dali::PropertyNotification& source); + + /** + * @brief Enable/Disable video hole for video playing. + * @param[in] enabled True if video hole is enabled, false otherwise. + */ + void EnableVideoHole(bool enabled); + + /** + * @brief Enable blend mode. + * @param[in] blendEnabled True if turn on blend mode, false otherwise. + */ + void EnableBlendMode(bool blendEnabled); + + /** + * @brief Enables/disables mouse events. The default is enabled. + * + * @param[in] enabled True if mouse events are enabled, false otherwise + */ + void EnableMouseEvents(bool enabled); + + /** + * @brief Enables/disables key events. The default is enabled. + * + * @param[in] enabled True if key events enabled, false otherwise + */ + void EnableKeyEvents(bool enabled); /** * @brief Callback function to be called when page load started. * @param[in] url The url currently being loaded */ - void OnPageLoadStarted( const std::string& url ); + void OnPageLoadStarted(const std::string& url); + + /** + * @brief Callback function to be called when page is loading in progress. + * @param[in] url The url currently being loaded + */ + void OnPageLoadInProgress(const std::string& url); /** * @brief Callback function to be called when page load finished. * @param[in] url The url currently being loaded */ - void OnPageLoadFinished( const std::string& url ); + void OnPageLoadFinished(const std::string& url); /** * @brief Callback function to be called when there is an error in page loading. * @param[in] url The url currently being loaded * @param[in] errorCode The error code */ - void OnPageLoadError( const std::string& url, int errorCode ); + void OnPageLoadError(const std::string& url, int errorCode); /** * @brief Callback function to be called when scroll edge is reached. * @param[in] e The scroll edge reached. */ - void OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge ); + void OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge); -private: + /** + * @brief Callback function to be called when url is changed. + * @param[in] url The url currently being loaded + */ + void OnUrlChanged(const std::string& url); - std::string mUrl; - Dali::Toolkit::Visual::Base mVisual; - Dali::Size mWebViewSize; - Dali::WebEngine mWebEngine; + /** + * Signal occurs when the Web View has been touched. + * @param[in] actor The Actor Touched + * @param[in] touch The Touch Data. + * @return Whether to consume event or not. + */ + bool OnTouchEvent(Actor actor, const Dali::TouchEvent& touch); - Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal; - Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; - Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; + /** + * Signal occurs when the Web View has been hovered. + * @param[in] actor The Actor Hovered + * @param[in] hover The Hover Data. + * @return Whether to consume event or not. + */ + bool OnHoverEvent(Actor actor, const Dali::HoverEvent& hover); + + /** + * Signal occurs when the Web View receives wheel event. + * @param[in] actor The Actor that receives Wheel event. + * @param[in] wheel The Wheel Data. + * @return Whether to consume event or not. + */ + bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel); + +private: + std::string mUrl; + Dali::Toolkit::Visual::Base mVisual; + Dali::Size mWebViewSize; + Dali::WebEngine mWebEngine; + + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal; + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadInProgressSignal; + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; + Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; + Dali::Toolkit::WebView::WebViewUrlChangedSignalType mUrlChangedSignal; 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; + std::unique_ptr mWebContext; + std::unique_ptr mWebCookieManager; + std::unique_ptr mWebSettings; + std::unique_ptr mWebBackForwardList; + Dali::Toolkit::ImageView mFaviconView; + + Dali::PropertyNotification mPositionUpdateNotification; + Dali::PropertyNotification mSizeUpdateNotification; + Dali::PropertyNotification mScaleUpdateNotification; + bool mVideoHoleEnabled; + Dali::Rect mWebViewArea; + bool mMouseEventsEnabled; + bool mKeyEventsEnabled; }; } // namespace Internal -inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle ) +inline Toolkit::Internal::WebView& GetImpl(Toolkit::WebView& handle) { - DALI_ASSERT_ALWAYS( handle ); + DALI_ASSERT_ALWAYS(handle); Dali::RefObject& impl = handle.GetImplementation(); - return static_cast< Toolkit::Internal::WebView& >( impl ); + return static_cast(impl); } -inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle ) +inline const Toolkit::Internal::WebView& GetImpl(const Toolkit::WebView& handle) { - DALI_ASSERT_ALWAYS( handle ); + DALI_ASSERT_ALWAYS(handle); const Dali::RefObject& impl = handle.GetImplementation(); - return static_cast< const Toolkit::Internal::WebView& >( impl ); + return static_cast(impl); } } // namespace Toolkit