layout/generic/nsAutoCopyListener.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:04b7e9bbe9b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsAutoCopyListener_h_
7 #define nsAutoCopyListener_h_
8
9 #include "nsISelectionListener.h"
10 #include "nsISelectionPrivate.h"
11 #include "mozilla/Attributes.h"
12
13 class nsAutoCopyListener MOZ_FINAL : public nsISelectionListener
14 {
15 public:
16 NS_DECL_ISUPPORTS
17 NS_DECL_NSISELECTIONLISTENER
18
19 void Listen(nsISelectionPrivate *aSelection)
20 {
21 NS_ASSERTION(aSelection, "Null selection passed to Listen()");
22 aSelection->AddSelectionListener(this);
23 }
24
25 static nsAutoCopyListener* GetInstance()
26 {
27 if (!sInstance) {
28 sInstance = new nsAutoCopyListener();
29
30 NS_ADDREF(sInstance);
31 }
32
33 return sInstance;
34 }
35
36 static void Shutdown()
37 {
38 NS_IF_RELEASE(sInstance);
39 }
40
41 private:
42 static nsAutoCopyListener* sInstance;
43 };
44
45 #endif

mercurial