[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

hausmann at webkit.org hausmann at webkit.org
Wed Apr 7 23:23:30 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 5c7bd63c2476cff4c5cb9799782996c4292f0301
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 5 08:12:07 2009 +0000

    [Qt] Fix enabling of input method support on QGraphicsWebView.
    https://bugs.webkit.org/show_bug.cgi?id=30605
    
    Patch by Simon Hausmann <hausmann at webkit.org> on 2009-11-01
    Reviewed by Kenneth Christiansen.
    
    Instead of setting the unsupported widget attribute on the
    QGraphicsWidget in setInputMethodEnabled() set the
    ItemAcceptsInputMethod GraphicsItem flag directly.
    
    Changed the existing input method auto test to run once
    on a QWebView and once on a QGraphicsWebView.
    
    * Api/qgraphicswebview.cpp:
    (QGraphicsWebViewPrivate::setInputMethodEnabled):
    * tests/qwebpage/tst_qwebpage.cpp:
    (tst_QWebPage::inputMethods_data):
    (inputMethodHints):
    (inputMethodEnabled):
    (tst_QWebPage::inputMethods):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qgraphicswebview.cpp b/WebKit/qt/Api/qgraphicswebview.cpp
index a70772e..e1288bc 100644
--- a/WebKit/qt/Api/qgraphicswebview.cpp
+++ b/WebKit/qt/Api/qgraphicswebview.cpp
@@ -90,8 +90,9 @@ void QGraphicsWebViewPrivate::update(const QRect & dirtyRect)
 
 void QGraphicsWebViewPrivate::setInputMethodEnabled(bool enable)
 {
-    q->setAttribute(Qt::WA_InputMethodEnabled, enable);
+    q->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable);
 }
+
 #if QT_VERSION >= 0x040600
 void QGraphicsWebViewPrivate::setInputMethodHint(Qt::InputMethodHint hint, bool enable)
 {
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index f337416..e40c95c 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,25 @@
+2009-11-01  Simon Hausmann  <hausmann at webkit.org>
+
+        Reviewed by Kenneth Christiansen.
+
+        [Qt] Fix enabling of input method support on QGraphicsWebView.
+        https://bugs.webkit.org/show_bug.cgi?id=30605
+
+        Instead of setting the unsupported widget attribute on the
+        QGraphicsWidget in setInputMethodEnabled() set the 
+        ItemAcceptsInputMethod GraphicsItem flag directly.
+
+        Changed the existing input method auto test to run once
+        on a QWebView and once on a QGraphicsWebView.
+
+        * Api/qgraphicswebview.cpp:
+        (QGraphicsWebViewPrivate::setInputMethodEnabled):
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::inputMethods_data):
+        (inputMethodHints):
+        (inputMethodEnabled):
+        (tst_QWebPage::inputMethods):
+
 2009-11-04  Simon Hausmann  <hausmann at webkit.org>
 
         Reviewed by Kenneth Christiansen.
diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index 6cbe2b1..26690cb 100644
--- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -21,6 +21,9 @@
 
 #include <QtTest/QtTest>
 
+#include <qgraphicsscene.h>
+#include <qgraphicsview.h>
+#include <qgraphicswebview.h>
 #include <qwebelement.h>
 #include <qwebpage.h>
 #include <qwidget.h>
@@ -120,6 +123,7 @@ private slots:
     void testOptionalJSObjects();
     void testEnablePersistentStorage();
     void consoleOutput();
+    void inputMethods_data();
     void inputMethods();
     void defaultTextEncoding();
     void errorPageExtension();
@@ -1264,28 +1268,77 @@ void tst_QWebPage::frameAt()
     frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos());
 }
 
+void tst_QWebPage::inputMethods_data()
+{
+    QTest::addColumn<QString>("viewType");
+    QTest::newRow("QWebView") << "QWebView";
+    QTest::newRow("QGraphicsWebView") << "QGraphicsWebView";
+}
+
+static Qt::InputMethodHints inputMethodHints(QObject* object)
+{
+    if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+        return o->inputMethodHints();
+    else if (QWidget* w = qobject_cast<QWidget*>(object))
+        return w->inputMethodHints();
+    return Qt::InputMethodHints();
+}
+
+static bool inputMethodEnabled(QObject* object)
+{
+    if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+        return o->flags() & QGraphicsItem::ItemAcceptsInputMethod;
+    else if (QWidget* w = qobject_cast<QWidget*>(object))
+        return w->testAttribute(Qt::WA_InputMethodEnabled);
+    return false;
+}
+
 void tst_QWebPage::inputMethods()
 {
-    m_view->page()->mainFrame()->setHtml("<html><body>" \
+    QFETCH(QString, viewType);
+    QWebPage* page = new QWebPage;
+    QObject* view = 0;
+    QObject* container = 0;
+    if (viewType == "QWebView") {
+        QWebView* wv = new QWebView;
+        wv->setPage(page);
+        view = wv;
+        container = view;
+    } else if (viewType == "QGraphicsWebView") {
+        QGraphicsWebView* wv = new QGraphicsWebView;
+        wv->setPage(page);
+        view = wv;
+
+        QGraphicsView* gv = new QGraphicsView;
+        QGraphicsScene* scene = new QGraphicsScene(gv);
+        gv->setScene(scene);
+        scene->addItem(wv);
+        wv->setGeometry(QRect(0, 0, 500, 500));
+
+        container = gv;
+    } else
+        QVERIFY2(false, "Unknown view type");
+
+    page->mainFrame()->setHtml("<html><body>" \
                                             "<input type='text' id='input1' style='font-family: serif' value='' maxlength='20'/><br>" \
                                             "<input type='password'/>" \
                                             "</body></html>");
-    m_view->page()->mainFrame()->setFocus();
+    page->mainFrame()->setFocus();
 
-    QWebElementCollection inputs = m_view->page()->mainFrame()->documentElement().findAll("input");
+    QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input");
 
     QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
-    m_view->page()->event(&evpres);
+    page->event(&evpres);
     QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
-    m_view->page()->event(&evrel);
+    page->event(&evrel);
 
     //ImMicroFocus
-    QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus);
+    QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus);
     QRect focusRect = variant.toRect();
     QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft()));
 
     //ImFont
-    variant = m_view->page()->inputMethodQuery(Qt::ImFont);
+    variant = page->inputMethodQuery(Qt::ImFont);
     QFont font = variant.value<QFont>();
     QCOMPARE(QString("-webkit-serif"), font.family());
 
@@ -1294,45 +1347,45 @@ void tst_QWebPage::inputMethods()
     //Insert text.
     {
         QInputMethodEvent eventText("QtWebKit", inputAttributes);
-        QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged()));
-        m_view->page()->event(&eventText);
+        QSignalSpy signalSpy(page, SIGNAL(microFocusChanged()));
+        page->event(&eventText);
         QCOMPARE(signalSpy.count(), 0);
     }
 
     {
         QInputMethodEvent eventText("", inputAttributes);
         eventText.setCommitString(QString("QtWebKit"), 0, 0);
-        m_view->page()->event(&eventText);
+        page->event(&eventText);
     }
 
 #if QT_VERSION >= 0x040600
     //ImMaximumTextLength
-    variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength);
+    variant = page->inputMethodQuery(Qt::ImMaximumTextLength);
     QCOMPARE(20, variant.toInt());
 
     //Set selection
     inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant());
     QInputMethodEvent eventSelection("",inputAttributes);
-    m_view->page()->event(&eventSelection);
+    page->event(&eventSelection);
 
     //ImAnchorPosition
-    variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition);
+    variant = page->inputMethodQuery(Qt::ImAnchorPosition);
     int anchorPosition =  variant.toInt();
     QCOMPARE(anchorPosition, 3);
 
     //ImCursorPosition
-    variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition);
+    variant = page->inputMethodQuery(Qt::ImCursorPosition);
     int cursorPosition =  variant.toInt();
     QCOMPARE(cursorPosition, 5);
 
     //ImCurrentSelection
-    variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection);
+    variant = page->inputMethodQuery(Qt::ImCurrentSelection);
     QString selectionValue = variant.value<QString>();
     QCOMPARE(selectionValue, QString("eb"));
 #endif
 
     //ImSurroundingText
-    variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
     QString value = variant.value<QString>();
     QCOMPARE(value, QString("QtWebKit"));
 
@@ -1343,29 +1396,31 @@ void tst_QWebPage::inputMethods()
         QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant());
         attributes.append(newSelection);
         QInputMethodEvent event("composition", attributes);
-        m_view->page()->event(&event);
+        page->event(&event);
     }
 
     // A ongoing composition should not change the surrounding text before it is committed.
-    variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+    variant = page->inputMethodQuery(Qt::ImSurroundingText);
     value = variant.value<QString>();
     QCOMPARE(value, QString("QtWebKit"));
 #endif
 
     //ImhHiddenText
     QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
-    m_view->page()->event(&evpresPassword);
+    page->event(&evpresPassword);
     QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
-    m_view->page()->event(&evrelPassword);
+    page->event(&evrelPassword);
 
-    QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled));
+    QVERIFY(inputMethodEnabled(view));
 #if QT_VERSION >= 0x040600
-    QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText);
+    QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText);
 
-    m_view->page()->event(&evpres);
-    m_view->page()->event(&evrel);
-    QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText));
+    page->event(&evpres);
+    page->event(&evrel);
+    QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText));
 #endif
+
+    delete container;
 }
 
 // import a little DRT helper function to trigger the garbage collector

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list