From 7b5d9e362098be032b31319688daeda21fa48ee3 Mon Sep 17 00:00:00 2001 From: yushihao4 Date: Mon, 27 Nov 2023 19:45:24 +0800 Subject: [PATCH] [webview]Fixed menu flicker when scrolling interface Signed-off-by: yushihao4 --- .../touch_selection_controller_client_osr.cc | 19 +++++++++++++++++++ .../touch_selection_controller_client_osr.h | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.cc b/libcef/browser/osr/touch_selection_controller_client_osr.cc index a7e6c4010..a6798ed9f 100644 --- a/libcef/browser/osr/touch_selection_controller_client_osr.cc +++ b/libcef/browser/osr/touch_selection_controller_client_osr.cc @@ -181,6 +181,9 @@ void CefTouchSelectionControllerClientOSR::OnTouchDown() { void CefTouchSelectionControllerClientOSR::OnTouchUp() { touch_down_ = false; + if (quick_menu_running_) { + return; + } UpdateQuickMenu(); } @@ -509,7 +512,11 @@ void CefTouchSelectionControllerClientOSR::OnSelectionEvent( break; case ui::SELECTION_HANDLES_MOVED: case ui::INSERTION_HANDLE_MOVED: +#if defined(IS_OHOS) + if (!handle_drag_in_progress_ && IsVaildHandleMoveAction()) { +#else if (!handle_drag_in_progress_) { +#endif UpdateQuickMenu(); } NotifyTouchSelectionChanged(true); @@ -703,6 +710,18 @@ bool CefTouchSelectionControllerClientOSR:: return false; } +#if defined(IS_OHOS) +bool CefTouchSelectionControllerClientOSR::IsVaildHandleMoveAction() { + base::TimeTicks nowTime = base::TimeTicks:Now(); + base::TimeDelta deltaTime = nowTime - selectHandlemoveTicks_; + selectHandlemoveTicks_ = base::TimeTicks:Now(); + if (deltaTime.InMilliseconds() > kQuickMenuDelayInMs) { + return false; + } + return true; +} +#endif + #if defined(OHOS_NWEB_EX) void CefTouchSelectionControllerClientOSR::SelectionTextNotEmpty( bool selectionTextNotEmpty) { diff --git a/libcef/browser/osr/touch_selection_controller_client_osr.h b/libcef/browser/osr/touch_selection_controller_client_osr.h index 5a4a6f963..461a53b9c 100755 --- a/libcef/browser/osr/touch_selection_controller_client_osr.h +++ b/libcef/browser/osr/touch_selection_controller_client_osr.h @@ -83,7 +83,9 @@ class CefTouchSelectionControllerClientOSR TouchSelectionControllerClientManager::Observer* observer) override; bool NeedPopupInsertTouchHandleQuickMenu(); - +#if defined(IS_OHOS) + bool IsVaildHandleMoveAction(); +#endif private: class EnvEventObserver; @@ -150,6 +152,9 @@ class CefTouchSelectionControllerClientOSR observers_; base::RetainingOneShotTimer quick_menu_timer_; +#if defined(IS_OHOS) + base::TimeTicks selectHandlemoveTicks_; +#endif bool quick_menu_requested_ = false; bool quick_menu_running_ = false; bool touch_down_ = false; -- Gitee