2011-03-29 Janne Koskinen <janne.p.koskinen@digia.com>
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 13:04:25 +0000 (13:04 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 13:04:25 +0000 (13:04 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Enterkey to go to Newline does not work in the text area(in HTML form)
        https://bugs.webkit.org/show_bug.cgi?id=33179

        Fixed newline generation from Qt::Key_Enter when editting text area using InputMethods.

        * WebCoreSupport/EditorClientQt.cpp:
        (WebCore::EditorClientQt::handleInputMethodKeydown):
        * tests/qwebpage/tst_qwebpage.cpp:
        (tst_QWebPage::inputMethods):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82238 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

index dc71087ef911306e6a7da6fbf9203ac7233ed15e..d95cdf4b8d6fd95a32e06cbba41b410c24272bdd 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-29  Janne Koskinen  <janne.p.koskinen@digia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Enterkey to go to Newline does not work in the text area(in HTML form)
+        https://bugs.webkit.org/show_bug.cgi?id=33179
+
+        Fixed newline generation from Qt::Key_Enter when editting text area using InputMethods.
+
+        * WebCoreSupport/EditorClientQt.cpp:
+        (WebCore::EditorClientQt::handleInputMethodKeydown):
+        * tests/qwebpage/tst_qwebpage.cpp:
+        (tst_QWebPage::inputMethods):
+
 2011-03-29  Andreas Kling  <kling@webkit.org>
 
         Reviewed by Simon Hausmann.
index 2df6f9a717726a6cf51b08885e1751c22c5525cd..f897e6cd5b49b4d5c81faa81e532be79397f6c30 100644 (file)
@@ -530,8 +530,20 @@ void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event)
 #endif // QT_NO_SHORTCUT
 }
 
-void EditorClientQt::handleInputMethodKeydown(KeyboardEvent*)
+void EditorClientQt::handleInputMethodKeydown(KeyboardEvent* event)
 {
+    const PlatformKeyboardEvent* kevent = event->keyEvent();
+    if (kevent->type() == PlatformKeyboardEvent::RawKeyDown) {
+        QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent());
+        switch (action) {
+        case QWebPage::InsertParagraphSeparator:
+        case QWebPage::InsertLineSeparator:
+            m_page->triggerAction(action);
+            break;
+        default:
+            break;
+        }
+    }
 }
 
 EditorClientQt::EditorClientQt(QWebPage* page)
index cfc181dfba78bbfde0adce6a283243ce607b49e7..d43b2de752cfa01ebae46b776bb8d88d0a0c2b3d 100644 (file)
@@ -2123,6 +2123,28 @@ void tst_QWebPage::inputMethods()
     clickOnPage(page, inputElement.geometry().center());
 
     QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
+
+    // START - Newline test for textarea
+    qApp->processEvents();
+    page->mainFrame()->setHtml("<html><body>" \
+                                            "<textarea rows='5' cols='1' id='input5' value=''/>" \
+                                            "</body></html>");
+    page->mainFrame()->evaluateJavaScript("var inputEle = document.getElementById('input5'); inputEle.focus(); inputEle.select();");
+    QKeyEvent keyEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
+    page->event(&keyEnter);
+    QList<QInputMethodEvent::Attribute> attribs;
+
+    QInputMethodEvent eventText("\n", attribs);
+    page->event(&eventText);
+
+    QInputMethodEvent eventText2("third line", attribs);
+    page->event(&eventText2);
+    qApp->processEvents();
+
+    QString inputValue2 = page->mainFrame()->evaluateJavaScript("document.getElementById('input5').value").toString();
+    QCOMPARE(inputValue2, QString("\n\nthird line"));
+    // END - Newline test for textarea
+
     delete container;
 }