Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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"
10 #include "nsCOMPtr.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsID.h"
13 #include "nsIDOMCharacterData.h"
14 #include "nsString.h"
15 #include "nscore.h"
16 #include "mozilla/TextRange.h"
18 class nsITransaction;
20 // {D4D25721-2813-11d3-9EA3-0060089FE59B}
21 #define IME_TEXT_TXN_CID \
22 {0xd4d25721, 0x2813, 0x11d3, \
23 {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
26 class nsIEditor;
29 /**
30 * A transaction that inserts text into a content node.
31 */
32 class IMETextTxn : public EditTxn
33 {
34 public:
35 static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; }
37 /** initialize the transaction
38 * @param aElement the text content node
39 * @param aOffset the location in aElement to do the insertion
40 * @param aReplaceLength the length of text to replace (0 == no replacement)
41 * @param aTextRangeArray clauses and/or caret information. This may be null.
42 * @param aString the new text to insert
43 * @param aSelCon used to get and set the selection
44 */
45 NS_IMETHOD Init(nsIDOMCharacterData *aElement,
46 uint32_t aOffset,
47 uint32_t aReplaceLength,
48 mozilla::TextRangeArray* aTextRangeArray,
49 const nsAString& aString,
50 nsIEditor* aEditor);
52 IMETextTxn();
54 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn)
56 NS_DECL_EDITTXN
58 NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
60 NS_IMETHOD MarkFixed(void);
62 // nsISupports declarations
64 // override QueryInterface to handle IMETextTxn request
65 NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
67 protected:
69 nsresult SetSelectionForRanges();
71 /** the text element to operate upon */
72 nsCOMPtr<nsIDOMCharacterData> mElement;
74 /** the offsets into mElement where the insertion should be placed*/
75 uint32_t mOffset;
77 uint32_t mReplaceLength;
79 /** the text to insert into mElement at mOffset */
80 nsString mStringToInsert;
82 /** the range list **/
83 nsRefPtr<mozilla::TextRangeArray> mRanges;
85 /** the editor, which is used to get the selection controller */
86 nsIEditor *mEditor;
88 bool mFixed;
89 };
91 #endif