From 05a4dd52a6b4a76a4a2790dad380ca289196f09d Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Mon, 7 Feb 2005 21:59:35 +0000 Subject: [PATCH] Bug 277875. Rewrite nsIFrame::GetWindow and make it not assert --- it's OK to not have a widget when we're printing. r+sr=bzbarsky --- layout/generic/nsFrame.cpp | 26 +++----------------------- layout/generic/nsIFrame.h | 1 + 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index ead1034f9a17..f7162271593b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2442,30 +2442,10 @@ nsIFrame::AreAncestorViewsVisible() const return PR_TRUE; } -nsIWidget* nsIFrame::GetWindow() const +nsIWidget* +nsIFrame::GetWindow() const { - const nsIFrame* frame; - for (frame = this; frame; frame = frame->GetAncestorWithView()) { - if (frame->HasView()) { - nsIWidget* window = frame->GetView()->GetWidget(); - if (window) { - return window; - } - } - } - - // Ask the view manager for the widget - NS_NOTREACHED("this shouldn't happen, should it?"); - nsIWidget* window; - GetPresContext()->GetViewManager()->GetWidget(&window); - // drop refcount that the view manager added, since we are not supposed - // to be adding a refcount - if (window) { - window->Release(); - } - - NS_POSTCONDITION(window, "no window in frame tree"); - return window; + return GetClosestView()->GetNearestWidget(nsnull); } nsIAtom* diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index f5552e542fd4..2e8706029434 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1044,6 +1044,7 @@ public: * view and the view has a window, then this frames window is * returned, otherwise this frame's geometric parent is checked * recursively upwards. + * XXX virtual because gfx callers use it! (themes) */ virtual nsIWidget* GetWindow() const;