Bumping manifests a=b2g-bump
[gecko.git] / editor / libeditor / IMETextTxn.h
blob55366b6c039968c4f54956a856ddddffca3b5343
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 IMETextTxn_h__
7 #define IMETextTxn_h__
9 #include "EditTxn.h" // base class
10 #include "nsAutoPtr.h" // mTextNode, mRanges
11 #include "nsCycleCollectionParticipant.h" // various macros
12 #include "nsString.h" // mStringToInsert
14 class nsEditor;
16 #define NS_IMETEXTTXN_IID \
17 { 0xb391355d, 0x346c, 0x43d1, \
18 { 0x85, 0xed, 0x9e, 0x65, 0xbe, 0xe7, 0x7e, 0x48 } }
20 namespace mozilla {
22 class TextRangeArray;
24 namespace dom {
26 class Text;
28 /**
29 * A transaction that inserts text into a content node.
31 class IMETextTxn : public EditTxn
33 public:
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMETEXTTXN_IID)
36 /** @param aTextNode the text content node
37 * @param aOffset the location in aTextNode to do the insertion
38 * @param aReplaceLength the length of text to replace (0 == no replacement)
39 * @param aTextRangeArray clauses and/or caret information. This may be null.
40 * @param aString the new text to insert
41 * @param aEditor used to get and set the selection
43 IMETextTxn(Text& aTextNode, uint32_t aOffset, uint32_t aReplaceLength,
44 TextRangeArray* aTextRangeArray, const nsAString& aString,
45 nsEditor& aEditor);
47 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
49 NS_DECL_ISUPPORTS_INHERITED
51 NS_DECL_EDITTXN
53 NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) MOZ_OVERRIDE;
55 void MarkFixed();
57 private:
58 ~IMETextTxn();
60 nsresult SetSelectionForRanges();
62 /** The text element to operate upon */
63 nsRefPtr<Text> mTextNode;
65 /** The offsets into mTextNode where the insertion should be placed */
66 uint32_t mOffset;
68 uint32_t mReplaceLength;
70 /** The range list **/
71 nsRefPtr<mozilla::TextRangeArray> mRanges;
73 /** The text to insert into mTextNode at mOffset */
74 nsString mStringToInsert;
76 /** The editor, which is used to get the selection controller */
77 nsEditor& mEditor;
79 bool mFixed;
82 NS_DEFINE_STATIC_IID_ACCESSOR(IMETextTxn, NS_IMETEXTTXN_IID)
87 #endif