bug 132334 - add nsIFrame::RemovedAsPrimaryFrame which allows the text control frame to access its editor before Destroy (when it is too late). a=asa, adt=jamiejr, sr=attinasi, r=jkeiser

This commit is contained in:
karnaze%netscape.com 2002-04-06 22:16:12 +00:00
Родитель d33dcc06e3
Коммит 2e61de16e8
6 изменённых файлов: 42 добавлений и 4 удалений

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

@ -8969,6 +8969,7 @@ DoDeletingFrameSubtree(nsIPresContext* aPresContext,
aFrame->GetContent(getter_AddRefs(content));
if (content) {
aFrameManager->SetPrimaryFrameFor(content, nsnull);
aFrame->RemovedAsPrimaryFrame(aPresContext);
aFrameManager->ClearAllUndisplayedContentIn(content);
}
@ -13539,6 +13540,7 @@ DoCleanupFrameReferences(nsIPresContext* aPresContext,
// Remove the mapping from the content object to its frame
aFrameManager->SetPrimaryFrameFor(content, nsnull);
aFrame->RemovedAsPrimaryFrame(aPresContext);
aFrameManager->ClearAllUndisplayedContentIn(content);
// Recursively walk the child frames.

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

@ -403,6 +403,11 @@ public:
*/
NS_IMETHOD Destroy(nsIPresContext* aPresContext) = 0;
/*
* Notify the frame that it has been removed as the primary frame for its content
*/
virtual void RemovedAsPrimaryFrame(nsIPresContext* aPresContext) {}
/**
* Called to set the initial list of frames. This happens after the frame
* has been initialized.

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

@ -403,6 +403,11 @@ public:
*/
NS_IMETHOD Destroy(nsIPresContext* aPresContext) = 0;
/*
* Notify the frame that it has been removed as the primary frame for its content
*/
virtual void RemovedAsPrimaryFrame(nsIPresContext* aPresContext) {}
/**
* Called to set the initial list of frames. This happens after the frame
* has been initialized.

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

@ -131,7 +131,6 @@ static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID);
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static nsresult GetElementFactoryService(nsIElementFactory **aFactory)
{
nsresult rv(NS_OK);
@ -1359,6 +1358,7 @@ nsGfxTextControlFrame2::nsGfxTextControlFrame2(nsIPresShell* aShell):nsStackFram
mSuggestedWidth = NS_FORMSIZE_NOTSET;
mSuggestedHeight = NS_FORMSIZE_NOTSET;
mScrollableView = nsnull;
mDidPreDestroy = PR_FALSE;
}
nsGfxTextControlFrame2::~nsGfxTextControlFrame2()
@ -1367,8 +1367,8 @@ nsGfxTextControlFrame2::~nsGfxTextControlFrame2()
//delete mTextSelImpl; dont delete this since mSelCon will release it.
}
NS_IMETHODIMP
nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext)
void
nsGfxTextControlFrame2::PreDestroy(nsIPresContext* aPresContext)
{
// notify the editor that we are going away
if (mEditor)
@ -1443,9 +1443,28 @@ nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext)
erP->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMKeyListener*,mTextListener), NS_GET_IID(nsIDOMKeyListener));
}
}
mDidPreDestroy = PR_TRUE;
}
NS_IMETHODIMP
nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext)
{
if (!mDidPreDestroy) {
PreDestroy(aPresContext);
}
return nsBoxFrame::Destroy(aPresContext);
}
void
nsGfxTextControlFrame2::RemovedAsPrimaryFrame(nsIPresContext* aPresContext)
{
if (!mDidPreDestroy) {
PreDestroy(aPresContext);
}
else NS_ASSERTION(PR_FALSE, "RemovedAsPrimaryFrame called after PreDestroy");
}
NS_IMETHODIMP
nsGfxTextControlFrame2::GetFrameType(nsIAtom** aType) const
{

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

@ -76,7 +76,9 @@ public:
nsGfxTextControlFrame2(nsIPresShell* aShell);
virtual ~nsGfxTextControlFrame2();
NS_IMETHOD Destroy(nsIPresContext* aPresContext);//remove yourself as a form control
virtual void RemovedAsPrimaryFrame(nsIPresContext* aPresContext);
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -192,6 +194,7 @@ protected:
void RemoveNewlines(nsString &aString);
NS_IMETHOD GetMaxLength(PRInt32* aSize);
NS_IMETHOD DoesAttributeExist(nsIAtom *aAtt);
void PreDestroy(nsIPresContext* aPresContext); // remove yourself as a form control
//helper methods
nsresult GetSizeFromContent(PRInt32* aSize) const;
@ -252,9 +255,11 @@ private:
nscoord mSuggestedHeight;
nsSize mSize;
// these packed bools could instead use the high order bits on mState, saving 4 bytes
PRPackedBool mUseEditor;
PRPackedBool mIsProcessing;
PRPackedBool mNotifyOnInput;//default this to off to stop any notifications until setup is complete
PRPackedBool mDidPreDestroy; // has PreDestroy been called
nsFormFrame *mFormFrame;
nsTextInputSelectionImpl *mTextSelImpl;

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

@ -8969,6 +8969,7 @@ DoDeletingFrameSubtree(nsIPresContext* aPresContext,
aFrame->GetContent(getter_AddRefs(content));
if (content) {
aFrameManager->SetPrimaryFrameFor(content, nsnull);
aFrame->RemovedAsPrimaryFrame(aPresContext);
aFrameManager->ClearAllUndisplayedContentIn(content);
}
@ -13539,6 +13540,7 @@ DoCleanupFrameReferences(nsIPresContext* aPresContext,
// Remove the mapping from the content object to its frame
aFrameManager->SetPrimaryFrameFor(content, nsnull);
aFrame->RemovedAsPrimaryFrame(aPresContext);
aFrameManager->ClearAllUndisplayedContentIn(content);
// Recursively walk the child frames.