Fix the document state listener mechanism so that you can install listeners after the editor has been created, and still get their 'document creation' notification called.

This commit is contained in:
sfraser%netscape.com 1999-08-03 06:53:45 +00:00
Родитель 31272b88d1
Коммит bbeffd28f0
7 изменённых файлов: 37 добавлений и 5 удалений

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

@ -596,12 +596,19 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
// Set the selection to the beginning:
BeginningOfDocument();
NS_POSTCONDITION(mDoc && mPresShell, "bad state");
return NS_OK;
}
NS_IMETHODIMP
nsEditor::PostCreate()
{
// update the UI with our state
NotifyDocumentListeners(eDocumentCreated);
NotifyDocumentListeners(eDocumentStateChanged);
NS_POSTCONDITION(mDoc && mPresShell, "bad state");
return NS_OK;
}

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

@ -143,6 +143,8 @@ public:
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
NS_IMETHOD PostCreate();
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);

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

@ -823,6 +823,10 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl)
rv = editor->AddDocumentStateListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// now all the listeners are set up, we can call PostCreate
rv = editor->PostCreate();
if (NS_FAILED(rv)) return rv;
#if 0
// get the URL of the page we are editing
// does not work currently, because file URL has /usr/local/bin crap in it.

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

@ -823,6 +823,10 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl)
rv = editor->AddDocumentStateListener(mStateMaintainer);
if (NS_FAILED(rv)) return rv;
// now all the listeners are set up, we can call PostCreate
rv = editor->PostCreate();
if (NS_FAILED(rv)) return rv;
#if 0
// get the URL of the page we are editing
// does not work currently, because file URL has /usr/local/bin crap in it.

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

@ -596,12 +596,19 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
// Set the selection to the beginning:
BeginningOfDocument();
NS_POSTCONDITION(mDoc && mPresShell, "bad state");
return NS_OK;
}
NS_IMETHODIMP
nsEditor::PostCreate()
{
// update the UI with our state
NotifyDocumentListeners(eDocumentCreated);
NotifyDocumentListeners(eDocumentStateChanged);
NS_POSTCONDITION(mDoc && mPresShell, "bad state");
return NS_OK;
}

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

@ -143,6 +143,8 @@ public:
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell);
NS_IMETHOD PostCreate();
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);

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

@ -82,7 +82,7 @@ public:
static const nsIID& GetIID() { static nsIID iid = NS_IEDITOR_IID; return iid; }
/**
* Init tells is to tell the implementation of nsIEditor to begin its services
* Init is to tell the implementation of nsIEditor to begin its services
* @param aDoc The dom document interface being observed
* @param aPresShell TEMP: The presentation shell displaying the document
* once events can tell us from what pres shell they originated,
@ -91,6 +91,12 @@ public:
*/
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell )=0;
/**
* PostCreate should be called after Init, and is the time that the editor tells
* its documentStateObservers that the document has been created.
*/
NS_IMETHOD PostCreate()=0;
/**
* return the DOM Document this editor is associated with
*