bug 1271436 - add nsIDocShell::GetCommandManager() r=smaug

This commit is contained in:
Trevor Saunders 2016-04-12 04:09:41 -04:00
parent 1e81548029
commit 256fff4fc9
7 changed files with 22 additions and 12 deletions

View File

@ -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");
}

View File

@ -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;
}

View File

@ -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();
};

View File

@ -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;

View File

@ -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();
}

View File

@ -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);

View File

@ -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);