From: Fang Xiaohui Date: Wed, 3 Mar 2021 06:57:33 +0000 (+0800) Subject: Add some properties into web view X-Git-Tag: dali_2.0.20~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3890e8d5e0d6c13b7a20538b0de12125946f6d87;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Add some properties into web view ewk_view_bg_color_set ewk_view_clear_tiles_on_hide_enabled_set ewk_view_tile_cover_area_multiplier_set ewk_view_set_cursor_by_client ewk_view_text_selection_text_get Change-Id: I353c858caf82034c4f95c283057bdb8fbc8f2132 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 0043f2c..b371dab 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -1072,6 +1072,27 @@ void WebEngine::SetSize( int width, int height ) { } +void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color) +{ +} + +void WebEngine::ClearTilesWhenHidden(bool cleared) +{ +} + +void WebEngine::SetTileCoverAreaMultiplier(float multiplier) +{ +} + +void WebEngine::EnableCursorByClient(bool enabled) +{ +} + +std::string WebEngine::GetSelectedText() const +{ + return "test"; +} + bool WebEngine::SendTouchEvent( const TouchEvent& touch ) { return true; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 7668926..36a058d 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -631,9 +631,30 @@ int UtcDaliWebViewProperty9(void) END_TEST; } +int UtcDaliWebViewPropertyBackgroundColorSelectedTextEtc(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + Dali::Vector4 testValue = Dali::Vector4(0.0f, 0.0f, 0.0f, 0.0f); + view.SetProperty(WebView::Property::DOCUMENT_BACKGROUND_COLOR, testValue); + view.SetProperty(WebView::Property::TILES_CLEARED_WHEN_HIDDEN, true); + view.SetProperty(WebView::Property::TILE_COVER_AREA_MULTIPLIER, 1.0f); + view.SetProperty(WebView::Property::CURSOR_ENABLED_BY_CLIENT, true); + + // Check default value + std::string testText("test"); + std::string output; + view.GetProperty(WebView::Property::SELECTED_TEXT).Get(output); + DALI_TEST_EQUALS(output, testText, TEST_LOCATION); + + END_TEST; +} + int UtcDaliWebViewPropertyTitleFavicon(void) { - // SCROLL_POSITION ToolkitTestApplication application; char argv[] = "--test"; diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h old mode 100644 new mode 100755 index d347824..2bb556e --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -131,6 +131,37 @@ public: * @note Default is true. */ KEY_EVENTS_ENABLED, + + /** + * @brief The background color of web page. + * @details name "documentBackgroundColor", type Property::VECTOR4. + */ + DOCUMENT_BACKGROUND_COLOR, + + /** + * @brief Whether tiles can be cleared or not when hidden. + * @details name "tilesClearedWhenHidden", type BOOLEAN. + */ + TILES_CLEARED_WHEN_HIDDEN, + + /** + * @brief The multiplier of cover area of tile when rendering web page. + * @details name "tileCoverAreaMultiplier", type FLOAT. + */ + TILE_COVER_AREA_MULTIPLIER, + + /** + * @brief Whether cursor is enabled or not by client. + * @details name "cursorEnabledByClient", type BOOLEAN. + */ + CURSOR_ENABLED_BY_CLIENT, + + /** + * @brief The selected text of web page. + * @details name "selectedText", type Property::STRING. + * @note The value is read-only. + */ + SELECTED_TEXT, }; }; diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp old mode 100644 new mode 100755 index 8053564..c4bf4e9 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -58,15 +58,20 @@ BaseHandle Create() // clang-format off DALI_TYPE_REGISTRATION_BEGIN(Toolkit::WebView, Toolkit::Control, Create) -DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "url", STRING, URL ) -DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "userAgent", STRING, USER_AGENT ) -DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION ) -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_PROPERTY_REGISTRATION(Toolkit, WebView, "mouseEventsEnabled", BOOLEAN, MOUSE_EVENTS_ENABLED) -DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "keyEventsEnabled", BOOLEAN, KEY_EVENTS_ENABLED ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "url", STRING, URL ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "userAgent", STRING, USER_AGENT ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION ) +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_PROPERTY_REGISTRATION(Toolkit, WebView, "mouseEventsEnabled", BOOLEAN, MOUSE_EVENTS_ENABLED ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "keyEventsEnabled", BOOLEAN, KEY_EVENTS_ENABLED ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "documentBackgroundColor", VECTOR4, DOCUMENT_BACKGROUND_COLOR ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tilesClearedWhenHidden", BOOLEAN, TILES_CLEARED_WHEN_HIDDEN ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tileCoverAreaMultiplier", FLOAT, TILE_COVER_AREA_MULTIPLIER) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "cursorEnabledByClient", BOOLEAN, CURSOR_ENABLED_BY_CLIENT ) +DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "selectedText", STRING, SELECTED_TEXT ) DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL ) DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadInProgress", PAGE_LOAD_IN_PROGRESS_SIGNAL) @@ -97,9 +102,9 @@ WebView::WebView(const std::string& locale, const std::string& timezoneId) mPageLoadStartedSignal(), mPageLoadFinishedSignal(), mPageLoadErrorSignal(), + mUrlChangedSignal(), mVideoHoleEnabled(true), mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height), - mUrlChangedSignal(), mMouseEventsEnabled(true), mKeyEventsEnabled(true) { @@ -121,9 +126,9 @@ WebView::WebView(int argc, char** argv) mPageLoadStartedSignal(), mPageLoadFinishedSignal(), mPageLoadErrorSignal(), + mUrlChangedSignal(), mVideoHoleEnabled(true), mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height), - mUrlChangedSignal(), mMouseEventsEnabled(true), mKeyEventsEnabled(true) { @@ -695,6 +700,42 @@ void WebView::SetProperty(BaseObject* object, Property::Index index, const Prope } break; } + case Toolkit::WebView::Property::DOCUMENT_BACKGROUND_COLOR: + { + Vector4 input; + if(value.Get(input)) + { + impl.SetDocumentBackgroundColor(input); + } + break; + } + case Toolkit::WebView::Property::TILES_CLEARED_WHEN_HIDDEN: + { + bool input; + if(value.Get(input)) + { + impl.ClearTilesWhenHidden(input); + } + break; + } + case Toolkit::WebView::Property::TILE_COVER_AREA_MULTIPLIER: + { + float input; + if(value.Get(input)) + { + impl.SetTileCoverAreaMultiplier(input); + } + break; + } + case Toolkit::WebView::Property::CURSOR_ENABLED_BY_CLIENT: + { + bool input; + if(value.Get(input)) + { + impl.EnableCursorByClient(input); + } + break; + } } } } @@ -755,6 +796,11 @@ Property::Value WebView::GetProperty(BaseObject* object, Property::Index propert value = impl.mKeyEventsEnabled; break; } + case Toolkit::WebView::Property::SELECTED_TEXT: + { + value = impl.GetSelectedText(); + break; + } default: break; } @@ -853,6 +899,43 @@ std::string WebView::GetTitle() const return mWebEngine ? mWebEngine.GetTitle() : kEmptyString; } +void WebView::SetDocumentBackgroundColor(Dali::Vector4 color) +{ + if(mWebEngine) + { + mWebEngine.SetDocumentBackgroundColor(color); + } +} + +void WebView::ClearTilesWhenHidden(bool cleared) +{ + if(mWebEngine) + { + mWebEngine.ClearTilesWhenHidden(cleared); + } +} + +void WebView::SetTileCoverAreaMultiplier(float multiplier) +{ + if(mWebEngine) + { + mWebEngine.SetTileCoverAreaMultiplier(multiplier); + } +} + +void WebView::EnableCursorByClient(bool enabled) +{ + if(mWebEngine) + { + mWebEngine.EnableCursorByClient(enabled); + } +} + +std::string WebView::GetSelectedText() const +{ + return mWebEngine ? mWebEngine.GetSelectedText() : kEmptyString; +} + const std::string& WebView::GetUserAgent() const { return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString; diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h old mode 100644 new mode 100755 index 9abfd49..0a610b5 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -336,6 +336,38 @@ private: std::string GetTitle() const; /** + * @brief Sets the background color of web page. + * @param[in] color The value of background color. + */ + void SetDocumentBackgroundColor(Dali::Vector4 color); + + /** + * @brief Clears tiles when hidden. + * + * @param[in] cleared Whether tiles are cleared or not + */ + void ClearTilesWhenHidden(bool cleared); + + /** + * @brief Sets multiplier of cover area of tile. + * + * @param[in] multiplier The multiplier of cover area + */ + void SetTileCoverAreaMultiplier(float multiplier); + + /** + * @brief Enables cursor by client. + * @param[in] enabled Whether cursor is enabled or not. + */ + void EnableCursorByClient(bool enabled); + + /** + * @brief Gets the selected text. + * @return The selected text + */ + std::string GetSelectedText() const; + + /** * @brief Get user agent string. * @return The string value of user agent */ @@ -450,6 +482,7 @@ private: Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadInProgressSignal; Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; + Dali::Toolkit::WebView::WebViewUrlChangedSignalType mUrlChangedSignal; Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal; std::unique_ptr mWebContext; @@ -463,7 +496,6 @@ private: Dali::PropertyNotification mScaleUpdateNotification; bool mVideoHoleEnabled; Dali::Rect mWebViewArea; - Dali::Toolkit::WebView::WebViewUrlChangedSignalType mUrlChangedSignal; bool mMouseEventsEnabled; bool mKeyEventsEnabled; };