Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
[gecko.git] / dom / events / IMEContentObserver.h
blobf9819dbe3178c38043418a7b4f284a4ce0543605
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=80: */
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/. */
7 #ifndef mozilla_IMEContentObserver_h_
8 #define mozilla_IMEContentObserver_h_
10 #include "mozilla/Attributes.h"
11 #include "nsCOMPtr.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsIDocShell.h" // XXX Why does only this need to be included here?
14 #include "nsIReflowObserver.h"
15 #include "nsISelectionListener.h"
16 #include "nsIScrollObserver.h"
17 #include "nsIWidget.h" // for nsIMEUpdatePreference
18 #include "nsStubMutationObserver.h"
19 #include "nsWeakReference.h"
21 class nsIContent;
22 class nsINode;
23 class nsISelection;
24 class nsPresContext;
26 namespace mozilla {
28 class EventStateManager;
30 // IMEContentObserver notifies widget of any text and selection changes
31 // in the currently focused editor
32 class IMEContentObserver MOZ_FINAL : public nsISelectionListener,
33 public nsStubMutationObserver,
34 public nsIReflowObserver,
35 public nsIScrollObserver,
36 public nsSupportsWeakReference
38 public:
39 IMEContentObserver();
41 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
42 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(IMEContentObserver,
43 nsISelectionListener)
44 NS_DECL_NSISELECTIONLISTENER
45 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
46 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
47 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
48 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
49 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
50 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
51 NS_DECL_NSIREFLOWOBSERVER
53 // nsIScrollObserver
54 virtual void ScrollPositionChanged() MOZ_OVERRIDE;
56 void Init(nsIWidget* aWidget, nsPresContext* aPresContext,
57 nsIContent* aContent);
58 void Destroy();
59 /**
60 * IMEContentObserver is stored by EventStateManager during observing.
61 * DisconnectFromEventStateManager() is called when EventStateManager stops
62 * storing the instance.
64 void DisconnectFromEventStateManager();
65 bool IsManaging(nsPresContext* aPresContext, nsIContent* aContent);
66 bool IsEditorHandlingEventForComposition() const;
67 bool KeepAliveDuringDeactive() const
69 return mUpdatePreference.WantDuringDeactive();
71 nsIWidget* GetWidget() const { return mWidget; }
72 nsresult GetSelectionAndRoot(nsISelection** aSelection,
73 nsIContent** aRoot) const;
75 private:
76 ~IMEContentObserver() {}
78 void NotifyContentAdded(nsINode* aContainer, int32_t aStart, int32_t aEnd);
79 void ObserveEditableNode();
81 nsCOMPtr<nsIWidget> mWidget;
82 nsCOMPtr<nsISelection> mSelection;
83 nsCOMPtr<nsIContent> mRootContent;
84 nsCOMPtr<nsINode> mEditableNode;
85 nsCOMPtr<nsIDocShell> mDocShell;
87 EventStateManager* mESM;
89 nsIMEUpdatePreference mUpdatePreference;
90 uint32_t mPreAttrChangeLength;
93 } // namespace mozilla
95 #endif // mozilla_IMEContentObserver_h_