Skip to content

Commit 9601dc5

Browse files
authored
refactor: replace --offscreen flag with ApplyWebPreferences (electron#28938)
1 parent e0fa327 commit 9601dc5

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

patches/chromium/.patches

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ web_contents.patch
103103
fix_route_mouse_event_navigations_through_the_web_contents_delegate.patch
104104
disable_unload_metrics.patch
105105
fix_add_check_for_sandbox_then_result.patch
106-
moves_background_color_setter_of_webview_to_blinks_webprefs_logic.patch
106+
extend_apply_webpreferences.patch
107107
fix_expose_decrementcapturercount_in_web_contents_impl.patch
108108
add_setter_for_browsermainloop_result_code.patch

patches/chromium/moves_background_color_setter_of_webview_to_blinks_webprefs_logic.patch renamed to patches/chromium/extend_apply_webpreferences.patch

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Samuel Attard <sattard@slack-corp.com>
33
Date: Mon, 8 Mar 2021 16:27:39 -0800
4-
Subject: moves background_color setter of WebView to blinks webprefs logic
4+
Subject: extend ApplyWebPreferences with Electron-specific logic
55

66
background_color can be updated at runtime, as such we need to apply the
77
new background color to the WebView in the ApplyPreferences method.
@@ -12,7 +12,7 @@ Ideally we could add an embedder observer pattern here but that can be
1212
done in future work.
1313

1414
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
15-
index affad073f806c509779c041128708fb074fee8ad..b2615fc4ea5e9ae96182fb611a419c7c5630e983 100644
15+
index affad073f806c509779c041128708fb074fee8ad..0d3486f136f77375a8977cefeef1e1dea7549045 100644
1616
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
1717
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
1818
@@ -155,6 +155,7 @@
@@ -23,7 +23,7 @@ index affad073f806c509779c041128708fb074fee8ad..b2615fc4ea5e9ae96182fb611a419c7c
2323
#include "third_party/blink/renderer/platform/graphics/image.h"
2424
#include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
2525
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
26-
@@ -1755,6 +1756,14 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
26+
@@ -1755,6 +1756,16 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
2727

2828
RuntimeEnabledFeatures::SetTranslateServiceEnabled(
2929
prefs.translate_service_available);
@@ -35,6 +35,8 @@ index affad073f806c509779c041128708fb074fee8ad..b2615fc4ea5e9ae96182fb611a419c7c
3535
+ color = static_cast<SkColor>(blink_color);
3636
+ }
3737
+ web_view->SetBaseBackgroundColor(color);
38+
+
39+
+ SetUseExternalPopupMenus(!prefs.offscreen);
3840
}
3941

4042
void WebViewImpl::ThemeChanged() {

shell/browser/web_contents_preferences.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,6 @@ void WebContentsPreferences::AppendCommandLineSwitches(
325325
}
326326
}
327327

328-
// --offscreen
329-
// TODO(loc): Offscreen is duplicated in WebPreferences because it's needed
330-
// earlier than we can get WebPreferences at the moment.
331-
if (IsEnabled(options::kOffscreen)) {
332-
command_line->AppendSwitch(options::kOffscreen);
333-
}
334-
335328
#if defined(OS_MAC)
336329
// Enable scroll bounce.
337330
if (IsEnabled(options::kScrollBounce))

shell/renderer/renderer_client_base.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,6 @@ void RendererClientBase::BindProcess(v8::Isolate* isolate,
148148
void RendererClientBase::RenderThreadStarted() {
149149
auto* command_line = base::CommandLine::ForCurrentProcess();
150150

151-
#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
152-
// On macOS, popup menus are rendered by the main process by default.
153-
// This causes problems in OSR, since when the popup is rendered separately,
154-
// it won't be captured in the rendered image.
155-
// TODO(loc): This will be wrong for in-process child windows, as this
156-
// function won't run again for them.
157-
if (command_line->HasSwitch(options::kOffscreen)) {
158-
blink::WebView::SetUseExternalPopupMenus(false);
159-
}
160-
#endif
161-
162151
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
163152
auto* thread = content::RenderThread::Get();
164153

0 commit comments

Comments
 (0)