Bug 1206545 - Store nsIPresShell pointer in constructor instead of Init(). r=roc

When constructing AccessibleCaretEventHub, bypass and store the
nsIPresShell pointer. This is a preparation for later patches.

Also, remove 'virtual' for Init() and Terminate() since the mock object
in gtest does not need to override them.

--HG--
extra : commitid : 4D5733d5Xr8
extra : rebase_source : ff934904a6144a3408746574a5534ab44731192d
This commit is contained in:
Ting-Yu Lin 2015-11-16 18:16:43 +08:00
Родитель e4bed32ba9
Коммит 3d15f9d1ae
4 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -368,7 +368,8 @@ MOZ_IMPL_STATE_CLASS_GETTER(LongTapState)
bool AccessibleCaretEventHub::sUseLongTapInjector = true;
AccessibleCaretEventHub::AccessibleCaretEventHub()
AccessibleCaretEventHub::AccessibleCaretEventHub(nsIPresShell* aPresShell)
: mPresShell(aPresShell)
{
static bool prefsAdded = false;
if (!prefsAdded) {
@ -383,10 +384,10 @@ AccessibleCaretEventHub::~AccessibleCaretEventHub()
}
void
AccessibleCaretEventHub::Init(nsIPresShell* aPresShell)
AccessibleCaretEventHub::Init()
{
if (mInitialized || !aPresShell || !aPresShell->GetCanvasFrame() ||
!aPresShell->GetCanvasFrame()->GetCustomContentContainer()) {
if (mInitialized || !mPresShell || !mPresShell->GetCanvasFrame() ||
!mPresShell->GetCanvasFrame()->GetCustomContentContainer()) {
return;
}
@ -399,8 +400,6 @@ AccessibleCaretEventHub::Init(nsIPresShell* aPresShell)
// without the following scriptBlocker.
nsAutoScriptBlocker scriptBlocker;
mPresShell = aPresShell;
nsPresContext* presContext = mPresShell->GetPresContext();
MOZ_ASSERT(presContext, "PresContext should be given in PresShell::Init()");

Просмотреть файл

@ -61,9 +61,9 @@ class AccessibleCaretEventHub : public nsIReflowObserver,
public nsSupportsWeakReference
{
public:
explicit AccessibleCaretEventHub();
virtual void Init(nsIPresShell* aPresShell);
virtual void Terminate();
explicit AccessibleCaretEventHub(nsIPresShell* aPresShell);
void Init();
void Terminate();
nsEventStatus HandleEvent(WidgetEvent* aEvent);

Просмотреть файл

@ -63,6 +63,7 @@ public:
using AccessibleCaretEventHub::FireScrollEnd;
explicit MockAccessibleCaretEventHub()
: AccessibleCaretEventHub(nullptr)
{
mManager = MakeUnique<MockAccessibleCaretManager>();
mInitialized = true;

Просмотреть файл

@ -897,7 +897,7 @@ PresShell::Init(nsIDocument* aDocument,
if (AccessibleCaretEnabled()) {
// Need to happen before nsFrameSelection has been set up.
mAccessibleCaretEventHub = new AccessibleCaretEventHub();
mAccessibleCaretEventHub = new AccessibleCaretEventHub(this);
}
mSelection = new nsFrameSelection();
@ -1679,7 +1679,7 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight)
// Initialize after nsCanvasFrame is created.
if (mAccessibleCaretEventHub) {
mAccessibleCaretEventHub->Init(this);
mAccessibleCaretEventHub->Init();
}
// nsAutoScriptBlocker going out of scope may have killed us too