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

Fix some warnings in js scripts

This commit is contained in:
David Rosca 2016-12-27 16:51:01 +01:00
parent 8cfe4c4c5e
commit 95603f652d
2 changed files with 8 additions and 2 deletions

View File

@ -107,6 +107,8 @@ QString Scripts::setupFormObserver()
" }, true);" " }, true);"
"}" "}"
"" ""
"if (!document.documentElement) return;"
""
"for (var i = 0; i < document.forms.length; ++i)" "for (var i = 0; i < document.forms.length; ++i)"
" registerForm(document.forms[i]);" " registerForm(document.forms[i]);"
"" ""
@ -126,10 +128,12 @@ QString Scripts::setupFormObserver()
QString Scripts::setCss(const QString &css) QString Scripts::setCss(const QString &css)
{ {
QString source = QL1S("(function() {" QString source = QL1S("(function() {"
"var head = document.getElementsByTagName('head')[0];"
"if (!head) return;"
"var css = document.createElement('style');" "var css = document.createElement('style');"
"css.setAttribute('type', 'text/css');" "css.setAttribute('type', 'text/css');"
"css.appendChild(document.createTextNode('%1'));" "css.appendChild(document.createTextNode('%1'));"
"document.getElementsByTagName('head')[0].appendChild(css);" "head.appendChild(css);"
"})()"); "})()");
QString style = css; QString style = css;

View File

@ -78,13 +78,15 @@ WebScrollBarManager::WebScrollBarManager(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
m_scrollbarJs = QL1S("(function() {" m_scrollbarJs = QL1S("(function() {"
"var head = document.getElementsByTagName('head')[0];"
"if (!head) return;"
"var css = document.createElement('style');" "var css = document.createElement('style');"
"css.setAttribute('type', 'text/css');" "css.setAttribute('type', 'text/css');"
"var size = %1 / window.devicePixelRatio + 'px';" "var size = %1 / window.devicePixelRatio + 'px';"
"css.appendChild(document.createTextNode('" "css.appendChild(document.createTextNode('"
" body::-webkit-scrollbar{width:'+size+';height:'+size+';}" " body::-webkit-scrollbar{width:'+size+';height:'+size+';}"
"'));" "'));"
"document.getElementsByTagName('head')[0].appendChild(css);" "head.appendChild(css);"
"})()"); "})()");
loadSettings(); loadSettings();