QWebPage::inputMethodQuery(Qt::ImCursorPosition) returns the end index (renderTextControl->selectionEnd()) of a selection inside an input field instead of the current cursor position. QWebPage::inputMethodQuery(Qt::ImAnchorPosition) returns the start index (renderTextControl->selectionStart()) of a selection inside an input field instead of the anchor position. To be specific: In Webkit, the START and END indices always correspond to the left and right edges of a selection irrespective of the current cursor direction. The bug is that the current implementation of QWebPage::inputMethodQuery() assumes incorrectly that the anchor position is the START index and that the current cursor position always corresponds to the END index.
I am working on a patch for submission.
(In reply to comment #1) > I am working on a patch for submission. Please consider adding an auto-test to it.
(In reply to comment #2) > (In reply to comment #1) > > I am working on a patch for submission. > Please consider adding an auto-test to it. Thanks! Just to clarify: I am working on a patch (including the fix and auto-tests) for submission.
Created attachment 56206 [details] Prosposed patch to fix the return values for Qt::ImCursorPosition and Qt::ImAnchorPosition in QWebPage::inputMethodQuery() when the Editor doesn't have a composition. The patch fixes the issue of incorrect values been returned for Qt::ImCursorPosition and Qt::ImAnchorPosition in QWebPage::inputMethodQuery() when the Editor doesn't have a composition.
So is it not solvable when in Composition mode? Or not relevant? (Not a loaded question, genuinely don't know.)
(In reply to comment #5) > So is it not solvable when in Composition mode? Or not relevant? (Not a loaded question, genuinely don't know.) Sorry I wasn't specific. The values seem to be correct in Composition mode. I don't think there is a bug in that case.
(In reply to comment #6) > (In reply to comment #5) > > So is it not solvable when in Composition mode? Or not relevant? (Not a loaded question, genuinely don't know.) > > Sorry I wasn't specific. The values seem to be correct in Composition mode. I don't think there is a bug in that case. Funny, tst_qwebpage has: //Set selection with negative length inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant()); QInputMethodEvent eventSelection3("",inputAttributes); page->event(&eventSelection3); //ImAnchorPosition variant = page->inputMethodQuery(Qt::ImAnchorPosition); anchorPosition = variant.toInt(); QCOMPARE(anchorPosition, 1); //ImCursorPosition variant = page->inputMethodQuery(Qt::ImCursorPosition); cursorPosition = variant.toInt(); QCOMPARE(cursorPosition, 6); which would suggest the opposite to me, but I don't know too much about input methods.
(In reply to comment #7) > (In reply to comment #6) > > (In reply to comment #5) > > > So is it not solvable when in Composition mode? Or not relevant? (Not a loaded question, genuinely don't know.) > > > > Sorry I wasn't specific. The values seem to be correct in Composition mode. I don't think there is a bug in that case. > Funny, tst_qwebpage has: > //Set selection with negative length > inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant()); > QInputMethodEvent eventSelection3("",inputAttributes); > page->event(&eventSelection3); > //ImAnchorPosition > variant = page->inputMethodQuery(Qt::ImAnchorPosition); > anchorPosition = variant.toInt(); > QCOMPARE(anchorPosition, 1); > //ImCursorPosition > variant = page->inputMethodQuery(Qt::ImCursorPosition); > cursorPosition = variant.toInt(); > QCOMPARE(cursorPosition, 6); > which would suggest the opposite to me, but I don't know too much about input methods. This test case causes the Editor to go into composistion mode and therefore QWebPage::inputMethodQuery() returns the correct values. I don't know whether it is supposed to go into composition mode in this case or not (And that is the concern I raised in an email to you last week since this test case was part of your commit #58218). The test case I am fixing is when the editor is not in composition mode and is different than this.
Comment on attachment 56206 [details] Prosposed patch to fix the return values for Qt::ImCursorPosition and Qt::ImAnchorPosition in QWebPage::inputMethodQuery() when the Editor doesn't have a composition. r=me
Comment on attachment 56206 [details] Prosposed patch to fix the return values for Qt::ImCursorPosition and Qt::ImAnchorPosition in QWebPage::inputMethodQuery() when the Editor doesn't have a composition. Clearing flags on attachment: 56206 Committed r59833: <http://trac.webkit.org/changeset/59833>
All reviewed patches have been landed. Closing bug.
Revision r59833 cherry-picked into qtwebkit-2.0 with commit cf6ec10122bf813a16705f55b29f522a78ce83de