Improve code related to scroll APIs in web view. 27/252027/4
authorhuayong.xu <huayong.xu@samsung.com>
Thu, 21 Jan 2021 10:55:45 +0000 (18:55 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Wed, 27 Jan 2021 01:48:42 +0000 (09:48 +0800)
This improvement is suggested by Mr. Richard Huang.

Change-Id: I6f26ada7119e535594217cbb379676730331b5c2

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
dali-toolkit/devel-api/controls/web-view/web-view.h
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.h

index 48676ea..d6419ff 100755 (executable)
@@ -446,22 +446,19 @@ public:
     mScrollPosition.y = y;
   }
 
     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()
   }
 
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
@@ -769,19 +766,19 @@ void WebEngine::SetScrollPosition( int x, int y )
   Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, 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 )
 }
 
 void WebEngine::SetSize( int width, int height )
index 53dfb5a..0380c26 100755 (executable)
@@ -196,17 +196,17 @@ public:
   /**
    * @brief WebView signal type related with page loading.
    */
   /**
    * @brief WebView signal type related with page loading.
    */
-  typedef Signal<void(WebView, const std::string&)> WebViewPageLoadSignalType;
+  using WebViewPageLoadSignalType = Signal< void( WebView, const std::string& ) >;
 
   /**
    * @brief WebView signal type related with page loading error.
    */
 
   /**
    * @brief WebView signal type related with page loading error.
    */
-  typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
+  using WebViewPageLoadErrorSignalType = Signal< void( WebView, const std::string&, LoadErrorCode ) >;
 
   /**
    * @brief WebView signal type related with scroll edge reached.
    */
 
   /**
    * @brief WebView signal type related with scroll edge reached.
    */
-  typedef Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)> WebViewScrollEdgeReachedSignalType;
+  using WebViewScrollEdgeReachedSignalType = Signal< void( WebView, Dali::WebEnginePlugin::ScrollEdge ) >;
 
 public:
   /**
 
 public:
   /**
index e89afab..78015c9 100755 (executable)
@@ -524,23 +524,17 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
       }
       case Toolkit::WebView::Property::SCROLL_POSITION:
       {
       }
       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:
       {
         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:
       {
         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:
         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
 }
 
 std::string WebView::GetTitle() const
index e3e61b3..14fb0b5 100755 (executable)
@@ -287,21 +287,21 @@ private:
    * @param[out] x The coordinate x of scroll
    * @param[out] y The coordinate y of scroll
    */
    * @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
    */
 
   /**
    * @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
    */
 
   /**
    * @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.
 
   /**
    * @brief Returns the title of the Web.