[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 632baaf..c121cc7
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -16,7 +16,7 @@
  */
 
 // CLASS HEADER
-#include "web-view-impl.h"
+#include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-back-forward-list.h>
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-load-error.h>
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-policy-decision.h>
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-settings.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
-#include <cstring>
-#include <memory>
 
 // 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-settings.h>
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
-#include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali-toolkit/public-api/image-loader/image-url.h>
+#include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
+#include <functional>
+#include <memory>
+#include <unordered_map>
+
 namespace Dali
 {
 namespace Toolkit
@@ -87,26 +92,78 @@ DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "loadProgressPercentage",  FLOAT,
 DALI_TYPE_REGISTRATION_END()
 // clang-format on
 
-} // namespace
+std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>>& GetPluginWebViewTable()
+{
+  static std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> pluginWebViewMap;
+  return pluginWebViewMap;
+}
+
+enum class DisplayAreaCalculateOption
+{
+  PROPERTY         = 0, ///< Calculate display update area by property
+  CURRENT_PROPERTY = 1, ///< Calculate display update area by current property
+};
+
+/**
+ * @brief Helper function to calculate exact display area, offset and size.
+ * It will be useful when view size is not integer value, or view size is not matched with texture size.
+ *
+ * @param[in] self The view itself.
+ * @param[in] option Option of this calculation. Let we decide what kind of property will be used.
+ * @return DisplayArea for this view.
+ */
+Rect<int32_t> CalculateDisplayArea(Dali::Actor self, DisplayAreaCalculateOption option)
+{
+  bool    positionUsesAnchorPoint = self.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
+  Vector3 actorSize               = (option == DisplayAreaCalculateOption::CURRENT_PROPERTY) ? self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::SCALE)
+                                                                                             : self.GetProperty<Vector3>(Actor::Property::SIZE) * self.GetProperty<Vector3>(Actor::Property::SCALE);
+  Vector3 anchorPointOffSet       = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+  Vector2 screenPosition          = (option == DisplayAreaCalculateOption::CURRENT_PROPERTY) ? self.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION)
+                                                                                             : Dali::DevelActor::CalculateScreenPosition(self);
 
-#define GET_ENUM_STRING(structName, inputExp) \
-  Scripting::GetLinearEnumerationName<Toolkit::WebView::structName::Type>(static_cast<Toolkit::WebView::structName::Type>(inputExp), structName##_TABLE, structName##_TABLE_COUNT)
+  Dali::Rect<int32_t> displayArea;
+  displayArea.x      = screenPosition.x - anchorPointOffSet.x;
+  displayArea.y      = screenPosition.y - anchorPointOffSet.y;
+  displayArea.width  = actorSize.x;
+  displayArea.height = actorSize.y;
 
-#define GET_ENUM_VALUE(structName, inputExp, outputExp) \
-  Scripting::GetEnumerationProperty<Toolkit::WebView::structName::Type>(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp)
+  return displayArea;
+}
 
-std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> WebView::mPluginWebViewMap;
+constexpr Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+
+/**
+ * @brief Helper function to calculate exact pixel area value by view and texture size.
+ * It will be useful when view size is not integer value, or view size is not matched with texture size.
+ *
+ * @param[in] viewSize The size of view.
+ * @param[in] textureWidth The width of texture, that must be integer type.
+ * @param[in] textureHeight The height of texture, that must be integer type.
+ * @return PixelArea value that image visual can use.
+ */
+Vector4 CalculatePixelArea(const Size& viewSize, const uint32_t textureWidth, const uint32_t textureHeight)
+{
+  float widthRatio  = textureWidth == 0u ? 1.0f : viewSize.width / static_cast<float>(textureWidth);
+  float heightRatio = textureHeight == 0u ? 1.0f : viewSize.height / static_cast<float>(textureHeight);
+  return Vector4(0.0f, 0.0f, widthRatio, heightRatio);
+}
+
+} // namespace
 
 WebView::WebView(const std::string& locale, const std::string& timezoneId)
 : Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)),
   mVisual(),
   mWebViewSize(Stage::GetCurrent().GetSize()),
   mWebEngine(),
+  mLastRenderedNativeImageWidth(0u),
+  mLastRenderedNativeImageHeight(0u),
   mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
   mVideoHoleEnabled(false),
   mMouseEventsEnabled(true),
   mKeyEventsEnabled(true),
-  mScreenshotCapturedCallback(nullptr)
+  mVisualChangeRequired(false),
+  mScreenshotCapturedCallback{nullptr},
+  mFrameRenderedCallback{nullptr}
 {
   mWebEngine = Dali::WebEngine::New();
 
@@ -122,11 +179,15 @@ WebView::WebView(uint32_t argc, char** argv)
   mVisual(),
   mWebViewSize(Stage::GetCurrent().GetSize()),
   mWebEngine(),
+  mLastRenderedNativeImageWidth(0u),
+  mLastRenderedNativeImageHeight(0u),
   mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
   mVideoHoleEnabled(false),
   mMouseEventsEnabled(true),
   mKeyEventsEnabled(true),
-  mScreenshotCapturedCallback(nullptr)
+  mVisualChangeRequired(false),
+  mScreenshotCapturedCallback{nullptr},
+  mFrameRenderedCallback{nullptr}
 {
   mWebEngine = Dali::WebEngine::New();
 
@@ -146,11 +207,10 @@ WebView::~WebView()
 {
   if(mWebEngine)
   {
-    mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnFrameRendered);
-    auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin());
-    if (iter != mPluginWebViewMap.end())
+    auto iter = GetPluginWebViewTable().find(mWebEngine.GetPlugin());
+    if(iter != GetPluginWebViewTable().end())
     {
-      mPluginWebViewMap.erase(iter);
+      GetPluginWebViewTable().erase(iter);
     }
     mWebEngine.Destroy();
   }
@@ -160,9 +220,9 @@ Toolkit::WebView WebView::New()
 {
   WebView*         impl   = new WebView();
   Toolkit::WebView handle = Toolkit::WebView(*impl);
-  if (impl->GetPlugin())
+  if(impl->GetPlugin())
   {
-    mPluginWebViewMap[impl->GetPlugin()] = handle;
+    GetPluginWebViewTable()[impl->GetPlugin()] = handle;
   }
   impl->Initialize();
   return handle;
@@ -172,9 +232,9 @@ Toolkit::WebView WebView::New(const std::string& locale, const std::string& time
 {
   WebView*         impl   = new WebView(locale, timezoneId);
   Toolkit::WebView handle = Toolkit::WebView(*impl);
-  if (impl->GetPlugin())
+  if(impl->GetPlugin())
   {
-    mPluginWebViewMap[impl->GetPlugin()] = handle;
+    GetPluginWebViewTable()[impl->GetPlugin()] = handle;
   }
   impl->Initialize();
   return handle;
@@ -184,9 +244,9 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv)
 {
   WebView*         impl   = new WebView(argc, argv);
   Toolkit::WebView handle = Toolkit::WebView(*impl);
-  if (impl->GetPlugin())
+  if(impl->GetPlugin())
   {
-    mPluginWebViewMap[impl->GetPlugin()] = handle;
+    GetPluginWebViewTable()[impl->GetPlugin()] = handle;
   }
   impl->Initialize();
   return handle;
@@ -194,8 +254,8 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv)
 
 Toolkit::WebView WebView::FindWebView(Dali::WebEnginePlugin* plugin)
 {
-  auto iter = mPluginWebViewMap.find(plugin);
-  if (iter != mPluginWebViewMap.end())
+  auto iter = GetPluginWebViewTable().find(plugin);
+  if(iter != GetPluginWebViewTable().end())
   {
     return iter->second.GetHandle();
   }
@@ -223,16 +283,18 @@ void WebView::OnInitialize()
   self.WheelEventSignal().Connect(this, &WebView::OnWheelEvent);
   Dali::DevelActor::VisibilityChangedSignal(self).Connect(this, &WebView::OnVisibilityChanged);
 
+  mWebViewVisibleState |= WebViewVisibleStateFlag::SELF_SHOW;
+
   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::UpdateDisplayArea);
-  mSizeUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
-  mScaleUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
+  mPositionUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
+  mSizeUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
+  mScaleUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
 
   if(mWebEngine)
   {
-    mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
+    mWebEngine.RegisterFrameRenderedCallback(std::bind(&WebView::OnFrameRendered, this));
     mWebSettings        = std::unique_ptr<Dali::Toolkit::WebSettings>(new WebSettings(mWebEngine.GetSettings()));
     mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>(new WebBackForwardList(mWebEngine.GetBackForwardList()));
   }
@@ -240,14 +302,21 @@ void WebView::OnInitialize()
   self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::FILLER);
 }
 
-Dali::WebEnginePlugin* WebView::GetPlugin() const
+DevelControl::ControlAccessible* WebView::CreateAccessibleObject()
 {
-  return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
+  return new WebViewAccessible(Self(), mWebEngine);
 }
 
-DevelControl::ControlAccessible* WebView::CreateAccessibleObject()
+void WebView::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
-  return new WebViewAccessible(Self(), mWebEngine);
+  if(!mWebEngine)
+  {
+    return;
+  }
+
+  auto displayArea = CalculateDisplayArea(Self(), DisplayAreaCalculateOption::PROPERTY);
+
+  SetDisplayArea(displayArea);
 }
 
 Dali::Toolkit::WebSettings* WebView::GetSettings() const
@@ -260,6 +329,11 @@ 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;
@@ -275,11 +349,6 @@ void WebView::LoadUrl(const std::string& url)
 {
   if(mWebEngine)
   {
-    if(!mVisual)
-    {
-      mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
-    }
-
     mWebEngine.LoadUrl(url);
   }
 }
@@ -288,11 +357,6 @@ void WebView::LoadHtmlString(const std::string& htmlString)
 {
   if(mWebEngine)
   {
-    if(!mVisual)
-    {
-      mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
-    }
-
     mWebEngine.LoadHtmlString(htmlString);
   }
 }
@@ -302,24 +366,14 @@ bool WebView::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const
   if(!mWebEngine)
     return false;
 
-  if(!mVisual)
-  {
-    mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
-  }
-
   return mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
 }
 
-bool WebView::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
+bool WebView::LoadContents(const int8_t* contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
 {
   if(!mWebEngine)
     return false;
 
-  if(!mVisual)
-  {
-    mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
-  }
-
   return mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri);
 }
 
@@ -439,7 +493,7 @@ void WebView::EvaluateJavaScript(const std::string& script, std::function<void(c
 {
   if(mWebEngine)
   {
-    mWebEngine.EvaluateJavaScript(script, resultHandler);
+    mWebEngine.EvaluateJavaScript(script, std::move(resultHandler));
   }
 }
 
@@ -447,7 +501,7 @@ void WebView::AddJavaScriptMessageHandler(const std::string& exposedObjectName,
 {
   if(mWebEngine)
   {
-    mWebEngine.AddJavaScriptMessageHandler(exposedObjectName, handler);
+    mWebEngine.AddJavaScriptMessageHandler(exposedObjectName, std::move(handler));
   }
 }
 
@@ -455,7 +509,7 @@ void WebView::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptA
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptAlertCallback(callback);
+    mWebEngine.RegisterJavaScriptAlertCallback(std::move(callback));
   }
 }
 
@@ -471,7 +525,7 @@ void WebView::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScrip
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptConfirmCallback(callback);
+    mWebEngine.RegisterJavaScriptConfirmCallback(std::move(callback));
   }
 }
 
@@ -487,7 +541,7 @@ void WebView::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScript
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptPromptCallback(callback);
+    mWebEngine.RegisterJavaScriptPromptCallback(std::move(callback));
   }
 }
 
@@ -515,7 +569,7 @@ bool WebView::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineH
   bool result = false;
   if(mWebEngine)
   {
-    result = mWebEngine.CreateHitTestAsynchronously(x, y, mode, callback);
+    result = mWebEngine.CreateHitTestAsynchronously(x, y, mode, std::move(callback));
   }
   return result;
 }
@@ -583,20 +637,20 @@ Dali::Toolkit::ImageView WebView::GetScreenshot(Dali::Rect<int32_t> viewArea, fl
 
 bool WebView::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback)
 {
-  mScreenshotCapturedCallback = callback;
+  mScreenshotCapturedCallback = std::move(callback);
   return mWebEngine ? mWebEngine.GetScreenshotAsynchronously(viewArea, scaleFactor, std::bind(&WebView::OnScreenshotCaptured, this, std::placeholders::_1)) : false;
 }
 
 bool WebView::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
 {
-  return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(callback) : false;
+  return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(std::move(callback)) : false;
 }
 
 void WebView::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterGeolocationPermissionCallback(callback);
+    mWebEngine.RegisterGeolocationPermissionCallback(std::move(callback));
   }
 }
 
@@ -608,37 +662,6 @@ void WebView::SetTtsFocus(bool focused)
   }
 }
 
-void WebView::UpdateDisplayArea(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<int32_t> 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::EnableVideoHole(bool enabled)
 {
   mVideoHoleEnabled = enabled;
@@ -678,7 +701,7 @@ void WebView::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePa
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadStartedCallback(callback);
+    mWebEngine.RegisterPageLoadStartedCallback(std::move(callback));
   }
 }
 
@@ -686,7 +709,7 @@ void WebView::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEngin
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadInProgressCallback(callback);
+    mWebEngine.RegisterPageLoadInProgressCallback(std::move(callback));
   }
 }
 
@@ -694,7 +717,7 @@ void WebView::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEngineP
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadFinishedCallback(callback);
+    mWebEngine.RegisterPageLoadFinishedCallback(std::move(callback));
   }
 }
 
@@ -702,7 +725,7 @@ void WebView::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePage
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadErrorCallback(callback);
+    mWebEngine.RegisterPageLoadErrorCallback(std::move(callback));
   }
 }
 
@@ -710,7 +733,7 @@ void WebView::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterScrollEdgeReachedCallback(callback);
+    mWebEngine.RegisterScrollEdgeReachedCallback(std::move(callback));
   }
 }
 
@@ -718,7 +741,7 @@ void WebView::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChan
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterUrlChangedCallback(callback);
+    mWebEngine.RegisterUrlChangedCallback(std::move(callback));
   }
 }
 
@@ -726,20 +749,20 @@ void WebView::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterFormRepostDecidedCallback(callback);
+    mWebEngine.RegisterFormRepostDecidedCallback(std::move(callback));
   }
 }
 
 void WebView::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
 {
-  mFrameRenderedCallback = callback;
+  mFrameRenderedCallback = std::move(callback);
 }
 
 void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterConsoleMessageReceivedCallback(callback);
+    mWebEngine.RegisterConsoleMessageReceivedCallback(std::move(callback));
   }
 }
 
@@ -747,7 +770,7 @@ void WebView::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEn
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterResponsePolicyDecidedCallback(callback);
+    mWebEngine.RegisterResponsePolicyDecidedCallback(std::move(callback));
   }
 }
 
@@ -755,7 +778,15 @@ void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::Web
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterNavigationPolicyDecidedCallback(callback);
+    mWebEngine.RegisterNavigationPolicyDecidedCallback(std::move(callback));
+  }
+}
+
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterNewWindowCreatedCallback(std::move(callback));
   }
 }
 
@@ -763,7 +794,7 @@ void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEng
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterCertificateConfirmedCallback(callback);
+    mWebEngine.RegisterCertificateConfirmedCallback(std::move(callback));
   }
 }
 
@@ -771,7 +802,7 @@ void WebView::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEn
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterSslCertificateChangedCallback(callback);
+    mWebEngine.RegisterSslCertificateChangedCallback(std::move(callback));
   }
 }
 
@@ -779,7 +810,7 @@ void WebView::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHt
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterHttpAuthHandlerCallback(callback);
+    mWebEngine.RegisterHttpAuthHandlerCallback(std::move(callback));
   }
 }
 
@@ -787,7 +818,7 @@ void WebView::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineC
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterContextMenuShownCallback(callback);
+    mWebEngine.RegisterContextMenuShownCallback(std::move(callback));
   }
 }
 
@@ -795,7 +826,7 @@ void WebView::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterContextMenuHiddenCallback(callback);
+    mWebEngine.RegisterContextMenuHiddenCallback(std::move(callback));
   }
 }
 
@@ -803,7 +834,7 @@ void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceive
 {
   if(mWebEngine)
   {
-    mWebEngine.GetPlainTextAsynchronously(callback);
+    mWebEngine.GetPlainTextAsynchronously(std::move(callback));
   }
 }
 
@@ -813,28 +844,86 @@ void WebView::OnFrameRendered()
   {
     mFrameRenderedCallback();
   }
-}
 
-void WebView::OnInitialFrameRendered()
-{
-  mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnInitialFrameRendered);
+  // Make sure that mVisual is created only if required.
+  if(mVisualChangeRequired || !mVisual)
+  {
+    // Reset flag
+    mVisualChangeRequired = false;
 
-  Dali::Toolkit::ImageUrl nativeImageUrl = Dali::Toolkit::Image::GenerateUrl(mWebEngine.GetNativeImageSource());
-  mVisual                                = Toolkit::VisualFactory::Get().CreateVisual({{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE}, {Toolkit::ImageVisual::Property::URL, nativeImageUrl.GetUrl()}});
+    auto nativeImageSourcePtr = mWebEngine.GetNativeImageSource();
 
-  if(mVisual)
+    mLastRenderedNativeImageWidth  = nativeImageSourcePtr->GetWidth();
+    mLastRenderedNativeImageHeight = nativeImageSourcePtr->GetHeight();
+
+    Dali::Toolkit::ImageUrl nativeImageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSourcePtr);
+
+    mVisual = Toolkit::VisualFactory::Get().CreateVisual(
+      {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
+       {Toolkit::ImageVisual::Property::URL, nativeImageUrl.GetUrl()},
+       {Toolkit::ImageVisual::Property::PIXEL_AREA, FULL_TEXTURE_RECT},
+       {Toolkit::ImageVisual::Property::WRAP_MODE_U, Dali::WrapMode::CLAMP_TO_EDGE},
+       {Toolkit::ImageVisual::Property::WRAP_MODE_V, Dali::WrapMode::CLAMP_TO_EDGE}});
+
+    if(mVisual)
+    {
+      DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+      EnableBlendMode(!mVideoHoleEnabled);
+    }
+  }
+}
+
+void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/)
+{
+  if(!mWebEngine)
   {
-    DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
-    EnableBlendMode(!mVideoHoleEnabled);
+    return;
   }
+
+  auto displayArea = CalculateDisplayArea(Self(), DisplayAreaCalculateOption::CURRENT_PROPERTY);
+
+  SetDisplayArea(displayArea);
 }
 
 void WebView::OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type)
 {
   if(type == Dali::DevelActor::VisibilityChange::Type::SELF)
   {
-    SetVisibility(isVisible);
+    if(isVisible)
+    {
+      mWebViewVisibleState |= WebViewVisibleStateFlag::SELF_SHOW;
+    }
+    else
+    {
+      mWebViewVisibleState &= ~WebViewVisibleStateFlag::SELF_SHOW;
+    }
+  }
+  else if(type == Dali::DevelActor::VisibilityChange::Type::PARENT)
+  {
+    if(isVisible)
+    {
+      mWebViewVisibleState |= WebViewVisibleStateFlag::PARENT_SHOW;
+      // TODO : We should consider double-hide called from parent
+    }
+    else
+    {
+      mWebViewVisibleState &= ~WebViewVisibleStateFlag::PARENT_SHOW;
+    }
   }
+  ApplyVisibilityCheck();
+}
+
+void WebView::OnWindowVisibilityChanged(Window window, bool visible)
+{
+  if(visible)
+  {
+    mWebViewVisibleState |= WebViewVisibleStateFlag::WINDOW_SHOW;
+  }
+  else
+  {
+    mWebViewVisibleState &= ~WebViewVisibleStateFlag::WINDOW_SHOW;
+  }
+  ApplyVisibilityCheck();
 }
 
 void WebView::OnScreenshotCaptured(Dali::PixelData pixel)
@@ -846,12 +935,71 @@ void WebView::OnScreenshotCaptured(Dali::PixelData pixel)
   }
 }
 
+void WebView::SetDisplayArea(const Dali::Rect<int32_t>& displayArea)
+{
+  Size displaySize = Size(displayArea.width, displayArea.height);
+  if(mWebViewSize != displaySize)
+  {
+    mWebViewSize = displaySize;
+  }
+
+  if(mWebViewArea != displayArea)
+  {
+    // WebEngine visual size changed. we have to re-create visual.
+    mVisualChangeRequired = true;
+
+    // Change old visual's pixel area matched as changed web view size
+    if(mVisual)
+    {
+      auto pixelArea = CalculatePixelArea(mWebViewSize, mLastRenderedNativeImageWidth, mLastRenderedNativeImageHeight);
+      Toolkit::GetImplementation(mVisual).DoAction(Toolkit::DevelVisual::Action::UPDATE_PROPERTY, {{Toolkit::ImageVisual::Property::PIXEL_AREA, pixelArea}});
+    }
+
+    mWebViewArea = displayArea;
+    mWebEngine.UpdateDisplayArea(mWebViewArea);
+  }
+}
+
 void WebView::OnSceneConnection(int depth)
 {
+  mWebViewVisibleState |= WebViewVisibleStateFlag::SCENE_ON;
+  mWebViewVisibleState |= WebViewVisibleStateFlag::PARENT_SHOW;
+  // TODO : We should consider already hided parent
+  Window window = DevelWindow::Get(Self());
+  if(window)
+  {
+    // Hold the weak handle of the placement window.
+    mPlacementWindow = window;
+    if(window.IsVisible())
+    {
+      mWebViewVisibleState |= WebViewVisibleStateFlag::WINDOW_SHOW;
+    }
+    else
+    {
+      mWebViewVisibleState &= ~WebViewVisibleStateFlag::WINDOW_SHOW;
+    }
+    DevelWindow::VisibilityChangedSignal(window).Connect(this, &WebView::OnWindowVisibilityChanged);
+  }
+  ApplyVisibilityCheck();
   Control::OnSceneConnection(depth);
   EnableBlendMode(!mVideoHoleEnabled);
 }
 
+void WebView::OnSceneDisconnection()
+{
+  mWebViewVisibleState &= ~WebViewVisibleStateFlag::SCENE_ON;
+  mWebViewVisibleState &= ~WebViewVisibleStateFlag::WINDOW_SHOW;
+  mWebViewVisibleState &= ~WebViewVisibleStateFlag::PARENT_SHOW;
+  Window window = mPlacementWindow.GetHandle();
+  if(window)
+  {
+    DevelWindow::VisibilityChangedSignal(window).Disconnect(this, &WebView::OnWindowVisibilityChanged);
+    mPlacementWindow.Reset();
+  }
+  ApplyVisibilityCheck();
+  Control::OnSceneDisconnection();
+}
+
 bool WebView::OnTouchEvent(Actor actor, const Dali::TouchEvent& touch)
 {
   bool result = false;
@@ -1270,8 +1418,15 @@ bool WebView::SetVisibility(bool visible)
   return mWebEngine ? mWebEngine.SetVisibility(visible) : false;
 }
 
+void WebView::ApplyVisibilityCheck()
+{
+  SetVisibility(mWebViewVisibleState == WebViewVisibleStateFlag::VISIBLE);
+}
+
 WebView::WebViewAccessible::WebViewAccessible(Dali::Actor self, Dali::WebEngine& webEngine)
-: ControlAccessible(self), mRemoteChild{}, mWebEngine{webEngine}
+: ControlAccessible(self),
+  mRemoteChild{},
+  mWebEngine{webEngine}
 {
   mRemoteChild.SetParent(this);
 
@@ -1288,10 +1443,25 @@ WebView::WebViewAccessible::WebViewAccessible(Dali::Actor self, Dali::WebEngine&
   }
 }
 
+Dali::Accessibility::Attributes WebView::WebViewAccessible::GetAttributes() const
+{
+  auto attributes = DevelControl::ControlAccessible::GetAttributes();
+
+  if(mRemoteChild.GetAddress())
+  {
+    attributes.insert_or_assign("child_bus", mRemoteChild.GetAddress().GetBus());
+  }
+
+  return attributes;
+}
+
 void WebView::WebViewAccessible::DoGetChildren(std::vector<Dali::Accessibility::Accessible*>& children)
 {
   if(mRemoteChild.GetAddress())
   {
+    // DoGetChildren is called at most once per every OnChildrenChanged.
+    // We have only one OnChildrenChanged in this case, so EmbedAtkSocket will be called only once.
+    Accessibility::Bridge::GetCurrentBridge()->EmbedAtkSocket(GetAddress(), mRemoteChild.GetAddress());
     children.push_back(&mRemoteChild);
   }
 }
@@ -1322,16 +1492,8 @@ void WebView::WebViewAccessible::SetRemoteChildAddress(Dali::Accessibility::Addr
 {
   mRemoteChild.SetAddress(address);
   OnChildrenChanged();
-
-  if(address)
-  {
-    Accessibility::Bridge::GetCurrentBridge()->EmbedAtkSocket(GetAddress(), address);
-  }
 }
 
-#undef GET_ENUM_STRING
-#undef GET_ENUM_VALUE
-
 } // namespace Internal
 
 } // namespace Toolkit