1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/base/DeleteTextTxn.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef DeleteTextTxn_h__ 1.10 +#define DeleteTextTxn_h__ 1.11 + 1.12 +#include "EditTxn.h" 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsCycleCollectionParticipant.h" 1.15 +#include "nsID.h" 1.16 +#include "nsIDOMCharacterData.h" 1.17 +#include "nsString.h" 1.18 +#include "nscore.h" 1.19 + 1.20 +class nsEditor; 1.21 +class nsRangeUpdater; 1.22 + 1.23 +/** 1.24 + * A transaction that removes text from a content node. 1.25 + */ 1.26 +class DeleteTextTxn : public EditTxn 1.27 +{ 1.28 +public: 1.29 + /** initialize the transaction. 1.30 + * @param aEditor the provider of basic editing operations 1.31 + * @param aElement the content node to remove text from 1.32 + * @param aOffset the location in aElement to begin the deletion 1.33 + * @param aNumCharsToDelete the number of characters to delete. Not the number of bytes! 1.34 + */ 1.35 + NS_IMETHOD Init(nsEditor* aEditor, 1.36 + nsIDOMCharacterData* aCharData, 1.37 + uint32_t aOffset, 1.38 + uint32_t aNumCharsToDelete, 1.39 + nsRangeUpdater* aRangeUpdater); 1.40 + 1.41 + DeleteTextTxn(); 1.42 + 1.43 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteTextTxn, EditTxn) 1.44 + NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); 1.45 + 1.46 + NS_DECL_EDITTXN 1.47 + 1.48 + uint32_t GetOffset() { return mOffset; } 1.49 + 1.50 + uint32_t GetNumCharsToDelete() { return mNumCharsToDelete; } 1.51 + 1.52 +protected: 1.53 + 1.54 + /** the provider of basic editing operations */ 1.55 + nsEditor* mEditor; 1.56 + 1.57 + /** the CharacterData node to operate upon */ 1.58 + nsCOMPtr<nsIDOMCharacterData> mCharData; 1.59 + 1.60 + /** the offset into mCharData where the deletion is to take place */ 1.61 + uint32_t mOffset; 1.62 + 1.63 + /** the number of characters to delete */ 1.64 + uint32_t mNumCharsToDelete; 1.65 + 1.66 + /** the text that was deleted */ 1.67 + nsString mDeletedText; 1.68 + 1.69 + /** range updater object */ 1.70 + nsRangeUpdater* mRangeUpdater; 1.71 +}; 1.72 + 1.73 +#endif