summaryrefslogtreecommitdiff
path: root/patch/patches/webkit_popups.patch
blob: 378d9fe98db1f4ca9045ec67c96e7f864f80a918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
diff --git third_party/blink/public/web/web_view.h third_party/blink/public/web/web_view.h
index c8655d9270b81..d11450d22123a 100644
--- third_party/blink/public/web/web_view.h
+++ third_party/blink/public/web/web_view.h
@@ -340,6 +340,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;
diff --git third_party/blink/renderer/core/exported/web_view_impl.cc third_party/blink/renderer/core/exported/web_view_impl.cc
index 9ce7b0b20d0e9..52b7713d3d250 100644
--- third_party/blink/renderer/core/exported/web_view_impl.cc
+++ third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -249,8 +249,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 {
@@ -563,6 +568,7 @@ WebViewImpl::WebViewImpl(
       chrome_client_(MakeGarbageCollected<ChromeClientImpl>(this)),
       minimum_zoom_level_(PageZoomFactorToZoomLevel(kMinimumPageZoomFactor)),
       maximum_zoom_level_(PageZoomFactorToZoomLevel(kMaximumPageZoomFactor)),
+      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 ac623b8bd6c06..3e0bd1dd8ce3b 100644
--- third_party/blink/renderer/core/exported/web_view_impl.h
+++ third_party/blink/renderer/core/exported/web_view_impl.h
@@ -134,7 +134,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_; }
@@ -840,6 +841,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_;
 
diff --git third_party/blink/renderer/core/page/chrome_client_impl.cc third_party/blink/renderer/core/page/chrome_client_impl.cc
index c1e0b9eff83cb..333ad8c8e2990 100644
--- third_party/blink/renderer/core/page/chrome_client_impl.cc
+++ third_party/blink/renderer/core/page/chrome_client_impl.cc
@@ -916,7 +916,7 @@ bool ChromeClientImpl::HasOpenedPopup() const {
 PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
                                            HTMLSelectElement& select) {
   NotifyPopupOpeningObservers();
-  if (WebViewImpl::UseExternalPopupMenus())
+  if (web_view_->UseExternalPopupMenus())
     return MakeGarbageCollected<ExternalPopupMenu>(frame, select);
 
   DCHECK(RuntimeEnabledFeatures::PagePopupEnabled());