Closed Bug 1764895 Opened 2 years ago Closed 7 months ago

Get rid of nsIEditor.setShouldTxnSetSelection, instead insertNode and deleteNode should have optional argument for equivalent feature

Categories

(Core :: DOM: Editor, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 3 open bugs)

Details

Attachments

(3 files)

nsIEditor.setShouldTxnSetSelection is used only with nsIEditor.insertNode and nsIEditor.deleteNode in comm-central. So, it's enough to make insertNode and deleteNode have new optional argument to do same thing.

The motivation of this is, I want to centralize selection updates instead of each DOM tree updater including transactions do it multiple times because of the performance reason of DOM Selection and making editor implementation simpler.

Additionally, comm-central does not guarantee the clean up of calling nsIEditor.setShouldTxnSetSelection(false) with try-finally. From point of view of this, this API style is a bad design.

Sorry, there was a problem with the detection of inactive users. I'm reverting the change.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED

nsIEditor.setShouldTxnSetSelection can preserve selection across multiple
editing. Therefore, we cannot manage the state only in the stack.

It's used only in comm-central, and used only with insertNode and
deleteNode. Therefore, adding new param to them to preserve selection
must be enough.

While I'm writing this patch, I realized that input event is not fired
by these methods because nobody set a placeholder transaction. That may
lead Thunderbird only IME crash bugs due to IMEContentObserver is not
notified editor properly. Therefore, this may fix some Thunderbird only
crashes.

Note that deleteNode should not update selection. However, I'm not 100%
sure that. Therefore, I add new param to deleteNode too. However,
some reviewers think it's unnecessary, I'll remove it before landing.

Finally, beforeinput and input caused by the method calls start updating
selection. However, I think that it should be better behavior. If Thunderbird
needs to guarantee that selection is set to whether the user expected when
it calls these methods with preserving selection.

It allows multiple edit action preserves Selection when updating the DOM tree.
However, most callers do not use finally to reset the state, and this makes
edit action handling complicated in some edge cases. Therefore, let's stop
supporting this feature. If Thunderbird requires the feature, the developers
should request additional param for preserving Selection like the preceding
patch.

Depends on D196004

It'll be removed and nsIEditor.insertNode() and nsIEditor.deleteNode()
have new optional parameter which if you set to true, selection won't be
modified by the editor (except beforeinput and input event listeners).

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/ac096e9798c4
part 1: Make `nsIEditor.insertNode` and `nsIEditor.deleteNode` take an optional parameter to preserve selection r=m_kato
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/12707a2d0153
part 2: Make comm-central stop using `nsIEditor.setShouldTxnSetSelection` r=mkmelin
https://hg.mozilla.org/comm-central/rev/a2942a799f19
Fix build bustage on comm-central. rs=bustage-fix

(In reply to Pulsebot from comment #8)

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/12707a2d0153
part 2: Make comm-central stop using nsIEditor.setShouldTxnSetSelection
r=mkmelin
https://hg.mozilla.org/comm-central/rev/a2942a799f19
Fix build bustage on comm-central. rs=bustage-fix

Thank you for the landing and fixing the bustage. I don't know why my try build succeeded to build...

Keywords: leave-open

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #9)

I don't know why my try build succeeded to build...

It built from what was the mozilla-central tip at the time. For it to have used your part 1 patch, you would have had to do a special Try build pointing to it (I think you knew that but I linked it anway).

(In reply to Geoff Lankow (:darktrojan) from comment #10)

(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #9)

I don't know why my try build succeeded to build...

It built from what was the mozilla-central tip at the time. For it to have used your part 1 patch, you would have had to do a special Try build pointing to it (I think you knew that but I linked it anway).

Oh, thanks. Oddly, I failed to update to the changeset which changed .gecko_rev.yml only when I pushed it.

FYI: The reason why I tried multiple times is, the document may be to old about pushing try builds. The decision task failed except when I push via Lando. Could you notify the document owner of updating required?

Flags: needinfo?(geoff)
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/2b83013fcfc8
part 3: Get rid of `nsIEditor.setShouldTxnSetSelection` r=m_kato DONTBUILD

I see your try run is based on mozilla-central from 9 days ago, but your try-comm-central run is based on comm-central from 5 days ago. In the meantime all of this happened (including some taskcluster config changes) on mozilla-central and comm-central has been updated to match. That's where the decision task failure has come from.

Ideally you'd push to try and try-cc at the same time, using the tip of both trees (assuming comm-central is in a good state, which isn't always the case). I'll add a note to that effect in the documentation.

Flags: needinfo?(geoff)
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: