зеркало из https://github.com/mozilla/pjs.git
Bug 351236, r+sr=neil
This commit is contained in:
Родитель
62ceeb1817
Коммит
de66d95d55
|
@ -49,14 +49,12 @@
|
|||
#include "nsString.h"
|
||||
|
||||
#include "nsICommandManager.h"
|
||||
#include "nsPICommandUpdater.h"
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsITransactionManager.h"
|
||||
|
||||
nsComposerCommandsUpdater::nsComposerCommandsUpdater()
|
||||
: mDOMWindow(nsnull)
|
||||
, mDocShell(nsnull)
|
||||
, mDirtyState(eStateUninitialized)
|
||||
, mSelectionCollapsed(eStateUninitialized)
|
||||
, mFirstDoOfFirstUndo(PR_TRUE)
|
||||
|
@ -248,7 +246,7 @@ nsComposerCommandsUpdater::Init(nsIDOMWindow* aDOMWindow)
|
|||
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aDOMWindow));
|
||||
if (window)
|
||||
{
|
||||
mDocShell = window->GetDocShell();
|
||||
mDocShell = do_GetWeakReference(window->GetDocShell());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -301,10 +299,7 @@ nsComposerCommandsUpdater::UpdateDirtyState(PRBool aNowDirty)
|
|||
nsresult
|
||||
nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
|
||||
{
|
||||
if (!mDocShell) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(mDocShell);
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = do_QueryInterface(commandManager);
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = GetCommandUpdater();
|
||||
if (!commandUpdater) return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
|
@ -358,10 +353,7 @@ nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
|
|||
nsresult
|
||||
nsComposerCommandsUpdater::UpdateOneCommand(const char *aCommand)
|
||||
{
|
||||
if (!mDocShell) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(mDocShell);
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = do_QueryInterface(commandManager);
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = GetCommandUpdater();
|
||||
if (!commandUpdater) return NS_ERROR_FAILURE;
|
||||
|
||||
commandUpdater->CommandStatusChanged(aCommand);
|
||||
|
@ -387,6 +379,18 @@ nsComposerCommandsUpdater::SelectionIsCollapsed()
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
already_AddRefed<nsPICommandUpdater>
|
||||
nsComposerCommandsUpdater::GetCommandUpdater()
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
NS_ENSURE_TRUE(docShell, nsnull);
|
||||
nsCOMPtr<nsICommandManager> manager = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsPICommandUpdater> updater = do_QueryInterface(manager);
|
||||
nsPICommandUpdater* retVal = nsnull;
|
||||
updater.swap(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsPICommandUpdater.h"
|
||||
|
||||
#include "nsISelectionListener.h"
|
||||
#include "nsIDocumentStateListener.h"
|
||||
|
@ -110,13 +112,15 @@ protected:
|
|||
nsresult UpdateDirtyState(PRBool aNowDirty);
|
||||
nsresult UpdateOneCommand(const char* aCommand);
|
||||
nsresult UpdateCommandGroup(const nsAString& aCommandGroup);
|
||||
|
||||
already_AddRefed<nsPICommandUpdater> GetCommandUpdater();
|
||||
|
||||
nsresult PrimeUpdateTimer();
|
||||
void TimerCallback();
|
||||
nsCOMPtr<nsITimer> mUpdateTimer;
|
||||
|
||||
nsIDOMWindow* mDOMWindow; // Weak reference
|
||||
nsIDocShell* mDocShell; // Weak reference
|
||||
nsWeakPtr mDocShell;
|
||||
PRInt8 mDirtyState;
|
||||
PRInt8 mSelectionCollapsed;
|
||||
PRPackedBool mFirstDoOfFirstUndo;
|
||||
|
|
Загрузка…
Ссылка в новой задаче