mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
212 lines
9.2 KiB
Diff
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 b1689844282d6..a4288bf5d3ba2 100644
|
|
--- third_party/blink/public/web/web_view.h
|
|
+++ third_party/blink/public/web/web_view.h
|
|
@@ -344,6 +344,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;
|
|
@@ -486,6 +487,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 1af1fa035b3da..f92d9b70fbd32 100644
|
|
--- third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
+++ third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
@@ -257,8 +257,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 {
|
|
@@ -615,6 +620,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 06f7cf79b4526..e0d395867f552 100644
|
|
--- third_party/blink/renderer/core/exported/web_view_impl.h
|
|
+++ third_party/blink/renderer/core/exported/web_view_impl.h
|
|
@@ -140,7 +140,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 de39a688207f8..41e5ffcfd5e09 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"
|
|
@@ -1922,8 +1924,9 @@ void LocalDOMWindow::moveBy(int x, int y) const {
|
|
return;
|
|
}
|
|
|
|
- if (IsPictureInPictureWindow())
|
|
+ if (IsPictureInPictureWindow() && !MovePictureInPictureEnabled()) {
|
|
return;
|
|
+ }
|
|
|
|
LocalFrame* frame = GetFrame();
|
|
Page* page = frame->GetPage();
|
|
@@ -1943,8 +1946,9 @@ void LocalDOMWindow::moveTo(int x, int y) const {
|
|
return;
|
|
}
|
|
|
|
- if (IsPictureInPictureWindow())
|
|
+ if (IsPictureInPictureWindow() && !MovePictureInPictureEnabled()) {
|
|
return;
|
|
+ }
|
|
|
|
LocalFrame* frame = GetFrame();
|
|
Page* page = frame->GetPage();
|
|
@@ -1967,7 +1971,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");
|
|
@@ -1995,7 +2000,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");
|
|
@@ -2464,6 +2470,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 615d1851fa041..a97811623a2e2 100644
|
|
--- third_party/blink/renderer/core/frame/local_dom_window.h
|
|
+++ third_party/blink/renderer/core/frame/local_dom_window.h
|
|
@@ -566,6 +566,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;
|
|
|
|
@@ -668,6 +673,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 e3888bb31414a..78dfff2048a67 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);
|
|
}
|
|
|