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;