/work/obj-fuzz/dist/include/mozilla/ComposerCommandsUpdater.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
2 | | * |
3 | | * This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_ComposerCommandsUpdater_h |
8 | | #define mozilla_ComposerCommandsUpdater_h |
9 | | |
10 | | #include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr |
11 | | #include "nsCycleCollectionParticipant.h" |
12 | | #include "nsIDocumentStateListener.h" |
13 | | #include "nsINamed.h" |
14 | | #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS |
15 | | #include "nsITimer.h" // for NS_DECL_NSITIMERCALLBACK, etc |
16 | | #include "nsITransactionListener.h" // for nsITransactionListener |
17 | | #include "nsIWeakReferenceUtils.h" // for nsWeakPtr |
18 | | #include "nscore.h" // for NS_IMETHOD, nsresult, etc |
19 | | |
20 | | class nsIDocShell; |
21 | | class nsITransaction; |
22 | | class nsITransactionManager; |
23 | | class nsPIDOMWindowOuter; |
24 | | class nsPICommandUpdater; |
25 | | |
26 | | namespace mozilla { |
27 | | |
28 | | class ComposerCommandsUpdater final : public nsIDocumentStateListener |
29 | | , public nsITransactionListener |
30 | | , public nsITimerCallback |
31 | | , public nsINamed |
32 | | { |
33 | | public: |
34 | | ComposerCommandsUpdater(); |
35 | | |
36 | | // nsISupports |
37 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
38 | | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ComposerCommandsUpdater, |
39 | | nsIDocumentStateListener) |
40 | | |
41 | | // nsIDocumentStateListener |
42 | | NS_DECL_NSIDOCUMENTSTATELISTENER |
43 | | |
44 | | // nsITimerCallback |
45 | | NS_DECL_NSITIMERCALLBACK |
46 | | |
47 | | // nsINamed |
48 | | NS_DECL_NSINAMED |
49 | | |
50 | | // nsITransactionListener |
51 | | NS_DECL_NSITRANSACTIONLISTENER |
52 | | |
53 | | nsresult Init(nsPIDOMWindowOuter* aDOMWindow); |
54 | | |
55 | | /** |
56 | | * OnSelectionChange() is called when selection is changed in the editor. |
57 | | */ |
58 | | void OnSelectionChange() |
59 | 0 | { |
60 | 0 | PrimeUpdateTimer(); |
61 | 0 | } |
62 | | |
63 | | protected: |
64 | | virtual ~ComposerCommandsUpdater(); |
65 | | |
66 | | enum |
67 | | { |
68 | | eStateUninitialized = -1, |
69 | | eStateOff = 0, |
70 | | eStateOn = 1, |
71 | | }; |
72 | | |
73 | | bool SelectionIsCollapsed(); |
74 | | nsresult UpdateDirtyState(bool aNowDirty); |
75 | | nsresult UpdateOneCommand(const char* aCommand); |
76 | | nsresult UpdateCommandGroup(const nsAString& aCommandGroup); |
77 | | |
78 | | already_AddRefed<nsPICommandUpdater> GetCommandUpdater(); |
79 | | |
80 | | nsresult PrimeUpdateTimer(); |
81 | | void TimerCallback(); |
82 | | |
83 | | nsCOMPtr<nsITimer> mUpdateTimer; |
84 | | nsCOMPtr<nsPIDOMWindowOuter> mDOMWindow; |
85 | | nsCOMPtr<nsIDocShell> mDocShell; |
86 | | |
87 | | int8_t mDirtyState; |
88 | | int8_t mSelectionCollapsed; |
89 | | bool mFirstDoOfFirstUndo; |
90 | | }; |
91 | | |
92 | | } // namespace mozilla |
93 | | |
94 | | #endif // #ifndef mozilla_ComposerCommandsUpdater_h |