Closed Bug 294168 Opened 20 years ago Closed 20 years ago

IME transaction of Undo/Redo buffer is broken when selected text is deleted by IME input

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta3

People

(Reporter: masayuki, Assigned: masayuki)

Details

(Keywords: inputmethod, intl)

Attachments

(2 files)

If the text that is in editor is selected, we can destroy undo/redo buffer by
IME input.(See this report by UTF-8)

i.e.,

1. type 'ab' in an editor
 a bI
2. select 'a' in the editor
[a]b
3. type any key with IME
 あIb
4. Undo
 bI                               <- 'a' is not recovered and caret position is 
                                     wrong
5. Redo
 あI                              <- 'b' is deleted!

## I ... caret position
## [ ] ... selection range


However, if we selected all text in the editor, we cannot reproduce it.

i.e.,
1. type 'ab'
 a bI
2. select 'ab'
[a b]
3. type with IME
 あI
4. Undo                   <-- 'ab' is recovered and it's selected.
[a b]
5. Redo
[あ]
if defined DEBUG_IMETXN in IMETextTxn.cpp, we can get following log.

first case(buggy)
Do IME Text element = 037FE0D4 replace = 0 len = 1
nsIPrivateTextRangeList[02F57A28]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
------------------------------------------------------------------
Do IME Text element = 037FE0D4 replace = 1 len = 1
nsIPrivateTextRangeList[02F58590]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
------------------------------------------------------------------
Do IME Text element = 037FE0D4 replace = 1 len = 1
nsIPrivateTextRangeList[035D85C0]
Merge IME Text element = 037FE0D4
IMETextTxn assimilated IMETextTxn:02F489C8

second case
Do IME Text element = 037FE1B4 replace = 0 len = 1
nsIPrivateTextRangeList[03A6F5E0]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
------------------------------------------------------------------
Do IME Text element = 037FE1B4 replace = 1 len = 1
nsIPrivateTextRangeList[03A77FF8]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
Merge IME Text element = 037FE1B4
IMETextTxn assimilated IMETextTxn:03A80820
------------------------------------------------------------------
Do IME Text element = 037FE1B4 replace = 1 len = 1
nsIPrivateTextRangeList[03A6F7E8]
Merge IME Text element = 037FE1B4
IMETextTxn assimilated IMETextTxn:03A80740

See second block of both case.
First case faild to marge the IMETextTxn.
first case log.
nsPlaintextEditor::SetCompositionString
nsPlaintextEditor::InsertText
nsEditor::InsertTextIntoTextNodeImpl
CreateTxnForIMEText
IMETextTxn::Init
Editor::DoTransaction ----------
mPlaceHolderBatch: 2; mPlaceHolderTxn: 00000000;
Editor::DoTransaction ----------
mPlaceHolderBatch: 2; mPlaceHolderTxn: 03EBC0E8;
PlaceholderTxn::Merge 03EBB7E0                    <- it is PlaceholderTxn pointer
Do IME Text element = 03E9BA94 replace = 1 len = 1
nsIPrivateTextRangeList[03EBBE00]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
PlaceholderTxn::Merge 03EBC010                    <- difference previous object
PlaceholderTxn::Merge mAbsorb is true.
PlaceholderTxn::Merge mIMETextTxn is null.        <- fail to merge
nsEditor::EndPlaceHolderTransaction 2
nsEditor::EndPlaceHolderTransaction 1

second case log.

nsPlaintextEditor::SetCompositionString
nsPlaintextEditor::InsertText
nsEditor::InsertTextIntoTextNodeImpl
CreateTxnForIMEText
IMETextTxn::Init
Editor::DoTransaction ----------
mPlaceHolderBatch: 2; mPlaceHolderTxn: 00000000;
Editor::DoTransaction ----------
mPlaceHolderBatch: 2; mPlaceHolderTxn: 03E66008;
PlaceholderTxn::Merge 03E63E08                    <- it is PlaceholderTxn pointer
Do IME Text element = 03E479B4 replace = 1 len = 1
nsIPrivateTextRangeList[03E64530]
range[0] start=1 end=1 type=TEXTRANGE_CARETPOSITION
range[1] start=0 end=1 type=TEXTRANGE_RAWINPUT
PlaceholderTxn::Merge 03E63E08                    <- same as previous object
PlaceholderTxn::Merge mAbsorb is true.
Merge IME Text element = 03E479B4
IMETextTxn assimilated IMETextTxn:03E646D8        <- successed to merge
nsEditor::EndPlaceHolderTransaction 2
nsEditor::EndPlaceHolderTransaction 1
Attached patch Patch rv1.0Splinter Review
It fixes this bug.
But I don't know that this is right or not.
The if statement is added by Joe Francis in Bug 24573.

Joe:
Is it necessary?
Assignee: mozeditor → masayuki
Status: NEW → ASSIGNED
Attachment #183607 - Flags: review?(mozeditor)
Flags: blocking1.8b3?
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta3
This patch changes following behavior, but I think it is better than current
behavior.

1. type 'aaaa'
2. select 'aa[aa]'
3. type 'bbbb'

Current behavior:
1st undo:  'aabb'
2nd undo:  'aaaa'
3rd undo:  ''

The patch's behavior:
1st undo:  'aaaa'
2nd undo:  ''

I think that the 'natural' is new behavior. Because user's step is not related
the selection.
Priority: P1 → --
Target Milestone: mozilla1.8beta3 → ---
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta3
Comment on attachment 183607 [details] [diff] [review]
Patch rv1.0

timeless:

Can you review it?
Attachment #183607 - Flags: review?(mozeditor) → review?(timeless)
Comment on attachment 183607 [details] [diff] [review]
Patch rv1.0

i wondered if the qi comment was correct but got distracted trying to follow
bonsai links and i've decided it's a bad use of my time.
Attachment #183607 - Flags: superreview?(tor)
Attachment #183607 - Flags: review?(timeless)
Attachment #183607 - Flags: review+
timeless:

I sent mail to tor. But he doesn't reply...
Aren't there other superreviewer?
Comment on attachment 183607 [details] [diff] [review]
Patch rv1.0

Simon: Could you check it?
Attachment #183607 - Flags: superreview?(tor) → superreview?(sfraser_bugs)
diff -w would be useful here.
Did you verify that this change doesn't regress any of the bugs listed in the
checkin comment for the line being removed:
"make selection sticky across undo/redo (24573); get bold/italic/underline
toolbar feedback working (24574); fix for 24856: unable to unbold text; fix for
24572: cant get selection between split lists"?
Maybe...

bug 24573 -> mozilla/ editor/ base/ PlaceholderTxn.cpp
             mozilla/ editor/ base/ PlaceholderTxn.h

bug 24574 -> mozilla/ editor/ base/ nsInterfaceState.cpp

bug 24856 -> ???

bug 24572 -> mozilla/ editor/ base/ nsHTMLEditRules.cpp
O.K. I completed to test for all bugs now, I cannot reproduce these bugs.
Comment on attachment 183607 [details] [diff] [review]
Patch rv1.0

Thanks for testing.
Attachment #183607 - Flags: superreview?(sfraser_bugs) → superreview+
Attachment #183607 - Flags: approval1.8b3?
Comment on attachment 183607 [details] [diff] [review]
Patch rv1.0

a=chofmann
Attachment #183607 - Flags: approval1.8b3? → approval1.8b3+
checked-in. thank you!
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Flags: blocking1.8b3?
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: