mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 803665 - part 2 - dispense with nsGlobalWindow::{First,Last}Timeout and nsTimeout::{Next,Previous}; r=bz
This commit is contained in:
parent
2f0460ea2f
commit
e5e7b91de6
@ -1310,9 +1310,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mListenerManager,
|
||||
nsEventListenerManager)
|
||||
|
||||
for (nsTimeout* timeout = tmp->FirstTimeout();
|
||||
for (nsTimeout* timeout = tmp->mTimeouts.getFirst();
|
||||
timeout;
|
||||
timeout = timeout->Next()) {
|
||||
timeout = timeout->getNext()) {
|
||||
cb.NoteNativeChild(timeout, NS_CYCLE_COLLECTION_PARTICIPANT(nsTimeout));
|
||||
}
|
||||
|
||||
@ -1417,7 +1417,9 @@ nsGlobalWindow::IsBlackForCC()
|
||||
void
|
||||
nsGlobalWindow::UnmarkGrayTimers()
|
||||
{
|
||||
for (nsTimeout* timeout = FirstTimeout(); timeout; timeout = timeout->Next()) {
|
||||
for (nsTimeout* timeout = mTimeouts.getFirst();
|
||||
timeout;
|
||||
timeout = timeout->getNext()) {
|
||||
if (timeout->mScriptHandler) {
|
||||
JSObject* o = timeout->mScriptHandler->GetScriptObject();
|
||||
xpc_UnmarkGrayObject(o);
|
||||
@ -9896,7 +9898,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
||||
// timeout events fire "early", so we need to test the timer as well
|
||||
// as the deadline.
|
||||
last_expired_timeout = nullptr;
|
||||
for (timeout = FirstTimeout(); timeout; timeout = timeout->Next()) {
|
||||
for (timeout = mTimeouts.getFirst(); timeout; timeout = timeout->getNext()) {
|
||||
if (((timeout == aTimeout) || (timeout->mWhen <= deadline)) &&
|
||||
(timeout->mFiringDepth == 0)) {
|
||||
// Mark any timeouts that are on the list to be fired with the
|
||||
@ -9944,10 +9946,10 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
||||
|
||||
Telemetry::AutoCounter<Telemetry::DOM_TIMERS_FIRED_PER_NATIVE_TIMEOUT> timeoutsRan;
|
||||
|
||||
for (timeout = FirstTimeout();
|
||||
for (timeout = mTimeouts.getFirst();
|
||||
timeout != &dummy_timeout && !IsFrozen();
|
||||
timeout = nextTimeout) {
|
||||
nextTimeout = timeout->Next();
|
||||
nextTimeout = timeout->getNext();
|
||||
|
||||
if (timeout->mFiringDepth != firingDepth) {
|
||||
// We skip the timeout since it's on the list to run at another
|
||||
@ -10011,7 +10013,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
||||
|
||||
// Running a timeout can cause another timeout to be deleted, so
|
||||
// we need to reset the pointer to the following timeout.
|
||||
nextTimeout = timeout->Next();
|
||||
nextTimeout = timeout->getNext();
|
||||
|
||||
timeout->remove();
|
||||
|
||||
@ -10064,7 +10066,7 @@ nsGlobalWindow::ClearTimeoutOrInterval(int32_t aTimerID)
|
||||
uint32_t public_id = (uint32_t)aTimerID;
|
||||
nsTimeout *timeout;
|
||||
|
||||
for (timeout = FirstTimeout(); timeout; timeout = timeout->Next()) {
|
||||
for (timeout = mTimeouts.getFirst(); timeout; timeout = timeout->getNext()) {
|
||||
if (timeout->mPublicId == public_id) {
|
||||
if (timeout->mRunning) {
|
||||
/* We're running from inside the timeout. Mark this
|
||||
@ -10109,13 +10111,13 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
// start at the timer after mTimeoutInsertionPoint, if there is one.
|
||||
// Otherwise, start at the beginning of the list.
|
||||
for (nsTimeout *timeout = mTimeoutInsertionPoint ?
|
||||
mTimeoutInsertionPoint->Next() : FirstTimeout();
|
||||
mTimeoutInsertionPoint->getNext() : mTimeouts.getFirst();
|
||||
timeout; ) {
|
||||
// It's important that this check be <= so that we guarantee that
|
||||
// taking NS_MAX with |now| won't make a quantity equal to
|
||||
// timeout->mWhen below.
|
||||
if (timeout->mWhen <= now) {
|
||||
timeout = timeout->Next();
|
||||
timeout = timeout->getNext();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -10152,7 +10154,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
|
||||
// Get the pointer to the next timeout now, before we move the
|
||||
// current timeout in the list.
|
||||
nsTimeout* nextTimeout = timeout->Next();
|
||||
nsTimeout* nextTimeout = timeout->getNext();
|
||||
|
||||
// It is safe to remove and re-insert because mWhen is now
|
||||
// strictly smaller than it used to be, so we know we'll insert
|
||||
@ -10176,7 +10178,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
|
||||
|
||||
timeout = nextTimeout;
|
||||
} else {
|
||||
timeout = timeout->Next();
|
||||
timeout = timeout->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10188,7 +10190,7 @@ nsGlobalWindow::ClearAllTimeouts()
|
||||
{
|
||||
nsTimeout *timeout, *nextTimeout;
|
||||
|
||||
for (timeout = FirstTimeout(); timeout; timeout = nextTimeout) {
|
||||
for (timeout = mTimeouts.getFirst(); timeout; timeout = nextTimeout) {
|
||||
/* If RunTimeout() is higher up on the stack for this
|
||||
window, e.g. as a result of document.write from a timeout,
|
||||
then we need to reset the list insertion point for
|
||||
@ -10197,7 +10199,7 @@ nsGlobalWindow::ClearAllTimeouts()
|
||||
if (mRunningTimeout == timeout)
|
||||
mTimeoutInsertionPoint = nullptr;
|
||||
|
||||
nextTimeout = timeout->Next();
|
||||
nextTimeout = timeout->getNext();
|
||||
|
||||
if (timeout->mTimer) {
|
||||
timeout->mTimer->Cancel();
|
||||
@ -10230,14 +10232,14 @@ nsGlobalWindow::InsertTimeoutIntoList(nsTimeout *aTimeout)
|
||||
// mTimeoutInsertionPoint, though. This optimizes for the common case of
|
||||
// insertion at the end.
|
||||
nsTimeout* prevSibling;
|
||||
for (prevSibling = LastTimeout();
|
||||
for (prevSibling = mTimeouts.getLast();
|
||||
prevSibling && prevSibling != mTimeoutInsertionPoint &&
|
||||
// This condition needs to match the one in SetTimeoutOrInterval that
|
||||
// determines whether to set mWhen or mTimeRemaining.
|
||||
((IsFrozen() || mTimeoutsSuspendDepth) ?
|
||||
prevSibling->mTimeRemaining > aTimeout->mTimeRemaining :
|
||||
prevSibling->mWhen > aTimeout->mWhen);
|
||||
prevSibling = prevSibling->Prev()) {
|
||||
prevSibling = prevSibling->getPrevious()) {
|
||||
/* Do nothing; just searching */
|
||||
}
|
||||
|
||||
@ -10534,7 +10536,7 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
|
||||
mozilla::dom::workers::SuspendWorkersForWindow(cx, this);
|
||||
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
for (nsTimeout *t = FirstTimeout(); t; t = t->Next()) {
|
||||
for (nsTimeout *t = mTimeouts.getFirst(); t; t = t->getNext()) {
|
||||
// Set mTimeRemaining to be the time remaining for this timer.
|
||||
if (t->mWhen > now)
|
||||
t->mTimeRemaining = t->mWhen - now;
|
||||
@ -10622,7 +10624,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
|
||||
bool _seenDummyTimeout = false;
|
||||
#endif
|
||||
|
||||
for (nsTimeout *t = FirstTimeout(); t; t = t->Next()) {
|
||||
for (nsTimeout *t = mTimeouts.getFirst(); t; t = t->getNext()) {
|
||||
// There's a chance we're being called with RunTimeout on the stack in which
|
||||
// case we have a dummy timeout in the list that *must not* be resumed. It
|
||||
// can be identified by a null mWindow.
|
||||
|
@ -144,14 +144,6 @@ struct nsTimeout : mozilla::LinkedListElement<nsTimeout>
|
||||
nsrefcnt Release();
|
||||
nsrefcnt AddRef();
|
||||
|
||||
nsTimeout* Next() {
|
||||
return getNext();
|
||||
}
|
||||
|
||||
nsTimeout* Prev() {
|
||||
return getPrevious();
|
||||
}
|
||||
|
||||
nsresult InitTimer(nsTimerCallbackFunc aFunc, uint64_t delay) {
|
||||
return mTimer->InitWithFuncCallback(aFunc, this, delay,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
@ -868,14 +860,6 @@ protected:
|
||||
|
||||
bool IsInModalState();
|
||||
|
||||
nsTimeout* FirstTimeout() {
|
||||
return mTimeouts.getFirst();
|
||||
}
|
||||
|
||||
nsTimeout* LastTimeout() {
|
||||
return mTimeouts.getLast();
|
||||
}
|
||||
|
||||
// Convenience functions for the many methods that need to scale
|
||||
// from device to CSS pixels or vice versa. Note: if a presentation
|
||||
// context is not available, they will assume a 1:1 ratio.
|
||||
|
Loading…
Reference in New Issue
Block a user