Files
cef/patch/patches/webkit_popups.patch
Marshall Greenblatt f8a746373e Update to Chromium version 138.0.7204.0 (#1465706)
Mac: Require Xcode 16.3 (16E140) and SDK 15.4 (24E241)
2025-06-03 14:20:59 -04:00

212 lines
9.2 KiB
Diff

diff --git third_party/blink/public/web/web_view.h third_party/blink/public/web/web_view.h
index 7c1eb9baabfb9..30761c0906087 100644
--- third_party/blink/public/web/web_view.h
+++ third_party/blink/public/web/web_view.h
@@ -343,6 +343,7 @@ class BLINK_EXPORT WebView {
// Sets whether select popup menus should be rendered by the browser.
static void SetUseExternalPopupMenus(bool);
+ virtual void SetUseExternalPopupMenusThisInstance(bool) = 0;
// Cancels and hides the current popup (datetime, select...) if any.
virtual void CancelPagePopup() = 0;
@@ -485,6 +486,11 @@ class BLINK_EXPORT WebView {
virtual void SetPageAttributionSupport(
network::mojom::AttributionSupport support) = 0;
+ // Sets whether to allow the use of JavaScript moveTo/By() and resizeTo/By()
+ // (without user activation) with Document picture-in-picture popups.
+ virtual void SetMovePictureInPictureEnabled(bool enabled) = 0;
+ virtual bool MovePictureInPictureEnabled() const = 0;
+
protected:
~WebView() = default;
};
diff --git third_party/blink/renderer/core/exported/web_view_impl.cc third_party/blink/renderer/core/exported/web_view_impl.cc
index feba9635b4066..c512154ada654 100644
--- third_party/blink/renderer/core/exported/web_view_impl.cc
+++ third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -258,8 +258,13 @@ void WebView::SetUseExternalPopupMenus(bool use_external_popup_menus) {
g_should_use_external_popup_menus = use_external_popup_menus;
}
-bool WebViewImpl::UseExternalPopupMenus() {
- return g_should_use_external_popup_menus;
+void WebViewImpl::SetUseExternalPopupMenusThisInstance(
+ bool use_external_popup_menus) {
+ should_use_external_popup_menus_ = use_external_popup_menus;
+}
+
+bool WebViewImpl::UseExternalPopupMenus() const {
+ return should_use_external_popup_menus_;
}
namespace {
@@ -616,6 +621,7 @@ WebViewImpl::WebViewImpl(
blink::ZoomFactorToZoomLevel(kMinimumBrowserZoomFactor)),
maximum_zoom_level_(
blink::ZoomFactorToZoomLevel(kMaximumBrowserZoomFactor)),
+ should_use_external_popup_menus_(g_should_use_external_popup_menus),
does_composite_(does_composite),
fullscreen_controller_(std::make_unique<FullscreenController>(this)),
page_base_background_color_(
diff --git third_party/blink/renderer/core/exported/web_view_impl.h third_party/blink/renderer/core/exported/web_view_impl.h
index eaa593b41ec2e..25328ea602056 100644
--- third_party/blink/renderer/core/exported/web_view_impl.h
+++ third_party/blink/renderer/core/exported/web_view_impl.h
@@ -139,7 +139,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
static HashSet<WebViewImpl*>& AllInstances();
// Returns true if popup menus should be rendered by the browser, false if
// they should be rendered by WebKit (which is the default).
- static bool UseExternalPopupMenus();
+ void SetUseExternalPopupMenusThisInstance(bool) override;
+ bool UseExternalPopupMenus() const;
// Returns whether frames under this WebView are backed by a compositor.
bool does_composite() const { return does_composite_; }
@@ -326,6 +327,13 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void UpdateColorProviders(
const ColorProviderColorMaps& color_provider_colors) override;
+ void SetMovePictureInPictureEnabled(bool enabled) override {
+ move_pip_enabled_ = enabled;
+ }
+ bool MovePictureInPictureEnabled() const override {
+ return move_pip_enabled_;
+ }
+
void DispatchPersistedPageshow(base::TimeTicks navigation_start);
void DispatchPagehide(mojom::blink::PagehideDispatch pagehide_dispatch);
void HookBackForwardCacheEviction(bool hook);
@@ -882,6 +890,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
float fake_page_scale_animation_page_scale_factor_ = 0.f;
bool fake_page_scale_animation_use_anchor_ = false;
+ bool should_use_external_popup_menus_;
+
float compositor_device_scale_factor_override_ = 0.f;
gfx::Transform device_emulation_transform_;
@@ -1011,6 +1021,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// CSS property.
bool supports_draggable_regions_ = false;
+ bool move_pip_enabled_ = false;
+
// All the registered observers.
base::ObserverList<WebViewObserver> observers_;
};
diff --git third_party/blink/renderer/core/frame/local_dom_window.cc third_party/blink/renderer/core/frame/local_dom_window.cc
index 23e8b0820df25..bcccbe2d61b96 100644
--- third_party/blink/renderer/core/frame/local_dom_window.cc
+++ third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -52,6 +52,7 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_picture_in_picture_window_options.h"
+#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/bindings/core/v8/binding_security.h"
#include "third_party/blink/renderer/bindings/core/v8/capture_source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/isolated_world_csp.h"
@@ -110,6 +111,7 @@
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/viewport_data.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
+#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_registry.h"
#include "third_party/blink/renderer/core/html/fenced_frame/fence.h"
#include "third_party/blink/renderer/core/html/forms/form_controller.h"
@@ -1960,8 +1962,9 @@ void LocalDOMWindow::moveBy(int x, int y) const {
return;
}
- if (IsPictureInPictureWindow())
+ if (IsPictureInPictureWindow() && !MovePictureInPictureEnabled()) {
return;
+ }
LocalFrame* frame = GetFrame();
Page* page = frame->GetPage();
@@ -1981,8 +1984,9 @@ void LocalDOMWindow::moveTo(int x, int y) const {
return;
}
- if (IsPictureInPictureWindow())
+ if (IsPictureInPictureWindow() && !MovePictureInPictureEnabled()) {
return;
+ }
LocalFrame* frame = GetFrame();
Page* page = frame->GetPage();
@@ -2005,7 +2009,8 @@ void LocalDOMWindow::resizeBy(int x,
}
if (IsPictureInPictureWindow()) {
- if (!LocalFrame::ConsumeTransientUserActivation(GetFrame())) {
+ if (!MovePictureInPictureEnabled() &&
+ !LocalFrame::ConsumeTransientUserActivation(GetFrame())) {
exception_state.ThrowDOMException(
DOMExceptionCode::kNotAllowedError,
"resizeBy() requires user activation in document picture-in-picture");
@@ -2033,7 +2038,8 @@ void LocalDOMWindow::resizeTo(int width,
}
if (IsPictureInPictureWindow()) {
- if (!LocalFrame::ConsumeTransientUserActivation(GetFrame())) {
+ if (!MovePictureInPictureEnabled() &&
+ !LocalFrame::ConsumeTransientUserActivation(GetFrame())) {
exception_state.ThrowDOMException(
DOMExceptionCode::kNotAllowedError,
"resizeTo() requires user activation in document picture-in-picture");
@@ -2502,6 +2508,12 @@ DOMWindow* LocalDOMWindow::openPictureInPictureWindow(
To<LocalDOMWindow>(result.frame->DomWindow());
pip_dom_window->SetIsPictureInPictureWindow();
+ if (WebLocalFrameImpl::FromFrame(entered_window->GetFrame())
+ ->View()
+ ->MovePictureInPictureEnabled()) {
+ pip_dom_window->SetMovePictureInPictureEnabled(true);
+ }
+
// Ensure that we're using the same compatibility mode as the opener document.
pip_dom_window->document()->SetCompatibilityMode(
entered_window->document()->GetCompatibilityMode());
diff --git third_party/blink/renderer/core/frame/local_dom_window.h third_party/blink/renderer/core/frame/local_dom_window.h
index 6856371c0729b..c851a94235306 100644
--- third_party/blink/renderer/core/frame/local_dom_window.h
+++ third_party/blink/renderer/core/frame/local_dom_window.h
@@ -582,6 +582,11 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
void SetIsPictureInPictureWindow();
+ void SetMovePictureInPictureEnabled(bool enabled) {
+ move_pip_enabled_ = enabled;
+ }
+ bool MovePictureInPictureEnabled() const { return move_pip_enabled_; }
+
// Return the viewport size including scrollbars.
gfx::Size GetViewportSize() const;
@@ -686,6 +691,8 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
// https://wicg.github.io/document-picture-in-picture/
bool is_picture_in_picture_window_ = false;
+ bool move_pip_enabled_ = false;
+
// The navigation id of a document is to identify navigation of special types
// like bfcache navigation or soft navigation. It changes when navigations
// of these types occur.
diff --git third_party/blink/renderer/core/page/chrome_client_impl.cc third_party/blink/renderer/core/page/chrome_client_impl.cc
index 72629f0c1af11..6100502a214ac 100644
--- third_party/blink/renderer/core/page/chrome_client_impl.cc
+++ third_party/blink/renderer/core/page/chrome_client_impl.cc
@@ -1002,7 +1002,7 @@ PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
HTMLSelectElement& select) {
NotifyPopupOpeningObservers();
- if (WebViewImpl::UseExternalPopupMenus()) {
+ if (web_view_->UseExternalPopupMenus()) {
return MakeGarbageCollected<ExternalPopupMenu>(frame, select);
}