1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Scripts: Element.tagName can be lowercase

Closes #2616
This commit is contained in:
David Rosca 2018-02-22 12:59:01 +01:00
parent 97a1765b6c
commit c6aefbbed3
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 13 additions and 13 deletions

View File

@ -131,10 +131,10 @@ QString Scripts::setupFormObserver()
" registerForm(document.forms[i]);"
""
"var observer = new MutationObserver(function(mutations) {"
" for (var i = 0; i < mutations.length; ++i)"
" for (var j = 0; j < mutations[i].addedNodes.length; ++j)"
" if (mutations[i].addedNodes[j].tagName == 'FORM')"
" registerForm(mutations[i].addedNodes[j]);"
" for (var mutation of mutations)"
" for (var node of mutation.addedNodes)"
" if (node.tagName && node.tagName.toLowerCase() == 'form')"
" registerForm(node);"
"});"
"observer.observe(document.documentElement, { childList: true, subtree: true });"
""
@ -303,11 +303,11 @@ QString Scripts::getFormData(const QPointF &pos)
{
QString source = QL1S("(function() {"
"var e = document.elementFromPoint(%1, %2);"
"if (!e || e.tagName != 'INPUT')"
"if (!e || e.tagName.toLowerCase() != 'input')"
" return;"
"var fe = e.parentElement;"
"while (fe) {"
" if (fe.tagName == 'FORM')"
" if (fe.tagName.toLowerCase() == 'form')"
" break;"
" fe = fe.parentElement;"
"}"

View File

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2015-2017 David Rosca <nowrep@gmail.com>
* Copyright (C) 2015-2018 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
@ -33,12 +33,12 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
"if (!e)"
" return;"
"function isMediaElement(e) {"
" return e.tagName == 'AUDIO' || e.tagName == 'VIDEO';"
" return e.tagName.toLowerCase() == 'audio' || e.tagName.toLowerCase() == 'video';"
"}"
"function isEditableElement(e) {"
" if (e.isContentEditable)"
" return true;"
" if (e.tagName == 'INPUT' || e.tagName == 'TEXTAREA')"
" if (e.tagName.toLowerCase() == 'input' || e.tagName.toLowerCase() == 'textarea')"
" return e.getAttribute('readonly') != 'readonly';"
" return false;"
"}"
@ -62,16 +62,16 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
"};"
"var r = e.getBoundingClientRect();"
"res.boundingRect = [r.top, r.left, r.width, r.height];"
"if (e.tagName == 'IMG')"
"if (e.tagName.toLowerCase() == 'img')"
" res.imageUrl = e.getAttribute('src');"
"if (e.tagName == 'A') {"
"if (e.tagName.toLowerCase() == 'a') {"
" res.linkTitle = e.text;"
" res.linkUrl = e.getAttribute('href');"
"}"
"while (e) {"
" if (res.linkTitle == '' && e.tagName == 'A')"
" if (res.linkTitle == '' && e.tagName.toLowerCase() == 'a')"
" res.linkTitle = e.text;"
" if (res.linkUrl == '' && e.tagName == 'A')"
" if (res.linkUrl == '' && e.tagName.toLowerCase() == 'a')"
" res.linkUrl = e.getAttribute('href');"
" if (res.mediaUrl == '' && isMediaElement(e)) {"
" res.mediaUrl = e.currentSrc;"