Changeset 60958 in webkit
- Timestamp:
- Jun 10, 2010 8:34:05 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60957 r60958 1 2010-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 1 17 2010-06-10 Daniel Cheng <dcheng@chromium.org> 2 18 -
trunk/WebCore/html/HTMLInputElement.h
r60419 r60958 102 102 virtual bool isInputTypeHidden() const { return m_type == HIDDEN; } 103 103 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; } 104 108 105 109 bool checked() const { return m_checked; } -
trunk/WebKit/qt/ChangeLog
r60949 r60958 1 2010-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 1 28 2010-06-10 Eric Seidel <eric@webkit.org> 2 29 -
trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
r60589 r60958 593 593 if (webPageClient) { 594 594 #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()); 606 614 } 607 615 } 608 webPageClient->setInputMethodHint(Qt::ImhHiddenText, isPasswordField); 616 609 617 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) 610 618 // disables auto-uppercase and predictive text for mobile devices -
trunk/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
r59378 r60958 20 20 #include "../util.h" 21 21 #include <QtTest/QtTest> 22 #include <QGraphicsSceneMouseEvent> 22 23 #include <QGraphicsView> 23 24 #include <qgraphicswebview.h> … … 33 34 void crashOnViewlessWebPages(); 34 35 void microFocusCoordinates(); 36 void focusInputTypes(); 35 37 }; 36 38 … … 76 78 }; 77 79 80 class GraphicsWebView : public QGraphicsWebView 81 { 82 Q_OBJECT 83 84 public: 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 78 103 void tst_QGraphicsWebView::crashOnViewlessWebPages() 79 104 { … … 141 166 } 142 167 168 void 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 143 219 144 220 QTEST_MAIN(tst_QGraphicsWebView) -
trunk/WebKit/qt/tests/qwebview/tst_qwebview.cpp
r58141 r60958 31 31 #include <qwebframe.h> 32 32 33 #include <QDebug>34 35 33 class tst_QWebView : public QObject 36 34 { … … 50 48 void reusePage(); 51 49 void microFocusCoordinates(); 50 void focusInputTypes(); 52 51 53 52 void crashTests(); 53 }; 54 55 class WebView : public QWebView 56 { 57 Q_OBJECT 58 59 public: 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 54 67 }; 55 68 … … 231 244 } 232 245 246 void 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 233 292 QTEST_MAIN(tst_QWebView) 234 293 #include "tst_qwebview.moc" -
trunk/WebKit/qt/tests/qwebview/tst_qwebview.qrc
r52444 r60958 3 3 <file>resources/index.html</file> 4 4 <file>resources/frame_a.html</file> 5 <file>resources/input_types.html</file> 5 6 </qresource> 6 7 </RCC>
Note: See TracChangeset
for help on using the changeset viewer.