mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1156160 - Update carets when document becomes visible. r=mtseng
When the user switches back to a tab which has the selection highlight on the document, call UpdateCarets() to bring the carets back. MozReview-Commit-ID: LxNoNRl4FHZ --HG-- extra : rebase_source : f6fdc9b5c646b064bbe1e27456bbeaac063bd04c
This commit is contained in:
parent
ad4d822074
commit
678e94aa9a
@ -32,7 +32,8 @@ namespace mozilla {
|
||||
#define AC_LOGV(message, ...) \
|
||||
AC_LOGV_BASE("AccessibleCaretEventHub (%p): " message, this, ##__VA_ARGS__);
|
||||
|
||||
NS_IMPL_ISUPPORTS(AccessibleCaretEventHub, nsIReflowObserver, nsIScrollObserver,
|
||||
NS_IMPL_ISUPPORTS(AccessibleCaretEventHub,
|
||||
nsIDocumentActivity, nsIReflowObserver, nsIScrollObserver,
|
||||
nsISelectionListener, nsISupportsWeakReference);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -433,6 +434,12 @@ AccessibleCaretEventHub::Init()
|
||||
|
||||
mDocShell = static_cast<nsDocShell*>(docShell);
|
||||
|
||||
nsIDocument* doc = mPresShell->GetDocument();
|
||||
if (doc) {
|
||||
doc->RegisterActivityObserver(
|
||||
NS_ISUPPORTS_CAST(nsIDocumentActivity*, this));
|
||||
}
|
||||
|
||||
if (sUseLongTapInjector) {
|
||||
mLongTapInjectorTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
@ -457,6 +464,12 @@ AccessibleCaretEventHub::Terminate()
|
||||
docShell->RemoveWeakScrollObserver(this);
|
||||
}
|
||||
|
||||
nsIDocument* doc = mPresShell->GetDocument();
|
||||
if (doc) {
|
||||
doc->UnregisterActivityObserver(
|
||||
NS_ISUPPORTS_CAST(nsIDocumentActivity*, this));
|
||||
}
|
||||
|
||||
if (mLongTapInjectorTimer) {
|
||||
mLongTapInjectorTimer->Cancel();
|
||||
}
|
||||
@ -701,6 +714,25 @@ AccessibleCaretEventHub::ReflowInterruptible(DOMHighResTimeStamp aStart,
|
||||
return Reflow(aStart, aEnd);
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaretEventHub::NotifyOwnerDocumentActivityChanged()
|
||||
{
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");
|
||||
|
||||
nsIDocument* doc = mPresShell->GetDocument();
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!doc->Hidden()) {
|
||||
mManager->OnDocumentVisible();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaretEventHub::AsyncPanZoomStarted()
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocumentActivity.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIReflowObserver.h"
|
||||
#include "nsIScrollObserver.h"
|
||||
@ -60,10 +61,12 @@ class WidgetTouchEvent;
|
||||
// Please see the wiki page for more information.
|
||||
// https://wiki.mozilla.org/AccessibleCaret
|
||||
//
|
||||
class AccessibleCaretEventHub : public nsIReflowObserver,
|
||||
public nsIScrollObserver,
|
||||
public nsISelectionListener,
|
||||
public nsSupportsWeakReference
|
||||
class AccessibleCaretEventHub
|
||||
: public nsIDocumentActivity
|
||||
, public nsIReflowObserver
|
||||
, public nsIScrollObserver
|
||||
, public nsISelectionListener
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
explicit AccessibleCaretEventHub(nsIPresShell* aPresShell);
|
||||
@ -76,6 +79,7 @@ public:
|
||||
void NotifyBlur(bool aIsLeavingDocument);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOCUMENTACTIVITY
|
||||
NS_DECL_NSIREFLOWOBSERVER
|
||||
NS_DECL_NSISELECTIONLISTENER
|
||||
|
||||
|
@ -751,6 +751,13 @@ AccessibleCaretManager::OnFrameReconstruction()
|
||||
mSecondCaret->EnsureApzAware();
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaretManager::OnDocumentVisible()
|
||||
{
|
||||
AC_LOG("%s: UpdateCarets()", __FUNCTION__);
|
||||
UpdateCarets();
|
||||
}
|
||||
|
||||
void
|
||||
AccessibleCaretManager::SetLastInputSource(uint16_t aInputSource)
|
||||
{
|
||||
|
@ -103,6 +103,10 @@ public:
|
||||
// was reconstructed, resulting in the content elements getting cloned.
|
||||
virtual void OnFrameReconstruction();
|
||||
|
||||
// Called by AccessibleCaretEventHub to inform us that the document
|
||||
// becomes visible.
|
||||
virtual void OnDocumentVisible();
|
||||
|
||||
// Update the manager with the last input source that was observed. This
|
||||
// is used in part to determine if the carets should be shown or hidden.
|
||||
void SetLastInputSource(uint16_t aInputSource);
|
||||
|
Loading…
Reference in New Issue
Block a user