Skip to content

Commit

Permalink
Bug 1656432 - part 2: Make FinderHighlighter use `nsIEditActionList…
Browse files Browse the repository at this point in the history
…ener::WillDeleteRanges()` instead of `nsIEditActionListener::WillDeleteSelection()` r=Gijs

For making editor performance better and editor code simpler, I want to
stop modifying `Selection` as far as possible.  Therefore, I'd like to
get rid of `nsIEditActionListener`.  Instead, there is new API,
`nsIEditActionListener::WillDeleteRanges()`.  This patch rewrites
`FinderHighlighter#WillDeleteSelection()` to
`FinderHighlighter#WillDeleteRanges()`.

Differential Revision: https://phabricator.services.mozilla.com/D85682
  • Loading branch information
masayuki-nakano committed Aug 4, 2020
1 parent d68f059 commit aef65d3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions toolkit/modules/FinderHighlighter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1889,9 +1889,8 @@ FinderHighlighter.prototype = {
}
},

WillDeleteSelection(selection) {
let editor = this._getEditableNode(selection.getRangeAt(0).startContainer)
.editor;
WillDeleteRanges(rangesToDelete) {
let { editor } = this._getEditableNode(rangesToDelete[0].startContainer);
let controller = editor.selectionController;
let fSelection = controller.getSelection(
Ci.nsISelectionController.SELECTION_FIND
Expand All @@ -1910,12 +1909,11 @@ FinderHighlighter.prototype = {
shouldDelete[fIndex] = false;
let fRange = fSelection.getRangeAt(fIndex);

for (let index = 0; index < selection.rangeCount; index++) {
for (let selRange of rangesToDelete) {
if (shouldDelete[fIndex]) {
continue;
}

let selRange = selection.getRangeAt(index);
let doesOverlap = this._checkOverlap(selRange, fRange);
if (doesOverlap) {
shouldDelete[fIndex] = true;
Expand Down

0 comments on commit aef65d3

Please sign in to comment.