Bug 1441279 - 6. Register accessible caret observers across docshell tree; r=bz

AccessibleCaretManager uses scroll and reflow observers to detect when
to update the position of carets. However, it currently only registers
the observers on the leaf docshell, so only changes in the innermost
iframe are detected; that is, it fails to update caret position when an
ancestor iframe is scrolled. This patch makes it register observers on
all ancestor docshells so that changes in ancestor iframes are detected
as well.

MozReview-Commit-ID: bwiSjj8936

--HG--
extra : rebase_source : d567f1d8df67f79769c6532b061e2df1e5ab878f
This commit is contained in:
Jim Chen 2018-04-02 17:13:46 -04:00
Родитель 5c7894b988
Коммит de337ec2e1
1 изменённых файлов: 17 добавлений и 6 удалений

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

@ -400,8 +400,15 @@ AccessibleCaretEventHub::Init()
return;
}
docShell->AddWeakReflowObserver(this);
docShell->AddWeakScrollObserver(this);
nsCOMPtr<nsIDocShell> curDocShell = docShell;
do {
curDocShell->AddWeakReflowObserver(this);
curDocShell->AddWeakScrollObserver(this);
nsCOMPtr<nsIDocShellTreeItem> tmp;
curDocShell->GetSameTypeParent(getter_AddRefs(tmp));
curDocShell = do_QueryInterface(tmp);
} while (curDocShell);
mDocShell = static_cast<nsDocShell*>(docShell);
@ -421,10 +428,14 @@ AccessibleCaretEventHub::Terminate()
return;
}
RefPtr<nsDocShell> docShell(mDocShell.get());
if (docShell) {
docShell->RemoveWeakReflowObserver(this);
docShell->RemoveWeakScrollObserver(this);
nsCOMPtr<nsIDocShell> curDocShell = mDocShell.get();
while (curDocShell) {
curDocShell->RemoveWeakReflowObserver(this);
curDocShell->RemoveWeakScrollObserver(this);
nsCOMPtr<nsIDocShellTreeItem> tmp;
curDocShell->GetSameTypeParent(getter_AddRefs(tmp));
curDocShell = do_QueryInterface(tmp);
}
if (mLongTapInjectorTimer) {