[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
old mode 100644 (file)
new mode 100755 (executable)
index abc2970..ff63f91
 
 // EXTERNAL INCLUDES
 #include <cstring>
+#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>
 #include <dali/devel-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/public-api/image-loader/image.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+
+#include <functional>
 
 namespace Dali
 {
@@ -49,54 +62,73 @@ BaseHandle Create()
   return Toolkit::WebView::New();
 }
 
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER )
-DALI_ENUM_TO_STRING_TABLE_END( CacheModel )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY )
-DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy )
-
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
 
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url",                     STRING,  URL                        )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel",              STRING,  CACHE_MODEL                )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy",      STRING,  COOKIE_ACCEPT_POLICY       )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent",               STRING,  USER_AGENT                 )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript",        BOOLEAN, ENABLE_JAVASCRIPT          )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY  )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING,  DEFAULT_TEXT_ENCODING_NAME )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize",         INTEGER, DEFAULT_FONT_SIZE          )
-
-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_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()
 
 const std::string kEmptyString;
 
-} // anonymous namepsace
+const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
 
-#define GET_ENUM_STRING( structName, inputExp ) \
-  Scripting::GetLinearEnumerationName< Toolkit::WebView::structName::Type >( static_cast< Toolkit::WebView::structName::Type >( inputExp ), structName##_TABLE, structName##_TABLE_COUNT )
+const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
+  varying mediump vec2 vTexCoord;\n
+  uniform sampler2D sTexture;\n
+  uniform lowp vec4 uColor;\n
+  uniform lowp vec3 mixColor;\n
+  uniform lowp float preMultipliedAlpha;\n
+  \n
+  void main()\n
+  {\n
+      gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(mixColor, 1.0);\n
+  }\n
+);
 
-#define GET_ENUM_VALUE( structName, inputExp, outputExp ) \
-  Scripting::GetEnumerationProperty< Toolkit::WebView::structName::Type >( inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp )
+Dali::Toolkit::Visual::Base CreateNativeImageVisual(NativeImageInterfacePtr nativeImageInterface)
+{
+  std::string fragmentShader;
+  const char* fragmentPrefix = nativeImageInterface->GetCustomFragmentPrefix();
+  if(fragmentPrefix)
+  {
+    fragmentShader = fragmentPrefix;
+    fragmentShader += FRAGMENT_SHADER_TEXTURE;
+  }
+  else
+  {
+    fragmentShader = FRAGMENT_SHADER_TEXTURE;
+  }
+
+  const char* customSamplerTypename = nativeImageInterface->GetCustomSamplerTypename();
+  if(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);
+
+  return Toolkit::VisualFactory::Get().CreateVisual(
+    { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
+      { Toolkit::Visual::Property::SHADER, { { Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, fragmentShader } } },
+      { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
+}
+
+} // anonymous namepsace
 
 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();
 
@@ -107,6 +139,23 @@ 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 ) ),
+  mVisual(),
+  mWebViewSize( Stage::GetCurrent().GetSize() ),
+  mWebEngine(),
+  mVideoHoleEnabled( true ),
+  mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height )
+{
+  mWebEngine = Dali::WebEngine::New();
+
+  // WebEngine is empty when it is not properly initialized.
+  if ( mWebEngine )
+  {
+    mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, argc, argv );
+  }
+}
+
 WebView::WebView()
 : WebView( "", "" )
 {
@@ -114,6 +163,10 @@ WebView::WebView()
 
 WebView::~WebView()
 {
+  if( mWebEngine )
+  {
+    mWebEngine.Destroy();
+  }
 }
 
 Toolkit::WebView WebView::New()
@@ -134,54 +187,93 @@ Toolkit::WebView WebView::New( const std::string& locale, const std::string& tim
   return handle;
 }
 
+Toolkit::WebView WebView::New( int argc, char** argv )
+{
+  WebView* impl = new WebView( argc, argv );
+  Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+  impl->Initialize();
+  return handle;
+}
+
 void WebView::OnInitialize()
 {
-  Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
-  Self().TouchSignal().Connect( this, &WebView::OnTouchEvent );
+  Actor self = Self();
 
-  if( mWebEngine )
+  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 );
+
+  if(mWebEngine)
   {
-    mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
-    mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
-    mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
+    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()));
   }
 }
 
-void WebView::LoadUrl( const std::string& url )
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
 {
-  mUrl = url;
-  if( mWebEngine )
-  {
-    Texture texture = Dali::Texture::New( *mWebEngine.GetNativeImageSource() );
-    const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
-    mVisual = Toolkit::VisualFactory::Get().CreateVisual(
-      { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
-        { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
+  return mWebSettings.get();
+}
 
-    if( mVisual )
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+  return mWebContext.get();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+  return mWebCookieManager.get();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+  return mWebBackForwardList.get();
+}
+
+Dali::WebEnginePlugin* WebView::GetPlugin() const
+{
+  return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
+}
+
+Dali::Toolkit::ImageView WebView::GetFavicon() const
+{
+  Dali::Toolkit::ImageView faviconView;
+  if(mWebEngine)
+  {
+    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)
   {
-    Texture texture = Dali::Texture::New( *mWebEngine.GetNativeImageSource() );
-    const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
-    mVisual = Toolkit::VisualFactory::Get().CreateVisual(
-      { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
-        { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
+    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);
   }
 }
 
@@ -217,6 +309,14 @@ void WebView::Resume()
   }
 }
 
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.ScrollBy( deltaX, deltaY );
+  }
+}
+
 bool WebView::CanGoForward()
 {
   return mWebEngine ? mWebEngine.CanGoForward() : false;
@@ -243,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 )
   {
@@ -251,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 )
   {
@@ -259,96 +359,112 @@ void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName,
   }
 }
 
-void WebView::ClearHistory()
+void WebView::ClearAllTilesResources()
 {
   if( mWebEngine )
   {
-    mWebEngine.ClearHistory();
+    mWebEngine.ClearAllTilesResources();
   }
 }
 
-void WebView::ClearCache()
+void WebView::ClearHistory()
 {
   if( mWebEngine )
   {
-    mWebEngine.ClearCache();
+    mWebEngine.ClearHistory();
   }
 }
 
-void WebView::ClearCookies()
+void WebView::SetTtsFocus(bool focused)
 {
-  if( mWebEngine )
+  if(mWebEngine && !HasKeyInputFocus())
   {
-    mWebEngine.ClearCookies();
+    mWebEngine.SetFocus(focused);
   }
 }
 
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
+void WebView::EnableVideoHole( bool enabled )
 {
-  return mPageLoadStartedSignal;
+  mVideoHoleEnabled = enabled;
+  EnableBlendMode(!mVideoHoleEnabled);
+  if(mWebEngine)
+  {
+    mWebEngine.EnableVideoHole(mVideoHoleEnabled);
+  }
 }
 
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
+void WebView::EnableBlendMode(bool blendEnabled)
 {
-  return mPageLoadFinishedSignal;
+  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::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
+void WebView::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
 {
-  return mPageLoadErrorSignal;
+  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);
   }
 }
 
-bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+void WebView::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback 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 ) )
+  if(mWebEngine)
   {
-    webView.PageLoadStartedSignal().Connect( tracker, functor );
-    connected = true;
+    mWebEngine.RegisterUrlChangedCallback(callback);
   }
-  else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL ) )
+}
+
+void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
+{
+  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);
   }
+}
 
-  return connected;
+void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.GetPlainTextAsynchronously(callback);
+  }
 }
 
 Vector3 WebView::GetNaturalSize()
@@ -359,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 );
@@ -396,20 +501,6 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
-      case Toolkit::WebView::Property::CACHE_MODEL:
-      {
-        Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel();
-        GET_ENUM_VALUE( CacheModel, value, output );
-        impl.SetCacheModel( output );
-        break;
-      }
-      case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
-      {
-        Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy();
-        GET_ENUM_VALUE( CookieAcceptPolicy, value, output );
-        impl.SetCookieAcceptPolicy( output );
-        break;
-      }
       case Toolkit::WebView::Property::USER_AGENT:
       {
         std::string input;
@@ -419,39 +510,21 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
-      case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
+      case Toolkit::WebView::Property::SCROLL_POSITION:
       {
-        bool input;
-        if( value.Get( input ) )
+        Vector2 input;
+        if ( value.Get( input ) )
         {
-          impl.EnableJavaScript( input );
+          impl.SetScrollPosition( input.x, input.y );
         }
         break;
       }
-      case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+      case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
       {
         bool input;
         if( value.Get( input ) )
         {
-          impl.LoadImagesAutomatically( input );
-        }
-        break;
-      }
-      case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
-      {
-        std::string input;
-        if( value.Get( input ) )
-        {
-          impl.SetDefaultTextEncodingName( input );
-        }
-        break;
-      }
-      case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
-      {
-        int input;
-        if( value.Get( input ) )
-        {
-          impl.SetDefaultFontSize( input );
+          impl.EnableVideoHole( input );
         }
         break;
       }
@@ -462,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 );
@@ -472,42 +543,43 @@ 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::CACHE_MODEL:
+      case Toolkit::WebView::Property::USER_AGENT:
       {
-        value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() );
+        value = impl.GetUserAgent();
         break;
       }
-      case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
+      case Toolkit::WebView::Property::SCROLL_POSITION:
       {
-        value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() );
+        int x, y;
+        impl.GetScrollPosition( x, y );
+        value = Vector2( x, y );
         break;
       }
-      case Toolkit::WebView::Property::USER_AGENT:
+      case Toolkit::WebView::Property::SCROLL_SIZE:
       {
-        value = impl.GetUserAgent();
+        int width, height;
+        impl.GetScrollSize( width, height );
+        value = Vector2( width, height );
         break;
       }
-      case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
+      case Toolkit::WebView::Property::CONTENT_SIZE:
       {
-        value = impl.IsJavaScriptEnabled();
+        int width, height;
+        impl.GetContentSize( width, height );
+        value = Vector2( width, height );
         break;
       }
-      case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+      case Toolkit::WebView::Property::TITLE:
       {
-        value = impl.AreImagesAutomaticallyLoaded();
+        value = impl.GetTitle();
         break;
       }
-      case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
+      case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
       {
-        value = impl.GetDefaultTextEncodingName();
-        break;
-      }
-      case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
-      {
-        value = impl.GetDefaultFontSize();
+        value = impl.mVideoHoleEnabled;
         break;
       }
       default:
@@ -518,10 +590,9 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
   return value;
 }
 
-bool WebView::OnTouchEvent( Actor actor, const Dali::TouchData& touch )
+bool WebView::OnTouchEvent( Actor actor, const Dali::TouchEvent& touch )
 {
   bool result = false;
-
   if( mWebEngine )
   {
     result = mWebEngine.SendTouchEvent( touch );
@@ -532,7 +603,6 @@ bool WebView::OnTouchEvent( Actor actor, const Dali::TouchData& touch )
 bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
 {
   bool result = false;
-
   if( mWebEngine )
   {
     result = mWebEngine.SendKeyEvent( event );
@@ -540,100 +610,124 @@ bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
   return result;
 }
 
-Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
+void WebView::OnKeyInputFocusGained()
 {
-  return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
+  if( mWebEngine )
+  {
+    mWebEngine.SetFocus( true );
+  }
+  EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
 }
 
-void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel )
+void WebView::OnKeyInputFocusLost()
 {
   if( mWebEngine )
   {
-    mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) );
+    mWebEngine.SetFocus( false );
   }
+  EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
 }
 
-Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const
+void WebView::OnFrameRendered()
 {
-  return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY;
-}
+  // Make sure that mVisual is created only once.
+  if (mVisual)
+    return;
 
-void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy )
-{
-  if( mWebEngine )
+  mVisual = CreateNativeImageVisual(mWebEngine.GetNativeImageSource());
+  if (mVisual)
   {
-    mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) );
+    DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+    EnableBlendMode(!mVideoHoleEnabled);
   }
 }
 
-const std::string& WebView::GetUserAgent() const
+void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/)
 {
-  return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
-}
+  if( !mWebEngine )
+    return;
 
-void WebView::SetUserAgent( const std::string& userAgent )
-{
-  if( mWebEngine )
+  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 )
   {
-    mWebEngine.SetUserAgent( userAgent );
+    mWebViewSize = displaySize;
+  }
+
+  if (mWebViewArea != displayArea )
+  {
+    mWebViewArea = displayArea;
+    mWebEngine.UpdateDisplayArea( mWebViewArea );
   }
 }
 
-bool WebView::IsJavaScriptEnabled() const
+void WebView::SetScrollPosition( int x, int y )
 {
-  return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true;
+  if( mWebEngine )
+  {
+    mWebEngine.SetScrollPosition( x, y );
+  }
 }
 
-void WebView::EnableJavaScript( bool enabled )
+void WebView::GetScrollPosition( int& x, int& y ) const
 {
   if( mWebEngine )
   {
-    mWebEngine.EnableJavaScript( enabled );
+    mWebEngine.GetScrollPosition( x, y );
   }
 }
 
-bool WebView::AreImagesAutomaticallyLoaded() const
+void WebView::GetScrollSize( int& width, int& height ) const
 {
-  return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true;
+  if( mWebEngine )
+  {
+    mWebEngine.GetScrollSize( width, height );
+  }
 }
 
-void WebView::LoadImagesAutomatically( bool automatic )
+void WebView::GetContentSize( int& width, int& height ) const
 {
   if( mWebEngine )
   {
-    mWebEngine.LoadImagesAutomatically( automatic );
+    mWebEngine.GetContentSize( width, height );
   }
 }
 
-const std::string& WebView::GetDefaultTextEncodingName() const
+std::string WebView::GetUrl() const
 {
-  return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString;
+  return mWebEngine ? mWebEngine.GetUrl() : kEmptyString;
 }
 
-void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+std::string WebView::GetTitle() const
 {
-  if( mWebEngine )
-  {
-    mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName );
-  }
+  return mWebEngine ?  mWebEngine.GetTitle() : kEmptyString;
 }
 
-int WebView::GetDefaultFontSize() const
+std::string WebView::GetUserAgent() const
 {
-  return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0;
+  return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
 }
 
-void WebView::SetDefaultFontSize( int defaultFontSize )
+void WebView::SetUserAgent( const std::string& userAgent )
 {
   if( mWebEngine )
   {
-    mWebEngine.SetDefaultFontSize( defaultFontSize );
+    mWebEngine.SetUserAgent( userAgent );
   }
 }
 
-#undef GET_ENUM_STRING
-#undef GET_ENUM_VALUE
-
 } // namespace Internal
 
 } // namespace Toolkit