2012-12-11 14:15:32 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2009-10-07 20:22:42 -07:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-07 20:22:42 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Code to notify things that animate before a refresh, at an appropriate
|
|
|
|
* refresh rate. (Perhaps temporary, until replaced by compositor.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsRefreshDriver_h_
|
|
|
|
#define nsRefreshDriver_h_
|
|
|
|
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "mozFlushType.h"
|
|
|
|
#include "nsTObserverArray.h"
|
2010-08-11 14:05:27 -07:00
|
|
|
#include "nsTArray.h"
|
2011-11-09 13:39:16 -08:00
|
|
|
#include "nsTHashtable.h"
|
2015-06-26 13:20:10 -07:00
|
|
|
#include "nsTObserverArray.h"
|
2013-05-17 13:57:26 -07:00
|
|
|
#include "nsClassHashtable.h"
|
2011-11-09 13:39:16 -08:00
|
|
|
#include "nsHashKeys.h"
|
2012-06-18 20:26:34 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-27 15:10:28 -07:00
|
|
|
#include "mozilla/Maybe.h"
|
2014-04-22 11:13:00 -07:00
|
|
|
#include "GeckoProfiler.h"
|
2014-05-28 14:42:17 -07:00
|
|
|
#include "mozilla/layers/TransactionIdAllocator.h"
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2009-12-21 13:46:24 -08:00
|
|
|
class nsPresContext;
|
2010-08-11 14:05:27 -07:00
|
|
|
class nsIPresShell;
|
2010-08-11 14:05:28 -07:00
|
|
|
class nsIDocument;
|
2011-11-09 13:39:16 -08:00
|
|
|
class imgIRequest;
|
2015-07-02 02:12:31 -07:00
|
|
|
class nsIDOMEvent;
|
|
|
|
class nsINode;
|
2013-08-19 06:08:44 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
class RefreshDriverTimer;
|
2015-01-13 15:38:00 -08:00
|
|
|
namespace layout {
|
|
|
|
class VsyncChild;
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|
2009-12-21 13:46:24 -08:00
|
|
|
|
2009-10-07 20:22:42 -07:00
|
|
|
/**
|
|
|
|
* An abstract base class to be implemented by callers wanting to be
|
|
|
|
* notified at refresh times. When nothing needs to be painted, callers
|
|
|
|
* may not be notified.
|
|
|
|
*/
|
|
|
|
class nsARefreshObserver {
|
|
|
|
public:
|
2009-12-21 13:46:25 -08:00
|
|
|
// AddRef and Release signatures that match nsISupports. Implementors
|
|
|
|
// must implement reference counting, and those that do implement
|
|
|
|
// nsISupports will already have methods with the correct signature.
|
|
|
|
//
|
|
|
|
// The refresh driver does NOT hold references to refresh observers
|
2010-06-26 19:43:13 -07:00
|
|
|
// except while it is notifying them.
|
2014-03-27 13:38:33 -07:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
|
2009-12-21 13:46:25 -08:00
|
|
|
|
2009-10-07 20:22:42 -07:00
|
|
|
virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
|
|
|
|
};
|
|
|
|
|
2013-08-19 06:08:44 -07:00
|
|
|
/**
|
|
|
|
* An abstract base class to be implemented by callers wanting to be notified
|
|
|
|
* that a refresh has occurred. Callers must ensure an observer is removed
|
|
|
|
* before it is destroyed.
|
|
|
|
*/
|
|
|
|
class nsAPostRefreshObserver {
|
|
|
|
public:
|
|
|
|
virtual void DidRefresh() = 0;
|
|
|
|
};
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
|
2015-03-27 11:52:19 -07:00
|
|
|
public nsARefreshObserver
|
|
|
|
{
|
2009-10-07 20:22:42 -07:00
|
|
|
public:
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit nsRefreshDriver(nsPresContext *aPresContext);
|
2009-10-07 20:22:42 -07:00
|
|
|
~nsRefreshDriver();
|
|
|
|
|
2011-03-07 08:58:48 -08:00
|
|
|
static void InitializeStatics();
|
2012-12-11 14:15:32 -08:00
|
|
|
static void Shutdown();
|
2011-03-07 08:58:48 -08:00
|
|
|
|
2011-04-11 23:18:43 -07:00
|
|
|
/**
|
|
|
|
* Methods for testing, exposed via nsIDOMWindowUtils. See
|
|
|
|
* nsIDOMWindowUtils.advanceTimeAndRefresh for description.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void AdvanceTimeAndRefresh(int64_t aMilliseconds);
|
2011-04-11 23:18:43 -07:00
|
|
|
void RestoreNormalRefresh();
|
2012-12-11 14:15:32 -08:00
|
|
|
void DoTick();
|
|
|
|
bool IsTestControllingRefreshesEnabled() const
|
|
|
|
{
|
|
|
|
return mTestControllingRefreshes;
|
|
|
|
}
|
2011-04-11 23:18:43 -07:00
|
|
|
|
2009-10-07 20:22:42 -07:00
|
|
|
/**
|
|
|
|
* Return the time of the most recent refresh. This is intended to be
|
|
|
|
* used by callers who want to start an animation now and want to know
|
|
|
|
* what time to consider the start of the animation. (This helps
|
|
|
|
* ensure that multiple animations started during the same event off
|
|
|
|
* the main event loop have the same start time.)
|
|
|
|
*/
|
|
|
|
mozilla::TimeStamp MostRecentRefresh() const;
|
2010-08-11 14:05:28 -07:00
|
|
|
/**
|
|
|
|
* Same thing, but in microseconds since the epoch.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int64_t MostRecentRefreshEpochTime() const;
|
2009-10-07 20:22:42 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add / remove refresh observers. Returns whether the operation
|
|
|
|
* succeeded.
|
|
|
|
*
|
|
|
|
* The flush type affects:
|
|
|
|
* + the order in which the observers are notified (lowest flush
|
|
|
|
* type to highest, in order registered)
|
|
|
|
* + (in the future) which observers are suppressed when the display
|
|
|
|
* doesn't require current position data or isn't currently
|
|
|
|
* painting, and, correspondingly, which get notified when there
|
|
|
|
* is a flush during such suppression
|
|
|
|
* and it must be either Flush_Style, Flush_Layout, or Flush_Display.
|
2009-12-21 13:46:25 -08:00
|
|
|
*
|
|
|
|
* The refresh driver does NOT own a reference to these observers;
|
|
|
|
* they must remove themselves before they are destroyed.
|
2013-08-19 06:08:44 -07:00
|
|
|
*
|
|
|
|
* The observer will be called even if there is no other activity.
|
2009-10-07 20:22:42 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AddRefreshObserver(nsARefreshObserver *aObserver,
|
2013-08-19 06:08:44 -07:00
|
|
|
mozFlushType aFlushType);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool RemoveRefreshObserver(nsARefreshObserver *aObserver,
|
2013-08-19 06:08:44 -07:00
|
|
|
mozFlushType aFlushType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an observer that will be called after each refresh. The caller
|
|
|
|
* must remove the observer before it is deleted. This does not trigger
|
|
|
|
* refresh driver ticks.
|
|
|
|
*/
|
|
|
|
void AddPostRefreshObserver(nsAPostRefreshObserver *aObserver);
|
|
|
|
void RemovePostRefreshObserver(nsAPostRefreshObserver *aObserver);
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
/**
|
|
|
|
* Add/Remove imgIRequest versions of observers.
|
|
|
|
*
|
|
|
|
* These are used for hooking into the refresh driver for
|
|
|
|
* controlling animated images.
|
|
|
|
*
|
|
|
|
* @note The refresh driver owns a reference to these listeners.
|
|
|
|
*
|
|
|
|
* @note Technically, imgIRequest objects are not nsARefreshObservers, but
|
|
|
|
* for controlling animated image repaint events, we subscribe the
|
|
|
|
* imgIRequests to the nsRefreshDriver for notification of paint events.
|
|
|
|
*
|
|
|
|
* @returns whether the operation succeeded, or void in the case of removal.
|
|
|
|
*/
|
|
|
|
bool AddImageRequest(imgIRequest* aRequest);
|
|
|
|
void RemoveImageRequest(imgIRequest* aRequest);
|
|
|
|
|
2010-08-11 14:05:27 -07:00
|
|
|
/**
|
|
|
|
* Add / remove presshells that we should flush style and layout on
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AddStyleFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 14:05:27 -07:00
|
|
|
NS_ASSERTION(!mStyleFlushObservers.Contains(aShell),
|
|
|
|
"Double-adding style flush observer");
|
2014-04-22 11:13:00 -07:00
|
|
|
// We only get the cause for the first observer each frame because capturing
|
|
|
|
// a stack is expensive. This is still useful if (1) you're trying to remove
|
|
|
|
// all flushes for a particial frame or (2) the costly flush is triggered
|
|
|
|
// near the call site where the first observer is triggered.
|
|
|
|
if (!mStyleCause) {
|
|
|
|
mStyleCause = profiler_get_backtrace();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
bool appended = mStyleFlushObservers.AppendElement(aShell) != nullptr;
|
2015-01-05 17:56:02 -08:00
|
|
|
EnsureTimerStarted();
|
2014-04-22 11:13:00 -07:00
|
|
|
|
2010-08-11 14:05:27 -07:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemoveStyleFlushObserver(nsIPresShell* aShell) {
|
|
|
|
mStyleFlushObservers.RemoveElement(aShell);
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AddLayoutFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 14:05:27 -07:00
|
|
|
NS_ASSERTION(!IsLayoutFlushObserver(aShell),
|
|
|
|
"Double-adding layout flush observer");
|
2014-04-22 11:13:00 -07:00
|
|
|
// We only get the cause for the first observer each frame because capturing
|
|
|
|
// a stack is expensive. This is still useful if (1) you're trying to remove
|
|
|
|
// all flushes for a particial frame or (2) the costly flush is triggered
|
|
|
|
// near the call site where the first observer is triggered.
|
|
|
|
if (!mReflowCause) {
|
|
|
|
mReflowCause = profiler_get_backtrace();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
bool appended = mLayoutFlushObservers.AppendElement(aShell) != nullptr;
|
2015-01-05 17:56:02 -08:00
|
|
|
EnsureTimerStarted();
|
2010-08-11 14:05:27 -07:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemoveLayoutFlushObserver(nsIPresShell* aShell) {
|
|
|
|
mLayoutFlushObservers.RemoveElement(aShell);
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsLayoutFlushObserver(nsIPresShell* aShell) {
|
2010-08-11 14:05:27 -07:00
|
|
|
return mLayoutFlushObservers.Contains(aShell);
|
|
|
|
}
|
2012-08-28 22:48:44 -07:00
|
|
|
bool AddPresShellToInvalidateIfHidden(nsIPresShell* aShell) {
|
|
|
|
NS_ASSERTION(!mPresShellsToInvalidateIfHidden.Contains(aShell),
|
|
|
|
"Double-adding style flush observer");
|
|
|
|
bool appended = mPresShellsToInvalidateIfHidden.AppendElement(aShell) != nullptr;
|
2015-01-05 17:56:02 -08:00
|
|
|
EnsureTimerStarted();
|
2012-08-28 22:48:44 -07:00
|
|
|
return appended;
|
|
|
|
}
|
|
|
|
void RemovePresShellToInvalidateIfHidden(nsIPresShell* aShell) {
|
|
|
|
mPresShellsToInvalidateIfHidden.RemoveElement(aShell);
|
|
|
|
}
|
2010-08-11 14:05:27 -07:00
|
|
|
|
2011-12-23 19:52:22 -08:00
|
|
|
/**
|
|
|
|
* Remember whether our presshell's view manager needs a flush
|
|
|
|
*/
|
2012-09-16 22:06:12 -07:00
|
|
|
void ScheduleViewManagerFlush();
|
2011-12-23 19:52:22 -08:00
|
|
|
void RevokeViewManagerFlush() {
|
|
|
|
mViewManagerFlushIsPending = false;
|
|
|
|
}
|
2012-08-28 22:47:18 -07:00
|
|
|
bool ViewManagerFlushIsPending() {
|
|
|
|
return mViewManagerFlushIsPending;
|
|
|
|
}
|
2011-12-23 19:52:22 -08:00
|
|
|
|
2010-09-08 22:38:04 -07:00
|
|
|
/**
|
2015-07-20 07:14:24 -07:00
|
|
|
* Add a document for which we have FrameRequestCallbacks
|
2010-09-08 22:38:04 -07:00
|
|
|
*/
|
2011-11-28 04:48:30 -08:00
|
|
|
void ScheduleFrameRequestCallbacks(nsIDocument* aDocument);
|
2010-09-08 22:38:04 -07:00
|
|
|
|
|
|
|
/**
|
2015-07-20 07:14:24 -07:00
|
|
|
* Remove a document for which we have FrameRequestCallbacks
|
2010-09-08 22:38:04 -07:00
|
|
|
*/
|
2011-11-28 04:48:30 -08:00
|
|
|
void RevokeFrameRequestCallbacks(nsIDocument* aDocument);
|
2010-09-08 22:38:04 -07:00
|
|
|
|
2015-07-02 02:12:31 -07:00
|
|
|
/**
|
|
|
|
* Queue a new event to dispatch in next tick before the style flush
|
|
|
|
*/
|
|
|
|
void ScheduleEventDispatch(nsINode* aTarget, nsIDOMEvent* aEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel all pending events scheduled by ScheduleEventDispatch which
|
|
|
|
* targets any node in aDocument.
|
|
|
|
*/
|
|
|
|
void CancelPendingEvents(nsIDocument* aDocument);
|
|
|
|
|
2009-12-21 13:46:24 -08:00
|
|
|
/**
|
|
|
|
* Tell the refresh driver that it is done driving refreshes and
|
|
|
|
* should stop its timer and forget about its pres context. This may
|
|
|
|
* be called from within a refresh.
|
|
|
|
*/
|
|
|
|
void Disconnect() {
|
|
|
|
StopTimer();
|
2012-07-30 07:20:58 -07:00
|
|
|
mPresContext = nullptr;
|
2009-12-21 13:46:24 -08:00
|
|
|
}
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2013-12-19 13:38:35 -08:00
|
|
|
bool IsFrozen() { return mFreezeCount > 0; }
|
|
|
|
|
2010-02-03 13:17:55 -08:00
|
|
|
/**
|
|
|
|
* Freeze the refresh driver. It should stop delivering future
|
2013-12-19 13:38:35 -08:00
|
|
|
* refreshes until thawed. Note that the number of calls to Freeze() must
|
|
|
|
* match the number of calls to Thaw() in order for the refresh driver to
|
|
|
|
* be un-frozen.
|
2010-02-03 13:17:55 -08:00
|
|
|
*/
|
|
|
|
void Freeze();
|
|
|
|
|
|
|
|
/**
|
2013-12-19 13:38:35 -08:00
|
|
|
* Thaw the refresh driver. If the number of calls to Freeze() matches the
|
|
|
|
* number of calls to this function, the refresh driver should start
|
|
|
|
* delivering refreshes again.
|
2010-02-03 13:17:55 -08:00
|
|
|
*/
|
|
|
|
void Thaw();
|
|
|
|
|
2010-08-26 21:26:23 -07:00
|
|
|
/**
|
|
|
|
* Throttle or unthrottle the refresh driver. This is done if the
|
|
|
|
* corresponding presshell is hidden or shown.
|
|
|
|
*/
|
|
|
|
void SetThrottled(bool aThrottled);
|
|
|
|
|
2010-08-11 14:05:27 -07:00
|
|
|
/**
|
|
|
|
* Return the prescontext we were initialized with
|
|
|
|
*/
|
|
|
|
nsPresContext* PresContext() const { return mPresContext; }
|
|
|
|
|
2015-01-13 15:38:00 -08:00
|
|
|
/**
|
|
|
|
* PBackgroundChild actor is created asynchronously in content process.
|
|
|
|
* We can't create vsync-based timers during PBackground startup. This
|
|
|
|
* function will be called when PBackgroundChild actor is created. Then we can
|
|
|
|
* do the pending vsync-based timer creation.
|
|
|
|
*/
|
|
|
|
static void PVsyncActorCreated(mozilla::layout::VsyncChild* aVsyncChild);
|
|
|
|
|
2010-02-19 09:11:40 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* Check whether the given observer is an observer for the given flush type
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRefreshObserver(nsARefreshObserver *aObserver,
|
2010-02-19 09:11:40 -08:00
|
|
|
mozFlushType aFlushType);
|
|
|
|
#endif
|
|
|
|
|
2011-12-23 19:52:26 -08:00
|
|
|
/**
|
|
|
|
* Default interval the refresh driver uses, in ms.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t DefaultInterval();
|
2011-12-23 19:52:26 -08:00
|
|
|
|
2013-09-04 04:47:21 -07:00
|
|
|
bool IsInRefresh() { return mInRefresh; }
|
|
|
|
|
2014-05-28 14:42:17 -07:00
|
|
|
// mozilla::layers::TransactionIdAllocator
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual uint64_t GetTransactionId() override;
|
|
|
|
void NotifyTransactionCompleted(uint64_t aTransactionId) override;
|
|
|
|
void RevokeTransactionId(uint64_t aTransactionId) override;
|
|
|
|
mozilla::TimeStamp GetTransactionStart() override;
|
2014-05-28 14:42:17 -07:00
|
|
|
|
2014-08-14 19:24:50 -07:00
|
|
|
bool IsWaitingForPaint(mozilla::TimeStamp aTime);
|
2014-05-28 14:43:41 -07:00
|
|
|
|
|
|
|
// nsARefreshObserver
|
2015-03-21 09:28:04 -07:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return TransactionIdAllocator::AddRef(); }
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return TransactionIdAllocator::Release(); }
|
|
|
|
virtual void WillRefresh(mozilla::TimeStamp aTime) override;
|
2009-12-21 13:46:24 -08:00
|
|
|
private:
|
2009-10-07 20:22:42 -07:00
|
|
|
typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
|
2011-11-09 13:39:16 -08:00
|
|
|
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
|
2013-05-17 13:57:26 -07:00
|
|
|
struct ImageStartData {
|
|
|
|
ImageStartData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::Maybe<mozilla::TimeStamp> mStartTime;
|
|
|
|
RequestTable mEntries;
|
|
|
|
};
|
|
|
|
typedef nsClassHashtable<nsUint32HashKey, ImageStartData> ImageStartTable;
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2015-07-02 02:12:31 -07:00
|
|
|
void DispatchPendingEvents();
|
2015-07-28 18:57:39 -07:00
|
|
|
void DispatchAnimationEvents();
|
2015-07-26 16:06:00 -07:00
|
|
|
void RunFrameRequestCallbacks(mozilla::TimeStamp aNowTime);
|
2015-04-21 09:44:40 -07:00
|
|
|
|
2012-12-11 14:15:32 -08:00
|
|
|
void Tick(int64_t aNowEpoch, mozilla::TimeStamp aNowTime);
|
|
|
|
|
2015-01-05 17:56:02 -08:00
|
|
|
enum EnsureTimerStartedFlags {
|
|
|
|
eNone = 0,
|
|
|
|
eAdjustingTimer = 1 << 0,
|
|
|
|
eAllowTimeToGoBackwards = 1 << 1
|
|
|
|
};
|
|
|
|
void EnsureTimerStarted(EnsureTimerStartedFlags aFlags = eNone);
|
2009-10-07 20:22:42 -07:00
|
|
|
void StopTimer();
|
2011-11-09 13:39:16 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t ObserverCount() const;
|
|
|
|
uint32_t ImageRequestCount() const;
|
2013-05-17 13:57:26 -07:00
|
|
|
static PLDHashOperator StartTableRequestCounter(const uint32_t& aKey,
|
|
|
|
ImageStartData* aEntry,
|
|
|
|
void* aUserArg);
|
|
|
|
static PLDHashOperator StartTableRefresh(const uint32_t& aKey,
|
|
|
|
ImageStartData* aEntry,
|
|
|
|
void* aUserArg);
|
2009-10-07 20:22:42 -07:00
|
|
|
ObserverArray& ArrayFor(mozFlushType aFlushType);
|
2010-02-03 13:17:55 -08:00
|
|
|
// Trigger a refresh immediately, if haven't been disconnected or frozen.
|
|
|
|
void DoRefresh();
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2012-12-11 14:15:32 -08:00
|
|
|
double GetRefreshTimerInterval() const;
|
2013-05-29 03:31:16 -07:00
|
|
|
double GetRegularTimerInterval(bool *outIsDefault = nullptr) const;
|
2015-04-21 09:44:40 -07:00
|
|
|
static double GetThrottledTimerInterval();
|
2011-03-04 07:27:02 -08:00
|
|
|
|
2015-05-29 23:50:51 -07:00
|
|
|
static mozilla::TimeDuration GetMinRecomputeVisibilityInterval();
|
|
|
|
|
2011-11-28 04:48:30 -08:00
|
|
|
bool HaveFrameRequestCallbacks() const {
|
|
|
|
return mFrameRequestCallbackDocs.Length() != 0;
|
2011-03-07 08:58:48 -08:00
|
|
|
}
|
|
|
|
|
2014-05-28 14:42:17 -07:00
|
|
|
void FinishedWaitingForTransaction();
|
|
|
|
|
2012-12-11 14:15:32 -08:00
|
|
|
mozilla::RefreshDriverTimer* ChooseTimer() const;
|
2015-01-13 15:38:00 -08:00
|
|
|
mozilla::RefreshDriverTimer* mActiveTimer;
|
2009-10-07 20:22:42 -07:00
|
|
|
|
2014-04-22 11:13:00 -07:00
|
|
|
ProfilerBacktrace* mReflowCause;
|
|
|
|
ProfilerBacktrace* mStyleCause;
|
|
|
|
|
2009-12-21 13:46:24 -08:00
|
|
|
nsPresContext *mPresContext; // weak; pres context passed in constructor
|
|
|
|
// and unset in Disconnect
|
|
|
|
|
2014-05-28 14:43:41 -07:00
|
|
|
nsRefPtr<nsRefreshDriver> mRootRefresh;
|
|
|
|
|
2014-05-28 14:42:17 -07:00
|
|
|
// The most recently allocated transaction id.
|
|
|
|
uint64_t mPendingTransaction;
|
|
|
|
// The most recently completed transaction id.
|
|
|
|
uint64_t mCompletedTransaction;
|
|
|
|
|
2013-12-19 13:38:35 -08:00
|
|
|
uint32_t mFreezeCount;
|
2015-04-21 09:44:40 -07:00
|
|
|
|
|
|
|
// How long we wait between ticks for throttled (which generally means
|
|
|
|
// non-visible) documents registered with a non-throttled refresh driver.
|
|
|
|
const mozilla::TimeDuration mThrottledFrameRequestInterval;
|
|
|
|
|
2015-05-29 23:50:51 -07:00
|
|
|
// How long we wait, at a minimum, before recomputing image visibility
|
|
|
|
// information. This is a minimum because, regardless of this interval, we
|
|
|
|
// only recompute visibility when we've seen a layout or style flush since the
|
|
|
|
// last time we did it.
|
|
|
|
const mozilla::TimeDuration mMinRecomputeVisibilityInterval;
|
|
|
|
|
2010-08-26 21:26:23 -07:00
|
|
|
bool mThrottled;
|
2015-05-29 23:50:51 -07:00
|
|
|
bool mNeedToRecomputeVisibility;
|
2011-04-11 23:18:43 -07:00
|
|
|
bool mTestControllingRefreshes;
|
2011-12-23 19:52:22 -08:00
|
|
|
bool mViewManagerFlushIsPending;
|
2012-12-11 14:15:32 -08:00
|
|
|
bool mRequestedHighPrecision;
|
2013-09-04 04:47:21 -07:00
|
|
|
bool mInRefresh;
|
2012-12-11 14:15:32 -08:00
|
|
|
|
2014-05-28 14:42:17 -07:00
|
|
|
// True if the refresh driver is suspended waiting for transaction
|
|
|
|
// id's to be returned and shouldn't do any work during Tick().
|
|
|
|
bool mWaitingForTransaction;
|
|
|
|
// True if Tick() was skipped because of mWaitingForTransaction and
|
|
|
|
// we should schedule a new Tick immediately when resumed instead
|
|
|
|
// of waiting until the next interval.
|
2014-08-14 19:24:50 -07:00
|
|
|
bool mSkippedPaints;
|
2014-05-28 14:42:17 -07:00
|
|
|
|
2012-12-11 14:15:32 -08:00
|
|
|
int64_t mMostRecentRefreshEpochTime;
|
|
|
|
mozilla::TimeStamp mMostRecentRefresh;
|
2014-08-14 19:24:50 -07:00
|
|
|
mozilla::TimeStamp mMostRecentTick;
|
2014-08-28 12:24:26 -07:00
|
|
|
mozilla::TimeStamp mTickStart;
|
2015-04-21 09:44:40 -07:00
|
|
|
mozilla::TimeStamp mNextThrottledFrameRequestTick;
|
2015-05-29 23:50:51 -07:00
|
|
|
mozilla::TimeStamp mNextRecomputeVisibilityTick;
|
2010-02-03 13:17:55 -08:00
|
|
|
|
2009-10-07 20:22:42 -07:00
|
|
|
// separate arrays for each flush type we support
|
|
|
|
ObserverArray mObservers[3];
|
2011-11-09 13:39:16 -08:00
|
|
|
RequestTable mRequests;
|
2013-05-17 13:57:26 -07:00
|
|
|
ImageStartTable mStartTable;
|
2011-11-09 13:39:16 -08:00
|
|
|
|
2015-07-02 02:12:31 -07:00
|
|
|
struct PendingEvent {
|
|
|
|
nsCOMPtr<nsINode> mTarget;
|
|
|
|
nsCOMPtr<nsIDOMEvent> mEvent;
|
|
|
|
};
|
|
|
|
|
2010-08-11 14:05:27 -07:00
|
|
|
nsAutoTArray<nsIPresShell*, 16> mStyleFlushObservers;
|
|
|
|
nsAutoTArray<nsIPresShell*, 16> mLayoutFlushObservers;
|
2012-08-28 22:48:44 -07:00
|
|
|
nsAutoTArray<nsIPresShell*, 16> mPresShellsToInvalidateIfHidden;
|
2010-08-11 14:05:28 -07:00
|
|
|
// nsTArray on purpose, because we want to be able to swap.
|
2011-11-28 04:48:30 -08:00
|
|
|
nsTArray<nsIDocument*> mFrameRequestCallbackDocs;
|
2015-04-21 09:44:40 -07:00
|
|
|
nsTArray<nsIDocument*> mThrottledFrameRequestCallbackDocs;
|
2015-06-26 13:20:10 -07:00
|
|
|
nsTObserverArray<nsAPostRefreshObserver*> mPostRefreshObservers;
|
2015-07-02 02:12:31 -07:00
|
|
|
nsTArray<PendingEvent> mPendingEvents;
|
2011-03-04 07:27:02 -08:00
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
// Helper struct for processing image requests
|
|
|
|
struct ImageRequestParameters {
|
2013-05-17 13:57:26 -07:00
|
|
|
mozilla::TimeStamp mCurrent;
|
|
|
|
mozilla::TimeStamp mPrevious;
|
|
|
|
RequestTable* mRequests;
|
|
|
|
mozilla::TimeStamp mDesired;
|
2011-11-09 13:39:16 -08:00
|
|
|
};
|
2012-12-11 14:15:32 -08:00
|
|
|
|
2015-07-15 02:05:06 -07:00
|
|
|
static void BeginRefreshingImages(RequestTable& aEntries,
|
|
|
|
ImageRequestParameters* aParms);
|
|
|
|
|
2012-12-11 14:15:32 -08:00
|
|
|
friend class mozilla::RefreshDriverTimer;
|
|
|
|
|
|
|
|
// turn on or turn off high precision based on various factors
|
|
|
|
void ConfigureHighPrecision();
|
|
|
|
void SetHighPrecisionTimersEnabled(bool aEnable);
|
2009-10-07 20:22:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsRefreshDriver_h_) */
|