diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 57056c60dcd..72260d45f9f 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -948,6 +948,12 @@ nsFrame::PaintSelf(nsPresContext* aPresContext, mStyleContext, 0); } +nsresult +nsIFrame::CreateWidgetForView(nsIView* aView) +{ + return aView->CreateWidget(kWidgetCID); +} + /** * */ @@ -5670,9 +5676,8 @@ nsFrame::SetParent(const nsIFrame* aParent) if (needsWidget) { nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE); nsIView* view = GetView(); - if (!view->HasWidget()) - view->CreateWidget(kWidgetCID); + CreateWidgetForView(view); } } diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index d9bf29c5800..bb7e7319d94 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -62,8 +62,6 @@ #include "nsReflowPath.h" #include "nsCSSFrameConstructor.h" -static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); - NS_IMETHODIMP nsHTMLContainerFrame::Paint(nsPresContext* aPresContext, nsIRenderingContext& aRenderingContext, @@ -581,7 +579,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame, // above the scrolling area const nsStyleDisplay* display = aFrame->GetStyleContext()->GetStyleDisplay(); if (NS_STYLE_POSITION_FIXED == display->mPosition) { - view->CreateWidget(kCChildCID); + aFrame->CreateWidgetForView(view); } // Reparent views on any child frames (or their descendants) to this diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 40b227a3f3a..8b3f07a6909 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -717,6 +717,14 @@ public: */ virtual PRBool NeedsView() { return PR_FALSE; } + /** + * This frame needs a view with a widget (e.g. because it's fixed + * positioned), so we call this to create the widget. If widgets for + * this frame type need to be of a certain type or require special + * initialization, that can be done here. + */ + virtual nsresult CreateWidgetForView(nsIView* aView); + /** * Event handling of GUI events. * diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index c92b0a28ba1..3ce661f64ba 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -780,6 +780,15 @@ nsObjectFrame::GetFrameName(nsAString& aResult) const } #endif +nsresult +nsObjectFrame::CreateWidgetForView(nsIView* aView) +{ + // Bug 179822: Create widget and allow non-unicode SubClass + nsWidgetInitData initData; + initData.mUnicode = PR_FALSE; + return aView->CreateWidget(kWidgetCID, &initData); +} + nsresult nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, @@ -805,12 +814,9 @@ nsObjectFrame::CreateWidget(nscoord aWidth, viewMan->AllowDoubleBuffering(doubleBuffer); #endif - if (!aViewOnly) { - // Bug 179822: Create widget and allow non-unicode SubClass - nsWidgetInitData initData; - initData.mUnicode = PR_FALSE; - nsresult result = view->CreateWidget(kWidgetCID, &initData); - if (NS_FAILED(result)) { + if (!aViewOnly && !view->HasWidget()) { + nsresult rv = CreateWidgetForView(view); + if (NS_FAILED(rv)) { return NS_OK; //XXX why OK? MMP } } diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index 772e61fc559..49f1dc94864 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -604,6 +604,7 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID, nsRect trect = mDimBounds; float scale; + NS_ASSERTION(!mWindow, "We already have a window for this view? BAD"); NS_IF_RELEASE(mWindow); mViewManager->GetDeviceContext(dx);