Closed Bug 1992288 Opened 5 months ago Closed 4 months ago

`TextEditor` becomes not available if reframing the text control in a `beforeinput`/`textInput` event listener

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED FIXED
147 Branch
Tracking Status
firefox-esr140 --- fixed
firefox145 --- fixed
firefox146 --- fixed
firefox147 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

()

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:1050

Attachments

(4 files)

Found while I investigating bug 1989331. If a beforeinput/textInput event listener reframes the text control frame, the TextEditor is destroyed. Then, the text control won't be reinitialized properly with new TextEditor. So, the text control can get focus but never work.

This is caused by the same root cause of bug 448784, bug 1339052 and bug1620050. We should keep using TextEditor in the TextControlState even after reframing.

Once the editor is destroyed while dispatching beforeinput event,
e.g., by a reframe of the text control frame, AutoEditActionDataSetter
marks "the editor has destroyed during my lifetime". Then, nested
EditActions always fail because the parent AutoEditActionDataSetter
thinks the editor is not available.

However, the editor can be reinitialized immediately. Then, the nested
EditActions should work (note that it does not mean that another user
input is handled, AutoEditActionDataSetter is used by some query
methods too). Therefore, this patch adds a new bool member to store
whether the editor is initialized again.

I think we could reset mEditorWasDestroyedDuringHandlingEditAction,
but I'm afraid to do that because it forgets the destroyed thing
completely and some features may need to abort handling something even
if the editor is restored since the editable nodes are recreated.
Therefore, this patch adds a new bool member for making this change
safer and anybody can access the details of the state.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
User Story: (updated)
User Story: (updated)
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/5a9aae988c77 https://hg.mozilla.org/integration/autoland/rev/a085296be533 Make `AutoEditActionDataSetter` manage whether the destroyed editor was reinitialized r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch

Once the editor is destroyed while dispatching beforeinput event,
e.g., by a reframe of the text control frame, AutoEditActionDataSetter
marks "the editor has destroyed during my lifetime". Then, nested
EditActions always fail because the parent AutoEditActionDataSetter
thinks the editor is not available.

However, the editor can be reinitialized immediately. Then, the nested
EditActions should work (note that it does not mean that another user
input is handled, AutoEditActionDataSetter is used by some query
methods too). Therefore, this patch adds a new bool member to store
whether the editor is initialized again.

I think we could reset mEditorWasDestroyedDuringHandlingEditAction,
but I'm afraid to do that because it forgets the destroyed thing
completely and some features may need to abort handling something even
if the editor is restored since the editable nodes are recreated.
Therefore, this patch adds a new bool member for making this change
safer and anybody can access the details of the state.

Original Revision: https://phabricator.services.mozilla.com/D271559

Attachment #9526395 - Flags: approval-mozilla-beta?
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56012 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Attachment #9526395 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: in-testsuite+

Once the editor is destroyed while dispatching beforeinput event,
e.g., by a reframe of the text control frame, AutoEditActionDataSetter
marks "the editor has destroyed during my lifetime". Then, nested
EditActions always fail because the parent AutoEditActionDataSetter
thinks the editor is not available.

However, the editor can be reinitialized immediately. Then, the nested
EditActions should work (note that it does not mean that another user
input is handled, AutoEditActionDataSetter is used by some query
methods too). Therefore, this patch adds a new bool member to store
whether the editor is initialized again.

I think we could reset mEditorWasDestroyedDuringHandlingEditAction,
but I'm afraid to do that because it forgets the destroyed thing
completely and some features may need to abort handling something even
if the editor is restored since the editable nodes are recreated.
Therefore, this patch adds a new bool member for making this change
safer and anybody can access the details of the state.

Original Revision: https://phabricator.services.mozilla.com/D271559

Attachment #9527614 - Flags: approval-mozilla-release?

Once the editor is destroyed while dispatching beforeinput event,
e.g., by a reframe of the text control frame, AutoEditActionDataSetter
marks "the editor has destroyed during my lifetime". Then, nested
EditActions always fail because the parent AutoEditActionDataSetter
thinks the editor is not available.

However, the editor can be reinitialized immediately. Then, the nested
EditActions should work (note that it does not mean that another user
input is handled, AutoEditActionDataSetter is used by some query
methods too). Therefore, this patch adds a new bool member to store
whether the editor is initialized again.

I think we could reset mEditorWasDestroyedDuringHandlingEditAction,
but I'm afraid to do that because it forgets the destroyed thing
completely and some features may need to abort handling something even
if the editor is restored since the editable nodes are recreated.
Therefore, this patch adds a new bool member for making this change
safer and anybody can access the details of the state.

Original Revision: https://phabricator.services.mozilla.com/D271559

Attachment #9527632 - Flags: approval-mozilla-esr140?
Attachment #9527614 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9527632 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: