- Revision
- 115801
- Author
- [email protected]
- Date
- 2012-05-02 01:10:38 -0700 (Wed, 02 May 2012)
Log Message
[Qt] QQuickWebView does not allow for input from virtual keyboard
https://bugs.webkit.org/show_bug.cgi?id=85350
Reviewed by Kenneth Christiansen.
It is necessary to set the ItemAcceptsInputMethod flag on the QQuickWebView if we have editable
content, in order for the input method to recognize that we can handle input method events.
Analyzed by Michael BrĂ¼ning.
* UIProcess/API/qt/qquickwebview.cpp: Add simple hook for executing JS as private C++ API.
(JSCallbackClosure):
(_javascript_Callback):
(QQuickWebView::runJavaScriptInMainFrame):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/tests/html/inputmethod.html: Added.
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
(tst_QQuickWebView):
(tst_QQuickWebView::runJavaScript): Simple helper for running JS.
(tst_QQuickWebView::inputMethod): Added simple test for ItemAcceptsInputMethod toggling.
* UIProcess/qt/QtWebPageEventHandler.cpp:
(WebKit::QtWebPageEventHandler::updateTextInputState): Set ItemAcceptsInputMethod as soon as we
have editable content.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (115800 => 115801)
--- trunk/Source/WebKit2/ChangeLog 2012-05-02 07:58:30 UTC (rev 115800)
+++ trunk/Source/WebKit2/ChangeLog 2012-05-02 08:10:38 UTC (rev 115801)
@@ -1,3 +1,29 @@
+2012-05-02 Simon Hausmann <[email protected]>
+
+ [Qt] QQuickWebView does not allow for input from virtual keyboard
+ https://bugs.webkit.org/show_bug.cgi?id=85350
+
+ Reviewed by Kenneth Christiansen.
+
+ It is necessary to set the ItemAcceptsInputMethod flag on the QQuickWebView if we have editable
+ content, in order for the input method to recognize that we can handle input method events.
+
+ Analyzed by Michael BrĂ¼ning.
+
+ * UIProcess/API/qt/qquickwebview.cpp: Add simple hook for executing JS as private C++ API.
+ (JSCallbackClosure):
+ (_javascript_Callback):
+ (QQuickWebView::runJavaScriptInMainFrame):
+ * UIProcess/API/qt/qquickwebview_p.h:
+ * UIProcess/API/qt/tests/html/inputmethod.html: Added.
+ * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
+ (tst_QQuickWebView):
+ (tst_QQuickWebView::runJavaScript): Simple helper for running JS.
+ (tst_QQuickWebView::inputMethod): Added simple test for ItemAcceptsInputMethod toggling.
+ * UIProcess/qt/QtWebPageEventHandler.cpp:
+ (WebKit::QtWebPageEventHandler::updateTextInputState): Set ItemAcceptsInputMethod as soon as we
+ have editable content.
+
2012-05-01 Anders Carlsson <[email protected]>
inspectorReallyUsesWebKitUserInterface should be more robust against missing files
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (115800 => 115801)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-05-02 07:58:30 UTC (rev 115800)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-05-02 08:10:38 UTC (rev 115801)
@@ -1635,4 +1635,25 @@
d->setZoomFactor(factor);
}
+struct JSCallbackClosure {
+ QPointer<QObject> receiver;
+ QByteArray method;
+};
+
+static void _javascript_Callback(WKSerializedScriptValueRef, WKErrorRef, void* context)
+{
+ JSCallbackClosure* closure = reinterpret_cast<JSCallbackClosure*>(context);
+ QMetaObject::invokeMethod(closure->receiver, closure->method);
+ delete closure;
+}
+
+void QQuickWebView::runJavaScriptInMainFrame(const QString &script, QObject *receiver, const char *method)
+{
+ Q_D(QQuickWebView);
+ JSCallbackClosure* closure = new JSCallbackClosure;
+ closure->receiver = receiver;
+ closure->method = method;
+ d->webPageProxy.get()->runJavaScriptInMainFrame(script, ScriptValueCallback::create(closure, _javascript_Callback));
+}
+
#include "moc_qquickwebview_p.cpp"
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (115800 => 115801)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-05-02 07:58:30 UTC (rev 115800)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-05-02 08:10:38 UTC (rev 115801)
@@ -147,6 +147,7 @@
// Private C++-only API.
qreal zoomFactor() const;
void setZoomFactor(qreal);
+ void runJavaScriptInMainFrame(const QString& script, QObject* receiver, const char* method);
public Q_SLOTS:
void loadHtml(const QString& html, const QUrl& baseUrl = QUrl(), const QUrl& unreachableUrl = QUrl());
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html (0 => 115801)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/html/inputmethod.html 2012-05-02 08:10:38 UTC (rev 115801)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<title>Basic Page For Input Method Testing</title>
+</head>
+<body>
+<h1>Basic page</h1>
+<input id="inputField" />
+</body>
+</html>
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp (115800 => 115801)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp 2012-05-02 07:58:30 UTC (rev 115800)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp 2012-05-02 08:10:38 UTC (rev 115801)
@@ -57,10 +57,13 @@
void titleUpdate();
void transparentWebViews();
+ void inputMethod();
+
private:
void prepareWebViewComponent();
inline QQuickWebView* newWebView();
inline QQuickWebView* webView() const;
+ void runJavaScript(const QString& script);
QScopedPointer<TestWindow> m_window;
QScopedPointer<QQmlComponent> m_component;
};
@@ -106,6 +109,13 @@
return static_cast<QQuickWebView*>(m_window->webView.data());
}
+void tst_QQuickWebView::runJavaScript(const QString &script)
+{
+ QEventLoop loop;
+ webView()->runJavaScriptInMainFrame(script, &loop, "quit");
+ loop.exec();
+}
+
void tst_QQuickWebView::accessPage()
{
QQuickWebPage* const pageDirectAccess = webView()->page();
@@ -363,6 +373,19 @@
// FIXME: test actual rendering results; https://bugs.webkit.org/show_bug.cgi?id=80609.
}
+void tst_QQuickWebView::inputMethod()
+{
+ QQuickWebView* view = webView();
+ view->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/inputmethod.html")));
+ QVERIFY(waitForLoadSucceeded(view));
+
+ QVERIFY(!view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
+ runJavaScript("document.getElementById('inputField').focus();");
+ QVERIFY(view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
+ runJavaScript("document.getElementById('inputField').blur();");
+ QVERIFY(!view->flags().testFlag(QQuickItem::ItemAcceptsInputMethod));
+}
+
void tst_QQuickWebView::scrollRequest()
{
webView()->setSize(QSizeF(300, 400));
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp (115800 => 115801)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2012-05-02 07:58:30 UTC (rev 115800)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2012-05-02 08:10:38 UTC (rev 115801)
@@ -409,6 +409,8 @@
const EditorState& editor = m_webPageProxy->editorState();
+ m_webView->setFlag(QQuickItem::ItemAcceptsInputMethod, editor.isContentEditable);
+
if (!m_webView->hasFocus())
return;