2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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/. */
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
#ifndef nsAutoCopyListener_h_
|
|
|
|
#define nsAutoCopyListener_h_
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
#include "nsISelectionListener.h"
|
|
|
|
#include "nsISelectionPrivate.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsAutoCopyListener final : public nsISelectionListener
|
2005-02-01 02:47:26 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISELECTIONLISTENER
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2016-06-03 19:04:22 +03:00
|
|
|
explicit nsAutoCopyListener(int16_t aClipboardID)
|
|
|
|
: mCachedClipboard(aClipboardID)
|
|
|
|
{}
|
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
void Listen(nsISelectionPrivate *aSelection)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aSelection, "Null selection passed to Listen()");
|
|
|
|
aSelection->AddSelectionListener(this);
|
|
|
|
}
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2016-06-03 19:04:22 +03:00
|
|
|
static nsAutoCopyListener* GetInstance(int16_t aClipboardID)
|
2005-02-01 02:47:26 +03:00
|
|
|
{
|
|
|
|
if (!sInstance) {
|
2016-06-03 19:04:22 +03:00
|
|
|
sInstance = new nsAutoCopyListener(aClipboardID);
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
NS_ADDREF(sInstance);
|
|
|
|
}
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
return sInstance;
|
|
|
|
}
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
static void Shutdown()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(sInstance);
|
|
|
|
}
|
2000-04-14 10:18:36 +04:00
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
private:
|
2014-06-24 02:40:01 +04:00
|
|
|
~nsAutoCopyListener() {}
|
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
static nsAutoCopyListener* sInstance;
|
2016-06-03 19:04:22 +03:00
|
|
|
int16_t mCachedClipboard;
|
2000-04-14 10:18:36 +04:00
|
|
|
};
|
|
|
|
|
2005-02-01 02:47:26 +03:00
|
|
|
#endif
|