Skip to content

Commit 60ea770

Browse files
author
Norisz Fay
committed
Backed out changeset da5c71190673 (bug 1773813) for causing build bustages CLOSED TREE
1 parent abe2904 commit 60ea770

20 files changed

+366
-242
lines changed

docshell/base/nsDocShell.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,14 +4641,20 @@ nsDocShell::Destroy() {
46414641
return NS_OK;
46424642
}
46434643

4644-
double nsDocShell::GetWidgetCSSToDeviceScale() {
4644+
NS_IMETHODIMP
4645+
nsDocShell::GetUnscaledDevicePixelsPerCSSPixel(double* aScale) {
46454646
if (mParentWidget) {
4646-
return mParentWidget->GetDefaultScale().scale;
4647+
*aScale = mParentWidget->GetDefaultScale().scale;
4648+
return NS_OK;
46474649
}
4648-
if (nsCOMPtr<nsIBaseWindow> ownerWindow = do_QueryInterface(mTreeOwner)) {
4649-
return ownerWindow->GetWidgetCSSToDeviceScale();
4650+
4651+
nsCOMPtr<nsIBaseWindow> ownerWindow(do_QueryInterface(mTreeOwner));
4652+
if (ownerWindow) {
4653+
return ownerWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
46504654
}
4651-
return 1.0;
4655+
4656+
*aScale = 1.0;
4657+
return NS_OK;
46524658
}
46534659

46544660
NS_IMETHODIMP

docshell/base/nsDocShellTreeOwner.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,14 @@ nsDocShellTreeOwner::Destroy() {
552552
return NS_ERROR_NULL_POINTER;
553553
}
554554

555-
double nsDocShellTreeOwner::GetWidgetCSSToDeviceScale() {
556-
return mWebBrowser ? mWebBrowser->GetWidgetCSSToDeviceScale() : 1.0;
555+
NS_IMETHODIMP
556+
nsDocShellTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale) {
557+
if (mWebBrowser) {
558+
return mWebBrowser->GetUnscaledDevicePixelsPerCSSPixel(aScale);
559+
}
560+
561+
*aScale = 1.0;
562+
return NS_OK;
557563
}
558564

559565
NS_IMETHODIMP

dom/base/nsGlobalWindowInner.cpp

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7518,37 +7518,53 @@ void nsGlobalWindowInner::SetReplaceableWindowCoord(
75187518
if (innerWidthSpecified || innerHeightSpecified || outerWidthSpecified ||
75197519
outerHeightSpecified) {
75207520
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = outer->GetTreeOwnerWindow();
7521+
nsCOMPtr<nsIScreen> screen;
75217522
nsCOMPtr<nsIScreenManager> screenMgr(
75227523
do_GetService("@mozilla.org/gfx/screenmanager;1"));
7524+
int32_t winLeft = 0;
7525+
int32_t winTop = 0;
7526+
int32_t winWidth = 0;
7527+
int32_t winHeight = 0;
7528+
double scale = 1.0;
75237529

75247530
if (treeOwnerAsWin && screenMgr) {
75257531
// Acquire current window size.
7526-
//
7527-
// FIXME: This needs to account for full zoom like the outer window code
7528-
// does! Ideally move there?
7529-
auto cssScale = treeOwnerAsWin->UnscaledDevicePixelsPerCSSPixel();
7530-
LayoutDeviceIntRect devWinRect = treeOwnerAsWin->GetPositionAndSize();
7531-
CSSIntRect cssWinRect = RoundedToInt(devWinRect / cssScale);
7532+
treeOwnerAsWin->GetUnscaledDevicePixelsPerCSSPixel(&scale);
7533+
treeOwnerAsWin->GetPositionAndSize(&winLeft, &winTop, &winWidth,
7534+
&winHeight);
7535+
winLeft = NSToIntRound(winHeight / scale);
7536+
winTop = NSToIntRound(winWidth / scale);
7537+
winWidth = NSToIntRound(winWidth / scale);
7538+
winHeight = NSToIntRound(winHeight / scale);
75327539

75337540
// Acquire content window size.
75347541
CSSSize contentSize;
75357542
outer->GetInnerSize(contentSize);
75367543

7537-
nsCOMPtr<nsIScreen> screen = screenMgr->ScreenForRect(RoundedToInt(
7538-
devWinRect / treeOwnerAsWin->DevicePixelsPerDesktopPixel()));
7544+
screenMgr->ScreenForRect(winLeft, winTop, winWidth, winHeight,
7545+
getter_AddRefs(screen));
7546+
75397547
if (screen) {
75407548
int32_t roundedValue = std::round(value);
75417549
int32_t* targetContentWidth = nullptr;
75427550
int32_t* targetContentHeight = nullptr;
7551+
int32_t screenWidth = 0;
7552+
int32_t screenHeight = 0;
7553+
int32_t chromeWidth = 0;
7554+
int32_t chromeHeight = 0;
75437555
int32_t inputWidth = 0;
75447556
int32_t inputHeight = 0;
75457557
int32_t unused = 0;
75467558

7547-
CSSIntSize availScreenSize =
7548-
RoundedToInt(screen->GetAvailRect().Size() / cssScale);
7559+
// Get screen dimensions (in device pixels)
7560+
screen->GetAvailRect(&unused, &unused, &screenWidth, &screenHeight);
7561+
// Convert them to CSS pixels
7562+
screenWidth = NSToIntRound(screenWidth / scale);
7563+
screenHeight = NSToIntRound(screenHeight / scale);
75497564

75507565
// Calculate the chrome UI size.
7551-
CSSIntSize chromeSize = cssWinRect.Size() - RoundedToInt(contentSize);
7566+
chromeWidth = winWidth - contentSize.width;
7567+
chromeHeight = winHeight - contentSize.height;
75527568

75537569
if (innerWidthSpecified || outerWidthSpecified) {
75547570
inputWidth = value;
@@ -7561,10 +7577,9 @@ void nsGlobalWindowInner::SetReplaceableWindowCoord(
75617577
}
75627578

75637579
nsContentUtils::CalcRoundedWindowSizeForResistingFingerprinting(
7564-
chromeSize.width, chromeSize.height, availScreenSize.width,
7565-
availScreenSize.height, inputWidth, inputHeight,
7566-
outerWidthSpecified, outerHeightSpecified, targetContentWidth,
7567-
targetContentHeight);
7580+
chromeWidth, chromeHeight, screenWidth, screenHeight, inputWidth,
7581+
inputHeight, outerWidthSpecified, outerHeightSpecified,
7582+
targetContentWidth, targetContentHeight);
75687583
value = T(roundedValue);
75697584
}
75707585
}

0 commit comments

Comments
 (0)