editor/libeditor/base/InsertTextTxn.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 InsertTextTxn_h__
michael@0 7 #define InsertTextTxn_h__
michael@0 8
michael@0 9 #include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
michael@0 10 #include "nsCOMPtr.h" // for nsCOMPtr
michael@0 11 #include "nsCycleCollectionParticipant.h"
michael@0 12 #include "nsID.h" // for nsIID
michael@0 13 #include "nsIDOMCharacterData.h" // for nsIDOMCharacterData
michael@0 14 #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
michael@0 15 #include "nsString.h" // for nsString
michael@0 16 #include "nscore.h" // for NS_IMETHOD, nsAString
michael@0 17
michael@0 18 class nsIEditor;
michael@0 19 class nsITransaction;
michael@0 20
michael@0 21
michael@0 22 #define INSERT_TEXT_TXN_CID \
michael@0 23 {/* 93276f00-ab2c-11d2-8f4b-006008159b0c*/ \
michael@0 24 0x93276f00, 0xab2c, 0x11d2, \
michael@0 25 {0x8f, 0xb4, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc} }
michael@0 26
michael@0 27 /**
michael@0 28 * A transaction that inserts text into a content node.
michael@0 29 */
michael@0 30 class InsertTextTxn : public EditTxn
michael@0 31 {
michael@0 32 public:
michael@0 33
michael@0 34 static const nsIID& GetCID() { static const nsIID iid = INSERT_TEXT_TXN_CID; return iid; }
michael@0 35
michael@0 36 /** initialize the transaction
michael@0 37 * @param aElement the text content node
michael@0 38 * @param aOffset the location in aElement to do the insertion
michael@0 39 * @param aString the new text to insert
michael@0 40 * @param aPresShell used to get and set the selection
michael@0 41 */
michael@0 42 NS_IMETHOD Init(nsIDOMCharacterData *aElement,
michael@0 43 uint32_t aOffset,
michael@0 44 const nsAString& aString,
michael@0 45 nsIEditor *aEditor);
michael@0 46
michael@0 47 InsertTextTxn();
michael@0 48
michael@0 49 NS_DECL_ISUPPORTS_INHERITED
michael@0 50 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
michael@0 51
michael@0 52 NS_DECL_EDITTXN
michael@0 53
michael@0 54 NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
michael@0 55
michael@0 56 /** return the string data associated with this transaction */
michael@0 57 NS_IMETHOD GetData(nsString& aResult);
michael@0 58
michael@0 59 protected:
michael@0 60
michael@0 61 /** return true if aOtherTxn immediately follows this txn */
michael@0 62 virtual bool IsSequentialInsert(InsertTextTxn *aOtherTxn);
michael@0 63
michael@0 64 /** the text element to operate upon */
michael@0 65 nsCOMPtr<nsIDOMCharacterData> mElement;
michael@0 66
michael@0 67 /** the offset into mElement where the insertion is to take place */
michael@0 68 uint32_t mOffset;
michael@0 69
michael@0 70 /** the text to insert into mElement at mOffset */
michael@0 71 nsString mStringToInsert;
michael@0 72
michael@0 73 /** the editor, which we'll need to get the selection */
michael@0 74 nsIEditor *mEditor;
michael@0 75 };
michael@0 76
michael@0 77 #endif

mercurial