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