Workaround QWebEnginePage not scrolling to anchors when opened in background tab

Closes #2242
remotes/origin/falkon
David Rosca 9 years ago
parent 8940609a00
commit 486b8f4c7d
  1. 10
      src/lib/webengine/webpage.cpp
  2. 6
      src/lib/webengine/webpage.h

@ -90,6 +90,16 @@ WebPage::WebPage(QObject* parent)
connect(this, &QWebEnginePage::proxyAuthenticationRequired, this, [this](const QUrl &, QAuthenticator *auth, const QString &proxyHost) {
mApp->networkManager()->proxyAuthentication(proxyHost, auth, view());
});
// Workaround QWebEnginePage not scrolling to anchors when opened in background tab
m_contentsResizedConnection = connect(this, &QWebEnginePage::contentsSizeChanged, this, [this]() {
const QString fragment = url().fragment();
if (!fragment.isEmpty()) {
const QString src = QSL("var els = document.querySelectorAll(\"[name='%1']\"); if (els.length) els[0].scrollIntoView();");
runJavaScript(src.arg(fragment));
}
disconnect(m_contentsResizedConnection);
});
}
WebPage::~WebPage()

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -115,6 +115,8 @@ private:
bool m_blockAlerts;
bool m_secureStatus;
bool m_adjustingScheduled;
QMetaObject::Connection m_contentsResizedConnection;
};
#endif // WEBPAGE_H

Loading…
Cancel
Save