From b66c2d1bea43fdb28c63d0582a8c4548abfd1a76 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 6 Jan 2023 13:33:32 -0500 Subject: [PATCH] Revert "Fix dismissal of select popups on NotifyMoveOrResizeStarted (see issue #3294)" This reverts commit 5f4bccd672c1ed745218a9d756e430f0164fd3ba. Reason for revert: This change causes a native parented browser to lose focus on move (fixes issue #3426). --- libcef/browser/alloy/browser_platform_delegate_alloy.cc | 7 +++++-- libcef/browser/frame_host_impl.cc | 7 +++++++ libcef/browser/frame_host_impl.h | 4 ++++ libcef/common/mojom/cef.mojom | 4 ++++ libcef/renderer/frame_impl.cc | 8 ++++++++ libcef/renderer/frame_impl.h | 1 + 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index 2620a5be9..2a8b43b1b 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -261,12 +261,15 @@ void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() { #if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)) void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() { - if (!web_contents_) { + if (!browser_) { return; } // Dismiss any existing popups. - web_contents_->ClearFocusedElement(); + auto frame = browser_->GetMainFrame(); + if (frame && frame->IsValid()) { + static_cast(frame.get())->NotifyMoveOrResizeStarted(); + } } #endif diff --git a/libcef/browser/frame_host_impl.cc b/libcef/browser/frame_host_impl.cc index c80de56e5..d77ce4019 100644 --- a/libcef/browser/frame_host_impl.cc +++ b/libcef/browser/frame_host_impl.cc @@ -304,6 +304,13 @@ void CefFrameHostImpl::RefreshAttributes() { } } +void CefFrameHostImpl::NotifyMoveOrResizeStarted() { + SendToRenderFrame(__FUNCTION__, + base::BindOnce([](const RenderFrameType& render_frame) { + render_frame->MoveOrResizeStarted(); + })); +} + void CefFrameHostImpl::LoadRequest(cef::mojom::RequestParamsPtr params) { if (!url_util::FixupGURL(params->url)) { return; diff --git a/libcef/browser/frame_host_impl.h b/libcef/browser/frame_host_impl.h index 8e6bba98a..a11afdcad 100644 --- a/libcef/browser/frame_host_impl.h +++ b/libcef/browser/frame_host_impl.h @@ -82,6 +82,10 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame { void SetFocused(bool focused); void RefreshAttributes(); + // Notification that a move or resize of the renderer's containing window has + // started. Used on Windows and Linux with the Alloy runtime. + void NotifyMoveOrResizeStarted(); + // Load the specified request. void LoadRequest(cef::mojom::RequestParamsPtr params); diff --git a/libcef/common/mojom/cef.mojom b/libcef/common/mojom/cef.mojom index 499aa33d4..02c83dd1f 100644 --- a/libcef/common/mojom/cef.mojom +++ b/libcef/common/mojom/cef.mojom @@ -79,6 +79,10 @@ interface RenderFrame { // Loading has stopped. DidStopLoading(); + + // Move or resize of the renderer's containing window has started. Used on + // Windows and Linux with the Alloy runtime. + MoveOrResizeStarted(); }; // Interface for communicating with a frame in the browser process. diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index ae59dc13a..d1b9ebac1 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -832,6 +832,14 @@ void CefFrameImpl::DidStopLoading() { } } +void CefFrameImpl::MoveOrResizeStarted() { + if (frame_) { + auto web_view = frame_->View(); + if (web_view) + web_view->CancelPagePopup(); + } +} + void CefFrameImpl::ContextLifecycleStateChanged( blink::mojom::blink::FrameLifecycleState state) { if (state == blink::mojom::FrameLifecycleState::kFrozen && IsMain() && diff --git a/libcef/renderer/frame_impl.h b/libcef/renderer/frame_impl.h index 9e371336d..b6638d89a 100644 --- a/libcef/renderer/frame_impl.h +++ b/libcef/renderer/frame_impl.h @@ -162,6 +162,7 @@ class CefFrameImpl int32_t startLine) override; void LoadRequest(cef::mojom::RequestParamsPtr params) override; void DidStopLoading() override; + void MoveOrResizeStarted() override; // blink_glue::CefExecutionContextLifecycleStateObserver methods: void ContextLifecycleStateChanged(