electron/patches/chromium/webview_fullscreen.patch
electron-roller[bot] 5c7579ab1c
chore: bump chromium to 121.0.6147.0 (main) (#40523)
* chore: bump chromium in DEPS to 121.0.6128.0

* build: update patches

* refactor: remove instrumentation from extensions code

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5002404

* refactor: modernization of tabs_api

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4997031

* fix: add RecordHover and RecordDrag handlers

* build: add missing pdf files

* chore: bump chromium in DEPS to 121.0.6129.0

* chore: bump chromium in DEPS to 121.0.6131.0

* chore: update patches

* refactor: remove will_cause_resize from ExitFullscreen

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5031312

* chore: add missing std converter include

Before these were being inferred as std::string implicitly, not anymore
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5029573

* chore: Unwrap UserScriptList from unique_ptrs

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5005198

* refactor: add PDF internal id into PDF stream info

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4876972

* refactor: add metadata to view classes

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4994885

* chore: run lint --fix

* chore: update libc++ filenames

* chore: clean up menubar

* chore: update patches after main merge

* 5010979: Replace base::WStringPiece usage with std::wstring_view | https://chromium-review.googlesource.com/c/chromium/src/+/5010979

* chore: bump chromium in DEPS to 121.0.6142.0

* chore: update patches

* 4969574: Refactor NativeDesktopMediaList | https://chromium-review.googlesource.com/c/chromium/src/+/4969574

* 5031192: [blink] Create new blink test suite that doesn't create blink Isolate | https://chromium-review.googlesource.com/c/chromium/src/+/5031192

* chore: update v8/devtools patches

* 5040722: [base] Replace MakeFixedFlatTreeSorted with tag type overloads | https://chromium-review.googlesource.com/c/chromium/src/+/5040722

* 5026474: Add --generate-pdf-document-outline | https://chromium-review.googlesource.com/c/chromium/src/+/5026474

* 5024297: Change parameter of CheckMediaAccessPermission from GURL to URL::Origin | https://chromium-review.googlesource.com/c/chromium/src/+/5024297

* 5034217: [RWS] Remove CanonicalCookie::IsSameParty method | https://chromium-review.googlesource.com/c/chromium/src/+/5034217

* 5037192: Rewrite usage of RenderFrame::GetRoutingID | https://chromium-review.googlesource.com/c/chromium/src/+/5037192

* 5041802: Reland "Incorporate policy override for OOPPD feature" | https://chromium-review.googlesource.com/c/chromium/src/+/5041802

* chore: bump chromium in DEPS to 121.0.6143.0

* chore: bump chromium in DEPS to 121.0.6145.0

* chore: update chromium patches

* 5049986: Use std::unique_ptr for MenuItemView::submenu_ member. | https://chromium-review.googlesource.com/c/chromium/src/+/5049986

* 5041595: picture-in-picture: Add PictureInPictureOcclusionTracker | https://chromium-review.googlesource.com/c/chromium/src/+/5041595

* chore: update all patches

* chore: bump chromium in DEPS to 121.0.6147.0

* chore: update patches

* 5051069: Use base::FunctionRef for BrowserPluginGuestManager. | https://chromium-review.googlesource.com/c/chromium/src/+/5051069

* 5057330: [base] Remove base::Erase()/base::EraseIf() overloads for std::set | https://chromium-review.googlesource.com/c/chromium/src/+/5057330

* fixup! 5041802: Reland "Incorporate policy override for OOPPD feature" | https://chromium-review.googlesource.com/c/chromium/src/+/5041802

* 5017518: Remove PPAPI if NaCl is disabled | https://chromium-review.googlesource.com/c/chromium/src/+/5017518

* 5002232: [DevTools] Console Insights: move from build flag to Feature API | https://chromium-review.googlesource.com/c/chromium/src/+/5002232

* 4970322: [X11] Move utils into x11::Connection | https://chromium-review.googlesource.com/c/chromium/src/+/4970322

* 5048950: Let MenuModelAdapter::CreateMenu return a std::unique_ptr<>. | https://chromium-review.googlesource.com/c/chromium/src/+/5048950

* chore: update libcxx filenames

* use Context::Scope in RunScriptsAtDocument{Start,End}

* 4775128: content: Reuse CC instance for main frame navigations

https://chromium-review.googlesource.com/c/chromium/src/+/4775128

* also wrap WebWorkerObserver::ContextWillDestroy with Context::Scope

* set LIBCPP_HARDENING_MODE

https://chromium-review.googlesource.com/c/chromium/src/+/5014271

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
Co-authored-by: Keeley Hammond <vertedinde@electronjs.org>
Co-authored-by: VerteDinde <keeleymhammond@gmail.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
2023-11-28 13:40:12 -08: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 6b2c1207d3e226c095b84edf10e468d554b6ae1a..3181ca160963caf1ac9a3d9e8783ec8c66069b97 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -7384,6 +7384,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 c7f6211a680244a9f3c617b9a87125e305f37319..46e399e99018aa900a78fe35278bbd28bb2b188d 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3697,21 +3697,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
const 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) {
@@ -3847,7 +3851,7 @@ void WebContentsImpl::EnterFullscreenMode(
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::EnterFullscreenMode");
DCHECK(CanEnterFullscreenMode(requesting_frame, options));
DCHECK(requesting_frame->IsActive());
- DCHECK(ContainsOrIsFocusedWebContents());
+ DCHECK(ContainsOrIsFocusedWebContents() || IsGuest());
// When WebView is the `delegate_` we can end up with VisualProperties changes
// synchronously. Notify the view ahead so it can handle the transition.
diff --git a/third_party/blink/renderer/core/fullscreen/fullscreen.cc b/third_party/blink/renderer/core/fullscreen/fullscreen.cc
index ab0d67d69c96eefb0887edb4e69e2d5451595989..e2b61e9c2014c77e9a609aec6adbb988cc7fbbeb 100644
--- a/third_party/blink/renderer/core/fullscreen/fullscreen.cc
+++ b/third_party/blink/renderer/core/fullscreen/fullscreen.cc
@@ -111,7 +111,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(