From df33ded7dcacc6890fed63baa1168ad0086b1ece Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Thu, 22 Jul 2021 22:13:37 +0900 Subject: [PATCH] Implement WebEngine::GetPlainTextAsynchronously Change-Id: Ieb9131ff7b6f3b454e8be3b3abc1d2e01e7d2d85 Signed-off-by: Jiyun Yang --- .../tizen-web-engine-chromium.cpp | 32 ++++++++++++++++++++++ .../tizen-web-engine-chromium.h | 17 ++++++++++++ .../web-engine-lwe/tizen-web-engine-lwe.cpp | 5 ++++ .../web-engine-lwe/tizen-web-engine-lwe.h | 5 ++++ 4 files changed, 59 insertions(+) diff --git a/dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp b/dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp index 7124e0f..5cc555c 100755 --- a/dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp +++ b/dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp @@ -816,6 +816,11 @@ public: ecore_wl2_window_alpha_set(win, !enabled); } + void GetPlainTextAsynchronously() + { + ewk_view_plain_text_get(mWebView, &WebViewContainerForDali::OnPlainTextReceived, &mClient); + } + private: static Dali::PixelData ConvertImageColorSpace(Evas_Object *image) { @@ -889,6 +894,19 @@ private: client->ConsoleMessageReceived(std::move(webConsoleMessage)); } + static void OnPlainTextReceived(Evas_Object* o, const char* plainText, void* data) + { + auto client = static_cast(data); + std::string resultText; + + if (plainText != nullptr) + { + resultText = std::string(plainText); + } + + client->PlainTextRecieved(resultText); + } + static void OnEdgeLeft(void* data, Evas_Object*, void*) { auto client = static_cast(data); @@ -1875,6 +1893,15 @@ void TizenWebEngineChromium::RegisterContextMenuHiddenCallback(WebEngineContextM mContextMenuHiddenCallback = callback; } +void TizenWebEngineChromium::GetPlainTextAsynchronously(PlainTextReceivedCallback callback) +{ + if (mWebViewContainer) + { + mPlainTextReceivedCallback = callback; + mWebViewContainer->GetPlainTextAsynchronously(); + } +} + // WebViewContainerClient Interface void TizenWebEngineChromium::UpdateImage(tbm_surface_h buffer) { @@ -2038,6 +2065,11 @@ bool TizenWebEngineChromium::HitTestCreated(std::unique_ptr(mHitTestCreatedCallback, std::move(hitTest)); } +void TizenWebEngineChromium::PlainTextRecieved(const std::string& plainText) +{ + ExecuteCallback(mPlainTextReceivedCallback, plainText); +} + } // namespace Plugin } // namespace Dali diff --git a/dali-extension/web-engine-chromium/tizen-web-engine-chromium.h b/dali-extension/web-engine-chromium/tizen-web-engine-chromium.h index 1996ffa..359bf92 100755 --- a/dali-extension/web-engine-chromium/tizen-web-engine-chromium.h +++ b/dali-extension/web-engine-chromium/tizen-web-engine-chromium.h @@ -215,6 +215,12 @@ public: * @brief Callback function to be called by WebViewContainer after hit test is created. */ virtual bool HitTestCreated(std::unique_ptr hitTest) = 0; + + /** + * @brief Callback function to be called by WebViewContainer as a result of getting plain text. + * @param [in] plainText The obtained plain text. + */ + virtual void PlainTextRecieved(const std::string& plainText) = 0; }; /** @@ -718,6 +724,11 @@ public: */ void RegisterContextMenuHiddenCallback(WebEngineContextMenuHiddenCallback callback) override; + /** + * @copydoc Dali::WebEnginePlugin::GetPlainTextAsynchronously() + */ + void GetPlainTextAsynchronously(PlainTextReceivedCallback callback) override; + // WebViewContainerClient Interface /** @@ -842,6 +853,11 @@ public: */ bool HitTestCreated(std::unique_ptr hitTest) override; + /** + * @copydoc Dali::Plugin::WebViewContainerClient::PlainTextRecieved() + */ + void PlainTextRecieved(const std::string& plainText) override; + private: WebViewContainerForDali* mWebViewContainer; Dali::NativeImageSourcePtr mDaliImageSrc; @@ -871,6 +887,7 @@ private: ScreenshotCapturedCallback mScreenshotCapturedCallback; VideoPlayingCallback mVideoPlayingCallback; GeolocationPermissionCallback mGeolocationPermissionCallback; + PlainTextReceivedCallback mPlainTextReceivedCallback; std::unordered_map mJavaScriptEvaluationResultHandlers; std::unordered_map mJavaScriptMessageHandlers; diff --git a/dali-extension/web-engine-lwe/tizen-web-engine-lwe.cpp b/dali-extension/web-engine-lwe/tizen-web-engine-lwe.cpp index 482b1b6..d4538a6 100755 --- a/dali-extension/web-engine-lwe/tizen-web-engine-lwe.cpp +++ b/dali-extension/web-engine-lwe/tizen-web-engine-lwe.cpp @@ -1299,5 +1299,10 @@ void TizenWebEngineLWE::RegisterContextMenuHiddenCallback(WebEngineContextMenuHi // NOT IMPLEMENTED } +void TizenWebEngineLWE::GetPlainTextAsynchronously(PlainTextReceivedCallback callback) +{ + // NOT IMPLEMENTED +} + } // namespace Plugin } // namespace Dali diff --git a/dali-extension/web-engine-lwe/tizen-web-engine-lwe.h b/dali-extension/web-engine-lwe/tizen-web-engine-lwe.h index 66cf702..9554850 100755 --- a/dali-extension/web-engine-lwe/tizen-web-engine-lwe.h +++ b/dali-extension/web-engine-lwe/tizen-web-engine-lwe.h @@ -548,6 +548,11 @@ public: */ void RegisterContextMenuHiddenCallback(WebEngineContextMenuHiddenCallback callback) override; + /** + * @copydoc Dali::WebEnginePlugin::GetPlainTextAsynchronously() + */ + void GetPlainTextAsynchronously(PlainTextReceivedCallback callback) override; + private: void UpdateBuffer(); -- 2.7.4