mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 02:52:12 +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:
parent
d328ad2023
commit
b88bbe4fc8
|
@ -39,6 +39,7 @@
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWebHistory>
|
#include <QWebHistory>
|
||||||
|
#include <QWebFrame>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
@ -467,10 +468,12 @@ void TabWidget::closeTab(int index, bool force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// window.beforeunload handling
|
// window.onbeforeunload handling
|
||||||
webView->load(QUrl());
|
if (!webView->page()->mainFrame()->evaluateJavaScript("window.onbeforeunload===null").toBool()) {
|
||||||
if (webView->url() != QUrl()) {
|
webView->load(QUrl());
|
||||||
return;
|
if (webView->url() != QUrl()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locationBars->removeWidget(webView->webTab()->locationBar());
|
m_locationBars->removeWidget(webView->webTab()->locationBar());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user