[Webkit-unassigned] [Bug 39625] [Qt] Sending a QInputMethodEvent::Selection event forces the Editor to go into Composition mode

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jul 12 14:55:56 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=39625





--- Comment #15 from Simon Hausmann <hausmann at webkit.org>  2010-07-12 14:55:56 PST ---
(In reply to comment #14)
> (In reply to comment #13)
> > (From update of attachment 57408 [details] [details])
> > I agree that the editor should not go into composition mode if just a selection is set, but I don't think ImSurroundingText should exclude the selection. That doesn't sound correct to me and in fact it's not what QTextEdit or QLineEdit do in response to that input method query.
> 
> OK, need some guidance on what is considered surrounding text in the following sequence then:
> 
>     //Set selection with negative length
>     inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 6, -5, QVariant());
>     QInputMethodEvent eventSelection3("",inputAttributes);
>     page->event(&eventSelection3);
> 
>     //ImCursorPosition
>     variant = page->inputMethodQuery(Qt::ImCursorPosition);
>     cursorPosition =  variant.toInt();
>     QCOMPARE(cursorPosition, 6);
> 
>     //ImCurrentSelection
>     variant = page->inputMethodQuery(Qt::ImCurrentSelection);
>     selectionValue = variant.value<QString>();
>     QCOMPARE(selectionValue, QString("tWebK"));
> 
>     //ImSurroundingText
>     variant = page->inputMethodQuery(Qt::ImSurroundingText);
>     QString value = variant.value<QString>();
>     QCOMPARE(value, QString("Qit"));
> 
> My understanding was that we set the selected text into composition mode with the first call. This makes the selected text the input area, so the subsequent call to ImSurroundingText should return the text that surrounds the text in composition mode, i.e. 'Qit'.

The way it works in QTextEdit/QLineEdit - which is also how the input methods on Symbian and Maemo are expecting it - is that the selection is literally the visible text selection and it is distinct from the surrounding text and the pre-edit string.

In other words:

    1) The surrounding text is the surrounding paragraph or block of text. It does not include the pre-edit string.
    2) The selection attribute in the input method events allows creating selections, as if the user created them using the mouse/keyboard. Therefore it is included in the ImSurroundingText, as it does not modify the text itself. ImCurrentSelection returns only the selected text.
    3) The pre-edit string is neither visible in the selection nor in the surrounding text.

So when receiving an input method event we should proceed like this (roughly, see QTextControl::inputMethodEvent for more details):

1) Determine if we are receiving text (pre-edit string, commit string or replacement length)
2) If we are receiving text, then the current selected text should be removed (if editable)
3) The replacementStart+length are is replaced with the commit string (even if empty)
4) New text selections from the attributes are applied.
5) Pre-edit text and formats are applied.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list