1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

[WebView] Better window.onbeforeunload handling

Let's first quickly check whether window.onbeforeunload is not null,
and then try to load empty page.
Always loading empty page was quite heavy, because it needed to clear
all web contents, it also fired loading signals, ...
This commit is contained in:
nowrep 2014-02-10 18:38:47 +01:00
parent d328ad2023
commit b88bbe4fc8

View File

@ -39,6 +39,7 @@
#include <QStackedWidget>
#include <QMouseEvent>
#include <QWebHistory>
#include <QWebFrame>
#include <QClipboard>
#include <QFile>
#include <QScrollArea>
@ -467,10 +468,12 @@ void TabWidget::closeTab(int index, bool force)
}
}
// window.beforeunload handling
webView->load(QUrl());
if (webView->url() != QUrl()) {
return;
// window.onbeforeunload handling
if (!webView->page()->mainFrame()->evaluateJavaScript("window.onbeforeunload===null").toBool()) {
webView->load(QUrl());
if (webView->url() != QUrl()) {
return;
}
}
m_locationBars->removeWidget(webView->webTab()->locationBar());