nsresult nsScreen::GetRect(nsRect& aRect) { // Return window inner rect to prevent fingerprinting. if (ShouldResistFingerprinting()) { return GetWindowInnerRect(aRect); } nsDeviceContext *context = GetDeviceContext(); if (!context) { return NS_ERROR_FAILURE; } context->GetRect(aRect); LayoutDevicePoint screenTopLeftDev = LayoutDevicePixel::FromAppUnits(aRect.TopLeft(), context->AppUnitsPerDevPixel()); DesktopPoint screenTopLeftDesk = screenTopLeftDev / context->GetDesktopToDeviceScale(); aRect.x = NSToIntRound(screenTopLeftDesk.x); aRect.y = NSToIntRound(screenTopLeftDesk.y); aRect.SetHeight(nsPresContext::AppUnitsToIntCSSPixels(aRect.Height())); aRect.SetWidth(nsPresContext::AppUnitsToIntCSSPixels(aRect.Width())); return NS_OK; }