Skip to content

Commit 3e833cb

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public: Fixed handling of QInputMethodEvents with nonzero replacementLength.
2 parents ab794fe + f234f24 commit 3e833cb

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,15 @@ void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
12571257
}
12581258
}
12591259

1260-
if (!ev->commitString().isEmpty())
1260+
if (renderTextControl && ev->replacementLength() > 0) {
1261+
renderTextControl->setSelectionStart(qMax(renderTextControl->selectionStart() + ev->replacementStart(), 0));
1262+
renderTextControl->setSelectionEnd(qMin(renderTextControl->selectionStart() + ev->replacementLength(), static_cast<int>(renderTextControl->text().length())));
1263+
// Commit regardless of whether commitString is empty, to get rid of selection.
12611264
editor->confirmComposition(ev->commitString());
1262-
else if (!ev->preeditString().isEmpty()) {
1265+
} else if (!ev->commitString().isEmpty()) {
1266+
editor->confirmComposition(ev->commitString());
1267+
}
1268+
if (!ev->preeditString().isEmpty()) {
12631269
QString preedit = ev->preeditString();
12641270
editor->setComposition(preedit, underlines, preedit.length(), 0);
12651271
}

src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,20 @@ void tst_QWebPage::inputMethods()
14941494
QCOMPARE(value, QString("QtWebKit"));
14951495
#endif
14961496

1497+
{
1498+
QList<QInputMethodEvent::Attribute> attributes;
1499+
QInputMethodEvent event(QString(), attributes);
1500+
event.setCommitString("XXX", 0, 0);
1501+
page->event(&event);
1502+
event.setCommitString(QString(), -2, 2); // Erase two characters.
1503+
page->event(&event);
1504+
event.setCommitString(QString(), -1, 1); // Erase one character.
1505+
page->event(&event);
1506+
variant = page->inputMethodQuery(Qt::ImSurroundingText);
1507+
value = variant.value<QString>();
1508+
QCOMPARE(value, QString("QtWebKit"));
1509+
}
1510+
14971511
//ImhHiddenText
14981512
QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
14991513
page->event(&evpresPassword);

0 commit comments

Comments
 (0)