mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Follow up to bug 404290, make sure embedding clients don't crash (bug 406108). r+sr=bzbarsky a1.9=blocking1.9
This commit is contained in:
parent
c3053199cd
commit
38864cbc95
@ -1866,11 +1866,20 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
||||
if (!treeOwnerAsWin) // we'll need this to actually size the docshell
|
||||
return;
|
||||
|
||||
float devPixelsPerCSSPixel = 1.0;
|
||||
nsCOMPtr<nsIWidget> mainWidget;
|
||||
treeOwnerAsWin->GetMainWidget(getter_AddRefs(mainWidget));
|
||||
if (!mainWidget) {
|
||||
// Some embedding clients don't support nsIDocShellTreeOwner's
|
||||
// GetMainWidget, so try going through nsIBaseWindow's GetParentWidget
|
||||
nsCOMPtr<nsIBaseWindow> shellWindow(do_QueryInterface(aDocShellItem));
|
||||
if (shellWindow)
|
||||
shellWindow->GetParentWidget(getter_AddRefs(mainWidget));
|
||||
}
|
||||
if (mainWidget) {
|
||||
nsCOMPtr<nsIDeviceContext> ctx = mainWidget->GetDeviceContext();
|
||||
|
||||
float DevPixelsPerCSSPixel = float(ctx->AppUnitsPerCSSPixel()) / ctx->AppUnitsPerDevPixel();
|
||||
devPixelsPerCSSPixel = float(ctx->AppUnitsPerCSSPixel()) / ctx->AppUnitsPerDevPixel();
|
||||
}
|
||||
|
||||
/* The current position and size will be unchanged if not specified
|
||||
(and they fit entirely onscreen). Also, calculate the difference
|
||||
@ -1892,17 +1901,17 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
||||
|
||||
// Set up left/top
|
||||
if (aSizeSpec.mLeftSpecified) {
|
||||
left = aSizeSpec.mLeft * DevPixelsPerCSSPixel;
|
||||
left = NSToIntRound(aSizeSpec.mLeft * devPixelsPerCSSPixel);
|
||||
}
|
||||
|
||||
if (aSizeSpec.mTopSpecified) {
|
||||
top = aSizeSpec.mTop * DevPixelsPerCSSPixel;
|
||||
top = NSToIntRound(aSizeSpec.mTop * devPixelsPerCSSPixel);
|
||||
}
|
||||
|
||||
// Set up width
|
||||
if (aSizeSpec.mOuterWidthSpecified) {
|
||||
if (!aSizeSpec.mUseDefaultWidth) {
|
||||
width = aSizeSpec.mOuterWidth * DevPixelsPerCSSPixel;
|
||||
width = NSToIntRound(aSizeSpec.mOuterWidth * devPixelsPerCSSPixel);
|
||||
} // Else specified to default; just use our existing width
|
||||
}
|
||||
else if (aSizeSpec.mInnerWidthSpecified) {
|
||||
@ -1910,14 +1919,14 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
||||
if (aSizeSpec.mUseDefaultWidth) {
|
||||
width = width - chromeWidth;
|
||||
} else {
|
||||
width = aSizeSpec.mInnerWidth * DevPixelsPerCSSPixel;
|
||||
width = NSToIntRound(aSizeSpec.mInnerWidth * devPixelsPerCSSPixel);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up height
|
||||
if (aSizeSpec.mOuterHeightSpecified) {
|
||||
if (!aSizeSpec.mUseDefaultHeight) {
|
||||
height = aSizeSpec.mOuterHeight * DevPixelsPerCSSPixel;
|
||||
height = NSToIntRound(aSizeSpec.mOuterHeight * devPixelsPerCSSPixel);
|
||||
} // Else specified to default; just use our existing height
|
||||
}
|
||||
else if (aSizeSpec.mInnerHeightSpecified) {
|
||||
@ -1925,7 +1934,7 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
||||
if (aSizeSpec.mUseDefaultHeight) {
|
||||
height = height - chromeHeight;
|
||||
} else {
|
||||
height = aSizeSpec.mInnerHeight * DevPixelsPerCSSPixel;
|
||||
height = NSToIntRound(aSizeSpec.mInnerHeight * devPixelsPerCSSPixel);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user