From 4c4bcb9a1630e69938269896520c270b64b18132 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Fri, 12 May 2000 03:16:07 +0000 Subject: [PATCH] Added lots of error checking in AdjustClientXYForNestedDocuments so that things will fail gracefully while the content area is in the early stages of development (no view manager, etc). Probably fixes bug #31563. --- layout/xul/base/src/nsMenuPopupFrame.cpp | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index d29b2e482b1..379d72bc7b8 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -267,10 +267,13 @@ nsMenuPopupFrame :: AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopu nsCOMPtr popupDocumentWidget; nsCOMPtr viewManager; inPopupShell->GetViewManager(getter_AddRefs(viewManager)); - nsIView* rootView; - viewManager->GetRootView(rootView); - nscoord wOffsetX, wOffsetY; - rootView->GetOffsetFromWidget(&wOffsetX, &wOffsetY, *getter_AddRefs(popupDocumentWidget)); + if ( viewManager ) { + nsIView* rootView; + viewManager->GetRootView(rootView); + nscoord wOffsetX, wOffsetY; + if ( rootView ) + rootView->GetOffsetFromWidget(&wOffsetX, &wOffsetY, *getter_AddRefs(popupDocumentWidget)); + } NS_WARN_IF_FALSE(popupDocumentWidget, "ACK, BAD WIDGET"); // Find the widget associated with the target's document. Recall that we cached the @@ -286,13 +289,20 @@ nsMenuPopupFrame :: AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopu if (targetDocument) { nsCOMPtr shell ( dont_AddRef(targetDocument->GetShellAt(0)) ); nsCOMPtr viewManagerTarget; - shell->GetViewManager(getter_AddRefs(viewManagerTarget)); - nsIView* rootViewTarget; - viewManagerTarget->GetRootView(rootViewTarget); - nscoord unusedX, unusedY; - rootViewTarget->GetOffsetFromWidget(&unusedX, &unusedY, *getter_AddRefs(targetDocumentWidget)); + if ( shell ) { + shell->GetViewManager(getter_AddRefs(viewManagerTarget)); + if ( viewManagerTarget ) { + nsIView* rootViewTarget; + viewManagerTarget->GetRootView(rootViewTarget); + if ( rootViewTarget ) { + nscoord unusedX, unusedY; + rootViewTarget->GetOffsetFromWidget(&unusedX, &unusedY, *getter_AddRefs(targetDocumentWidget)); + } + } + } } } + NS_WARN_IF_FALSE(targetDocumentWidget, "ACK, BAD TARGET"); // the offset we need is the difference between the upper left corner of the two widgets. Use // screen coordinates to find the global offset between them.