diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index da599bfb4c421957545b3cce036dfa542430202f..a047b2be5688778271160e710f87270d11579897 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -125,6 +125,7 @@ ApplicationWindow { shortcut: "Ctrl+T" onTriggered: { tabs.createEmptyTab() + tabs.currentIndex = tabs.count - 1 addressBar.forceActiveFocus(); addressBar.selectAll(); } @@ -284,7 +285,7 @@ ApplicationWindow { function createEmptyTab() { var tab = addTab("", tabComponent) // We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately. - tabs.currentIndex = tabs.count - 1 + tab.active = true tab.title = Qt.binding(function() { return tab.item.title }) return tab } @@ -335,6 +336,10 @@ ApplicationWindow { if (!request.userInitiated) print("Warning: Blocked a popup window.") else if (request.destination == WebEngineView.NewViewInTab) { + var tab = tabs.createEmptyTab() + tabs.currentIndex = tabs.count - 1 + request.openIn(tab.item) + } else if (request.destination == WebEngineView.NewViewInBackgroundTab) { var tab = tabs.createEmptyTab() request.openIn(tab.item) } else if (request.destination == WebEngineView.NewViewInDialog) { diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index e0fb3d7d808052f343ae0bd6a94e426337ea73da..409514411c11fe7e87345a125ee156aef61a0c45 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -49,6 +49,7 @@ #include "web_engine_settings.h" #include "web_engine_visited_links_manager.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/invalidate_type.h" #include "content/public/browser/navigation_entry.h" @@ -60,6 +61,7 @@ #include "content/public/common/frame_navigate_params.h" #include "content/public/common/url_constants.h" #include "content/public/common/web_preferences.h" +#include "ui/events/latency_info.h" namespace QtWebEngineCore { @@ -115,9 +117,13 @@ void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* s void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) { + Q_UNUSED(source) WebContentsAdapter *newAdapter = createWindow(new_contents, disposition, initial_pos, user_gesture); if (was_blocked) *was_blocked = !newAdapter; + + if (content::RenderWidgetHostImpl *impl = content::RenderWidgetHostImpl::From(new_contents->GetRenderViewHost())) + impl->WasShown(ui::LatencyInfo()); } void WebContentsDelegateQt::CloseContents(content::WebContents *source) diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 85d400cafdafd7003e1d91f8da6b2eb66c462b37..72ccb128a3fb28a7d441ec1ab9ee235c54cfbcc3 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -559,7 +559,7 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent return; } - if (browserContextAdapter() != webContents->browserContextAdapter()) { + if (webContents->browserContextAdapter() && browserContextAdapter() != webContents->browserContextAdapter()) { qWarning("Can not adopt content from a different WebEngineProfile."); return; } diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml index 45fad8d9c4d932b8b63ed63c5065cb13246db192..e173080dd377de5d9a84250db12adf9ba8fde39e 100644 --- a/tests/quicktestbrowser/BrowserWindow.qml +++ b/tests/quicktestbrowser/BrowserWindow.qml @@ -128,6 +128,7 @@ ApplicationWindow { shortcut: "Ctrl+T" onTriggered: { tabs.createEmptyTab() + tabs.currentIndex = tabs.count - 1 addressBar.forceActiveFocus(); addressBar.selectAll(); } @@ -299,7 +300,7 @@ ApplicationWindow { function createEmptyTab() { var tab = addTab("", tabComponent) // We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately. - tabs.currentIndex = tabs.count - 1 + tab.active = true tab.title = Qt.binding(function() { return tab.item.title }) return tab } @@ -374,6 +375,10 @@ ApplicationWindow { if (!request.userInitiated) print("Warning: Blocked a popup window.") else if (request.destination == WebEngineView.NewViewInTab) { + var tab = tabs.createEmptyTab() + tabs.currentIndex = tabs.count - 1 + request.openIn(tab.item.webView) + } else if (request.destination == WebEngineView.NewViewInBackgroundTab) { var tab = tabs.createEmptyTab() request.openIn(tab.item.webView) } else if (request.destination == WebEngineView.NewViewInDialog) {