diff options
author | Janne Koskinen <janne.p.koskinen@digia.com> | 2010-11-23 09:00:29 (GMT) |
---|---|---|
committer | Janne Koskinen <janne.p.koskinen@digia.com> | 2010-11-23 09:00:29 (GMT) |
commit | 9d9ecb86b80a57e5dcfafb71dc289ca62f64371a (patch) | |
tree | 042793f4283c96c8520efea7d1f4a6177dbfa45e | |
parent | a9467c8542ff745471e077ac8be554d3a0087e4a (diff) | |
parent | 7e28274421e2df5ff1798a74450fc07c4c366e9c (diff) | |
download | Qt-9d9ecb86b80a57e5dcfafb71dc289ca62f64371a.zip Qt-9d9ecb86b80a57e5dcfafb71dc289ca62f64371a.tar.gz Qt-9d9ecb86b80a57e5dcfafb71dc289ca62f64371a.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 38 | ||||
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 14 |
2 files changed, 35 insertions, 17 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 9b97c8b..5bb3c57 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1351,26 +1351,30 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev) } } - if (!ev->commitString().isEmpty()) + if (renderTextControl && ev->replacementLength() > 0) { + renderTextControl->setSelectionStart(qMax(renderTextControl->selectionStart() + ev->replacementStart(), 0)); + renderTextControl->setSelectionEnd(qMin(renderTextControl->selectionStart() + ev->replacementLength(), static_cast<int>(renderTextControl->text().length()))); + // Commit regardless of whether commitString is empty, to get rid of selection. editor->confirmComposition(ev->commitString()); - else { - // 1. empty preedit with a selection attribute, and start/end of 0 cancels composition - // 2. empty preedit with a selection attribute, and start/end of non-0 updates selection of current preedit text - // 3. populated preedit with a selection attribute, and start/end of 0 or non-0 updates selection of supplied preedit text - // 4. otherwise event is updating supplied pre-edit text - QString preedit = ev->preeditString(); + } else if (!ev->commitString().isEmpty()) { + editor->confirmComposition(ev->commitString()); + } + // 1. empty preedit with a selection attribute, and start/end of 0 cancels composition + // 2. empty preedit with a selection attribute, and start/end of non-0 updates selection of current preedit text + // 3. populated preedit with a selection attribute, and start/end of 0 or non-0 updates selection of supplied preedit text + // 4. otherwise event is updating supplied pre-edit text + QString preedit = ev->preeditString(); #if QT_VERSION >= 0x040600 - if (hasSelection) { - QString text = (renderTextControl) ? QString(renderTextControl->text()) : QString(); - if (preedit.isEmpty() && selection.start + selection.length > 0) - preedit = text; - editor->setComposition(preedit, underlines, - (selection.length < 0) ? selection.start + selection.length : selection.start, - (selection.length < 0) ? selection.start : selection.start + selection.length); - } else + if (hasSelection) { + QString text = (renderTextControl) ? QString(renderTextControl->text()) : QString(); + if (preedit.isEmpty() && selection.start + selection.length > 0) + preedit = text; + editor->setComposition(preedit, underlines, + (selection.length < 0) ? selection.start + selection.length : selection.start, + (selection.length < 0) ? selection.start : selection.start + selection.length); + } else #endif - editor->setComposition(preedit, underlines, preedit.length(), 0); - } + editor->setComposition(preedit, underlines, preedit.length(), 0); ev->accept(); } diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index b7ffb8a..31cf277 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -1502,6 +1502,20 @@ void tst_QWebPage::inputMethods() QCOMPARE(value, QString("QtWebKit")); #endif + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event(QString(), attributes); + event.setCommitString("XXX", 0, 0); + page->event(&event); + event.setCommitString(QString(), -2, 2); // Erase two characters. + page->event(&event); + event.setCommitString(QString(), -1, 1); // Erase one character. + page->event(&event); + variant = page->inputMethodQuery(Qt::ImSurroundingText); + value = variant.value<QString>(); + QCOMPARE(value, QString("QtWebKit")); + } + // Cancel current composition first inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); QInputMethodEvent eventSelection4("", inputAttributes); |