mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1054901 - Add AsyncPanZoomStarted/Stopped notifications to scroll observers. r=roc
This commit is contained in:
parent
a712b649ab
commit
341859dcfa
@ -2896,6 +2896,36 @@ nsDocShell::RemoveWeakScrollObserver(nsIScrollObserver* aObserver)
|
||||
return mScrollObservers.RemoveElement(obs) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShell::NotifyAsyncPanZoomStarted()
|
||||
{
|
||||
nsTObserverArray<nsWeakPtr>::ForwardIterator iter(mScrollObservers);
|
||||
while (iter.HasMore()) {
|
||||
nsWeakPtr ref = iter.GetNext();
|
||||
nsCOMPtr<nsIScrollObserver> obs = do_QueryReferent(ref);
|
||||
if (obs) {
|
||||
obs->AsyncPanZoomStarted();
|
||||
} else {
|
||||
mScrollObservers.RemoveElement(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShell::NotifyAsyncPanZoomStopped()
|
||||
{
|
||||
nsTObserverArray<nsWeakPtr>::ForwardIterator iter(mScrollObservers);
|
||||
while (iter.HasMore()) {
|
||||
nsWeakPtr ref = iter.GetNext();
|
||||
nsCOMPtr<nsIScrollObserver> obs = do_QueryReferent(ref);
|
||||
if (obs) {
|
||||
obs->AsyncPanZoomStopped();
|
||||
} else {
|
||||
mScrollObservers.RemoveElement(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::NotifyScrollObservers()
|
||||
{
|
||||
|
@ -243,6 +243,13 @@ public:
|
||||
}
|
||||
|
||||
nsresult HistoryTransactionRemoved(int32_t aIndex);
|
||||
|
||||
// Notify Scroll observers when an async panning/zooming transform
|
||||
// has started being applied
|
||||
void NotifyAsyncPanZoomStarted();
|
||||
// Notify Scroll observers when an async panning/zooming transform
|
||||
// is no longer applied
|
||||
void NotifyAsyncPanZoomStopped();
|
||||
protected:
|
||||
// Object Management
|
||||
virtual ~nsDocShell();
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_ISCROLLOBSERVER_IID \
|
||||
{ 0x7c1a8b63, 0xe322, 0x4827, \
|
||||
{ 0xa4, 0xb1, 0x3b, 0x6e, 0x59, 0x03, 0x47, 0x7e } }
|
||||
{ 0x03465b77, 0x9ce2, 0x4d19, \
|
||||
{ 0xb2, 0xf6, 0x82, 0xae, 0xee, 0x85, 0xc3, 0xbf } }
|
||||
|
||||
class nsIScrollObserver : public nsISupports
|
||||
{
|
||||
@ -21,6 +21,16 @@ public:
|
||||
* Called when the scroll position of some element has changed.
|
||||
*/
|
||||
virtual void ScrollPositionChanged() = 0;
|
||||
|
||||
/**
|
||||
* Called when an async panning/zooming transform has started being applied.
|
||||
*/
|
||||
virtual void AsyncPanZoomStarted(){};
|
||||
|
||||
/**
|
||||
* Called when an async panning/zooming transform is no longer applied.
|
||||
*/
|
||||
virtual void AsyncPanZoomStopped(){};
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsEmbedCID.h"
|
||||
#include <algorithm>
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@ -1873,6 +1874,15 @@ TabChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
|
||||
if (scrollbarOwner) {
|
||||
scrollbarOwner->ScrollbarActivityStarted();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIDocShell> docshell(doc->GetDocShell());
|
||||
if (docshell) {
|
||||
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
|
||||
nsdocshell->NotifyAsyncPanZoomStarted();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APZStateChange::TransformEnd:
|
||||
@ -1882,6 +1892,15 @@ TabChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
|
||||
if (scrollbarOwner) {
|
||||
scrollbarOwner->ScrollbarActivityStopped();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIDocShell> docshell(doc->GetDocShell());
|
||||
if (docshell) {
|
||||
nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
|
||||
nsdocshell->NotifyAsyncPanZoomStopped();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APZStateChange::StartTouch:
|
||||
|
Loading…
Reference in New Issue
Block a user