From cbf66a807770ba6ea33493330775fd6be3d66d56 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 14 Apr 2022 15:12:23 -0400 Subject: [PATCH] views: Fix crash when clicking a draggable region (fixes issue #3311) --- libcef/browser/views/browser_view_view.h | 8 +++++++- patch/patches/chrome_runtime_views.patch | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libcef/browser/views/browser_view_view.h b/libcef/browser/views/browser_view_view.h index 955bd709e..bd47b9e0a 100644 --- a/libcef/browser/views/browser_view_view.h +++ b/libcef/browser/views/browser_view_view.h @@ -16,7 +16,13 @@ // CefViewView template. class WebViewEx : public views::WebView { public: - WebViewEx() : views::WebView(nullptr) {} + WebViewEx() : views::WebView(nullptr) { + // Mouse events on draggable regions will not be handled by the WebView. + // Avoid the resulting DCHECK in NativeViewHost::OnMousePressed by + // configuring the NativeViewHost not to process events via the view + // hierarchy. + holder()->SetCanProcessEventsWithinSubtree(false); + } }; class CefBrowserViewView diff --git a/patch/patches/chrome_runtime_views.patch b/patch/patches/chrome_runtime_views.patch index abe6e1f51..e52763759 100644 --- a/patch/patches/chrome_runtime_views.patch +++ b/patch/patches/chrome_runtime_views.patch @@ -397,6 +397,22 @@ index a6f15f3436bef..5e2ab8373458b 100644 int browser_view_width = vertical_layout_rect_.width(); bool toolbar_visible = delegate_->IsToolbarVisible(); int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; +diff --git chrome/browser/ui/views/frame/contents_web_view.cc chrome/browser/ui/views/frame/contents_web_view.cc +index 5f985efa03120..cd38b49974ecb 100644 +--- chrome/browser/ui/views/frame/contents_web_view.cc ++++ chrome/browser/ui/views/frame/contents_web_view.cc +@@ -24,6 +24,11 @@ + ContentsWebView::ContentsWebView(content::BrowserContext* browser_context) + : views::WebView(browser_context), + status_bubble_(nullptr) { ++ // Mouse events on draggable regions will not be handled by the WebView. ++ // Avoid the resulting DCHECK in NativeViewHost::OnMousePressed by ++ // configuring the NativeViewHost not to process events via the view ++ // hierarchy. ++ holder()->SetCanProcessEventsWithinSubtree(false); + } + + ContentsWebView::~ContentsWebView() { diff --git chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index 7475765f4b514..25c59d942782b 100644 --- chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc