editor/libeditor/base/PlaceholderTxn.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 AggregatePlaceholderTxn_h__
     7 #define AggregatePlaceholderTxn_h__
     9 #include "EditAggregateTxn.h"
    10 #include "nsEditorUtils.h"
    11 #include "nsIAbsorbingTransaction.h"
    12 #include "nsIDOMNode.h"
    13 #include "nsCOMPtr.h"
    14 #include "nsWeakPtr.h"
    15 #include "nsWeakReference.h"
    16 #include "nsAutoPtr.h"
    18 class nsHTMLEditor;
    19 class IMETextTxn;
    21 /**
    22  * An aggregate transaction that knows how to absorb all subsequent
    23  * transactions with the same name.  This transaction does not "Do" anything.
    24  * But it absorbs other transactions via merge, and can undo/redo the
    25  * transactions it has absorbed.
    26  */
    28 class PlaceholderTxn : public EditAggregateTxn, 
    29                        public nsIAbsorbingTransaction, 
    30                        public nsSupportsWeakReference
    31 {
    32 public:
    33   NS_DECL_ISUPPORTS_INHERITED  
    35   PlaceholderTxn();
    37   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn)
    38 // ------------ EditAggregateTxn -----------------------
    40   NS_DECL_EDITTXN
    42   NS_IMETHOD RedoTransaction();
    43   NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
    45 // ------------ nsIAbsorbingTransaction -----------------------
    47   NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState,
    48                   nsEditor* aEditor);
    50   NS_IMETHOD GetTxnName(nsIAtom **aName);
    52   NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult);
    54   NS_IMETHOD EndPlaceHolderBatch();
    56   NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress);
    58   NS_IMETHOD Commit();
    60   NS_IMETHOD RememberEndingSelection();
    62 protected:
    64   /** the presentation shell, which we'll need to get the selection */
    65   bool        mAbsorb;          // do we auto absorb any and all transaction?
    66   nsWeakPtr   mForwarding;
    67   IMETextTxn *mIMETextTxn;      // first IME txn in this placeholder - used for IME merging
    68                                 // non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
    69   bool        mCommitted;       // do we stop auto absorbing any matching placeholder txns?
    70   // these next two members store the state of the selection in a safe way. 
    71   // selection at the start of the txn is stored, as is the selection at the end.
    72   // This is so that UndoTransaction() and RedoTransaction() can restore the
    73   // selection properly.
    74   nsAutoPtr<nsSelectionState> mStartSel; // use a pointer because this is constructed before we exist
    75   nsSelectionState  mEndSel;
    76   nsEditor*         mEditor;   /** the editor for this transaction */
    77 };
    80 #endif

mercurial