зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
be01dfffa2
Коммит
d86a1421e4
|
@ -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
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче