Bug 852804 - a11y::SelectionManager shouldn't hold a strong ref to focused element, r=tbsaunde

This commit is contained in:
Alexander Surkov 2013-03-23 10:59:48 +09:00
parent baa3b6d269
commit b6bb324e88
3 changed files with 13 additions and 13 deletions

View File

@ -154,6 +154,10 @@ FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
DocAccessible* document =
GetAccService()->GetDocAccessible(DOMDoc);
if (document) {
// Clear selection listener for previously focused element.
if (targetNode->IsElement())
SelectionMgr()->ClearControlSelectionListener();
document->HandleNotification<FocusManager, nsINode>
(this, &FocusManager::ProcessDOMFocus, DOMDoc);
}

View File

@ -36,17 +36,13 @@ SelectionManager::Shutdown()
void
SelectionManager::ClearControlSelectionListener()
{
if (!mCurrentControl)
if (!mCurrCtrlFrame)
return;
nsIFrame* frame = mCurrentControl->GetPrimaryFrame();
if (!frame)
return;
mCurrentControl = nullptr;
const nsFrameSelection* frameSel = frame->GetConstFrameSelection();
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for the element!");
mCurrCtrlFrame = nullptr;
if (!frameSel)
return;
@ -70,14 +66,13 @@ SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
// the current focus.
ClearControlSelectionListener();
mCurrentControl = aFocusedElm;
mLastTextAccessible = nullptr;
nsIFrame* frame = aFocusedElm->GetPrimaryFrame();
if (!frame)
mCurrCtrlFrame = aFocusedElm->GetPrimaryFrame();
if (!mCurrCtrlFrame)
return;
const nsFrameSelection* frameSel = frame->GetConstFrameSelection();
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for focused element!");
if (!frameSel)
return;

View File

@ -7,6 +7,7 @@
#define mozilla_a11y_SelectionManager_h__
#include "nsAutoPtr.h"
#include "nsIFrame.h"
#include "nsISelectionListener.h"
class nsIContent;
@ -101,7 +102,7 @@ protected:
private:
// Currently focused control.
nsCOMPtr<nsIContent> mCurrentControl;
nsWeakFrame mCurrCtrlFrame;
// Info for the the last selection event.
// If it was on a control, then its control's selection. Otherwise, it's for