Added NULL pointer checks in GetPrimaryFrameFor() and GetPlaceholderFrameFor()

This commit is contained in:
troy%netscape.com 1999-08-05 03:23:39 +00:00
Родитель 3ae06bfbdc
Коммит 2c5e8babc6
2 изменённых файлов: 54 добавлений и 8 удалений

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

@ -300,7 +300,7 @@ protected:
PRBool mDisplayNonTextSelection; PRBool mDisplayNonTextSelection;
PRBool mScrollingEnabled; //used to disable programmable scrolling from outside PRBool mScrollingEnabled; //used to disable programmable scrolling from outside
CantRenderReplacedElementEvent* mPostedEvents; CantRenderReplacedElementEvent* mPostedEvents;
nsIFrameManager* mFrameManager; nsIFrameManager* mFrameManager; // we hold a reference
private: private:
void RevokePostedEvents(); void RevokePostedEvents();
@ -468,7 +468,10 @@ PresShell::~PresShell()
} }
// Revoke any events posted to the event queue that we haven't processed yet // Revoke any events posted to the event queue that we haven't processed yet
RevokePostedEvents(); RevokePostedEvents();
mFrameManager->Release(); // Destroy the frame manager before destroying the frame hierarchy. That way
// we won't waste time removing content->frame mappings for frames being
// destroyed
NS_IF_RELEASE(mFrameManager);
if (mRootFrame) if (mRootFrame)
mRootFrame->Destroy(*mPresContext); mRootFrame->Destroy(*mPresContext);
if (mDocument) if (mDocument)
@ -1864,7 +1867,17 @@ NS_IMETHODIMP
PresShell::GetPrimaryFrameFor(nsIContent* aContent, PresShell::GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aResult) const nsIFrame** aResult) const
{ {
return mFrameManager->GetPrimaryFrameFor(aContent, aResult); nsresult rv;
if (mFrameManager) {
rv = mFrameManager->GetPrimaryFrameFor(aContent, aResult);
} else {
*aResult = nsnull;
rv = NS_OK;
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1900,7 +1913,17 @@ NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame, PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const nsIFrame** aResult) const
{ {
return mFrameManager->GetPlaceholderFrameFor(aFrame, aResult); nsresult rv;
if (mFrameManager) {
rv = mFrameManager->GetPlaceholderFrameFor(aFrame, aResult);
} else {
*aResult = nsnull;
rv = NS_OK;
}
return rv;
} }
//nsIViewObserver //nsIViewObserver

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

@ -300,7 +300,7 @@ protected:
PRBool mDisplayNonTextSelection; PRBool mDisplayNonTextSelection;
PRBool mScrollingEnabled; //used to disable programmable scrolling from outside PRBool mScrollingEnabled; //used to disable programmable scrolling from outside
CantRenderReplacedElementEvent* mPostedEvents; CantRenderReplacedElementEvent* mPostedEvents;
nsIFrameManager* mFrameManager; nsIFrameManager* mFrameManager; // we hold a reference
private: private:
void RevokePostedEvents(); void RevokePostedEvents();
@ -468,7 +468,10 @@ PresShell::~PresShell()
} }
// Revoke any events posted to the event queue that we haven't processed yet // Revoke any events posted to the event queue that we haven't processed yet
RevokePostedEvents(); RevokePostedEvents();
mFrameManager->Release(); // Destroy the frame manager before destroying the frame hierarchy. That way
// we won't waste time removing content->frame mappings for frames being
// destroyed
NS_IF_RELEASE(mFrameManager);
if (mRootFrame) if (mRootFrame)
mRootFrame->Destroy(*mPresContext); mRootFrame->Destroy(*mPresContext);
if (mDocument) if (mDocument)
@ -1864,7 +1867,17 @@ NS_IMETHODIMP
PresShell::GetPrimaryFrameFor(nsIContent* aContent, PresShell::GetPrimaryFrameFor(nsIContent* aContent,
nsIFrame** aResult) const nsIFrame** aResult) const
{ {
return mFrameManager->GetPrimaryFrameFor(aContent, aResult); nsresult rv;
if (mFrameManager) {
rv = mFrameManager->GetPrimaryFrameFor(aContent, aResult);
} else {
*aResult = nsnull;
rv = NS_OK;
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -1900,7 +1913,17 @@ NS_IMETHODIMP
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame, PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame,
nsIFrame** aResult) const nsIFrame** aResult) const
{ {
return mFrameManager->GetPlaceholderFrameFor(aFrame, aResult); nsresult rv;
if (mFrameManager) {
rv = mFrameManager->GetPlaceholderFrameFor(aFrame, aResult);
} else {
*aResult = nsnull;
rv = NS_OK;
}
return rv;
} }
//nsIViewObserver //nsIViewObserver