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

PageFormCompleter: Coding style

PageFormCompleter::getAllElementsFromPage doesn't need passing
QWebPage *
This commit is contained in:
nowrep 2013-11-15 19:35:06 +01:00
parent 2c1e4bd613
commit 2276a7f274
2 changed files with 9 additions and 5 deletions

View File

@ -49,7 +49,7 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
return formData; return formData;
} }
const QWebElementCollection &allForms = getAllElementsFromPage(m_page, "form"); const QWebElementCollection &allForms = getAllElementsFromPage("form");
// Find form that contains password value sent in data // Find form that contains password value sent in data
foreach (const QWebElement &formElement, allForms) { foreach (const QWebElement &formElement, allForms) {
@ -100,7 +100,7 @@ bool PageFormCompleter::completePage(const QByteArray &data) const
inputTypes << "text" << "password" << "email"; inputTypes << "text" << "password" << "email";
// Find all input elements in the page // Find all input elements in the page
const QWebElementCollection &inputs = getAllElementsFromPage(m_page, "input"); const QWebElementCollection &inputs = getAllElementsFromPage("input");
for (int i = 0; i < queryItems.count(); i++) { for (int i = 0; i < queryItems.count(); i++) {
const QString &key = queryItems.at(i).first; const QString &key = queryItems.at(i).first;
@ -230,12 +230,16 @@ PageFormCompleter::QueryItems PageFormCompleter::createQueryItems(QByteArray dat
return arguments; return arguments;
} }
QWebElementCollection PageFormCompleter::getAllElementsFromPage(QWebPage* page, const QString &selector) const QWebElementCollection PageFormCompleter::getAllElementsFromPage(const QString &selector) const
{ {
QWebElementCollection list; QWebElementCollection list;
if (!m_page) {
return list;
}
QList<QWebFrame*> frames; QList<QWebFrame*> frames;
frames.append(page->mainFrame()); frames.append(m_page->mainFrame());
while (!frames.isEmpty()) { while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst(); QWebFrame* frame = frames.takeFirst();
if (frame) { if (frame) {

View File

@ -55,7 +55,7 @@ private:
QByteArray convertWebKitFormBoundaryIfNecessary(const QByteArray &data) const; QByteArray convertWebKitFormBoundaryIfNecessary(const QByteArray &data) const;
QueryItem findUsername(const QWebElement &form) const; QueryItem findUsername(const QWebElement &form) const;
QueryItems createQueryItems(QByteArray data) const; QueryItems createQueryItems(QByteArray data) const;
QWebElementCollection getAllElementsFromPage(QWebPage* page, const QString &selector) const; QWebElementCollection getAllElementsFromPage(const QString &selector) const;
QWebPage* m_page; QWebPage* m_page;
}; };