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

Tweaked Click2Flash replacing script.

- it now creates temporary empty element that has the same size and
  occupies the same position as original flash object
This commit is contained in:
nowrep 2012-04-17 15:11:26 +02:00
parent e204af30c6
commit 2c4b6e3d42
5 changed files with 31 additions and 21 deletions

View File

@ -123,9 +123,10 @@ void BookmarksWidget::toggleSpeedDial()
void BookmarksWidget::showAt(QWidget* _parent)
{
show();
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
move((p.x() + _parent->width()) - width(), p.y() + _parent->height());
show();
}
BookmarksWidget::~BookmarksWidget()

View File

@ -240,20 +240,18 @@ void ClickToFlash::load()
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;
var qz_c2f_clone = this.cloneNode(true);
var qz_c2f_parentNode = this.parentNode;
var qz_c2f_substituteElement = document.createElement(this.tagName);
this.parentNode.removeChild(this);
qz_c2f_substituteElement.width = this.width;
qz_c2f_substituteElement.height = this.height;
setTimeout(function(){
if(qz_c2f_nextSibling) {
qz_c2f_parentNode.insertBefore(qz_c2f_clone,qz_c2f_nextSibling);
}
else {
qz_c2f_parentNode.appendChild(qz_c2f_clone);
}
}, 250);
this.parentNode.replaceChild(qz_c2f_substituteElement, this);
setTimeout(function(){
qz_c2f_parentNode.replaceChild(qz_c2f_clone, qz_c2f_substituteElement);
}, 250);
*/
@ -264,10 +262,10 @@ void ClickToFlash::load()
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);}},250);";
"var qz_c2f_substituteElement=document.createElement(this.tagName);"
"qz_c2f_substituteElement.width=this.width;qz_c2f_substituteElement.height=this.height;"
"this.parentNode.replaceChild(qz_c2f_substituteElement,this);setTimeout(function(){"
"qz_c2f_parentNode.replaceChild(qz_c2f_clone,qz_c2f_substituteElement);},250);";
m_element.evaluateJavaScript(js);
}

View File

@ -31,6 +31,10 @@ WebPluginFactory::WebPluginFactory(WebPage* page)
QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const
{
if (url.isEmpty()) {
return 0;
}
QString mime = mimeType.trimmed(); //Fixing bad behaviour when mimeType contains spaces
if (mime.isEmpty()) {
if (url.toString().endsWith(".swf")) {
@ -43,7 +47,7 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons
if (mime != "application/x-shockwave-flash") {
if (mime != "application/futuresplash" && mime != "application/x-java-applet") {
qDebug() << "WebPluginFactory::create missing mimeType handler for: " << mime;
qDebug() << "WebPluginFactory::create creating object of mimeType : " << mime;
}
return 0;
}

View File

@ -74,9 +74,15 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
void RSSWidget::showAt(QWidget* _parent)
{
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
move((p.x() + _parent->width() - width()), p.y() + _parent->height());
show();
const QPoint &widgetPos = _parent->mapToGlobal(QPoint(0, 0));
QPoint newPos;
newPos.setX(widgetPos.x() + _parent->width() - width());
newPos.setY(widgetPos.y() + _parent->height());
move(newPos);
}
void RSSWidget::addRss()

View File

@ -88,9 +88,10 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
void SiteInfoWidget::showAt(QWidget* _parent)
{
show();
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
move(p.x(), p.y() + _parent->height());
show();
}
SiteInfoWidget::~SiteInfoWidget()