Don't use static variable for UseExternalPopupMenus

https://chromium-review.googlesource.com/c/chromium/src/+/6534657
This commit is contained in:
John Kleinschmidt
2025-06-09 13:57:05 -04:00
parent 57d0945c4e
commit b946020f1d
2 changed files with 10 additions and 14 deletions

View File

@@ -3,8 +3,11 @@ From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 8 Mar 2021 16:27:39 -0800
Subject: extend ApplyWebPreferences with Electron-specific logic
background_color can be updated at runtime, as such we need to apply the
new background color to the WebView in the ApplyPreferences method.
On macOS, popup menus are rendered by the main process by default.
This causes problems in OSR, since when the popup is rendered separately,
it won't be captured in the rendered image.
Offscreen can be updated at runtime, as such we need to apply the
turn on/off ExternalPopupMenu in the ApplyPreferences method.
There is no current way to attach an observer to these prefs so patching
is our only option.
@@ -12,22 +15,15 @@ Ideally we could add an embedder observer pattern here but that can be
done in future work.
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
index 5e0df4263d176b699e940f20d79e90e5b3259014..a765b2d1e97f0017f5cd1daf625ec2451eea9d27 100644
index 5e0df4263d176b699e940f20d79e90e5b3259014..d9125c7905cb4e5dd00c3d5c05c87d45079cca94 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -173,6 +173,7 @@
#include "third_party/blink/renderer/core/view_transition/view_transition_supplement.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
#include "third_party/blink/renderer/platform/fonts/generic_font_family_settings.h"
+#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
@@ -1882,6 +1883,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
@@ -1882,6 +1882,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
#if BUILDFLAG(IS_MAC)
web_view_impl->SetMaximumLegibleScale(
prefs.default_maximum_page_scale_factor);
+ SetUseExternalPopupMenus(!prefs.offscreen);
+ web_view_impl->GetChromeClient().SetUseExternalPopupMenusForTesting(
+ !prefs.offscreen);
#endif
#if BUILDFLAG(IS_WIN)

View File

@@ -241,7 +241,7 @@ index aa8b248b94ea7f6c0e04dc66e976dc7923ff3a98..868630ed2adb8f40fb7f002d45b260c0
bool RenderVSyncNotificationEnabled() const {
return render_v_sync_notification_enabled_;
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
index a765b2d1e97f0017f5cd1daf625ec2451eea9d27..412e6658d5cb4f7b04f93223a84c694412a28c4f 100644
index d9125c7905cb4e5dd00c3d5c05c87d45079cca94..caa6b25d2346353cee5688e99aac2a6e3528e3b1 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -3597,6 +3597,9 @@ void WebViewImpl::UpdateRendererPreferences(