gecko-dev/layout/generic/nsAutoCopyListener.h

54 строки
1.2 KiB
C
Исходник Обычный вид История

/* -*- 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
#ifndef nsAutoCopyListener_h_
#define nsAutoCopyListener_h_
2000-04-14 10:18:36 +04:00
#include "nsISelectionListener.h"
#include "nsISelectionPrivate.h"
#include "mozilla/Attributes.h"
2000-04-14 10:18:36 +04:00
class nsAutoCopyListener final : public nsISelectionListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISELECTIONLISTENER
2000-04-14 10:18:36 +04:00
explicit nsAutoCopyListener(int16_t aClipboardID)
: mCachedClipboard(aClipboardID)
{}
void Listen(nsISelectionPrivate *aSelection)
{
NS_ASSERTION(aSelection, "Null selection passed to Listen()");
aSelection->AddSelectionListener(this);
}
2000-04-14 10:18:36 +04:00
static nsAutoCopyListener* GetInstance(int16_t aClipboardID)
{
if (!sInstance) {
sInstance = new nsAutoCopyListener(aClipboardID);
2000-04-14 10:18:36 +04:00
NS_ADDREF(sInstance);
}
2000-04-14 10:18:36 +04:00
return sInstance;
}
2000-04-14 10:18:36 +04:00
static void Shutdown()
{
NS_IF_RELEASE(sInstance);
}
2000-04-14 10:18:36 +04:00
private:
~nsAutoCopyListener() {}
static nsAutoCopyListener* sInstance;
int16_t mCachedClipboard;
2000-04-14 10:18:36 +04:00
};
#endif