From 684000d9a5be65aaea5864ae1869d7cab737e089 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 14 Jul 2021 16:40:33 +0000 Subject: [accessibility] Remove selection listeners from shutting down PresShell. --- accessible/base/SelectionManager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'accessible/base/SelectionManager.cpp') diff --git a/accessible/base/SelectionManager.cpp b/accessible/base/SelectionManager.cpp index 30e01cbfcd..662ba52b70 100644 --- a/accessible/base/SelectionManager.cpp +++ b/accessible/base/SelectionManager.cpp @@ -120,6 +120,24 @@ SelectionManager::RemoveDocSelectionListener(nsIPresShell* aPresShell) // selection. Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck); spellSel->RemoveSelectionListener(this); + + if (mCurrCtrlNormalSel) { + if (mCurrCtrlNormalSel->GetPresShell() == aPresShell) { + // Remove 'this' registered as selection listener for the normal selection + // if we are removing listeners for its PresShell. + mCurrCtrlNormalSel->RemoveSelectionListener(this); + mCurrCtrlNormalSel = nullptr; + } + } + + if (mCurrCtrlSpellSel) { + if (mCurrCtrlSpellSel->GetPresShell() == aPresShell) { + // Remove 'this' registered as selection listener for the spellcheck + // selection if we are removing listeners for its PresShell. + mCurrCtrlSpellSel->RemoveSelectionListener(this); + mCurrCtrlSpellSel = nullptr; + } + } } void -- cgit v1.2.3