/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include "web-view-impl.h"
// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
-#include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
-#include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
-#include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
-#include <dali/devel-api/adaptor-framework/web-engine-context-menu.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-form-repost-decision.h>
-#include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
-#include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
-#include <dali/devel-api/adaptor-framework/web-engine-load-error.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/adaptor-framework/web-engine/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-context-menu.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-form-repost-decision.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-hit-test.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-http-auth-handler.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/common/stage.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.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/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/public-api/image-loader/image.h>
#define GET_ENUM_VALUE(structName, inputExp, outputExp) \
Scripting::GetEnumerationProperty<Toolkit::WebView::structName::Type>(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp)
+std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> WebView::mPluginWebViewMap;
+
WebView::WebView(const std::string& locale, const std::string& timezoneId)
: Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)),
mVisual(),
if(mWebEngine)
{
mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnFrameRendered);
+ auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin());
+ if (iter != mPluginWebViewMap.end())
+ {
+ mPluginWebViewMap.erase(iter);
+ }
mWebEngine.Destroy();
}
}
{
WebView* impl = new WebView();
Toolkit::WebView handle = Toolkit::WebView(*impl);
-
+ if (impl->GetPlugin())
+ {
+ mPluginWebViewMap[impl->GetPlugin()] = handle;
+ }
impl->Initialize();
return handle;
}
{
WebView* impl = new WebView(locale, timezoneId);
Toolkit::WebView handle = Toolkit::WebView(*impl);
-
+ if (impl->GetPlugin())
+ {
+ mPluginWebViewMap[impl->GetPlugin()] = handle;
+ }
impl->Initialize();
return handle;
}
{
WebView* impl = new WebView(argc, argv);
Toolkit::WebView handle = Toolkit::WebView(*impl);
-
+ if (impl->GetPlugin())
+ {
+ mPluginWebViewMap[impl->GetPlugin()] = handle;
+ }
impl->Initialize();
return handle;
}
+Toolkit::WebView WebView::FindWebView(Dali::WebEnginePlugin* plugin)
+{
+ auto iter = mPluginWebViewMap.find(plugin);
+ if (iter != mPluginWebViewMap.end())
+ {
+ return iter->second.GetHandle();
+ }
+ return Toolkit::WebView();
+}
+
+Dali::WebEngineContext* WebView::GetContext()
+{
+ return Dali::WebEngine::GetContext();
+}
+
+Dali::WebEngineCookieManager* WebView::GetCookieManager()
+{
+ return Dali::WebEngine::GetCookieManager();
+}
+
void WebView::OnInitialize()
{
Actor self = Self();
self.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ self.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
self.TouchedSignal().Connect(this, &WebView::OnTouchEvent);
self.HoveredSignal().Connect(this, &WebView::OnHoverEvent);
self.WheelEventSignal().Connect(this, &WebView::OnWheelEvent);
if(mWebEngine)
{
mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
- 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()));
}
+
+ self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::FILLER);
}
-Dali::Toolkit::WebSettings* WebView::GetSettings() const
+Dali::WebEnginePlugin* WebView::GetPlugin() const
{
- return mWebSettings.get();
+ return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
}
-Dali::Toolkit::WebContext* WebView::GetContext() const
+DevelControl::ControlAccessible* WebView::CreateAccessibleObject()
{
- return mWebContext.get();
+ return new WebViewAccessible(Self(), mWebEngine);
}
-Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
{
- return mWebCookieManager.get();
+ return mWebSettings.get();
}
Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
}
}
+void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
+{
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterNavigationPolicyDecidedCallback(callback);
+ }
+}
+
void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
if(mWebEngine)
return mWebEngine ? mWebEngine.SetVisibility(visible) : false;
}
+WebView::WebViewAccessible::WebViewAccessible(Dali::Actor self, Dali::WebEngine& webEngine)
+: ControlAccessible(self), mRemoteChild{}, mWebEngine{webEngine}
+{
+ mRemoteChild.SetParent(this);
+
+ Dali::Accessibility::Bridge::EnabledSignal().Connect(this, &WebViewAccessible::OnAccessibilityEnabled);
+ Dali::Accessibility::Bridge::DisabledSignal().Connect(this, &WebViewAccessible::OnAccessibilityDisabled);
+
+ if(Dali::Accessibility::IsUp())
+ {
+ OnAccessibilityEnabled();
+ }
+ else
+ {
+ OnAccessibilityDisabled();
+ }
+}
+
+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);
+ }
+}
+
+void WebView::WebViewAccessible::OnAccessibilityEnabled()
+{
+ if(!mWebEngine)
+ {
+ return;
+ }
+
+ mWebEngine.ActivateAccessibility(true);
+ SetRemoteChildAddress(mWebEngine.GetAccessibilityAddress());
+}
+
+void WebView::WebViewAccessible::OnAccessibilityDisabled()
+{
+ if(!mWebEngine)
+ {
+ return;
+ }
+
+ SetRemoteChildAddress({});
+ mWebEngine.ActivateAccessibility(false);
+}
+
+void WebView::WebViewAccessible::SetRemoteChildAddress(Dali::Accessibility::Address address)
+{
+ mRemoteChild.SetAddress(address);
+ OnChildrenChanged();
+}
+
#undef GET_ENUM_STRING
#undef GET_ENUM_VALUE