1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Click2Flash: Fixed browser window flashing on loading some flash objects

- this bug so far occurs only on X11
- implemented asynchronous JavaScript element replacing
This commit is contained in:
nowrep 2012-04-15 15:44:08 +02:00
parent ba1cf804eb
commit 75a004499e
4 changed files with 44 additions and 9 deletions

View File

@ -229,9 +229,43 @@ void ClickToFlash::load()
qWarning("Click2Flash: Cannot find Flash object.");
}
else {
QWebElement substitute = m_element.clone();
substitute.setAttribute(QLatin1String("type"), "application/futuresplash");
m_element.replace(substitute);
/*
Old code caused sometimes flashing of the whole browser window and then somehow
ruined rendering of opacity effects, etc.. in the window on X11.
QWebElement substitute = m_element.clone();
substitute.setAttribute(QLatin1String("type"), "application/futuresplash");
m_element.replace(substitute);
So asynchronous JavaScript code is used to remove element from page and then substitute
it with unblocked Flash. The JavaScript code is:
var qz_c2f_clone = this.cloneNode(true);
var qz_c2f_parentNode = this.parentNode;
var qz_c2f_nextSibling = this.nextSibling;
this.parentNode.removeChild(this);
setTimeout(function(){
if(qz_c2f_nextSibling) {
qz_c2f_parentNode.insertBefore(qz_c2f_clone,qz_c2f_nextSibling);
}
else {
qz_c2f_parentNode.appendChild(qz_c2f_clone);
}
}, 0);
*/
m_element.setAttribute("type", "application/futuresplash");
QString js = "var qz_c2f_clone=this.cloneNode(true);var qz_c2f_parentNode=this.parentNode;"
"var qz_c2f_nextSibling=this.nextSibling;this.parentNode.removeChild(this);"
"setTimeout(function(){if(qz_c2f_nextSibling){"
"qz_c2f_parentNode.insertBefore(qz_c2f_clone,qz_c2f_nextSibling);}"
"else{qz_c2f_parentNode.appendChild(qz_c2f_clone);}"
"}, 0);";
m_element.evaluateJavaScript(js);
acceptedUrl = m_url;
acceptedArgNames = m_argumentNames;
@ -295,7 +329,3 @@ void ClickToFlash::showInfo()
qz_centerWidgetToParent(widg, m_page->view());
widg->show();
}
ClickToFlash::~ClickToFlash()
{
}

View File

@ -61,7 +61,6 @@ class QT_QUPZILLA_EXPORT ClickToFlash : public QWidget
public:
explicit ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames, const QStringList &argumentValues, WebPage* parentPage);
~ClickToFlash();
static bool isAlreadyAccepted(const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues);
@ -97,7 +96,6 @@ private:
static QStringList acceptedArgNames;
static QStringList acceptedArgValues;
WebPage* m_page;
};

View File

@ -432,6 +432,12 @@ QWebPage* WebPage::createWindow(QWebPage::WebWindowType type)
return new PopupWebPage(type, p_QupZilla);
}
QObject* WebPage::createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
{
qDebug() << Q_FUNC_INFO;
return pluginFactory()->create(classid, url, paramNames, paramValues);
}
void WebPage::addAdBlockRule(const QString &filter, const QUrl &url)
{
AdBlockedEntry entry;

View File

@ -100,6 +100,7 @@ private slots:
protected:
bool event(QEvent* event);
QWebPage* createWindow(QWebPage::WebWindowType type);
QObject* createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
private:
bool supportsExtension(Extension extension) const;