electron/patches/chromium/webview_fullscreen.patch
electron-roller[bot] 26e1bda335
chore: bump chromium to 140.0.7301.0 (main) (#47747)
* chore: bump chromium in DEPS to 140.0.7296.0

* chore: update patches

* 6702959: Remove OwnedByWidgetPassKey usage from content analysis dialog tests | https://chromium-review.googlesource.com/c/chromium/src/+/6702959

* 6722750: Remove un-used `stream_id` argument for `AidaCodeComplete` | https://chromium-review.googlesource.com/c/chromium/src/+/6722750

* 6696478: Reland Reland [video pip] Add fade in/out animation to controls visibility changes | https://chromium-review.googlesource.com/c/chromium/src/+/6696478

* chore: update libc++-filenames

* build: explicitly include cstdlib in Boyer-Moore patch

* chore: bump chromium in DEPS to 140.0.7297.0

* chore: update patches

* 6729537: [FPF] Pipe flag state from the browser to the renderer | https://chromium-review.googlesource.com/c/chromium/src/+/6729537

* 6727996: [Win] Detect pre-IPC crashes in sandboxed utility processes | https://chromium-review.googlesource.com/c/chromium/src/+/6727996

* 6707182: Move wtf/cross_thread_copier*.* to "blink" namespace | https://chromium-review.googlesource.com/c/chromium/src/+/6707182

* 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796

* chore: bump chromium in DEPS to 140.0.7299.0

* chore: update patches

* chore: update main patches

* build: reset the minimum macOS SDK to 15 to match upstream

This reverts commit 499e987c77.

* 6730215: Remove IPC_MESSAGE_LOG_ENABLED ifdef blocks. | https://chromium-review.googlesource.com/c/chromium/src/+/6730215

* 6690442: Delete ppapi/buildflags/buildflags.h | https://chromium-review.googlesource.com/c/chromium/src/+/6690442

* [wip]: 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681

* chore: bump chromium in DEPS to 140.0.7301.0

* chore: update patches

* 6656309: extensions: Port proxy API to desktop Android | https://chromium-review.googlesource.com/c/chromium/src/+/6656309

* 6758510: Reland 'Move GN enable_plugins variable out of //ppapi' | https://chromium-review.googlesource.com/c/chromium/src/+/6758510

* 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466

* 6735979: [FSA] Replace `request_writable` with a new enum `FileSystemAccessPermissionMode`. | https://chromium-review.googlesource.com/c/chromium/src/+/6735979

* 6712080: Reland "Turn on gender translation PAK generation everywhere" | https://chromium-review.googlesource.com/c/chromium/src/+/6712080

* 6730796: extensions: Extract safe browsing/telemetry methods to new client class | https://chromium-review.googlesource.com/c/chromium/src/+/6730796

* build: restore minimum macOS SDK to 10, restore patch

This reverts commit a04c579b994d5f4a782b793a69f34ff7a260e74f.

* fixup! 6701466: [Extensions] Remove NaCl arch info from Update Client URLs | https://chromium-review.googlesource.com/c/chromium/src/+/6701466

* chore: correct node patches

* fixup! 6667681: Use more binaries from clang toolchain in mac build | https://chromium-review.googlesource.com/c/chromium/src/+/6667681

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-07-21 09:32:53 -07:00

102 lines
5.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 4 Oct 2018 14:57:02 -0700
Subject: fix: also propagate fullscreen state for outer frame
When entering fullscreen with Element.requestFullscreen in child frames,
the parent frame should also enter fullscreen mode too. Chromium handles
this for iframes, but not for webviews as they are essentially main
frames instead of child frames.
This patch makes webviews propagate the fullscreen state to embedder.It also handles a
DCHECK preventing guest webcontents from becoming the focused webContents.
Note that we also need to manually update embedder's
`api::WebContents::IsFullscreenForTabOrPending` value.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
index 858650444361a7ad749ef68e5fb91b5609fb7b6e..c6958be31c1dcd0be0cad132db15b2cf7d8fc3cb 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -8884,6 +8884,17 @@ void RenderFrameHostImpl::EnterFullscreen(
}
}
+ // Entering fullscreen from webview should also notify its outer frame.
+ if (frame_tree_node()->render_manager()->IsMainFrameForInnerDelegate()) {
+ RenderFrameProxyHost* outer_proxy =
+ frame_tree_node()->render_manager()->GetProxyToOuterDelegate();
+ DCHECK(outer_proxy);
+ if (outer_proxy->is_render_frame_proxy_live()) {
+ outer_proxy->GetAssociatedRemoteFrame()->WillEnterFullscreen(
+ options.Clone());
+ }
+ }
+
// Focus the window if another frame may have delegated the capability.
if (had_fullscreen_token && !GetView()->HasFocus())
GetView()->Focus();
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a783afcda81f97504425de4224ed40f711852d18..574a00073861a9edd2f5d7daaab43e763b5a9e37 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4399,21 +4399,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) {
OPTIONAL_TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
"WebContentsImpl::PreHandleKeyboardEvent");
- auto* outermost_contents = GetOutermostWebContents();
- // TODO(wjmaclean): Generalize this to forward all key events to the outermost
- // delegate's handler.
- if (outermost_contents != this && IsFullscreen() &&
- event.windows_key_code == ui::VKEY_ESCAPE) {
- // When an inner WebContents has focus and is fullscreen, redirect <esc>
- // key events to the outermost WebContents so it can be handled by that
- // WebContents' delegate.
- if (outermost_contents->PreHandleKeyboardEvent(event) ==
- KeyboardEventProcessingResult::HANDLED) {
+
+ auto handled = delegate_ ? delegate_->PreHandleKeyboardEvent(this, event)
+ : KeyboardEventProcessingResult::NOT_HANDLED;
+
+ if (IsFullscreen() && event.windows_key_code == ui::VKEY_ESCAPE) {
+ if (handled == KeyboardEventProcessingResult::HANDLED)
return KeyboardEventProcessingResult::HANDLED;
+
+ // When an inner WebContents has focus and is fullscreen, traverse through
+ // containing webcontents to any that may handle the escape key.
+ while (auto* outer_web_contents = GetOuterWebContents()) {
+ auto result = outer_web_contents->PreHandleKeyboardEvent(event);
+ if (result == KeyboardEventProcessingResult::HANDLED) {
+ return KeyboardEventProcessingResult::HANDLED;
+ }
}
}
- return delegate_ ? delegate_->PreHandleKeyboardEvent(this, event)
- : KeyboardEventProcessingResult::NOT_HANDLED;
+
+ return handled;
}
bool WebContentsImpl::HandleMouseEvent(const blink::WebMouseEvent& event) {
@@ -4572,7 +4576,7 @@ void WebContentsImpl::EnterFullscreenMode(
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::EnterFullscreenMode");
DCHECK(CanEnterFullscreenMode(requesting_frame));
DCHECK(requesting_frame->IsActive());
- DCHECK(ContainsOrIsFocusedWebContents());
+ DCHECK(ContainsOrIsFocusedWebContents() || IsGuest());
if (base::FeatureList::IsEnabled(
features::kAutomaticFullscreenContentSetting)) {
// Ensure the window is made active to take input focus. The user may have
diff --git a/third_party/blink/renderer/core/fullscreen/fullscreen.cc b/third_party/blink/renderer/core/fullscreen/fullscreen.cc
index 4bfea29fb8bcdf8af69fa686d1474c3530e2d3f9..e5403852d06bfe00fc1ed2ea097245b942d2c056 100644
--- a/third_party/blink/renderer/core/fullscreen/fullscreen.cc
+++ b/third_party/blink/renderer/core/fullscreen/fullscreen.cc
@@ -105,7 +105,7 @@ void FullscreenElementChanged(Document& document,
// is the iframe element for the out-of-process frame that contains the
// fullscreen element. Hence, it must match :-webkit-full-screen-ancestor.
if (new_request_type & FullscreenRequestType::kForCrossProcessDescendant) {
- DCHECK(IsA<HTMLIFrameElement>(new_element));
+ // DCHECK(IsA<HTMLIFrameElement>(new_element));
new_element->SetContainsFullScreenElement(true);
}
new_element->SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(