зеркало из https://github.com/mozilla/pjs.git
pass the pres shell to the editor init method
This commit is contained in:
Родитель
37c42ee98d
Коммит
fc1fcf9966
|
@ -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__
|
||||
|
|
Загрузка…
Ссылка в новой задаче