зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616565: remove indirect calls to `NotifySelectionListeners` in `Selection`. r=smaug
Slightly clarfifies the relation of `Selection` and `nsFrameSelection`. This requires undesirable 'kungFuDeathGrips'. However, they existed already, only via an indirect call. Differential Revision: https://phabricator.services.mozilla.com/D63479 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f5cfed260d
Коммит
90e61dc61a
|
@ -1801,9 +1801,9 @@ void Selection::RemoveAllRanges(ErrorResult& aRv) {
|
||||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
||||||
frameSelection->ClearTableCellSelection();
|
frameSelection->ClearTableCellSelection();
|
||||||
|
|
||||||
|
RefPtr<Selection> kungFuDeathGrip{this};
|
||||||
// Be aware, this instance may be destroyed after this call.
|
// Be aware, this instance may be destroyed after this call.
|
||||||
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
|
result = NotifySelectionListeners();
|
||||||
result = frameSelection->NotifySelectionListeners(GetType());
|
|
||||||
|
|
||||||
// Also need to notify the frames!
|
// Also need to notify the frames!
|
||||||
// PresShell::CharacterDataChanged should do that on DocumentChanged
|
// PresShell::CharacterDataChanged should do that on DocumentChanged
|
||||||
|
@ -1847,7 +1847,8 @@ void Selection::AddRangeAndSelectFramesAndNotifyListeners(nsRange& aRange,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaybeAddTableCellRange might flush frame.
|
// MaybeAddTableCellRange might flush frame and `NotifySelectionListeners`
|
||||||
|
// below might destruct `this`.
|
||||||
RefPtr<Selection> kungFuDeathGrip(this);
|
RefPtr<Selection> kungFuDeathGrip(this);
|
||||||
|
|
||||||
// This inserts a table cell range in proper document order
|
// This inserts a table cell range in proper document order
|
||||||
|
@ -1889,9 +1890,7 @@ void Selection::AddRangeAndSelectFramesAndNotifyListeners(nsRange& aRange,
|
||||||
SelectFrames(presContext, range, true);
|
SelectFrames(presContext, range, true);
|
||||||
|
|
||||||
// Be aware, this instance may be destroyed after this call.
|
// Be aware, this instance may be destroyed after this call.
|
||||||
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
|
result = NotifySelectionListeners();
|
||||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
|
||||||
result = frameSelection->NotifySelectionListeners(GetType());
|
|
||||||
if (NS_FAILED(result)) {
|
if (NS_FAILED(result)) {
|
||||||
aRv.Throw(result);
|
aRv.Throw(result);
|
||||||
}
|
}
|
||||||
|
@ -1971,10 +1970,9 @@ void Selection::RemoveRangeAndUnselectFramesAndNotifyListeners(
|
||||||
|
|
||||||
if (!mFrameSelection) return; // nothing to do
|
if (!mFrameSelection) return; // nothing to do
|
||||||
|
|
||||||
|
RefPtr<Selection> kungFuDeathGrip{this};
|
||||||
// Be aware, this instance may be destroyed after this call.
|
// Be aware, this instance may be destroyed after this call.
|
||||||
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
|
rv = NotifySelectionListeners();
|
||||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
|
||||||
rv = frameSelection->NotifySelectionListeners(GetType());
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
aRv.Throw(rv);
|
aRv.Throw(rv);
|
||||||
}
|
}
|
||||||
|
@ -2095,9 +2093,9 @@ void Selection::Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
|
||||||
SetAnchorFocusRange(0);
|
SetAnchorFocusRange(0);
|
||||||
SelectFrames(presContext, range, true);
|
SelectFrames(presContext, range, true);
|
||||||
|
|
||||||
|
RefPtr<Selection> kungFuDeathGrip{this};
|
||||||
// Be aware, this instance may be destroyed after this call.
|
// Be aware, this instance may be destroyed after this call.
|
||||||
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
|
result = NotifySelectionListeners();
|
||||||
result = frameSelection->NotifySelectionListeners(GetType());
|
|
||||||
if (NS_FAILED(result)) {
|
if (NS_FAILED(result)) {
|
||||||
aRv.Throw(result);
|
aRv.Throw(result);
|
||||||
}
|
}
|
||||||
|
@ -2567,10 +2565,9 @@ void Selection::Extend(nsINode& aContainer, uint32_t aOffset,
|
||||||
nsAtomCString(content->NodeInfo()->NameAtom()).get(), aOffset);
|
nsAtomCString(content->NodeInfo()->NameAtom()).get(), aOffset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RefPtr<Selection> kungFuDeathGrip{this};
|
||||||
// Be aware, this instance may be destroyed after this call.
|
// Be aware, this instance may be destroyed after this call.
|
||||||
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
|
res = NotifySelectionListeners();
|
||||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
|
||||||
res = frameSelection->NotifySelectionListeners(GetType());
|
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
aRv.Throw(res);
|
aRv.Throw(res);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче