2002-01-30 07:46:54 +03: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/. */
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef nsComposerCommandsUpdater_h__
|
|
|
|
#define nsComposerCommandsUpdater_h__
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr
|
2002-01-30 07:46:54 +03:00
|
|
|
#include "nsIDocumentStateListener.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsISelectionListener.h"
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS
|
|
|
|
#include "nsITimer.h" // for NS_DECL_NSITIMERCALLBACK, etc
|
|
|
|
#include "nsITransactionListener.h" // for nsITransactionListener
|
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
|
|
|
#include "nscore.h" // for NS_IMETHOD, nsresult, etc
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowOuter;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsITransaction;
|
2002-01-30 07:46:54 +03:00
|
|
|
class nsITransactionManager;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsPICommandUpdater;
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
class nsComposerCommandsUpdater : public nsISelectionListener,
|
|
|
|
public nsIDocumentStateListener,
|
|
|
|
public nsITransactionListener,
|
|
|
|
public nsITimerCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsComposerCommandsUpdater();
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-01-30 07:46:54 +03:00
|
|
|
// nsISelectionListener
|
|
|
|
NS_DECL_NSISELECTIONLISTENER
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-01-30 07:46:54 +03:00
|
|
|
// nsIDocumentStateListener
|
|
|
|
NS_DECL_NSIDOCUMENTSTATELISTENER
|
|
|
|
|
|
|
|
// nsITimerCallback interfaces
|
2002-09-07 09:38:16 +04:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
/** nsITransactionListener interfaces
|
2015-05-28 18:58:42 +03:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD WillDo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
|
|
|
|
NS_IMETHOD DidDo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aDoResult) override;
|
|
|
|
NS_IMETHOD WillUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
|
|
|
|
NS_IMETHOD DidUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aUndoResult) override;
|
|
|
|
NS_IMETHOD WillRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
|
|
|
|
NS_IMETHOD DidRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aRedoResult) override;
|
|
|
|
NS_IMETHOD WillBeginBatch(nsITransactionManager *aManager, bool *aInterrupt) override;
|
|
|
|
NS_IMETHOD DidBeginBatch(nsITransactionManager *aManager, nsresult aResult) override;
|
|
|
|
NS_IMETHOD WillEndBatch(nsITransactionManager *aManager, bool *aInterrupt) override;
|
|
|
|
NS_IMETHOD DidEndBatch(nsITransactionManager *aManager, nsresult aResult) override;
|
2002-01-30 07:46:54 +03:00
|
|
|
NS_IMETHOD WillMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsITransaction *aTransactionToMerge, bool *aInterrupt) override;
|
2002-01-30 07:46:54 +03:00
|
|
|
NS_IMETHOD DidMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction,
|
|
|
|
nsITransaction *aTransactionToMerge,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aDidMerge, nsresult aMergeResult) override;
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsresult Init(nsPIDOMWindowOuter* aDOMWindow);
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsComposerCommandsUpdater();
|
|
|
|
|
2002-01-30 07:46:54 +03:00
|
|
|
enum {
|
|
|
|
eStateUninitialized = -1,
|
2011-10-17 18:59:28 +04:00
|
|
|
eStateOff = false,
|
|
|
|
eStateOn = true
|
2002-01-30 07:46:54 +03:00
|
|
|
};
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SelectionIsCollapsed();
|
2015-05-28 18:58:42 +03:00
|
|
|
nsresult UpdateDirtyState(bool aNowDirty);
|
2002-11-13 02:03:27 +03:00
|
|
|
nsresult UpdateOneCommand(const char* aCommand);
|
|
|
|
nsresult UpdateCommandGroup(const nsAString& aCommandGroup);
|
2007-05-28 00:57:13 +04:00
|
|
|
|
|
|
|
already_AddRefed<nsPICommandUpdater> GetCommandUpdater();
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-01-30 07:46:54 +03:00
|
|
|
nsresult PrimeUpdateTimer();
|
|
|
|
void TimerCallback();
|
|
|
|
nsCOMPtr<nsITimer> mUpdateTimer;
|
2002-11-13 02:03:27 +03:00
|
|
|
|
2009-01-14 15:24:10 +03:00
|
|
|
nsWeakPtr mDOMWindow;
|
2007-05-28 00:57:13 +04:00
|
|
|
nsWeakPtr mDocShell;
|
2015-05-28 18:58:42 +03:00
|
|
|
int8_t mDirtyState;
|
|
|
|
int8_t mSelectionCollapsed;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mFirstDoOfFirstUndo;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
extern "C" nsresult NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult);
|
2002-01-30 07:46:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
#endif // nsComposerCommandsUpdater_h__
|