Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
6 #ifndef nsAutoCopyListener_h_
7 #define nsAutoCopyListener_h_
9 #include "nsISelectionListener.h"
10 #include "nsISelectionPrivate.h"
11 #include "mozilla/Attributes.h"
13 class nsAutoCopyListener MOZ_FINAL : public nsISelectionListener
14 {
15 public:
16 NS_DECL_ISUPPORTS
17 NS_DECL_NSISELECTIONLISTENER
19 void Listen(nsISelectionPrivate *aSelection)
20 {
21 NS_ASSERTION(aSelection, "Null selection passed to Listen()");
22 aSelection->AddSelectionListener(this);
23 }
25 static nsAutoCopyListener* GetInstance()
26 {
27 if (!sInstance) {
28 sInstance = new nsAutoCopyListener();
30 NS_ADDREF(sInstance);
31 }
33 return sInstance;
34 }
36 static void Shutdown()
37 {
38 NS_IF_RELEASE(sInstance);
39 }
41 private:
42 static nsAutoCopyListener* sInstance;
43 };
45 #endif