summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-11-19 10:15:55 (GMT)
committeraxis <qt-info@nokia.com>2010-11-19 14:02:39 (GMT)
commitf234f248fa8f0d2bb74a14f5ee3cb489f256c0f2 (patch)
treec5a10ce71ad0b8f60e351ba5ffe8cb8aea091dba /src/3rdparty
parentab794fe3a0d2992d770c09527c479a563f21164e (diff)
downloadQt-f234f248fa8f0d2bb74a14f5ee3cb489f256c0f2.zip
Qt-f234f248fa8f0d2bb74a14f5ee3cb489f256c0f2.tar.gz
Qt-f234f248fa8f0d2bb74a14f5ee3cb489f256c0f2.tar.bz2
Fixed handling of QInputMethodEvents with nonzero replacementLength.
These types of events replace text that is already in the widget, but WebKit did not check for replacementLength at all. RevBy: Janne Koskinen Task: QT-4303 Task: https://bugs.webkit.org/show_bug.cgi?id=49787 AutoTest: Included
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp10
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp14
2 files changed, 22 insertions, 2 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index ff92f0b..d9a2cbe 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -1257,9 +1257,15 @@ 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 if (!ev->preeditString().isEmpty()) {
+ } else if (!ev->commitString().isEmpty()) {
+ editor->confirmComposition(ev->commitString());
+ }
+ if (!ev->preeditString().isEmpty()) {
QString preedit = ev->preeditString();
editor->setComposition(preedit, underlines, preedit.length(), 0);
}
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 55ee42a..b566365 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -1494,6 +1494,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"));
+ }
+
//ImhHiddenText
QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
page->event(&evpresPassword);