From c3d4f24720992a250565d256713896f83f1c568e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 27 Jan 2020 20:35:02 -0500 Subject: [PATCH] cefsimple: Fix sizing of popup windows with --use-views (see issue #2854) --- tests/cefsimple/simple_app.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/cefsimple/simple_app.cc b/tests/cefsimple/simple_app.cc index e9c8a5f0e..baa20d10f 100644 --- a/tests/cefsimple/simple_app.cc +++ b/tests/cefsimple/simple_app.cc @@ -54,6 +54,27 @@ class SimpleWindowDelegate : public CefWindowDelegate { DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate); }; +class SimpleBrowserViewDelegate : public CefBrowserViewDelegate { + public: + SimpleBrowserViewDelegate() {} + + bool OnPopupBrowserViewCreated(CefRefPtr browser_view, + CefRefPtr popup_browser_view, + bool is_devtools) OVERRIDE { + // Create a new top-level Window for the popup. It will show itself after + // creation. + CefWindow::CreateTopLevelWindow( + new SimpleWindowDelegate(popup_browser_view)); + + // We created the Window. + return true; + } + + private: + IMPLEMENT_REFCOUNTING(SimpleBrowserViewDelegate); + DISALLOW_COPY_AND_ASSIGN(SimpleBrowserViewDelegate); +}; + } // namespace SimpleApp::SimpleApp() {} @@ -91,7 +112,8 @@ void SimpleApp::OnContextInitialized() { if (use_views) { // Create the BrowserView. CefRefPtr browser_view = CefBrowserView::CreateBrowserView( - handler, url, browser_settings, nullptr, nullptr, nullptr); + handler, url, browser_settings, nullptr, nullptr, + new SimpleBrowserViewDelegate()); // Create the Window. It will show itself after creation. CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(browser_view));