From 230f7cbe4ed646516f8f7d5c833665cb7f152093 Mon Sep 17 00:00:00 2001 From: "mats.palmgren@bredband.net" Date: Sun, 13 May 2007 17:42:38 -0700 Subject: [PATCH] Don't create a widget if the view already has one and check error return code from CreateViewForFrame(). b=374102 r+sr=roc --- layout/xul/base/src/nsBoxFrame.cpp | 4 +++- layout/xul/base/src/nsLeafBoxFrame.cpp | 6 ++++-- layout/xul/base/src/nsMenuPopupFrame.cpp | 4 +++- layout/xul/base/src/nsSplitterFrame.cpp | 11 ++++++++--- layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp | 11 +++++++++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 3586082619d..ddbe79bccde 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -199,13 +199,15 @@ nsBoxFrame::Init(nsIContent* aContent, nsIFrame* aPrevInFlow) { nsresult rv = nsContainerFrame::Init(aContent, aParent, aPrevInFlow); + NS_ENSURE_SUCCESS(rv, rv); MarkIntrinsicWidthsDirty(); // see if we need a widget if (aParent && aParent->IsBoxFrame()) { if (aParent->ChildrenMustHaveWidgets()) { - nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); + rv = nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); nsIView* view = GetView(); if (!view->HasWidget()) diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 4e5c704bc9c..109c72f47c2 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -97,13 +97,15 @@ nsLeafBoxFrame::Init( nsIFrame* aPrevInFlow) { nsresult rv = nsLeafFrame::Init(aContent, aParent, aPrevInFlow); + NS_ENSURE_SUCCESS(rv, rv); // see if we need a widget if (aParent && aParent->IsBoxFrame()) { if (aParent->ChildrenMustHaveWidgets()) { - nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); - nsIView* view = GetView(); + rv = nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); + nsIView* view = GetView(); if (!view->HasWidget()) view->CreateWidget(kWidgetCID); } diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 4708db528f8..8f805800a65 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -156,6 +156,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow); + NS_ENSURE_SUCCESS(rv, rv); // Set up a mediator which can be used for callbacks on this frame. mTimerMediator = new nsMenuPopupTimerMediator(this); @@ -171,7 +172,8 @@ nsMenuPopupFrame::Init(nsIContent* aContent, GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool); mMenuCanOverlapOSBar = tempBool; - CreateViewForFrame(presContext, this, GetStyleContext(), PR_TRUE); + rv = CreateViewForFrame(presContext, this, GetStyleContext(), PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); // Now that we've made a view, remove it and insert it at the correct // position in the view hierarchy (as the root view). We do this so that we diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 476224489a3..397b12ae1d5 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -358,16 +358,21 @@ nsSplitterFrame::Init(nsIContent* aContent, } nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow); + NS_ENSURE_SUCCESS(rv, rv); - nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); - nsIView* view = GetView(); + rv = nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); if (!realTimeDrag) { + nsIView* view = GetView(); // currently this only works on win32 and mac static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); // Need to have a widget to appear on top of other widgets. - view->CreateWidget(kCChildCID); + NS_ASSERTION(!view->HasWidget(), "have an unwanted widget"); + if (!view->HasWidget()) { + view->CreateWidget(kCChildCID); + } } mInner->mState = nsSplitterFrameInner::Open; diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 16a449849c2..e93958f112b 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -207,8 +207,15 @@ nsTreeBodyFrame::Init(nsIContent* aContent, nsIFrame* aPrevInFlow) { nsresult rv = nsLeafBoxFrame::Init(aContent, aParent, aPrevInFlow); - nsBoxFrame::CreateViewForFrame(PresContext(), this, GetStyleContext(), PR_TRUE); - nsLeafBoxFrame::GetView()->CreateWidget(kWidgetCID); + NS_ENSURE_SUCCESS(rv, rv); + + rv = nsBoxFrame::CreateViewForFrame(PresContext(), this, GetStyleContext(), PR_TRUE); + NS_ENSURE_SUCCESS(rv, rv); + + nsIView* view = nsLeafBoxFrame::GetView(); + if (!view->HasWidget()) { + view->CreateWidget(kWidgetCID); + } mIndentation = GetIndentation(); mRowHeight = GetRowHeight();