зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1656432 - part 3: Get rid of `nsIEditActionListener::WillDeleteSelection()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D85683
This commit is contained in:
Родитель
aef65d3a65
Коммит
25994d720f
|
@ -4023,24 +4023,17 @@ nsresult EditorBase::DeleteSelectionWithTransaction(
|
|||
// Notify nsIEditActionListener::WillDelete[Selection|Text]
|
||||
if (!mActionListeners.IsEmpty()) {
|
||||
if (!deleteContent) {
|
||||
AutoActionListenerArray listeners(mActionListeners.Clone());
|
||||
for (auto& listener : listeners) {
|
||||
DebugOnly<nsresult> rvIgnored =
|
||||
listener->WillDeleteSelection(SelectionRefPtr());
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rvIgnored),
|
||||
"nsIEditActionListener::WillDeleteSelection() failed, but ignored");
|
||||
MOZ_DIAGNOSTIC_ASSERT(!Destroyed(),
|
||||
"nsIEditActionListener::WillDeleteSelection() "
|
||||
"must not destroy the editor");
|
||||
// FYI: Currently, there should be only one listener at most.
|
||||
// Therefore, retrieving the lastest ranges everytime before
|
||||
// calling `WillDeleteRanges()` must be fine.
|
||||
AutoTArray<RefPtr<nsRange>, 8> ranges;
|
||||
for (uint32_t i = 0; i < SelectionRefPtr()->RangeCount(); i++) {
|
||||
ranges.AppendElement(SelectionRefPtr()->GetRangeAt(i)->CloneRange());
|
||||
}
|
||||
if (!ranges.IsEmpty()) {
|
||||
if (SelectionRefPtr()->RangeCount()) {
|
||||
AutoActionListenerArray listeners(mActionListeners.Clone());
|
||||
for (auto& listener : listeners) {
|
||||
// FYI: Currently, there should be only one listener at most.
|
||||
// Therefore, retrieving the lastest ranges everytime before
|
||||
// calling `WillDeleteRanges()` must be fine.
|
||||
AutoTArray<RefPtr<nsRange>, 8> ranges;
|
||||
for (uint32_t i = 0; i < SelectionRefPtr()->RangeCount(); i++) {
|
||||
ranges.AppendElement(
|
||||
SelectionRefPtr()->GetRangeAt(i)->CloneRange());
|
||||
}
|
||||
DebugOnly<nsresult> rvIgnored = listener->WillDeleteRanges(ranges);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rvIgnored),
|
||||
|
|
|
@ -2665,7 +2665,7 @@ class HTMLEditor final : public TextEditor,
|
|||
* atomic elements like `<br>`, `<hr>`, `<img>`, `<input>`, etc and
|
||||
* data nodes except text node (e.g., comment node).
|
||||
* If aAtomicContent is a invisible `<br>` element, this will call
|
||||
* `WillDeleteSelection()` recursively after deleting it.
|
||||
* `HandleDeleteSelectionInternal()` recursively after deleting it.
|
||||
*
|
||||
* @param aDirectionAndAmount Direction of the deletion.
|
||||
* @param aStripWrappers Must be eStrip or eNoStrip.
|
||||
|
@ -2807,8 +2807,8 @@ class HTMLEditor final : public TextEditor,
|
|||
/**
|
||||
* HandleDeleteCollapsedSelectionAtOtherBlockBoundary() handles deletion at
|
||||
* other block boundary (i.e., immediately before or after a block).
|
||||
* If this does not join blocks, `WillDeleteSelection()` may be called
|
||||
* recursively.
|
||||
* If this does not join blocks, `HandleDeleteSelectionInternal()` may be
|
||||
* called recursively.
|
||||
*
|
||||
* @param aDirectionAndAmount Direction of the deletion.
|
||||
* @param aStripWrappers Must be eStrip or eNoStrip.
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
webidl CharacterData;
|
||||
webidl Node;
|
||||
webidl Range;
|
||||
webidl Selection;
|
||||
|
||||
/*
|
||||
Editor Action Listener interface to outside world
|
||||
|
@ -72,12 +71,6 @@ interface nsIEditActionListener : nsISupports
|
|||
in long aOffset,
|
||||
in long aLength);
|
||||
|
||||
/**
|
||||
* Called before the editor deletes the selection.
|
||||
* @param aSelection The selection to be deleted
|
||||
*/
|
||||
void WillDeleteSelection(in Selection aSelection);
|
||||
|
||||
/**
|
||||
* Called before the editor deletes the ranges.
|
||||
* @param aRangesToDelete The ranges to be deleted.
|
||||
|
|
|
@ -2908,11 +2908,6 @@ TextServicesDocument::WillDeleteText(CharacterData* aTextNode, int32_t aOffset,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextServicesDocument::WillDeleteSelection(Selection* aSelection) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextServicesDocument::WillDeleteRanges(
|
||||
const nsTArray<RefPtr<nsRange>>& aRangesToDelete) {
|
||||
|
|
|
@ -1900,7 +1900,7 @@ FinderHighlighter.prototype = {
|
|||
let numberOfDeletedSelections = 0;
|
||||
let numberOfMatches = fSelection.rangeCount;
|
||||
|
||||
// We need to test if any ranges in the deleted selection (selection)
|
||||
// We need to test if any ranges to be deleted
|
||||
// are in any of the ranges of the find selection
|
||||
// Usually both selections will only contain one range, however
|
||||
// either may contain more than one.
|
||||
|
|
Загрузка…
Ссылка в новой задаче