From 4db1405ffa66c33f3746baa09301cdc4e05cacc7 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 7 Jan 2010 13:25:23 +0100 Subject: Modifies the google chat example to use the DOM API Now that it's there, we might as well use it! Reviewed-by: Benjamin Poulain --- examples/webkit/googlechat/form.ui | 6 +++++ examples/webkit/googlechat/googlechat.cpp | 38 +++++++++++++++++-------------- examples/webkit/googlechat/googlechat.h | 3 ++- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/examples/webkit/googlechat/form.ui b/examples/webkit/googlechat/form.ui index 3b9fb82..4939ea1 100644 --- a/examples/webkit/googlechat/form.ui +++ b/examples/webkit/googlechat/form.ui @@ -48,6 +48,9 @@ Qt::AlignCenter + + true + @@ -160,6 +163,9 @@ Login + + true + diff --git a/examples/webkit/googlechat/googlechat.cpp b/examples/webkit/googlechat/googlechat.cpp index 12ea071..8eb033c 100644 --- a/examples/webkit/googlechat/googlechat.cpp +++ b/examples/webkit/googlechat/googlechat.cpp @@ -80,9 +80,8 @@ void GoogleChat::showError(const QString &msg) { showStatus(QString("Error: %1").arg(msg)); } -QString GoogleChat::evalJS(const QString &js) { - QWebFrame *frame = form.webView->page()->mainFrame(); - return frame->evaluateJavaScript(js).toString(); +QWebElement GoogleChat::document() const { + return form.webView->page()->mainFrame()->documentElement(); } void GoogleChat::adjustLoginButton() { @@ -112,9 +111,11 @@ void GoogleChat::doLogin() { showStatus("Logging in..."); QString userEmail = userName + "@gmail.com"; - evalJS(QString("document.getElementById('Email').value = \"%1\";").arg(userEmail)); - evalJS(QString("document.getElementById('Passwd').value = \"%1\";").arg(password)); - evalJS("document.getElementById('gaia_loginform').submit();"); + + document().findFirst("#Email").setAttribute("value", userEmail); + document().findFirst("#Passwd").setAttribute("value", password); + document().findFirst("#gaia_loginform").evaluateJavaScript("this.submit();"); + } void GoogleChat::initialPage(bool ok) { @@ -124,11 +125,12 @@ void GoogleChat::initialPage(bool ok) { } if (ok) { - QString s1 = evalJS("document.getElementById('Email').name"); - QString s2 = evalJS("document.getElementById('Passwd').name"); - QString s3 = evalJS("document.getElementById('gaia_loginform').id"); - if (s1 == "Email" && s2 == "Passwd" && s3 == "gaia_loginform") { + QWebElement email = document().findFirst("#Email"); + QWebElement passwd = document().findFirst("#Passwd"); + QWebElement loginForm = document().findFirst("#gaia_loginform"); + if (!email.isNull() && !passwd.isNull() && !loginForm.isNull()) { form.stackedWidget->setCurrentIndex(1); + form.userNameEdit->setFocus(); form.webView->disconnect(); return; } @@ -139,8 +141,8 @@ void GoogleChat::initialPage(bool ok) { void GoogleChat::hideElements() { - evalJS("var e = document.getElementsByClassName('footer-footer')[0]; e.parentElement.removeChild(e)"); - evalJS("var e = document.getElementsByClassName('title-bar-bg title-bar')[0]; e.parentElement.removeChild(e)"); + document().findFirst(".footer-footer").removeFromDocument(); + document().findFirst(".title-bar-bg .title-bar").removeFromDocument(); QTimer::singleShot(2000, this, SLOT(hideElements())); } @@ -152,16 +154,18 @@ void GoogleChat::loginPage(bool ok) { showError("Service unavailable"); } else { // check for any error message - QString c = evalJS("document.getElementsByClassName('errormsg').length"); - if (c == "0") { + + QWebElement e = document().findFirst(".errormsg"); + if (e.isNull()) { form.stackedWidget->setCurrentIndex(2); QTimer::singleShot(500, this, SLOT(hideElements())); return; } - QString err = "Unknown login failure."; - if (c == "1") { - err = evalJS("document.getElementsByClassName('errormsg')[0].textContent"); + QString err = "Unknown login failure."; + const QString errorMessage = e.toPlainText(); + if (!errorMessage.isEmpty()) { + err = errorMessage; err = err.simplified(); } showError(err); diff --git a/examples/webkit/googlechat/googlechat.h b/examples/webkit/googlechat/googlechat.h index 70f921e..617587a 100644 --- a/examples/webkit/googlechat/googlechat.h +++ b/examples/webkit/googlechat/googlechat.h @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include "ui_form.h" @@ -53,7 +54,7 @@ public: protected: void showStatus(const QString &msg); void showError(const QString &msg); - QString evalJS(const QString &js); + QWebElement document() const; private slots: -- cgit v0.12 From c603ca1c8e99dd0ec7e1d0b56b432d8eca21226a Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Mon, 11 Jan 2010 15:10:17 +0100 Subject: Make compile on HPUX Reviewed-by: axis --- src/corelib/kernel/qcore_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 328fd3d..0fd965b 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -42,7 +42,9 @@ #include "qcore_unix_p.h" #ifndef Q_OS_VXWORKS +# if !defined(Q_OS_HPUX) || defined(__ia64) # include +# endif # include #else # include -- cgit v0.12 From 06b513193715d5f442a6fd749667aed83944927a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 12 Jan 2010 21:57:13 +0100 Subject: QtWebKit changelog for Qt 4.6.1 From qtwebkit-4.6.0 to de77f8ee69c434bde9306c8f407ee2e443a00188 --- dist/changes-4.6.1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/changes-4.6.1 b/dist/changes-4.6.1 index 4aa4d5a..612aeda 100644 --- a/dist/changes-4.6.1 +++ b/dist/changes-4.6.1 @@ -101,6 +101,18 @@ QtOpenGL compressed textures if the appropriate extensions are present in the GL implementation. +QtwebKit +-------- + + - Fixed user agent string on Symbian (webkit.org/b/31961) + - QWebInspector: Don't disable when hiding (webkit.org/b/31851) + - Fix JavaScript prompt behaviour for empty/null strings (webkit.org/b/30914) + - Fixed lastIndexOf() on Symbian (webkit.org/b/31773) + - Fixed crash with Flash on Windows with MinGW + - Fixed wrapping of QObjects with recurring identity (webkit.org/b/31681) + - Fixed compilation with ICC + - Fixed assertion when dragging SVG images (webkit.org/b/32511) + QtScript -------- -- cgit v0.12