mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-01 11:27:55 +00:00
bug 1271436 - add nsIDocShell::GetCommandManager() r=smaug
This commit is contained in:
parent
1e81548029
commit
256fff4fc9
@ -537,12 +537,12 @@ DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const
|
||||
nsresult
|
||||
DocAccessible::AddEventListeners()
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(mDocumentNode->GetDocShell());
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocumentNode->GetDocShell());
|
||||
|
||||
// We want to add a command observer only if the document is content and has
|
||||
// an editor.
|
||||
if (docShellTreeItem->ItemType() == nsIDocShellTreeItem::typeContent) {
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(docShellTreeItem);
|
||||
if (docShell->ItemType() == nsIDocShellTreeItem::typeContent) {
|
||||
nsCOMPtr<nsICommandManager> commandManager = docShell->GetCommandManager();
|
||||
if (commandManager)
|
||||
commandManager->AddCommandObserver(this, "obs_documentCreated");
|
||||
}
|
||||
@ -567,12 +567,12 @@ DocAccessible::RemoveEventListeners()
|
||||
if (mDocumentNode) {
|
||||
mDocumentNode->RemoveObserver(this);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(mDocumentNode->GetDocShell());
|
||||
NS_ASSERTION(docShellTreeItem, "doc should support nsIDocShellTreeItem.");
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocumentNode->GetDocShell());
|
||||
NS_ASSERTION(docShell, "doc should support nsIDocShellTreeItem.");
|
||||
|
||||
if (docShellTreeItem) {
|
||||
if (docShellTreeItem->ItemType() == nsIDocShellTreeItem::typeContent) {
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(docShellTreeItem);
|
||||
if (docShell) {
|
||||
if (docShell->ItemType() == nsIDocShellTreeItem::typeContent) {
|
||||
nsCOMPtr<nsICommandManager> commandManager = docShell->GetCommandManager();
|
||||
if (commandManager) {
|
||||
commandManager->RemoveCommandObserver(this, "obs_documentCreated");
|
||||
}
|
||||
|
@ -14465,3 +14465,10 @@ nsDocShell::GetTabChild()
|
||||
nsCOMPtr<nsITabChild> tc = do_GetInterface(owner);
|
||||
return tc.forget();
|
||||
}
|
||||
|
||||
nsICommandManager*
|
||||
nsDocShell::GetCommandManager()
|
||||
{
|
||||
NS_ENSURE_SUCCESS(EnsureCommandHandler(), nullptr);
|
||||
return mCommandManager;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ interface nsIReflowObserver;
|
||||
interface nsIScrollObserver;
|
||||
interface nsITabParent;
|
||||
interface nsITabChild;
|
||||
interface nsICommandManager;
|
||||
native TabChildRef(already_AddRefed<nsITabChild>);
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
@ -1105,4 +1106,6 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
*/
|
||||
[binaryname(ScriptableTabChild)] readonly attribute nsITabChild tabChild;
|
||||
[noscript,notxpcom,nostdcall] TabChildRef GetTabChild();
|
||||
|
||||
[noscript,nostdcall,notxpcom] nsICommandManager GetCommandManager();
|
||||
};
|
||||
|
@ -2963,7 +2963,7 @@ nsHTMLDocument::GetMidasCommandManager(nsICommandManager** aCmdMgr)
|
||||
if (!docshell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mMidasCommandManager = do_GetInterface(docshell);
|
||||
mMidasCommandManager = docshell->GetCommandManager();
|
||||
if (!mMidasCommandManager)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -354,7 +354,7 @@ nsComposerCommandsUpdater::GetCommandUpdater()
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
|
||||
NS_ENSURE_TRUE(docShell, nullptr);
|
||||
nsCOMPtr<nsICommandManager> manager = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsICommandManager> manager = docShell->GetCommandManager();
|
||||
nsCOMPtr<nsPICommandUpdater> updater = do_QueryInterface(manager);
|
||||
return updater.forget();
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
* 4. In the appropriate location in editorSession, editor, or commands code,
|
||||
* trigger the notification of this observer by something like:
|
||||
*
|
||||
* nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(mDocShell);
|
||||
* nsCOMPtr<nsICommandManager> commandManager = mDocShell->GetCommandManager();
|
||||
* nsCOMPtr<nsPICommandUpdater> commandUpdater = do_QueryInterface(commandManager);
|
||||
* NS_ENSURE_TRUE(commandUpdater, NS_ERROR_FAILURE);
|
||||
* commandUpdater->CommandStatusChanged(obs_documentCreated);
|
||||
|
@ -820,7 +820,7 @@ nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIDocShell *docShell = piWindow->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsICommandManager> commandManager = docShell->GetCommandManager();
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater =
|
||||
do_QueryInterface(commandManager);
|
||||
NS_ENSURE_TRUE(commandUpdater, NS_ERROR_FAILURE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user