Changeset 60958 in webkit


Ignore:
Timestamp:
Jun 10, 2010 8:34:05 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-10 Raine Makelainen <raine.makelainen@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Impossible to set input method hints based HTML5 input types
https://bugs.webkit.org/show_bug.cgi?id=40107

Helper methods for checking "tel", "number", "email",
and "url" input element types.

  • html/HTMLInputElement.h: (WebCore::HTMLInputElement::isTelephoneField): (WebCore::HTMLInputElement::isNumberField): (WebCore::HTMLInputElement::isEmailField): (WebCore::HTMLInputElement::isUrlField):

2010-06-10 Raine Makelainen <raine.makelainen@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Impossible to set input method hints based HTML5 input types
https://bugs.webkit.org/show_bug.cgi?id=40107

EditorClientQt to set input method hints for "number", "tel",
"email", and "url" HTML input elements.

Tests for HTML input elements and input method hints added for
QGraphicsWebView and QWebView.

  • WebCoreSupport/EditorClientQt.cpp: (WebCore::EditorClientQt::setInputMethodState):
  • tests/qgraphicswebview/resources/input_types.html: Added.
  • tests/qgraphicswebview/tst_qgraphicswebview.cpp: (GraphicsWebView::GraphicsWebView): (GraphicsWebView::fireMouseClick): (tst_QGraphicsWebView::focusInputTypes):
  • tests/qgraphicswebview/tst_qgraphicswebview.qrc: Added.
  • tests/qwebview/resources/input_types.html: Added.
  • tests/qwebview/tst_qwebview.cpp: (WebView::fireMouseClick): (tst_QWebView::focusInputTypes):
  • tests/qwebview/tst_qwebview.qrc:
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60957 r60958  
     12010-06-10  Raine Makelainen  <raine.makelainen@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Impossible to set input method hints based HTML5 input types
     6        https://bugs.webkit.org/show_bug.cgi?id=40107
     7
     8        Helper methods for checking "tel", "number", "email",
     9        and "url" input element types.
     10
     11        * html/HTMLInputElement.h:
     12        (WebCore::HTMLInputElement::isTelephoneField):
     13        (WebCore::HTMLInputElement::isNumberField):
     14        (WebCore::HTMLInputElement::isEmailField):
     15        (WebCore::HTMLInputElement::isUrlField):
     16
    1172010-06-10  Daniel Cheng  <dcheng@chromium.org>
    218
  • trunk/WebCore/html/HTMLInputElement.h

    r60419 r60958  
    102102    virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
    103103    virtual bool isPasswordField() const { return m_type == PASSWORD; }
     104    bool isTelephoneField() const { return m_type == TELEPHONE; }
     105    bool isNumberField() const { return m_type == NUMBER; }
     106    bool isEmailField() const { return m_type == EMAIL; }
     107    bool isUrlField() const { return m_type == URL; }
    104108
    105109    bool checked() const { return m_checked; }
  • trunk/WebKit/qt/ChangeLog

    r60949 r60958  
     12010-06-10  Raine Makelainen  <raine.makelainen@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Impossible to set input method hints based HTML5 input types
     6        https://bugs.webkit.org/show_bug.cgi?id=40107
     7
     8        EditorClientQt to set input method hints for "number", "tel",
     9        "email", and "url" HTML input elements.
     10
     11        Tests for HTML input elements and input method hints added for
     12        QGraphicsWebView and QWebView.
     13
     14        * WebCoreSupport/EditorClientQt.cpp:
     15        (WebCore::EditorClientQt::setInputMethodState):
     16        * tests/qgraphicswebview/resources/input_types.html: Added.
     17        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
     18        (GraphicsWebView::GraphicsWebView):
     19        (GraphicsWebView::fireMouseClick):
     20        (tst_QGraphicsWebView::focusInputTypes):
     21        * tests/qgraphicswebview/tst_qgraphicswebview.qrc: Added.
     22        * tests/qwebview/resources/input_types.html: Added.
     23        * tests/qwebview/tst_qwebview.cpp:
     24        (WebView::fireMouseClick):
     25        (tst_QWebView::focusInputTypes):
     26        * tests/qwebview/tst_qwebview.qrc:
     27
    1282010-06-10  Eric Seidel  <eric@webkit.org>
    229
  • trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp

    r60589 r60958  
    593593    if (webPageClient) {
    594594#if QT_VERSION >= 0x040600
    595         bool isPasswordField = false;
    596         if (!active) {
    597             // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag
    598             // for password fields. The Qt platform is responsible for determining which widget
    599             // will receive input method events for password fields.
    600             Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
    601             if (frame && frame->document() && frame->document()->focusedNode()) {
    602                 if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) {
    603                     HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
    604                     active = isPasswordField = inputElement->isPasswordField();
    605               }
     595        HTMLInputElement* inputElement = 0;
     596        Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
     597        if (frame && frame->document() && frame->document()->focusedNode())
     598            if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag))
     599                inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
     600
     601        if (inputElement) {
     602            if (!active) {
     603                // Setting the Qt::WA_InputMethodEnabled attribute true and Qt::ImhHiddenText flag
     604                // for password fields. The Qt platform is responsible for determining which widget
     605                // will receive input method events for password fields.
     606                active = inputElement->isPasswordField();
     607                webPageClient->setInputMethodHint(Qt::ImhHiddenText, active);
     608            } else {
     609                // Set input method hints for "number", "tel", "email", and "url" input elements.
     610                webPageClient->setInputMethodHint(Qt::ImhDialableCharactersOnly, inputElement->isTelephoneField());
     611                webPageClient->setInputMethodHint(Qt::ImhDigitsOnly, inputElement->isNumberField());
     612                webPageClient->setInputMethodHint(Qt::ImhEmailCharactersOnly, inputElement->isEmailField());
     613                webPageClient->setInputMethodHint(Qt::ImhUrlCharactersOnly, inputElement->isUrlField());
    606614            }
    607615        }
    608         webPageClient->setInputMethodHint(Qt::ImhHiddenText, isPasswordField);
     616
    609617#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
    610618        // disables auto-uppercase and predictive text for mobile devices
  • trunk/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

    r59378 r60958  
    2020#include "../util.h"
    2121#include <QtTest/QtTest>
     22#include <QGraphicsSceneMouseEvent>
    2223#include <QGraphicsView>
    2324#include <qgraphicswebview.h>
     
    3334    void crashOnViewlessWebPages();
    3435    void microFocusCoordinates();
     36    void focusInputTypes();
    3537};
    3638
     
    7678};
    7779
     80class GraphicsWebView : public QGraphicsWebView
     81{
     82    Q_OBJECT
     83
     84public:
     85    GraphicsWebView(QGraphicsItem* parent = 0): QGraphicsWebView(parent)
     86    {
     87    }
     88
     89    void fireMouseClick(QPointF point) {
     90        QGraphicsSceneMouseEvent presEv(QEvent::GraphicsSceneMousePress);
     91        presEv.setPos(point);
     92        presEv.setButton(Qt::LeftButton);
     93        presEv.setButtons(Qt::LeftButton);
     94        QGraphicsSceneMouseEvent relEv(QEvent::GraphicsSceneMouseRelease);
     95        relEv.setPos(point);
     96        relEv.setButton(Qt::LeftButton);
     97        relEv.setButtons(Qt::LeftButton);
     98        QGraphicsWebView::sceneEvent(&presEv);
     99        QGraphicsWebView::sceneEvent(&relEv);
     100    }
     101};
     102
    78103void tst_QGraphicsWebView::crashOnViewlessWebPages()
    79104{
     
    141166}
    142167
     168void tst_QGraphicsWebView::focusInputTypes()
     169{
     170    QWebPage* page = new QWebPage;
     171    GraphicsWebView* webView = new GraphicsWebView;
     172    webView->setPage( page );
     173    QGraphicsView* view = new QGraphicsView;
     174    QGraphicsScene* scene = new QGraphicsScene(view);
     175    view->setScene(scene);
     176    scene->addItem(webView);
     177    view->setGeometry(QRect(0,0,500,500));
     178    QCoreApplication::processEvents();
     179    QUrl url("qrc:///resources/input_types.html");
     180    page->mainFrame()->load(url);
     181    page->mainFrame()->setFocus();
     182
     183    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
     184
     185    // 'text' type
     186    webView->fireMouseClick(QPointF(20.0, 10.0));
     187#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
     188    QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase);
     189    QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText);
     190#else
     191    QVERIFY(webView->inputMethodHints() == Qt::ImhNone);
     192#endif
     193
     194    // 'password' field
     195    webView->fireMouseClick(QPointF(20.0, 60.0));
     196    QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText);
     197
     198    // 'tel' field
     199    webView->fireMouseClick(QPointF(20.0, 110.0));
     200    QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly);
     201
     202    // 'number' field
     203    webView->fireMouseClick(QPointF(20.0, 160.0));
     204    QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly);
     205
     206    // 'email' field
     207    webView->fireMouseClick(QPointF(20.0, 210.0));
     208    QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly);
     209
     210    // 'url' field
     211    webView->fireMouseClick(QPointF(20.0, 260.0));
     212    QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly);
     213
     214    delete webView;
     215    delete view;
     216}
     217
     218
    143219
    144220QTEST_MAIN(tst_QGraphicsWebView)
  • trunk/WebKit/qt/tests/qwebview/tst_qwebview.cpp

    r58141 r60958  
    3131#include <qwebframe.h>
    3232
    33 #include <QDebug>
    34 
    3533class tst_QWebView : public QObject
    3634{
     
    5048    void reusePage();
    5149    void microFocusCoordinates();
     50    void focusInputTypes();
    5251
    5352    void crashTests();
     53};
     54
     55class WebView : public QWebView
     56{
     57    Q_OBJECT
     58
     59public:
     60    void fireMouseClick(QPoint point) {
     61        QMouseEvent presEv(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
     62        QMouseEvent relEv(QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
     63        QWebView::mousePressEvent(&presEv);
     64        QWebView::mousePressEvent(&relEv);
     65    }
     66
    5467};
    5568
     
    231244}
    232245
     246void tst_QWebView::focusInputTypes()
     247{
     248    QWebPage* page = new QWebPage;
     249    WebView* webView = new WebView;
     250    webView->setPage( page );
     251
     252    QCoreApplication::processEvents();
     253    QUrl url("qrc:///resources/input_types.html");
     254    page->mainFrame()->load(url);
     255    page->mainFrame()->setFocus();
     256
     257    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
     258
     259    // 'text' type
     260    webView->fireMouseClick(QPoint(20, 10));
     261#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
     262    QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase);
     263    QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText);
     264#else
     265    QVERIFY(webView->inputMethodHints() == Qt::ImhNone);
     266#endif
     267
     268    // 'password' field
     269    webView->fireMouseClick(QPoint(20, 60));
     270    QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText);
     271
     272    // 'tel' field
     273    webView->fireMouseClick(QPoint(20, 110));
     274    QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly);
     275
     276    // 'number' field
     277    webView->fireMouseClick(QPoint(20, 160));
     278    QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly);
     279
     280    // 'email' field
     281    webView->fireMouseClick(QPoint(20, 210));
     282    QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly);
     283
     284    // 'url' field
     285    webView->fireMouseClick(QPoint(20, 260));
     286    QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly);
     287
     288    delete webView;
     289
     290}
     291
    233292QTEST_MAIN(tst_QWebView)
    234293#include "tst_qwebview.moc"
  • trunk/WebKit/qt/tests/qwebview/tst_qwebview.qrc

    r52444 r60958  
    33    <file>resources/index.html</file>
    44    <file>resources/frame_a.html</file>
     5    <file>resources/input_types.html</file>
    56</qresource>
    67</RCC>
Note: See TracChangeset for help on using the changeset viewer.