Bug 891424. Directly remove nsCocoaWindow's from their parent in Destroy(). This allows us to stop implementing GetParent because the mac widget code has some assumptions about that always returning null. r=smichaud

This reverts implementing GetParent on nsCocoaWindow's (ie back out bug 869151) because the mac widget code has some assumptions about that. Instead we just remove nsCocoaWindow's from their mParent in Destroy() which will still keep bug 869151 fixed.
This commit is contained in:
Timothy Nikkel 2013-07-09 22:52:19 -05:00
parent 4e8716913a
commit 5f02247d3d
3 changed files with 14 additions and 7 deletions

View File

@ -222,8 +222,6 @@ public:
NS_IMETHOD Destroy();
virtual nsIWidget* GetParent(void);
NS_IMETHOD Show(bool aState);
virtual nsIWidget* GetSheetWindowParent(void);
NS_IMETHOD Enable(bool aState);

View File

@ -516,6 +516,11 @@ NS_IMETHODIMP nsCocoaWindow::Destroy()
mPopupContentView->Destroy();
nsBaseWidget::Destroy();
// nsBaseWidget::Destroy() calls GetParent()->RemoveChild(this). But we
// don't implement GetParent(), so we need to do the equivalent here.
if (mParent) {
mParent->RemoveChild(this);
}
nsBaseWidget::OnDestroy();
if (mFullScreen) {
@ -536,11 +541,6 @@ NS_IMETHODIMP nsCocoaWindow::Destroy()
return NS_OK;
}
nsIWidget* nsCocoaWindow::GetParent()
{
return mParent;
}
nsIWidget* nsCocoaWindow::GetSheetWindowParent(void)
{
if (mWindowType != eWindowType_sheet)

View File

@ -476,7 +476,16 @@ void nsBaseWidget::AddChild(nsIWidget* aChild)
//-------------------------------------------------------------------------
void nsBaseWidget::RemoveChild(nsIWidget* aChild)
{
#ifdef DEBUG
#ifdef XP_MACOSX
// nsCocoaWindow doesn't implement GetParent, so in that case parent will be
// null and we'll just have to do without this assertion.
nsIWidget* parent = aChild->GetParent();
NS_ASSERTION(!parent || parent == this, "Not one of our kids!");
#else
NS_ASSERTION(aChild->GetParent() == this, "Not one of our kids!");
#endif
#endif
if (mLastChild == aChild) {
mLastChild = mLastChild->GetPrevSibling();