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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef IMETextTxn_h__ |
michael@0 | 7 | #define IMETextTxn_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "EditTxn.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 12 | #include "nsID.h" |
michael@0 | 13 | #include "nsIDOMCharacterData.h" |
michael@0 | 14 | #include "nsString.h" |
michael@0 | 15 | #include "nscore.h" |
michael@0 | 16 | #include "mozilla/TextRange.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsITransaction; |
michael@0 | 19 | |
michael@0 | 20 | // {D4D25721-2813-11d3-9EA3-0060089FE59B} |
michael@0 | 21 | #define IME_TEXT_TXN_CID \ |
michael@0 | 22 | {0xd4d25721, 0x2813, 0x11d3, \ |
michael@0 | 23 | {0x9e, 0xa3, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }} |
michael@0 | 24 | |
michael@0 | 25 | |
michael@0 | 26 | class nsIEditor; |
michael@0 | 27 | |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * A transaction that inserts text into a content node. |
michael@0 | 31 | */ |
michael@0 | 32 | class IMETextTxn : public EditTxn |
michael@0 | 33 | { |
michael@0 | 34 | public: |
michael@0 | 35 | static const nsIID& GetCID() { static const nsIID iid = IME_TEXT_TXN_CID; return iid; } |
michael@0 | 36 | |
michael@0 | 37 | /** initialize the transaction |
michael@0 | 38 | * @param aElement the text content node |
michael@0 | 39 | * @param aOffset the location in aElement to do the insertion |
michael@0 | 40 | * @param aReplaceLength the length of text to replace (0 == no replacement) |
michael@0 | 41 | * @param aTextRangeArray clauses and/or caret information. This may be null. |
michael@0 | 42 | * @param aString the new text to insert |
michael@0 | 43 | * @param aSelCon used to get and set the selection |
michael@0 | 44 | */ |
michael@0 | 45 | NS_IMETHOD Init(nsIDOMCharacterData *aElement, |
michael@0 | 46 | uint32_t aOffset, |
michael@0 | 47 | uint32_t aReplaceLength, |
michael@0 | 48 | mozilla::TextRangeArray* aTextRangeArray, |
michael@0 | 49 | const nsAString& aString, |
michael@0 | 50 | nsIEditor* aEditor); |
michael@0 | 51 | |
michael@0 | 52 | IMETextTxn(); |
michael@0 | 53 | |
michael@0 | 54 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IMETextTxn, EditTxn) |
michael@0 | 55 | |
michael@0 | 56 | NS_DECL_EDITTXN |
michael@0 | 57 | |
michael@0 | 58 | NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge); |
michael@0 | 59 | |
michael@0 | 60 | NS_IMETHOD MarkFixed(void); |
michael@0 | 61 | |
michael@0 | 62 | // nsISupports declarations |
michael@0 | 63 | |
michael@0 | 64 | // override QueryInterface to handle IMETextTxn request |
michael@0 | 65 | NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); |
michael@0 | 66 | |
michael@0 | 67 | protected: |
michael@0 | 68 | |
michael@0 | 69 | nsresult SetSelectionForRanges(); |
michael@0 | 70 | |
michael@0 | 71 | /** the text element to operate upon */ |
michael@0 | 72 | nsCOMPtr<nsIDOMCharacterData> mElement; |
michael@0 | 73 | |
michael@0 | 74 | /** the offsets into mElement where the insertion should be placed*/ |
michael@0 | 75 | uint32_t mOffset; |
michael@0 | 76 | |
michael@0 | 77 | uint32_t mReplaceLength; |
michael@0 | 78 | |
michael@0 | 79 | /** the text to insert into mElement at mOffset */ |
michael@0 | 80 | nsString mStringToInsert; |
michael@0 | 81 | |
michael@0 | 82 | /** the range list **/ |
michael@0 | 83 | nsRefPtr<mozilla::TextRangeArray> mRanges; |
michael@0 | 84 | |
michael@0 | 85 | /** the editor, which is used to get the selection controller */ |
michael@0 | 86 | nsIEditor *mEditor; |
michael@0 | 87 | |
michael@0 | 88 | bool mFixed; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | #endif |