#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-settings.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <toolkit-application.h>
namespace Dali
{
}
+void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
+{
+}
+
+void WebEngine::EnableVideoHole( bool enabled )
+{
+}
+
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
{
return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
END_TEST;
}
+int UtcDaliWebViewMove(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+ view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+ application.GetScene().Add( view );
+ application.SendNotification();
+ application.Render();
+
+ view.SetProperty( Actor::Property::POSITION, Vector2( 100, 100 ));
+ Vector3 viewPos = view.GetProperty<Vector3>( Actor::Property::POSITION );
+ DALI_TEST_EQUALS( viewPos, Vector3( 100, 100, 0 ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewPropertyVideoHole(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ const bool kDefaultValue = true;
+ const bool kTestValue = false;
+
+ // Check default value
+ bool output;
+ Property::Value value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
+ DALI_TEST_CHECK( value.Get( output ) );
+ DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+
+ // Check Set/GetProperty
+ view.SetProperty( WebView::Property::VIDEO_HOLE_ENABLED, kTestValue );
+ value = view.GetProperty( WebView::Property::VIDEO_HOLE_ENABLED );
+ DALI_TEST_CHECK( value.Get( output ) );
+ DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliWebViewGetWebBackForwardList(void)
{
ToolkitTestApplication application;
/**
* @brief The user agent string.
- * @details Name "userAgent", type Property::STRING.
+ * @details name "userAgent", type Property::STRING.
*/
USER_AGENT,
/**
* @brief The current position of scroll.
- * @details Name "scrollPosition", type Property::VECTOR2.
+ * @details name "scrollPosition", type Property::VECTOR2.
*/
SCROLL_POSITION,
/**
- * @brief The current position of scroll.
- * @details Name "scrollSize", type Property::VECTOR2. Read-only.
+ * @brief The current size of scroll.
+ * @details name "scrollSize", type Property::VECTOR2.
+ * @note The value is read-only.
*/
SCROLL_SIZE,
/**
- * @brief The current position of scroll.
- * @details Name "contentSize", type Property::VECTOR2. Read-only.
+ * @brief The current size of content.
+ * @details name "contentSize", type Property::VECTOR2.
+ * @note The value is read-only.
*/
CONTENT_SIZE,
/**
* @brief The title of web page.
- * @details Name "title", type Property::STRING.
+ * @details name "title", type Property::STRING.
* @note The value is read-only.
*/
TITLE,
+
+ /**
+ * @brief Whether video hole is enabled or not.
+ * @details name "videoHoleEnabled", type Property::BOOLEAN.
+ * @note The value is read-only.
+ */
+ VIDEO_HOLE_ENABLED,
};
};
*/
enum class LoadErrorCode
{
- /**
- * @brief Unknown.
- */
- UNKNOWN = 0,
-
- /**
- * @brief User canceled.
- */
- CANCELED,
-
- /**
- * @brief Can't show the page for this MIME type.
- */
- CANT_SUPPORT_MIMETYPE,
-
- /**
- * @brief File IO error.
- */
- FAILED_FILE_IO,
-
- /**
- * @brief Cannot connect to the network.
- */
- CANT_CONNECT,
-
- /**
- * @brief Fail to look up host from the DNS.
- */
- CANT_LOOKUP_HOST,
-
- /**
- * @brief Fail to SSL/TLS handshake.
- */
- FAILED_TLS_HANDSHAKE,
-
- /**
- * @brief Received certificate is invalid.
- */
- INVALID_CERTIFICATE,
-
- /**
- * @brief Connection timeout.
- */
- REQUEST_TIMEOUT,
-
- /**
- * @brief Too many redirects.
- */
- TOO_MANY_REDIRECTS,
-
- /**
- * @brief Too many requests during this load.
- */
- TOO_MANY_REQUESTS,
-
- /**
- * @brief Malformed URL.
- */
- BAD_URL,
-
- /**
- * @brief Unsupported scheme.
- */
- UNSUPPORTED_SCHEME,
-
- /**
- * @brief User authentication failed on the server.
- */
- AUTHENTICATION,
-
- /**
- * @brief Web server has an internal server error.
- */
- INTERNAL_SERVER
+ UNKNOWN = 0, ///< Unknown.
+ CANCELED, ///< User canceled.
+ CANT_SUPPORT_MIMETYPE, ///< Can't show the page for this MIME type.
+ FAILED_FILE_IO, ///< File IO error.
+ CANT_CONNECT, ///< Cannot connect to the network.
+ CANT_LOOKUP_HOST, ///< Fail to look up host from the DNS.
+ FAILED_TLS_HANDSHAKE, ///< Fail to SSL/TLS handshake.
+ INVALID_CERTIFICATE, ///< Received certificate is invalid.
+ REQUEST_TIMEOUT, ///< Connection timeout.
+ TOO_MANY_REDIRECTS, ///< Too many redirects.
+ TOO_MANY_REQUESTS, ///< Too many requests during this load.
+ BAD_URL, ///< Malformed URL.
+ UNSUPPORTED_SCHEME, ///< Unsupported scheme.
+ AUTHENTICATION, ///< User authentication failed on the server.
+ INTERNAL_SERVER ///< Web server has an internal server error.
};
/**
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 )
mWebEngine(),
mPageLoadStartedSignal(),
mPageLoadFinishedSignal(),
- mPageLoadErrorSignal()
+ mPageLoadErrorSignal(),
+ mVideoHoleEnabled( true ),
+ mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height )
{
mWebEngine = Dali::WebEngine::New();
mWebEngine(),
mPageLoadStartedSignal(),
mPageLoadFinishedSignal(),
- mPageLoadErrorSignal()
+ mPageLoadErrorSignal(),
+ mVideoHoleEnabled( true ),
+ mWebViewArea ( 0, 0, mWebViewSize.width, mWebViewSize.height )
{
mWebEngine = Dali::WebEngine::New();
WebView::~WebView()
{
+ if( mWebEngine )
+ {
+ mWebEngine.Destroy();
+ }
}
Toolkit::WebView WebView::New()
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 )
{
DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
mWebEngine.LoadUrl( url );
}
+
+ if ( mVideoHoleEnabled )
+ {
+ EnableBlendMode( false );
+ }
}
}
DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
mWebEngine.LoadHtmlString( htmlString );
}
+
+ if ( mVideoHoleEnabled )
+ {
+ EnableBlendMode( false );
+ }
}
}
}
}
+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;
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 )
}
break;
}
+ case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
+ {
+ bool input;
+ if( value.Get( input ) )
+ {
+ impl.EnableVideoHole( input );
+ }
+ break;
+ }
}
}
}
value = impl.GetTitle();
break;
}
+ case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
+ {
+ value = impl.mVideoHoleEnabled;
+ break;
+ }
default:
break;
}
#include <memory>
#include <dali/devel-api/adaptor-framework/web-engine.h>
#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/object/property-notification.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
Vector3 GetNaturalSize() override;
/**
- * @copydoc Toolkit::Control::OnRelayout()
- */
- void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
-
- /**
* Signal occurs when the Web View has been touched.
* @param[in] actor The Actor Touched
* @param[in] touch The Touch Data.
*/
void OnKeyInputFocusLost() override;
+ /**
+ * @copydoc Toolkit::Control::OnSceneConnection()
+ */
+ void OnSceneConnection( int depth ) override;
+
private:
// Undefined
void SetUserAgent( const std::string& userAgent );
/**
+ * @brief Updates 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 EnableVideoHole( bool enabled );
+
+ /**
+ * @brief Enable blend mode.
+ * @param[in] blendEnabled True if turn on blend mode, false otherwise.
+ */
+ void EnableBlendMode( bool blendEnabled );
+
+ /**
* @brief Callback function to be called when page load started.
* @param[in] url The url currently being loaded
*/
std::unique_ptr<Dali::Toolkit::WebSettings> mWebSettings;
std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
Dali::Toolkit::ImageView mFaviconView;
+
+ Dali::PropertyNotification mPositionUpdateNotification;
+ Dali::PropertyNotification mSizeUpdateNotification;
+ Dali::PropertyNotification mScaleUpdateNotification;
+ bool mVideoHoleEnabled;
+ Dali::Rect< int > mWebViewArea;
};
} // namespace Internal