Merge backout

This commit is contained in:
Chris Jones 2010-08-19 19:02:36 -05:00
commit 4b9742b50c

View File

@ -710,40 +710,35 @@ nsresult nsView::CreateWidget(const nsIID &aWindowIID,
nsCOMPtr<nsIDeviceContext> dx;
mViewManager->GetDeviceContext(*getter_AddRefs(dx));
if (aWidgetInitData->mWindowType == eWindowType_popup) {
if (aNative && aWidgetInitData->mWindowType != eWindowType_popup) {
mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
else {
if (!initDataPassedIn && GetParent() &&
GetParent()->GetViewManager() != mViewManager)
initData.mListenForResizes = PR_TRUE;
if (aParentWidget) {
NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
"popup widget type expected");
mWindow->Create(aParentWidget, nsnull, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
else {
// XXX/cjones: having these two separate creation cases seems
// ... um ... unnecessary, but it's the way the old code did it.
// Please unify them by first finding a suitable parent nsIWidget,
// then passing only either the non-null parentWidget or the
// native ID to Create().
nsIWidget* nearestParent = GetParent() ? GetParent()->GetNearestWidget(nsnull)
: nsnull;
if (!nearestParent) {
nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
: nsnull;
if (aWidgetInitData->mWindowType == eWindowType_popup) {
// Without a parent, we can't make a popup. This can happen
// when printing
return NS_ERROR_FAILURE;
if (!parentWidget)
return NS_ERROR_FAILURE;
mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
} else {
mWindow->Create(parentWidget, nsnull, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
mWindow->Create(nsnull, nearestParent->GetNativeData(NS_NATIVE_WIDGET), trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
}
else if (aNative) {
mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
else {
initData.mListenForResizes = (!initDataPassedIn && GetParent() &&
GetParent()->GetViewManager() != mViewManager);
nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
: nsnull;
mWindow->Create(parentWidget, nsnull, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
if (aEnableDragDrop) {
mWindow->EnableDragDrop(PR_TRUE);