2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-03-15 03:57:32 +03:00
|
|
|
|
|
|
|
#ifndef AggregatePlaceholderTxn_h__
|
|
|
|
#define AggregatePlaceholderTxn_h__
|
|
|
|
|
|
|
|
#include "EditAggregateTxn.h"
|
2000-01-31 13:30:12 +03:00
|
|
|
#include "nsEditorUtils.h"
|
1999-09-30 00:08:15 +04:00
|
|
|
#include "nsIAbsorbingTransaction.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
2007-01-11 17:38:02 +03:00
|
|
|
#include "nsAutoPtr.h"
|
1999-03-15 03:57:32 +03:00
|
|
|
|
2014-08-29 15:43:24 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1999-10-26 22:54:47 +04:00
|
|
|
class IMETextTxn;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
1999-09-30 00:08:15 +04:00
|
|
|
|
1999-03-15 03:57:32 +03:00
|
|
|
/**
|
|
|
|
* An aggregate transaction that knows how to absorb all subsequent
|
|
|
|
* transactions with the same name. This transaction does not "Do" anything.
|
|
|
|
* But it absorbs other transactions via merge, and can undo/redo the
|
|
|
|
* transactions it has absorbed.
|
|
|
|
*/
|
2015-05-28 18:58:42 +03:00
|
|
|
|
|
|
|
class PlaceholderTxn : public EditAggregateTxn,
|
|
|
|
public nsIAbsorbingTransaction,
|
1999-09-30 00:08:15 +04:00
|
|
|
public nsSupportsWeakReference
|
1999-03-15 03:57:32 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-05-28 18:58:42 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
1999-03-15 03:57:32 +03:00
|
|
|
PlaceholderTxn();
|
|
|
|
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn)
|
1999-09-30 00:08:15 +04:00
|
|
|
// ------------ EditAggregateTxn -----------------------
|
|
|
|
|
2007-01-11 17:38:02 +03:00
|
|
|
NS_DECL_EDITTXN
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD RedoTransaction() override;
|
|
|
|
NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge) override;
|
2001-03-09 17:23:59 +03:00
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
// ------------ nsIAbsorbingTransaction -----------------------
|
|
|
|
|
2012-07-23 14:27:22 +04:00
|
|
|
NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEditor* aEditor) override;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetTxnName(nsIAtom **aName) override;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult) override;
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD EndPlaceHolderBatch() override;
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress) override;
|
1999-03-15 03:57:32 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Commit() override;
|
1999-10-26 22:54:47 +04:00
|
|
|
|
2015-01-02 09:14:13 +03:00
|
|
|
nsresult RememberEndingSelection();
|
1999-03-15 03:57:32 +03:00
|
|
|
|
|
|
|
protected:
|
2014-07-09 01:23:18 +04:00
|
|
|
virtual ~PlaceholderTxn();
|
1999-03-15 03:57:32 +03:00
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
/** the presentation shell, which we'll need to get the selection */
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAbsorb; // do we auto absorb any and all transaction?
|
1999-10-26 22:54:47 +04:00
|
|
|
nsWeakPtr mForwarding;
|
2014-08-29 15:43:24 +04:00
|
|
|
mozilla::dom::IMETextTxn *mIMETextTxn; // first IME txn in this placeholder - used for IME merging
|
2005-11-26 00:57:13 +03:00
|
|
|
// non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mCommitted; // do we stop auto absorbing any matching placeholder txns?
|
2015-05-28 18:58:42 +03:00
|
|
|
// these next two members store the state of the selection in a safe way.
|
2000-01-31 13:30:12 +03:00
|
|
|
// selection at the start of the txn is stored, as is the selection at the end.
|
2001-03-09 17:23:59 +03:00
|
|
|
// This is so that UndoTransaction() and RedoTransaction() can restore the
|
|
|
|
// selection properly.
|
2007-01-11 17:38:02 +03:00
|
|
|
nsAutoPtr<nsSelectionState> mStartSel; // use a pointer because this is constructed before we exist
|
2000-01-31 13:30:12 +03:00
|
|
|
nsSelectionState mEndSel;
|
2012-07-23 14:27:22 +04:00
|
|
|
nsEditor* mEditor; /** the editor for this transaction */
|
1999-03-15 03:57:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|