pass the pres shell to the editor init method

This commit is contained in:
buster%netscape.com 1999-01-14 18:52:16 +00:00
Родитель 37c42ee98d
Коммит fc1fcf9966
3 изменённых файлов: 29 добавлений и 22 удалений

Просмотреть файл

@ -2387,18 +2387,22 @@ nsBrowserWindow::DoEditorMode(nsIWebShell *aWebShell)
aWebShell->GetContentViewer(&mCViewer);
if (nsnull != mCViewer) {
nsIDocumentViewer* mDViewer;
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer)) {
nsIDocument* mDoc;
mDViewer->GetDocument(mDoc);
if (nsnull != mDoc) {
nsIDOMDocument* mDOMDoc;
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &mDOMDoc)) {
NS_InitEditorMode(mDOMDoc);
NS_RELEASE(mDOMDoc);
}
NS_RELEASE(mDoc);
}
NS_RELEASE(mDViewer);
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer))
{
nsIDocument* mDoc;
mDViewer->GetDocument(mDoc);
if (nsnull != mDoc) {
nsIDOMDocument* mDOMDoc;
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &mDOMDoc))
{
nsIPresShell* shell = GetPresShellFor(aWebShell);
NS_InitEditorMode(mDOMDoc, shell);
NS_RELEASE(mDOMDoc);
NS_IF_RELEASE(shell);
}
NS_RELEASE(mDoc);
}
NS_RELEASE(mDViewer);
}
NS_RELEASE(mCViewer);
}

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsString.h"
#include "nsIDOMText.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIEditor.h"
#include "nsEditorCID.h"
@ -50,11 +51,17 @@ static NS_DEFINE_CID(kEditorCID, NS_EDITOR_CID);
#endif
nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument)
nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument, nsIPresShell* aPresShell)
{
nsresult result = NS_OK;
static needsInit=PR_TRUE;
NS_ASSERTION(nsnull!=aDOMDocument, "null document");
NS_ASSERTION(nsnull!=aPresShell, "null presentation shell");
if ((nsnull==aDOMDocument) || (nsnull==aPresShell))
return NS_ERROR_NULL_POINTER;
if (PR_TRUE==needsInit)
{
gEditor=(nsIEditor*)1; // XXX: hack to get around null pointer problem
@ -92,7 +99,7 @@ nsresult NS_InitEditorMode(nsIDOMDocument *aDOMDocument)
printf("ERROR: QueryInterface() returned NULL pointer.\n");
return NS_ERROR_NULL_POINTER;
}
gEditor->Init(aDOMDocument);
gEditor->Init(aDOMDocument, aPresShell);
return result;
}

Просмотреть файл

@ -19,15 +19,11 @@
#ifndef nsEditorMode_h__
#define nsEditorMode_h__
#include "nsIDOMDocument.h"
#include "nsError.h"
extern nsresult NS_InitEditorMode(nsIDOMDocument * aDOMDocument);
extern nsresult nsAppendText(nsString *aStr);
extern nsresult nsDeleteLast();
extern nsresult nsSetCurrentNode(nsIDOMNode *aNode);
extern nsresult nsGetCurrentNode(nsIDOMNode **aNode);
class nsIDOMDocument;
class nsIPresShell;
nsresult RegisterEventListeners();
nsresult GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode);
extern nsresult NS_InitEditorMode(nsIDOMDocument * aDOMDocument, nsIPresShell* aPresShell);
#endif //nsEditorMode_h__