mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 582057, part d: Simplify nsView::LoadWidget and return early if it fails. r=roc
This commit is contained in:
parent
7e921c626f
commit
4aa2f7ef7b
@ -688,6 +688,11 @@ nsresult nsView::CreateWidget(const nsIID &aWindowIID,
|
|||||||
NS_RELEASE(mWindow);
|
NS_RELEASE(mWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult rv = LoadWidget(aWindowIID);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
PRBool initDataPassedIn = PR_TRUE;
|
PRBool initDataPassedIn = PR_TRUE;
|
||||||
nsWidgetInitData initData;
|
nsWidgetInitData initData;
|
||||||
if (!aWidgetInitData) {
|
if (!aWidgetInitData) {
|
||||||
@ -702,48 +707,46 @@ nsresult nsView::CreateWidget(const nsIID &aWindowIID,
|
|||||||
|
|
||||||
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
|
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
|
||||||
|
|
||||||
if (NS_OK == LoadWidget(aWindowIID))
|
nsCOMPtr<nsIDeviceContext> dx;
|
||||||
{
|
mViewManager->GetDeviceContext(*getter_AddRefs(dx));
|
||||||
nsCOMPtr<nsIDeviceContext> dx;
|
|
||||||
mViewManager->GetDeviceContext(*getter_AddRefs(dx));
|
|
||||||
|
|
||||||
if (aNative && aWidgetInitData->mWindowType != eWindowType_popup)
|
if (aNative && aWidgetInitData->mWindowType != eWindowType_popup) {
|
||||||
mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
if (!initDataPassedIn && GetParent() &&
|
if (!initDataPassedIn && GetParent() &&
|
||||||
GetParent()->GetViewManager() != mViewManager)
|
GetParent()->GetViewManager() != mViewManager)
|
||||||
initData.mListenForResizes = PR_TRUE;
|
initData.mListenForResizes = PR_TRUE;
|
||||||
if (aParentWidget) {
|
if (aParentWidget) {
|
||||||
NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
|
NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
|
||||||
"popup widget type expected");
|
"popup widget type expected");
|
||||||
mWindow->Create(aParentWidget, nsnull, trect,
|
mWindow->Create(aParentWidget, nsnull, trect,
|
||||||
|
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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
|
||||||
|
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);
|
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
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
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (aEnableDragDrop) {
|
|
||||||
mWindow->EnableDragDrop(PR_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// propagate the z-index to the widget.
|
|
||||||
UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aEnableDragDrop) {
|
||||||
|
mWindow->EnableDragDrop(PR_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// propagate the z-index to the widget.
|
||||||
|
UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
|
||||||
|
|
||||||
//make sure visibility state is accurate
|
//make sure visibility state is accurate
|
||||||
|
|
||||||
if (aResetVisibility) {
|
if (aResetVisibility) {
|
||||||
@ -825,20 +828,16 @@ void nsView::SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost)
|
|||||||
//
|
//
|
||||||
nsresult nsView::LoadWidget(const nsCID &aClassIID)
|
nsresult nsView::LoadWidget(const nsCID &aClassIID)
|
||||||
{
|
{
|
||||||
ViewWrapper* wrapper = new ViewWrapper(this);
|
NS_ABORT_IF_FALSE(!mWindow, "Already have a widget?");
|
||||||
if (!wrapper)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
NS_ADDREF(wrapper); // Will be released in ~nsView
|
|
||||||
|
|
||||||
nsresult rv = CallCreateInstance(aClassIID, &mWindow);
|
nsresult rv = CallCreateInstance(aClassIID, &mWindow);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
if (NS_SUCCEEDED(rv)) {
|
return rv;
|
||||||
// Set the widget's client data
|
|
||||||
mWindow->SetClientData(wrapper);
|
|
||||||
} else {
|
|
||||||
delete wrapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewWrapper* wrapper = new ViewWrapper(this);
|
||||||
|
NS_ADDREF(wrapper); // Will be released in ~nsView
|
||||||
|
mWindow->SetClientData(wrapper);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user