From: dongsug song Date: Thu, 5 Jan 2023 09:04:12 +0000 (+0000) Subject: Merge "[Tizen] Add an API for 'create,window' event." into tizen_7.0 X-Git-Tag: accepted/tizen/7.0/unified/20230106.165626^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a55079df3e5c5f1774b8f5dcef457351d5c8e199;hp=-c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Merge "[Tizen] Add an API for 'create,window' event." into tizen_7.0 --- a55079df3e5c5f1774b8f5dcef457351d5c8e199 diff --combined dali-toolkit/internal/controls/web-view/web-view-impl.cpp index ded91c5,fb22d58..d2fe130 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@@ -39,7 -39,6 +39,6 @@@ #include #include #include - #include // INTERNAL INCLUDES #include @@@ -50,6 -49,9 +49,9 @@@ #include #include + #include + #include + namespace Dali { namespace Toolkit @@@ -89,12 -91,6 +91,6 @@@ DALI_TYPE_REGISTRATION_END( } // namespace - #define GET_ENUM_STRING(structName, inputExp) \ - Scripting::GetLinearEnumerationName(static_cast(inputExp), structName##_TABLE, structName##_TABLE_COUNT) - - #define GET_ENUM_VALUE(structName, inputExp, outputExp) \ - Scripting::GetEnumerationProperty(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp) - std::unordered_map> WebView::mPluginWebViewMap; WebView::WebView(const std::string& locale, const std::string& timezoneId) @@@ -106,7 -102,8 +102,8 @@@ mVideoHoleEnabled(false), mMouseEventsEnabled(true), mKeyEventsEnabled(true), - mScreenshotCapturedCallback(nullptr) + mScreenshotCapturedCallback{nullptr}, + mFrameRenderedCallback{nullptr} { mWebEngine = Dali::WebEngine::New(); @@@ -126,7 -123,8 +123,8 @@@ WebView::WebView(uint32_t argc, char** mVideoHoleEnabled(false), mMouseEventsEnabled(true), mKeyEventsEnabled(true), - mScreenshotCapturedCallback(nullptr) + mScreenshotCapturedCallback{nullptr}, + mFrameRenderedCallback{nullptr} { mWebEngine = Dali::WebEngine::New(); @@@ -146,7 -144,6 +144,6 @@@ WebView::~WebView( { if(mWebEngine) { - mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnFrameRendered); auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin()); if (iter != mPluginWebViewMap.end()) { @@@ -226,13 -223,13 +223,13 @@@ void WebView::OnInitialize( 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(new WebSettings(mWebEngine.GetSettings())); mWebBackForwardList = std::unique_ptr(new WebBackForwardList(mWebEngine.GetBackForwardList())); } @@@ -240,11 -237,6 +237,6 @@@ 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); @@@ -260,6 -252,11 +252,11 @@@ Dali::Toolkit::WebBackForwardList* WebV 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 -272,6 +272,6 @@@ void WebView::LoadUrl(const std::string { if(mWebEngine) { - if(!mVisual) - { - mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered); - } - mWebEngine.LoadUrl(url); } } @@@ -288,11 -280,6 +280,6 @@@ void WebView::LoadHtmlString(const std: { if(mWebEngine) { - if(!mVisual) - { - mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered); - } - mWebEngine.LoadHtmlString(htmlString); } } @@@ -302,11 -289,6 +289,6 @@@ bool WebView::LoadHtmlStringOverrideCur if(!mWebEngine) return false; - if(!mVisual) - { - mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered); - } - return mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl); } @@@ -315,11 -297,6 +297,6 @@@ bool WebView::LoadContents(const std::s if(!mWebEngine) return false; - if(!mVisual) - { - mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered); - } - return mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri); } @@@ -608,37 -585,6 +585,6 @@@ void WebView::SetTtsFocus(bool focused } } - void WebView::UpdateDisplayArea(Dali::PropertyNotification& /*source*/) - { - if(!mWebEngine) - return; - - Actor self(Self()); - - bool positionUsesAnchorPoint = self.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT); - Vector3 actorSize = self.GetCurrentProperty(Actor::Property::SIZE) * self.GetCurrentProperty(Actor::Property::SCALE); - Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); - Vector2 screenPosition = self.GetProperty(Actor::Property::SCREEN_POSITION); - - Dali::Rect 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; @@@ -759,6 -705,14 +705,14 @@@ void WebView::RegisterNavigationPolicyD } } + void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback) + { + if(mWebEngine) + { + mWebEngine.RegisterNewWindowCreatedCallback(callback); + } + } + void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback) { if(mWebEngine) @@@ -813,15 -767,13 +767,13 @@@ void WebView::OnFrameRendered( { 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); @@@ -829,6 -781,37 +781,37 @@@ } } + void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/) + { + if(!mWebEngine) + return; + + Actor self(Self()); + + bool positionUsesAnchorPoint = self.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT); + Vector3 actorSize = self.GetCurrentProperty(Actor::Property::SIZE) * self.GetCurrentProperty(Actor::Property::SCALE); + Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); + Vector2 screenPosition = self.GetProperty(Actor::Property::SCREEN_POSITION); + + Dali::Rect 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) @@@ -1288,25 -1271,10 +1271,25 @@@ WebView::WebViewAccessible::WebViewAcce } } +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& 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); } } @@@ -1337,11 -1305,13 +1320,8 @@@ void WebView::WebViewAccessible::SetRem { mRemoteChild.SetAddress(address); OnChildrenChanged(); - - if(address) - { - Accessibility::Bridge::GetCurrentBridge()->EmbedAtkSocket(GetAddress(), address); - } } - #undef GET_ENUM_STRING - #undef GET_ENUM_VALUE - } // namespace Internal } // namespace Toolkit diff --combined dali-toolkit/internal/controls/web-view/web-view-impl.h index cfbb31e,79915a3..fc5d06a --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@@ -99,6 -99,11 +99,11 @@@ public Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; /** + * @copydoc Dali::Toolkit::WebView::GetPlugin() + */ + Dali::WebEnginePlugin* GetPlugin() const; + + /** * @copydoc Dali::Toolkit::WebView::GetFavicon() */ Dali::Toolkit::ImageView GetFavicon() const; @@@ -374,6 -379,11 +379,11 @@@ 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); @@@ -465,11 -475,6 +475,6 @@@ private 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 @@@ -593,12 -598,6 +598,6 @@@ 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. */ @@@ -661,9 -660,10 +660,10 @@@ 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. @@@ -689,11 -689,6 +689,11 @@@ protected protected: /** + * @copydoc Dali::Accessibility::Accessible::GetAttributes() + */ + Dali::Accessibility::Attributes GetAttributes() const override; + + /** * @copydoc Dali::Accessibility::ActorAccessible::DoGetChildren() */ void DoGetChildren(std::vector& children) override;