From: huayong.xu Date: Thu, 21 Jan 2021 10:55:45 +0000 (+0800) Subject: Improve code related to scroll APIs in web view. X-Git-Tag: dali_2.0.11~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=9d1d199ec60bf11a03662e1e17b7f772785d11c1 Improve code related to scroll APIs in web view. This improvement is suggested by Mr. Richard Huang. Change-Id: I6f26ada7119e535594217cbb379676730331b5c2 --- 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 48676ea..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 @@ -446,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() @@ -769,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/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 53dfb5a..0380c26 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -196,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: /** 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 e89afab..78015c9 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -524,23 +524,17 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper } 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: @@ -606,28 +600,19 @@ 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; } std::string WebView::GetTitle() const 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 e3e61b3..14fb0b5 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -287,21 +287,21 @@ 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; + Dali::Vector2 GetContentSize() const; /** * @brief Returns the title of the Web.