2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsRepeatService.h"
|
2002-09-07 09:38:16 +04:00
|
|
|
#include "nsIServiceManager.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsRepeatService* nsRepeatService::gInstance = nullptr;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
nsRepeatService::nsRepeatService()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mCallback(nullptr), mCallbackData(nullptr)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRepeatService::~nsRepeatService()
|
|
|
|
{
|
2008-02-15 05:04:34 +03:00
|
|
|
NS_ASSERTION(!mCallback && !mCallbackData, "Callback was not removed before shutdown");
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRepeatService*
|
|
|
|
nsRepeatService::GetInstance()
|
|
|
|
{
|
2000-11-08 06:20:22 +03:00
|
|
|
if (!gInstance) {
|
|
|
|
gInstance = new nsRepeatService();
|
|
|
|
NS_IF_ADDREF(gInstance);
|
|
|
|
}
|
|
|
|
return gInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
nsRepeatService::Shutdown()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(gInstance);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2009-12-12 01:03:31 +03:00
|
|
|
void nsRepeatService::Start(Callback aCallback, void* aCallbackData,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aInitialDelay)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(aCallback != nullptr, "null ptr");
|
2000-01-19 10:40:18 +03:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
mCallback = aCallback;
|
2008-02-15 05:04:34 +03:00
|
|
|
mCallbackData = aCallbackData;
|
2000-05-17 06:49:35 +04:00
|
|
|
nsresult rv;
|
2000-09-14 03:57:52 +04:00
|
|
|
mRepeatTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2008-02-15 05:04:34 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2009-12-12 01:03:31 +03:00
|
|
|
mRepeatTimer->InitWithCallback(this, aInitialDelay, nsITimer::TYPE_ONE_SHOT);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-15 05:04:34 +03:00
|
|
|
void nsRepeatService::Stop(Callback aCallback, void* aCallbackData)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2008-02-15 05:04:34 +03:00
|
|
|
if (mCallback != aCallback || mCallbackData != aCallbackData)
|
|
|
|
return;
|
|
|
|
|
2002-08-03 23:51:51 +04:00
|
|
|
//printf("Stopping repeat timer\n");
|
1999-08-20 02:16:23 +04:00
|
|
|
if (mRepeatTimer) {
|
|
|
|
mRepeatTimer->Cancel();
|
2012-07-30 18:20:58 +04:00
|
|
|
mRepeatTimer = nullptr;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
mCallback = nullptr;
|
|
|
|
mCallbackData = nullptr;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2002-09-07 09:38:16 +04:00
|
|
|
NS_IMETHODIMP nsRepeatService::Notify(nsITimer *timer)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
// do callback
|
2000-01-19 10:40:18 +03:00
|
|
|
if (mCallback)
|
2008-02-15 05:04:34 +03:00
|
|
|
mCallback(mCallbackData);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
|
|
|
// start timer again.
|
2002-08-03 23:51:51 +04:00
|
|
|
if (mRepeatTimer) {
|
2008-02-15 05:04:34 +03:00
|
|
|
mRepeatTimer->InitWithCallback(this, REPEAT_DELAY, nsITimer::TYPE_ONE_SHOT);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
2002-09-07 09:38:16 +04:00
|
|
|
return NS_OK;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsRepeatService, nsITimerCallback)
|