Title: [103233] trunk/Source/WebKit2
- Revision
- 103233
- Author
- kenn...@webkit.org
- Date
- 2011-12-19 06:27:47 -0800 (Mon, 19 Dec 2011)
Log Message
First stab at upstreaming our virtual keyboard code
Reviewed by Simon Hausmann.
Add basic implementation of inputMethodEvent
* UIProcess/qt/QtWebPageEventHandler.cpp:
(QtWebPageEventHandler::handleEvent):
(QtWebPageEventHandler::inputMethodEvent):
* UIProcess/qt/QtWebPageEventHandler.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (103232 => 103233)
--- trunk/Source/WebKit2/ChangeLog 2011-12-19 14:01:00 UTC (rev 103232)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-19 14:27:47 UTC (rev 103233)
@@ -1,3 +1,16 @@
+2011-12-19 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ First stab at upstreaming our virtual keyboard code
+
+ Reviewed by Simon Hausmann.
+
+ Add basic implementation of inputMethodEvent
+
+ * UIProcess/qt/QtWebPageEventHandler.cpp:
+ (QtWebPageEventHandler::handleEvent):
+ (QtWebPageEventHandler::inputMethodEvent):
+ * UIProcess/qt/QtWebPageEventHandler.h:
+
2011-12-19 Simon Hausmann <simon.hausm...@nokia.com>
[Qt][WK2] Add support for modal event loop processing for WTR
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp (103232 => 103233)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2011-12-19 14:01:00 UTC (rev 103232)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2011-12-19 14:27:47 UTC (rev 103233)
@@ -32,8 +32,10 @@
#include <QMimeData>
#include <QtQuick/QQuickCanvas>
#include <QStyleHints>
+#include <QTextFormat>
#include <QTouchEvent>
#include <WebCore/DragData.h>
+#include <WebCore/Editor.h>
using namespace WebKit;
using namespace WebCore;
@@ -135,6 +137,9 @@
case QEvent::TouchUpdate:
touchEvent(static_cast<QTouchEvent*>(ev));
return true;
+ case QEvent::InputMethod:
+ inputMethodEvent(static_cast<QInputMethodEvent*>(ev));
+ return false; // Look at comment in qquickwebpage.cpp
}
// FIXME: Move all common event handling here.
@@ -311,6 +316,68 @@
m_interactionEngine = engine;
}
+void QtWebPageEventHandler::inputMethodEvent(QInputMethodEvent* ev)
+{
+ QString commit = ev->commitString();
+ QString composition = ev->preeditString();
+
+ // NOTE: We might want to handle events of one char as special
+ // and resend them as key events to make web site completion work.
+
+ int cursorPositionWithinComposition = 0;
+
+ Vector<CompositionUnderline> underlines;
+
+ for (int i = 0; i < ev->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute& attr = ev->attributes().at(i);
+ switch (attr.type) {
+ case QInputMethodEvent::TextFormat: {
+ if (composition.isEmpty())
+ break;
+
+ QTextCharFormat textCharFormat = attr.value.value<QTextFormat>().toCharFormat();
+ QColor qcolor = textCharFormat.underlineColor();
+ Color color = makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha());
+ int start = qMin(attr.start, (attr.start + attr.length));
+ int end = qMax(attr.start, (attr.start + attr.length));
+ underlines.append(CompositionUnderline(start, end, color, false));
+ break;
+ }
+ case QInputMethodEvent::Cursor:
+ if (attr.length)
+ cursorPositionWithinComposition = attr.start;
+ break;
+ // Selection is handled further down.
+ default: break;
+ }
+ }
+
+ if (composition.isEmpty()) {
+ int selectionStart = -1;
+ int selectionLength = 0;
+ for (int i = 0; i < ev->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute& attr = ev->attributes().at(i);
+ if (attr.type == QInputMethodEvent::Selection) {
+ selectionStart = attr.start;
+ selectionLength = attr.length;
+
+ ASSERT(selectionStart >= 0);
+ ASSERT(selectionLength >= 0);
+ break;
+ }
+ }
+
+ // FIXME: Confirm the composition here.
+ } else {
+ ASSERT(cursorPositionWithinComposition >= 0);
+ ASSERT(replacementStart >= 0);
+
+ // FIXME: Set the composition here.
+ }
+
+ ev->accept();
+}
+
void QtWebPageEventHandler::touchEvent(QTouchEvent* event)
{
#if ENABLE(TOUCH_EVENTS)
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h (103232 => 103233)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h 2011-12-19 14:01:00 UTC (rev 103232)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h 2011-12-19 14:27:47 UTC (rev 103233)
@@ -28,6 +28,7 @@
#include "WebPageProxy.h"
#include <QBasicTimer>
#include <QKeyEvent>
+#include <QInputMethodEvent>
#include <QTouchEvent>
#include <WKPage.h>
@@ -85,6 +86,7 @@
void timerEvent(QTimerEvent*);
void touchEvent(QTouchEvent*);
+ void inputMethodEvent(QInputMethodEvent*);
QPoint m_lastClick;
QBasicTimer m_clickTimer;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes