From: JIYUN YANG Date: Mon, 1 Feb 2021 08:47:18 +0000 (+0000) Subject: Merge "Update position & size of web view." into devel/master X-Git-Tag: dali_2.0.12~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=893ca7b6b58b59ed4671daf867c4a319d8c9a770;hp=-c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Merge "Update position & size of web view." into devel/master --- 893ca7b6b58b59ed4671daf867c4a319d8c9a770 diff --combined dali-toolkit/internal/controls/web-view/web-view-impl.cpp index 0cf97a4,27fee70..9e31e46 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@@ -67,6 -67,7 +67,7 @@@ DALI_PROPERTY_REGISTRATION( Toolkit, We DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE ) DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "title", STRING, TITLE ) + DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "videoHoleEnabled", BOOLEAN, VIDEO_HOLE_ENABLED ) DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL ) DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL ) @@@ -93,7 -94,9 +94,9 @@@ WebView::WebView( const std::string& lo mWebEngine(), mPageLoadStartedSignal(), mPageLoadFinishedSignal(), - mPageLoadErrorSignal() + mPageLoadErrorSignal(), + mVideoHoleEnabled( true ), + mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height ) { mWebEngine = Dali::WebEngine::New(); @@@ -112,7 -115,9 +115,9 @@@ WebView::WebView( int argc, char** arg mWebEngine(), mPageLoadStartedSignal(), mPageLoadFinishedSignal(), - mPageLoadErrorSignal() + mPageLoadErrorSignal(), + mVideoHoleEnabled( true ), + mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height ) { mWebEngine = Dali::WebEngine::New(); @@@ -130,6 -135,10 +135,10 @@@ WebView::WebView( WebView::~WebView() { + if( mWebEngine ) + { + mWebEngine.Destroy(); + } } Toolkit::WebView WebView::New() @@@ -161,8 -170,17 +170,17 @@@ Toolkit::WebView WebView::New( int argc void WebView::OnInitialize() { - Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true ); - Self().TouchedSignal().Connect( this, &WebView::OnTouchEvent ); + Actor self = Self(); + + self.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true ); + self.TouchedSignal().Connect( this, &WebView::OnTouchEvent ); + + 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 ); if( mWebEngine ) { @@@ -205,7 -223,7 +223,7 @@@ Dali::Toolkit::ImageView& WebView::GetF Dali::PixelData pixelData = mWebEngine.GetFavicon(); std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData ); mFaviconView = Dali::Toolkit::ImageView::New( url ); - mFaviconView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mFaviconView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) ); } return mFaviconView; @@@ -228,6 -246,11 +246,11 @@@ void WebView::LoadUrl( const std::strin DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual ); mWebEngine.LoadUrl( url ); } + + if ( mVideoHoleEnabled ) + { + EnableBlendMode( false ); + } } } @@@ -246,6 -269,11 +269,11 @@@ void WebView::LoadHtmlString( const std DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual ); mWebEngine.LoadHtmlString( htmlString ); } + + if ( mVideoHoleEnabled ) + { + EnableBlendMode( false ); + } } } @@@ -347,6 -375,59 +375,59 @@@ void WebView::ClearHistory( } } + 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< int > 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; + + EnableBlendMode( !mVideoHoleEnabled ); + + if( mWebEngine ) + { + mWebEngine.EnableVideoHole( mVideoHoleEnabled ); + } + } + + void WebView::EnableBlendMode( bool blendEnabled ) + { + Actor self = Self(); + for (uint32_t i = 0; i < self.GetRendererCount(); i++) + { + Dali::Renderer render = self.GetRendererAt( i ); + render.SetProperty( Renderer::Property::BLEND_MODE, blendEnabled ? BlendMode::ON : BlendMode::OFF ); + } + } + Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal() { return mPageLoadStartedSignal; @@@ -446,19 -527,11 +527,11 @@@ Vector3 WebView::GetNaturalSize( return Vector3( mWebViewSize ); } - void WebView::OnRelayout( const Vector2& size, RelayoutContainer& container ) + void WebView::OnSceneConnection( int depth ) { - Control::OnRelayout( size, container ); - - if( size.width > 0 && size.height > 0 && mWebViewSize != size ) - { - mWebViewSize = size; + Control::OnSceneConnection( depth ); - if( mWebEngine ) - { - mWebEngine.SetSize( size.width, size.height ); - } - } + EnableBlendMode( !mVideoHoleEnabled ); } void WebView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) @@@ -497,6 -570,15 +570,15 @@@ } break; } + case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED: + { + bool input; + if( value.Get( input ) ) + { + impl.EnableVideoHole( input ); + } + break; + } } } } @@@ -542,6 -624,11 +624,11 @@@ Property::Value WebView::GetProperty( B value = impl.GetTitle(); break; } + case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED: + { + value = impl.mVideoHoleEnabled; + break; + } default: break; }