void EnableVideoHole(bool enabled) override {}
bool SendHoverEvent(const HoverEvent& event) override { return false; }
bool SendWheelEvent(const WheelEvent& event) override { return false; }
- WebEngineFrameRenderedSignalType& FrameRenderedSignal() override { return frameRenderedSignal; }
+ void RegisterFrameRenderedCallback(WebEngineFrameRenderedCallback callback) override {}
void RegisterPageLoadStartedCallback(WebEnginePageLoadCallback callback) override {}
void RegisterPageLoadInProgressCallback(WebEnginePageLoadCallback callback) override {}
void RegisterPageLoadFinishedCallback(WebEnginePageLoadCallback callback) override {}
void RegisterConsoleMessageReceivedCallback(WebEngineConsoleMessageReceivedCallback callback) override {}
void RegisterResponsePolicyDecidedCallback(WebEngineResponsePolicyDecidedCallback callback) override {}
void RegisterNavigationPolicyDecidedCallback(WebEngineNavigationPolicyDecidedCallback callback) override {}
+ void RegisterNewWindowCreatedCallback(WebEngineNewWindowCreatedCallback callback) override {}
void RegisterCertificateConfirmedCallback(WebEngineCertificateCallback callback) override {}
void RegisterSslCertificateChangedCallback(WebEngineCertificateCallback callback) override {}
void RegisterHttpAuthHandlerCallback(WebEngineHttpAuthHandlerCallback callback) override {}
private:
MockWebEngineSettings settings;
MockWebEngineBackForwardList backForwardList;
- WebEngineFrameRenderedSignalType frameRenderedSignal;
};
Dali::WebEnginePlugin* GetWebEnginePlugin()
}
}
- Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal()
+ void RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
{
- return mFrameRenderedSignal;
+ mFrameRenderedCallback = callback;
}
void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
mNavigationPolicyDecisionCallback = callback;
}
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+ {
+ mNewWindowCreatedCallback = callback;
+ }
+
void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
mCertificateConfirmCallback = callback;
size_t mCurrentPlusOnePos;
std::string mUserAgent;
- Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType mFrameRenderedSignal;
-
bool mEvaluating;
float mPageZoomFactor;
float mTextZoomFactor;
Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback mConsoleMessageCallback;
Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback mResponsePolicyDecisionCallback;
Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback mNavigationPolicyDecisionCallback;
+ Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback mNewWindowCreatedCallback;
Dali::WebEnginePlugin::WebEngineCertificateCallback mCertificateConfirmCallback;
Dali::WebEnginePlugin::WebEngineCertificateCallback mSslCertificateChangedCallback;
Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback mHttpAuthHandlerCallback;
std::unique_ptr<Dali::WebEngineFormRepostDecision> repostDecision(new MockWebEngineFormRepostDecision());
gInstance->mFormRepostDecidedCallback(std::move(repostDecision));
}
- gInstance->mFrameRenderedSignal.Emit();
if (gInstance->mFrameRenderedCallback)
{
gInstance->mFrameRenderedCallback();
std::unique_ptr<Dali::WebEnginePolicyDecision> policyDecision(new MockWebEnginePolicyDecision());
gInstance->mNavigationPolicyDecisionCallback(std::move(policyDecision));
}
+ if (gInstance->mNewWindowCreatedCallback)
+ {
+ Dali::WebEnginePlugin* plugin = 0;
+ gInstance->mNewWindowCreatedCallback(plugin);
+ }
if (gInstance->mCertificateConfirmCallback)
{
std::unique_ptr<Dali::WebEngineCertificate> certificate(new MockWebEngineCertificate());
{
}
-Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
+void WebEngine::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
{
- return Internal::Adaptor::GetImplementation(*this).FrameRenderedSignal();
+ Internal::Adaptor::GetImplementation(*this).RegisterFrameRenderedCallback(callback);
}
void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
Internal::Adaptor::GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
}
+void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ Internal::Adaptor::GetImplementation(*this).RegisterNewWindowCreatedCallback(callback);
+}
+
void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
Internal::Adaptor::GetImplementation( *this ).RegisterCertificateConfirmedCallback(callback);
static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
static int gResponsePolicyDecidedCallbackCalled = 0;
static int gNavigationPolicyDecidedCallbackCalled = 0;
+static int gNewWindowCreatedCallbackCalled = 0;
static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
static int gCertificateConfirmCallbackCalled = 0;
static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
gNavigationPolicyDecidedCallbackCalled++;
}
+static void OnNewWindowCreated(Dali::WebEnginePlugin*& outPlugin)
+{
+ gNewWindowCreatedCallbackCalled++;
+ WebView newView = WebView::New();
+ outPlugin = newView.GetPlugin();
+}
+
static void OnUrlChanged(const std::string& url)
{
gUrlChangedCallbackCalled++;
END_TEST;
}
+int UtcDaliWebViewNewWindowCreated(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK(view);
+
+ // load url.
+ view.RegisterNewWindowCreatedCallback(&OnNewWindowCreated);
+ DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 0, TEST_LOCATION);
+
+ view.LoadUrl(TEST_URL1);
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliWebViewHitTest(void)
{
ToolkitTestApplication application;
return Dali::Toolkit::GetImpl(*this).GetBackForwardList();
}
+Dali::WebEnginePlugin* WebView::GetPlugin() const
+{
+ return Dali::Toolkit::GetImpl(*this).GetPlugin();
+}
+
Dali::Toolkit::ImageView WebView::GetFavicon() const
{
return Dali::Toolkit::GetImpl(*this).GetFavicon();
Dali::Toolkit::GetImpl(*this).RegisterNavigationPolicyDecidedCallback(callback);
}
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ Dali::Toolkit::GetImpl(*this).RegisterNewWindowCreatedCallback(callback);
+}
+
void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
Dali::Toolkit::GetImpl(*this).RegisterCertificateConfirmedCallback(callback);
namespace Dali
{
+class WebEngineContext;
+class WebEngineCookieManager;
+
namespace Toolkit
{
class ImageView;
class WebBackForwardList;
-class WebContext;
-class WebCookieManager;
class WebSettings;
namespace Internal DALI_INTERNAL
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @brief Gets web engine plugin.
+ */
+ Dali::WebEnginePlugin* GetPlugin() const;
+
+ /**
* @brief Get favicon of web page.
*
* @return Handle to a favicon
void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
/**
+ * @brief Callback to be called when a new window would be created.
+ *
+ * @param[in] callback
+ */
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+ /**
* @brief Callback to be called when certificate need be confirmed.
*
* @param[in] callback
#include "web-view-impl.h"
// EXTERNAL INCLUDES
+#include <cstring>
#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/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/public-api/image-loader/image-url.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <functional>
+#include <memory>
+
namespace Dali
{
namespace Toolkit
} // namespace
-#define GET_ENUM_STRING(structName, inputExp) \
- Scripting::GetLinearEnumerationName<Toolkit::WebView::structName::Type>(static_cast<Toolkit::WebView::structName::Type>(inputExp), structName##_TABLE, structName##_TABLE_COUNT)
-
-#define GET_ENUM_VALUE(structName, inputExp, outputExp) \
- Scripting::GetEnumerationProperty<Toolkit::WebView::structName::Type>(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp)
-
std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> WebView::mPluginWebViewMap;
WebView::WebView(const std::string& locale, const std::string& timezoneId)
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
mKeyEventsEnabled(true),
- mScreenshotCapturedCallback(nullptr)
+ mScreenshotCapturedCallback{nullptr},
+ mFrameRenderedCallback{nullptr}
{
mWebEngine = Dali::WebEngine::New();
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
mKeyEventsEnabled(true),
- mScreenshotCapturedCallback(nullptr)
+ mScreenshotCapturedCallback{nullptr},
+ mFrameRenderedCallback{nullptr}
{
mWebEngine = Dali::WebEngine::New();
{
if(mWebEngine)
{
- mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnFrameRendered);
auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin());
if (iter != mPluginWebViewMap.end())
{
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()));
}
self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::FILLER);
}
-Dali::WebEnginePlugin* WebView::GetPlugin() const
-{
- return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
-}
-
DevelControl::ControlAccessible* WebView::CreateAccessibleObject()
{
return new WebViewAccessible(Self(), mWebEngine);
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)
{
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
mWebEngine.LoadUrl(url);
}
}
{
if(mWebEngine)
{
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
mWebEngine.LoadHtmlString(htmlString);
}
}
if(!mWebEngine)
return false;
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
return mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
}
if(!mWebEngine)
return false;
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
return mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri);
}
}
}
-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;
}
}
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterNewWindowCreatedCallback(callback);
+ }
+}
+
void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
if(mWebEngine)
{
mFrameRenderedCallback();
}
-}
-void WebView::OnInitialFrameRendered()
-{
- mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnInitialFrameRendered);
+ // Make sure that mVisual is created only once.
+ if (mVisual)
+ return;
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)
{
DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
}
}
+void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/)
+{
+ if(!mWebEngine)
+ return;
+
+ Actor self(Self());
+
+ bool positionUsesAnchorPoint = self.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
+ Vector3 actorSize = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::SCALE);
+ Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+ Vector2 screenPosition = self.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+
+ Dali::Rect<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::OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type)
{
if(type == Dali::DevelActor::VisibilityChange::Type::SELF)
OnChildrenChanged();
}
-#undef GET_ENUM_STRING
-#undef GET_ENUM_VALUE
-
} // namespace Internal
} // namespace Toolkit
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @copydoc Dali::Toolkit::WebView::GetPlugin()
+ */
+ Dali::WebEnginePlugin* GetPlugin() const;
+
+ /**
* @copydoc Dali::Toolkit::WebView::GetFavicon()
*/
Dali::Toolkit::ImageView GetFavicon() const;
void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
/**
+ * @copydoc Dali::Toolkit::WebView::RegisterNewWindowCreatedCallback()
+ */
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+ /**
* @copydoc Dali::Toolkit::WebView::RegisterCertificateConfirmedCallback()
*/
void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback);
WebView& operator=(const WebView& webView);
/**
- * @brief Gets web engine plugin.
- */
- Dali::WebEnginePlugin* GetPlugin() const;
-
- /**
* @brief Set an absolute scroll of the given view.
* @param[in] x The coordinate x of scroll
* @param[in] y The coordinate y of scroll
bool SetVisibility(bool visible);
/**
- * @brief Update display area of web view.
- * @param[in] source The soource triggers Notification.
- */
- void UpdateDisplayArea(Dali::PropertyNotification& source);
-
- /**
* @brief Enable/Disable video hole for video playing.
* @param[in] enabled True if video hole is enabled, false otherwise.
*/
void OnFrameRendered();
/**
- * @brief Callback function to be called when frame is rendered. This is to check initial buffer is ready.
+ * @brief Callback for updating display area of web view.
+ * @param[in] source The soource triggers Notification.
*/
- void OnInitialFrameRendered();
+ void OnDisplayAreaUpdated(Dali::PropertyNotification& source);
/**
* @brief Callback function to be called when visibility is changed.