[Tizen] Update contents of webview when frame is rendered.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.cpp
index e1bb727..ff63f91 100755 (executable)
@@ -23,6 +23,7 @@
 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
@@ -42,6 +43,8 @@
 #include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
+#include <functional>
+
 namespace Dali
 {
 
@@ -61,17 +64,13 @@ BaseHandle Create()
 
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
 
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url",                     STRING,  URL                        )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent",               STRING,  USER_AGENT                 )
-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           )
-DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadError",           PAGE_LOAD_ERROR_SIGNAL              )
-DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "scrollEdgeReached",       SCROLL_EDGE_REACHED_SIGNAL          )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url",              STRING,  URL                )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent",        STRING,  USER_AGENT         )
+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_PROPERTY_REGISTRATION( Toolkit, WebView, "videoHoleEnabled", BOOLEAN, VIDEO_HOLE_ENABLED )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -88,16 +87,15 @@ const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
   \n
   void main()\n
   {\n
-      gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
+      gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(mixColor, 1.0);\n
   }\n
 );
 
-Dali::Toolkit::Visual::Base CreateNativeImageVisual( NativeImageInterfacePtr nativeImageInterface )
+Dali::Toolkit::Visual::Base CreateNativeImageVisual(NativeImageInterfacePtr nativeImageInterface)
 {
   std::string fragmentShader;
-
   const char* fragmentPrefix = nativeImageInterface->GetCustomFragmentPrefix();
-  if( fragmentPrefix )
+  if(fragmentPrefix)
   {
     fragmentShader = fragmentPrefix;
     fragmentShader += FRAGMENT_SHADER_TEXTURE;
@@ -108,13 +106,13 @@ Dali::Toolkit::Visual::Base CreateNativeImageVisual( NativeImageInterfacePtr nat
   }
 
   const char* customSamplerTypename = nativeImageInterface->GetCustomSamplerTypename();
-  if( customSamplerTypename )
+  if(customSamplerTypename)
   {
-    fragmentShader.replace( fragmentShader.find( DEFAULT_SAMPLER_TYPENAME ), strlen( DEFAULT_SAMPLER_TYPENAME ), customSamplerTypename );
+    fragmentShader.replace(fragmentShader.find(DEFAULT_SAMPLER_TYPENAME), strlen(DEFAULT_SAMPLER_TYPENAME), customSamplerTypename);
   }
 
-  Texture texture = Dali::Texture::New( *nativeImageInterface );
-  const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
+  Texture texture = Dali::Texture::New(*nativeImageInterface);
+  const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
 
   return Toolkit::VisualFactory::Get().CreateVisual(
     { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
@@ -124,21 +122,13 @@ Dali::Toolkit::Visual::Base CreateNativeImageVisual( NativeImageInterfacePtr nat
 
 } // anonymous namepsace
 
-#define GET_ENUM_STRING( structName, inputExp ) \
-  Scripting::GetLinearEnumerationName< Toolkit::WebView::structName::Type >( static_cast< Toolkit::WebView::structName::Type >( inputExp ), structName##_TABLE, structName##_TABLE_COUNT )
-
-#define GET_ENUM_VALUE( structName, inputExp, outputExp ) \
-  Scripting::GetEnumerationProperty< Toolkit::WebView::structName::Type >( inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp )
-
 WebView::WebView( const std::string& locale, const std::string& timezoneId )
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
-  mUrl(),
   mVisual(),
   mWebViewSize( Stage::GetCurrent().GetSize() ),
   mWebEngine(),
-  mPageLoadStartedSignal(),
-  mPageLoadFinishedSignal(),
-  mPageLoadErrorSignal()
+  mVideoHoleEnabled( true ),
+  mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height )
 {
   mWebEngine = Dali::WebEngine::New();
 
@@ -151,13 +141,11 @@ 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()
+  mVideoHoleEnabled( true ),
+  mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height )
 {
   mWebEngine = Dali::WebEngine::New();
 
@@ -175,6 +163,10 @@ WebView::WebView()
 
 WebView::~WebView()
 {
+  if( mWebEngine )
+  {
+    mWebEngine.Destroy();
+  }
 }
 
 Toolkit::WebView WebView::New()
@@ -206,20 +198,25 @@ Toolkit::WebView WebView::New( int argc, char** argv )
 
 void WebView::OnInitialize()
 {
-  Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
-  Self().TouchedSignal().Connect( this, &WebView::OnTouchEvent );
+  Actor self = Self();
 
-  if( mWebEngine )
-  {
-    mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
-    mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
-    mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
-    mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
+  self.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+  self.TouchedSignal().Connect(this, &WebView::OnTouchEvent);
+
+  mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
+  mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
+  mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
+  mPositionUpdateNotification.NotifySignal().Connect( this, &WebView::OnDisplayAreaUpdated );
+  mSizeUpdateNotification.NotifySignal().Connect( this, &WebView::OnDisplayAreaUpdated );
+  mScaleUpdateNotification.NotifySignal().Connect( this, &WebView::OnDisplayAreaUpdated );
 
-    mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>( new WebContext( mWebEngine.GetContext() ) );
-    mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>( new WebCookieManager( mWebEngine.GetCookieManager() ) );
-    mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>( new WebSettings( mWebEngine.GetSettings() ) );
-    mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>( new WebBackForwardList( mWebEngine.GetBackForwardList() ) );
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterFrameRenderedCallback(std::bind(&WebView::OnFrameRendered, this));
+    mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>(new WebContext(mWebEngine.GetContext()));
+    mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>(new WebCookieManager(mWebEngine.GetCookieManager()));
+    mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>(new WebSettings(mWebEngine.GetSettings()));
+    mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>(new WebBackForwardList(mWebEngine.GetBackForwardList()));
   }
 }
 
@@ -243,46 +240,40 @@ Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
   return mWebBackForwardList.get();
 }
 
-Dali::Toolkit::ImageView& WebView::GetFavicon()
+Dali::WebEnginePlugin* WebView::GetPlugin() const
 {
-  if ( mWebEngine )
-  {
-    Dali::PixelData pixelData = mWebEngine.GetFavicon();
-    std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData );
-    mFaviconView = Dali::Toolkit::ImageView::New( url );
-    mFaviconView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) );
-  }
-  return mFaviconView;
+  return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
 }
 
-void WebView::LoadUrl( const std::string& url )
+Dali::Toolkit::ImageView WebView::GetFavicon() const
 {
-  mUrl = url;
-  if( mWebEngine )
+  Dali::Toolkit::ImageView faviconView;
+  if(mWebEngine)
   {
-    mVisual = CreateNativeImageVisual( mWebEngine.GetNativeImageSource() );
-
-    if( mVisual )
+    Dali::PixelData pixelData = mWebEngine.GetFavicon();
+    if(pixelData)
     {
-      // Clean up previously registered visual and add new one.
-      DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
-      mWebEngine.LoadUrl( url );
+      std::string url = Dali::Toolkit::Image::GenerateUrl(pixelData);
+      faviconView     = Dali::Toolkit::ImageView::New(url);
+      faviconView.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
     }
   }
+  return faviconView;
 }
 
-void WebView::LoadHtmlString( const std::string& htmlString )
+void WebView::LoadUrl(const std::string& url)
 {
-  if( mWebEngine )
+  if(mWebEngine)
   {
-    mVisual = CreateNativeImageVisual( mWebEngine.GetNativeImageSource() );
+    mWebEngine.LoadUrl(url);
+  }
+}
 
-    if( mVisual )
-    {
-      DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
-      mWebEngine.LoadHtmlString( htmlString );
-    }
+void WebView::LoadHtmlString(const std::string& htmlString)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.LoadHtmlString(htmlString);
   }
 }
 
@@ -352,7 +343,7 @@ void WebView::GoBack()
   }
 }
 
-void WebView::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
+void WebView::EvaluateJavaScript( const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler )
 {
   if( mWebEngine )
   {
@@ -360,7 +351,7 @@ void WebView::EvaluateJavaScript( const std::string& script, std::function< void
   }
 }
 
-void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler )
+void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler )
 {
   if( mWebEngine )
   {
@@ -384,91 +375,96 @@ void WebView::ClearHistory()
   }
 }
 
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
+void WebView::SetTtsFocus(bool focused)
 {
-  return mPageLoadStartedSignal;
+  if(mWebEngine && !HasKeyInputFocus())
+  {
+    mWebEngine.SetFocus(focused);
+  }
 }
 
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
+void WebView::EnableVideoHole( bool enabled )
 {
-  return mPageLoadFinishedSignal;
+  mVideoHoleEnabled = enabled;
+  EnableBlendMode(!mVideoHoleEnabled);
+  if(mWebEngine)
+  {
+    mWebEngine.EnableVideoHole(mVideoHoleEnabled);
+  }
 }
 
-Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
+void WebView::EnableBlendMode(bool blendEnabled)
 {
-  return mPageLoadErrorSignal;
+  Actor self = Self();
+  for (uint32_t i = 0; i < self.GetRendererCount(); i++)
+  {
+    Dali::Renderer render = self.GetRendererAt(i);
+    render.SetProperty(Renderer::Property::BLEND_MODE, blendEnabled ? BlendMode::ON : BlendMode::OFF);
+  }
 }
 
-Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+void WebView::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
 {
-  return mScrollEdgeReachedSignal;
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterPageLoadStartedCallback(callback);
+  }
 }
 
-void WebView::OnPageLoadStarted( const std::string& url )
+void WebView::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
 {
-  if( !mPageLoadStartedSignal.Empty() )
+  if(mWebEngine)
   {
-    Dali::Toolkit::WebView handle( GetOwner() );
-    mPageLoadStartedSignal.Emit( handle, url );
+    mWebEngine.RegisterPageLoadFinishedCallback(callback);
   }
 }
 
-void WebView::OnPageLoadFinished( const std::string& url )
+void WebView::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
 {
-  if( !mPageLoadFinishedSignal.Empty() )
+  if(mWebEngine)
   {
-    Dali::Toolkit::WebView handle( GetOwner() );
-    mPageLoadFinishedSignal.Emit( handle, url );
+    mWebEngine.RegisterPageLoadErrorCallback(callback);
   }
 }
 
-void WebView::OnPageLoadError( const std::string& url, int errorCode )
+void WebView::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
 {
-  if( !mPageLoadErrorSignal.Empty() )
+  if(mWebEngine)
   {
-    Dali::Toolkit::WebView handle( GetOwner() );
-    mPageLoadErrorSignal.Emit( handle, url, static_cast< Toolkit::WebView::LoadErrorCode >( errorCode ) );
+    mWebEngine.RegisterScrollEdgeReachedCallback(callback);
   }
 }
 
-void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
+void WebView::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
 {
-  if( !mScrollEdgeReachedSignal.Empty() )
+  if(mWebEngine)
   {
-    Dali::Toolkit::WebView handle( GetOwner() );
-    mScrollEdgeReachedSignal.Emit( handle, edge );
+    mWebEngine.RegisterUrlChangedCallback(callback);
   }
 }
 
-bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
 {
-  Dali::BaseHandle handle( object );
-
-  bool connected = false;
-  Toolkit::WebView webView = Toolkit::WebView::DownCast( handle );
-
-  if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_STARTED_SIGNAL ) )
-  {
-    webView.PageLoadStartedSignal().Connect( tracker, functor );
-    connected = true;
-  }
-  else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL ) )
+  if(mWebEngine)
   {
-    webView.PageLoadFinishedSignal().Connect( tracker, functor );
-    connected = true;
+    mWebEngine.RegisterNavigationPolicyDecidedCallback(callback);
   }
-  else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_ERROR_SIGNAL ) )
+}
+
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+  if(mWebEngine)
   {
-    webView.PageLoadErrorSignal().Connect( tracker, functor );
-    connected = true;
+    mWebEngine.RegisterNewWindowCreatedCallback(callback);
   }
-  else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
+}
+
+void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
+{
+  if(mWebEngine)
   {
-    webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
-    connected = true;
+    mWebEngine.GetPlainTextAsynchronously(callback);
   }
-
-  return connected;
 }
 
 Vector3 WebView::GetNaturalSize()
@@ -479,29 +475,18 @@ Vector3 WebView::GetNaturalSize()
     mVisual.GetNaturalSize( rendererNaturalSize );
     return Vector3( rendererNaturalSize );
   }
-
   return Vector3( mWebViewSize );
 }
 
-void WebView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+void WebView::OnSceneConnection( int depth )
 {
-  Control::OnRelayout( size, container );
-
-  if( size.width > 0 && size.height > 0 && mWebViewSize != size )
-  {
-    mWebViewSize = size;
-
-    if( mWebEngine )
-    {
-      mWebEngine.SetSize( size.width, size.height );
-    }
-  }
+  Control::OnSceneConnection( depth );
+  EnableBlendMode( !mVideoHoleEnabled );
 }
 
 void WebView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
 {
   Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
-
   if( webView )
   {
     WebView& impl = GetImpl( webView );
@@ -534,6 +519,15 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
+      case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
+      {
+        bool input;
+        if( value.Get( input ) )
+        {
+          impl.EnableVideoHole( input );
+        }
+        break;
+      }
     }
   }
 }
@@ -541,9 +535,7 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
 Property::Value WebView::GetProperty( BaseObject* object, Property::Index propertyIndex )
 {
   Property::Value value;
-
   Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
-
   if( webView )
   {
     WebView& impl = GetImpl( webView );
@@ -551,7 +543,7 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
     {
       case Toolkit::WebView::Property::URL:
       {
-        value = impl.mUrl;
+        value = impl.GetUrl();
         break;
       }
       case Toolkit::WebView::Property::USER_AGENT:
@@ -585,6 +577,11 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
         value = impl.GetTitle();
         break;
       }
+      case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
+      {
+        value = impl.mVideoHoleEnabled;
+        break;
+      }
       default:
          break;
     }
@@ -596,7 +593,6 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
 bool WebView::OnTouchEvent( Actor actor, const Dali::TouchEvent& touch )
 {
   bool result = false;
-
   if( mWebEngine )
   {
     result = mWebEngine.SendTouchEvent( touch );
@@ -607,7 +603,6 @@ bool WebView::OnTouchEvent( Actor actor, const Dali::TouchEvent& touch )
 bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
 {
   bool result = false;
-
   if( mWebEngine )
   {
     result = mWebEngine.SendKeyEvent( event );
@@ -621,7 +616,6 @@ void WebView::OnKeyInputFocusGained()
   {
     mWebEngine.SetFocus( true );
   }
-
   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
 }
 
@@ -631,10 +625,54 @@ void WebView::OnKeyInputFocusLost()
   {
     mWebEngine.SetFocus( false );
   }
-
   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
 }
 
+void WebView::OnFrameRendered()
+{
+  // Make sure that mVisual is created only once.
+  if (mVisual)
+    return;
+
+  mVisual = CreateNativeImageVisual(mWebEngine.GetNativeImageSource());
+  if (mVisual)
+  {
+    DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+    EnableBlendMode(!mVideoHoleEnabled);
+  }
+}
+
+void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/)
+{
+  if( !mWebEngine )
+    return;
+
+  Actor self( Self() );
+
+  bool positionUsesAnchorPoint = self.GetProperty< bool >( Actor::Property::POSITION_USES_ANCHOR_POINT );
+  Vector3 actorSize = self.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) * self.GetCurrentProperty< Vector3 >( Actor::Property::SCALE );
+  Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) : AnchorPoint::TOP_LEFT );
+  Vector2 screenPosition = self.GetProperty< Vector2 >( Actor::Property::SCREEN_POSITION );
+
+  Dali::Rect< int > displayArea;
+  displayArea.x = screenPosition.x - anchorPointOffSet.x;
+  displayArea.y = screenPosition.y - anchorPointOffSet.y;
+  displayArea.width = actorSize.x;
+  displayArea.height = actorSize.y;
+
+  Size displaySize = Size( displayArea.width, displayArea.height );
+  if ( mWebViewSize != displaySize )
+  {
+    mWebViewSize = displaySize;
+  }
+
+  if (mWebViewArea != displayArea )
+  {
+    mWebViewArea = displayArea;
+    mWebEngine.UpdateDisplayArea( mWebViewArea );
+  }
+}
+
 void WebView::SetScrollPosition( int x, int y )
 {
   if( mWebEngine )
@@ -667,12 +705,17 @@ void WebView::GetContentSize( int& width, int& height ) const
   }
 }
 
+std::string WebView::GetUrl() const
+{
+  return mWebEngine ? mWebEngine.GetUrl() : kEmptyString;
+}
+
 std::string WebView::GetTitle() const
 {
   return mWebEngine ?  mWebEngine.GetTitle() : kEmptyString;
 }
 
-const std::string& WebView::GetUserAgent() const
+std::string WebView::GetUserAgent() const
 {
   return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
 }
@@ -685,9 +728,6 @@ void WebView::SetUserAgent( const std::string& userAgent )
   }
 }
 
-#undef GET_ENUM_STRING
-#undef GET_ENUM_VALUE
-
 } // namespace Internal
 
 } // namespace Toolkit