/*
- * 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-request-interceptor.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/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/image-loader/image-url.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
namespace Dali
DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "textZoomFactor", FLOAT, TEXT_ZOOM_FACTOR )
DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "loadProgressPercentage", FLOAT, LOAD_PROGRESS_PERCENTAGE )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadInProgress", PAGE_LOAD_IN_PROGRESS_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_SIGNAL_REGISTRATION(Toolkit, WebView, "urlChanged", URL_CHANGED_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "formRepostDecision", FORM_REPOST_DECISION_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "frameRendered", FRAME_RENDERED_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "requestInterceptor", REQUEST_INTERCEPTOR_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "consoleMessage", CONSOLE_MESSAGE_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "responsePolicyDecided", POLICY_DECISION )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "certificateConfirm", CERTIFICATE_CONFIRM_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "sslCertificateChanged", SSL_CERTIFICATE_CHANGED_SIGNAL)
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "httpAuthRequest", HTTP_AUTH_REQUEST_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "contextMenuShown", CONTEXT_MENU_SHOWN_SIGNAL )
-DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "contextMenuHidden", CONTEXT_MENU_HIDDEN_SIGNAL )
-
DALI_TYPE_REGISTRATION_END()
// clang-format on
#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(),
mWebViewSize(Stage::GetCurrent().GetSize()),
mWebEngine(),
- mPageLoadStartedSignal(),
- mPageLoadFinishedSignal(),
- mPageLoadErrorSignal(),
- mUrlChangedSignal(),
mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
mVisual(),
mWebViewSize(Stage::GetCurrent().GetSize()),
mWebEngine(),
- mPageLoadStartedSignal(),
- mPageLoadFinishedSignal(),
- mPageLoadErrorSignal(),
- mUrlChangedSignal(),
mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
{
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.PageLoadStartedSignal().Connect(this, &WebView::OnPageLoadStarted);
- mWebEngine.PageLoadInProgressSignal().Connect(this, &WebView::OnPageLoadInProgress);
- mWebEngine.PageLoadFinishedSignal().Connect(this, &WebView::OnPageLoadFinished);
- mWebEngine.PageLoadErrorSignal().Connect(this, &WebView::OnPageLoadError);
- mWebEngine.ScrollEdgeReachedSignal().Connect(this, &WebView::OnScrollEdgeReached);
- mWebEngine.UrlChangedSignal().Connect(this, &WebView::OnUrlChanged);
- mWebEngine.FormRepostDecisionSignal().Connect(this, &WebView::OnFormRepostDecision);
mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
- mWebEngine.RequestInterceptorSignal().Connect(this, &WebView::OnInterceptRequest);
- mWebEngine.ConsoleMessageSignal().Connect(this, &WebView::OnConsoleMessage);
- mWebEngine.ResponsePolicyDecisionSignal().Connect(this, &WebView::OnResponsePolicyDecided);
- mWebEngine.CertificateConfirmSignal().Connect(this, &WebView::OnCertificateConfirm);
- mWebEngine.SslCertificateChangedSignal().Connect(this, &WebView::OnSslCertificateChanged);
- mWebEngine.HttpAuthHandlerSignal().Connect(this, &WebView::OnHttpAuthenticationRequest);
- mWebEngine.ContextMenuShownSignal().Connect(this, &WebView::OnContextMenuShown);
- mWebEngine.ContextMenuHiddenSignal().Connect(this, &WebView::OnContextMenuHidden);
-
- 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
return Dali::Toolkit::ImageView();
}
- std::string url = Dali::Toolkit::Image::GenerateUrl(pixel);
- Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url);
+ Dali::Toolkit::ImageUrl url = Dali::Toolkit::Image::GenerateUrl(pixel);
+ Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url.GetUrl());
imageView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixel.GetWidth(), pixel.GetHeight()));
return imageView;
}
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
-{
- return mPageLoadStartedSignal;
-}
-
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadInProgressSignal()
-{
- return mPageLoadInProgressSignal;
-}
-
-Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
-{
- return mPageLoadFinishedSignal;
-}
-
-Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
+void WebView::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
{
- return mPageLoadErrorSignal;
-}
-
-Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
-{
- return mScrollEdgeReachedSignal;
-}
-
-Dali::Toolkit::WebView::WebViewUrlChangedSignalType& WebView::UrlChangedSignal()
-{
- return mUrlChangedSignal;
-}
-
-Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType& WebView::FormRepostDecisionSignal()
-{
- return mFormRepostDecisionSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterPageLoadStartedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewFrameRenderedSignalType& WebView::FrameRenderedSignal()
+void WebView::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
{
- return mFrameRenderedSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterPageLoadInProgressCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewRequestInterceptorSignalType& WebView::RequestInterceptorSignal()
+void WebView::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
{
- return mRequestInterceptorSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterPageLoadFinishedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewConsoleMessageSignalType& WebView::ConsoleMessageSignal()
+void WebView::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
{
- return mConsoleMessageSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterPageLoadErrorCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewResponsePolicyDecisionSignalType& WebView::ResponsePolicyDecisionSignal()
+void WebView::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
{
- return mResponsePolicyDecisionSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterScrollEdgeReachedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewCertificateSignalType& WebView::CertificateConfirmSignal()
+void WebView::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
{
- return mCertificateConfirmSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterUrlChangedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewCertificateSignalType& WebView::SslCertificateChangedSignal()
+void WebView::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback)
{
- return mSslCertificateChangedSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterFormRepostDecidedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewHttpAuthHandlerSignalType& WebView::HttpAuthHandlerSignal()
+void WebView::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
{
- return mHttpAuthHandlerSignal;
+ mFrameRenderedCallback = callback;
}
-Dali::Toolkit::WebView::WebViewContextMenuShownSignalType& WebView::ContextMenuShownSignal()
+void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
{
- return mContextMenuShownSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterConsoleMessageReceivedCallback(callback);
+ }
}
-Dali::Toolkit::WebView::WebViewContextMenuHiddenSignalType& WebView::ContextMenuHiddenSignal()
+void WebView::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback)
{
- return mContextMenuHiddenSignal;
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterResponsePolicyDecidedCallback(callback);
+ }
}
-void WebView::OnPageLoadStarted(const std::string& url)
+void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
{
- if(!mPageLoadStartedSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mPageLoadStartedSignal.Emit(handle, url);
+ mWebEngine.RegisterNavigationPolicyDecidedCallback(callback);
}
}
-void WebView::OnPageLoadInProgress(const std::string& url)
+void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
- if(!mPageLoadInProgressSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mPageLoadInProgressSignal.Emit(handle, url);
+ mWebEngine.RegisterCertificateConfirmedCallback(callback);
}
}
-void WebView::OnPageLoadFinished(const std::string& url)
+void WebView::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
- if(!mPageLoadFinishedSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mPageLoadFinishedSignal.Emit(handle, url);
+ mWebEngine.RegisterSslCertificateChangedCallback(callback);
}
}
-void WebView::OnPageLoadError(std::shared_ptr<Dali::WebEngineLoadError> error)
+void WebView::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback)
{
- if(!mPageLoadErrorSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mPageLoadErrorSignal.Emit(handle, std::move(error));
+ mWebEngine.RegisterHttpAuthHandlerCallback(callback);
}
}
-void WebView::OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
+void WebView::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback)
{
- if(!mScrollEdgeReachedSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mScrollEdgeReachedSignal.Emit(handle, edge);
+ mWebEngine.RegisterContextMenuShownCallback(callback);
}
}
-void WebView::OnUrlChanged(const std::string& url)
+void WebView::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback)
{
- if(!mUrlChangedSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mUrlChangedSignal.Emit(handle, url);
+ mWebEngine.RegisterContextMenuHiddenCallback(callback);
}
}
-void WebView::OnFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
+void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
{
- if(!mFormRepostDecisionSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mFormRepostDecisionSignal.Emit(handle, std::move(decision));
+ mWebEngine.GetPlainTextAsynchronously(callback);
}
}
void WebView::OnFrameRendered()
{
- if(!mFrameRenderedSignal.Empty())
+ if(mFrameRenderedCallback)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mFrameRenderedSignal.Emit(handle);
+ mFrameRenderedCallback();
}
}
{
mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnInitialFrameRendered);
- 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}});
+ 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()}});
if(mVisual)
{
}
}
-void WebView::OnInterceptRequest(std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
+void WebView::OnSceneConnection(int depth)
{
- if(!mRequestInterceptorSignal.Empty())
- {
- Dali::Toolkit::WebView handle(GetOwner());
- mRequestInterceptorSignal.Emit(handle, std::move(interceptor));
- }
+ Control::OnSceneConnection(depth);
+ EnableBlendMode(!mVideoHoleEnabled);
}
-void WebView::OnConsoleMessage(std::shared_ptr<Dali::WebEngineConsoleMessage> message)
+bool WebView::OnTouchEvent(Actor actor, const Dali::TouchEvent& touch)
{
- if(!mConsoleMessageSignal.Empty())
- {
- Dali::Toolkit::WebView handle(GetOwner());
- mConsoleMessageSignal.Emit(handle, std::move(message));
- }
-}
+ bool result = false;
-void WebView::OnResponsePolicyDecided(std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
-{
- if(!mResponsePolicyDecisionSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mResponsePolicyDecisionSignal.Emit(handle, std::move(decision));
+ result = mWebEngine.SendTouchEvent(touch);
}
+ return result;
}
-void WebView::OnCertificateConfirm(std::shared_ptr<Dali::WebEngineCertificate> certificate)
+bool WebView::OnKeyEvent(const Dali::KeyEvent& event)
{
- if(!mCertificateConfirmSignal.Empty())
- {
- Dali::Toolkit::WebView handle(GetOwner());
- mCertificateConfirmSignal.Emit(handle, std::move(certificate));
- }
-}
+ bool result = false;
-void WebView::OnSslCertificateChanged(std::shared_ptr<Dali::WebEngineCertificate> certificate)
-{
- if(!mSslCertificateChangedSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mSslCertificateChangedSignal.Emit(handle, std::move(certificate));
+ result = mWebEngine.SendKeyEvent(event);
}
+ return result;
}
-void WebView::OnHttpAuthenticationRequest(std::shared_ptr<Dali::WebEngineHttpAuthHandler> handler)
+bool WebView::OnHoverEvent(Actor actor, const Dali::HoverEvent& hover)
{
- if(!mHttpAuthHandlerSignal.Empty())
+ bool result = false;
+ if(mWebEngine && mMouseEventsEnabled)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mHttpAuthHandlerSignal.Emit(handle, std::move(handler));
+ result = mWebEngine.SendHoverEvent(hover);
}
+ return result;
}
-void WebView::OnContextMenuShown(std::shared_ptr<Dali::WebEngineContextMenu> menu)
+bool WebView::OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
{
- if(!mContextMenuShownSignal.Empty())
+ bool result = false;
+ if(mWebEngine && mMouseEventsEnabled)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mContextMenuShownSignal.Emit(handle, std::move(menu));
+ result = mWebEngine.SendWheelEvent(wheel);
}
+ return result;
}
-void WebView::OnContextMenuHidden(std::shared_ptr<Dali::WebEngineContextMenu> menu)
+void WebView::OnKeyInputFocusGained()
{
- if(!mContextMenuHiddenSignal.Empty())
+ if(mWebEngine)
{
- Dali::Toolkit::WebView handle(GetOwner());
- mContextMenuHiddenSignal.Emit(handle, std::move(menu));
+ mWebEngine.SetFocus(true);
}
+
+ EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last.
}
-bool WebView::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
+void WebView::OnKeyInputFocusLost()
{
- 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_IN_PROGRESS_SIGNAL))
- {
- webView.PageLoadInProgressSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL))
- {
- webView.PageLoadFinishedSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), PAGE_LOAD_ERROR_SIGNAL))
- {
- webView.PageLoadErrorSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL))
- {
- webView.ScrollEdgeReachedSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), URL_CHANGED_SIGNAL))
- {
- webView.UrlChangedSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), FORM_REPOST_DECISION_SIGNAL))
- {
- webView.FormRepostDecisionSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), FRAME_RENDERED_SIGNAL))
- {
- webView.FrameRenderedSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), REQUEST_INTERCEPTOR_SIGNAL))
- {
- webView.RequestInterceptorSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), CONSOLE_MESSAGE_SIGNAL))
- {
- webView.ConsoleMessageSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), POLICY_DECISION))
- {
- webView.ResponsePolicyDecisionSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), CERTIFICATE_CONFIRM_SIGNAL))
- {
- webView.CertificateConfirmSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), SSL_CERTIFICATE_CHANGED_SIGNAL))
- {
- webView.SslCertificateChangedSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), HTTP_AUTH_REQUEST_SIGNAL))
- {
- webView.HttpAuthHandlerSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), CONTEXT_MENU_SHOWN_SIGNAL))
- {
- webView.ContextMenuShownSignal().Connect(tracker, functor);
- connected = true;
- }
- else if(0 == strcmp(signalName.c_str(), CONTEXT_MENU_HIDDEN_SIGNAL))
+ if(mWebEngine)
{
- webView.ContextMenuHiddenSignal().Connect(tracker, functor);
- connected = true;
+ mWebEngine.SetFocus(false);
}
- return connected;
+ EmitKeyInputFocusSignal(false); // Calls back into the Control hence done last.
}
Vector3 WebView::GetNaturalSize()
return Vector3(mWebViewSize);
}
-void WebView::OnSceneConnection(int depth)
-{
- 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));
return value;
}
-bool WebView::OnTouchEvent(Actor actor, const Dali::TouchEvent& touch)
-{
- bool result = false;
-
- if(mWebEngine)
- {
- result = mWebEngine.SendTouchEvent(touch);
- }
- return result;
-}
-
-bool WebView::OnKeyEvent(const Dali::KeyEvent& event)
-{
- bool result = false;
-
- if(mWebEngine)
- {
- result = mWebEngine.SendKeyEvent(event);
- }
- return result;
-}
-
-bool WebView::OnHoverEvent(Actor actor, const Dali::HoverEvent& hover)
-{
- bool result = false;
- if(mWebEngine && mMouseEventsEnabled)
- {
- result = mWebEngine.SendHoverEvent(hover);
- }
- return result;
-}
-
-bool WebView::OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
-{
- bool result = false;
- if(mWebEngine && mMouseEventsEnabled)
- {
- result = mWebEngine.SendWheelEvent(wheel);
- }
- return result;
-}
-
-void WebView::OnKeyInputFocusGained()
-{
- if(mWebEngine)
- {
- mWebEngine.SetFocus(true);
- }
-
- EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last.
-}
-
-void WebView::OnKeyInputFocusLost()
-{
- if(mWebEngine)
- {
- mWebEngine.SetFocus(false);
- }
-
- EmitKeyInputFocusSignal(false); // Calls back into the Control hence done last.
-}
-
void WebView::SetScrollPosition(int32_t x, int32_t y)
{
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