Open Bug 258291 Opened 20 years ago Updated 3 years ago

Empty undo/redo transaction is created when IME cannceled

Categories

(Core :: DOM: Editor, defect, P5)

defect

Tracking

()

People

(Reporter: masayuki, Unassigned)

References

Details

(Keywords: inputmethod)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a3) Gecko/20040906
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a3) Gecko/20040906

If IME is cannceled, the transaction is created.
But the transaction is empty.

Reproducible: Always
Steps to Reproduce:
1. Turn off the IME.
2. Type 'A'.
3. Turn on the IME.
4. Type any char.
5. Cancel the composition by hitting ESC key.
6. Turn off the IME.
7. Type 'B'.
Actual Results:  
1st Undo -> 'A'
2nd Undo -> 'A'    <== Empty transaction
3rd Undo -> ''

Expected Results:  
1st Undo -> 'A'
2nd Undo -> ''

http://lxr.mozilla.org/seamonkey/source/editor/libeditor/base/nsEditor.cpp#1919
1919 nsEditor::EndComposition(void)
1920 {
1921   if (!mInIMEMode) return NS_OK; // nothing to do
1922   
1923   nsresult result = NS_OK;
1924 
1925   // commit the IME transaction..we can get at it via the transaction mgr.
1926   // Note that this means IME won't work without an undo stack!
1927   if (mTxnMgr) 
1928   {
1929     nsCOMPtr<nsITransaction> txn;
1930     result = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));  
1931     nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryInterface(txn);
1932     if (plcTxn)
1933     {
1934       result = plcTxn->Commit();
1935     }
1936   }

The IME transaction is always commited.
Is there a way to tell the IME was cancelled?
I think that if IME is canceled, the transaction has no-string.
Hmm... I can't find where the transaction is created here.  Is there a way we
can ask it for the string it got?

Alternately, could we extend the IME api to have an explicit cancel instead of
just an "end"?
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Contact: bugzilla → editor
Assignee: mozeditor → nobody
I've researched this.

Currently, nsEditor adds all transactions to its transaction manager when composition string is changed. I think that this is the root problem.

When I add Undo button on the toolbar by addon (https://addons.mozilla.org/en-US/firefox/addon/toolbar-buttons/?src=search), the undo button is enabled when I type first character of composition string. This is not good behavior. When composition is committed, the composition transaction should be added in the undo stack.

If we can separate the IME transaction from Undo stack, we can get more flexibility for handling composition. E.g., if web content's script moves selection, the composing string can move there. But it's too difficult to implement such behavior in current design. But I think if we can fix such issues, we can fix all strange behavior during composition with events or script. It's great improvement.

I think that nsEditor will be able to track composition which is started on it after bug 705057 fixed. Then, I will be able to work on this bug.
Depends on: 705057
We should really only touch the undo stack when an IME transaction is committed.  That sounds sane to m.

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority and severity.

If you have reason to believe this is wrong, please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.