Bug 1930725 - Clean up a bit nsDeviceContext. r=layout-reviewers,TYLin
Differential Revision: https://phabricator.services.mozilla.com/D228703
This commit is contained in:
@@ -3680,7 +3680,7 @@ nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal) {
|
||||
// extra resize reflow after this point.
|
||||
nsRect screenRect;
|
||||
if (nsPresContext* presContext = GetPresContext()) {
|
||||
presContext->DeviceContext()->GetRect(screenRect);
|
||||
screenRect = presContext->DeviceContext()->GetRect();
|
||||
}
|
||||
nsSize oldSize;
|
||||
PrepareForFullscreenChange(GetDocShell(), screenRect.Size(), &oldSize);
|
||||
|
||||
@@ -82,10 +82,7 @@ CSSIntRect nsScreen::GetRect() {
|
||||
if (NS_WARN_IF(!context)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
nsRect r;
|
||||
context->GetRect(r);
|
||||
return CSSIntRect::FromAppUnitsRounded(r);
|
||||
return CSSIntRect::FromAppUnitsRounded(context->GetRect());
|
||||
}
|
||||
|
||||
CSSIntRect nsScreen::GetAvailRect() {
|
||||
@@ -111,10 +108,7 @@ CSSIntRect nsScreen::GetAvailRect() {
|
||||
if (NS_WARN_IF(!context)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
nsRect r;
|
||||
context->GetClientRect(r);
|
||||
return CSSIntRect::FromAppUnitsRounded(r);
|
||||
return CSSIntRect::FromAppUnitsRounded(context->GetClientRect());
|
||||
}
|
||||
|
||||
uint16_t nsScreen::GetOrientationAngle() const {
|
||||
|
||||
@@ -201,37 +201,32 @@ bool nsDeviceContext::GetScreenIsHDR() {
|
||||
return screen->GetIsHDR();
|
||||
}
|
||||
|
||||
nsresult nsDeviceContext::GetDeviceSurfaceDimensions(nscoord& aWidth,
|
||||
nscoord& aHeight) {
|
||||
if (IsPrinterContext()) {
|
||||
aWidth = mWidth;
|
||||
aHeight = mHeight;
|
||||
} else {
|
||||
nsRect area;
|
||||
ComputeFullAreaUsingScreen(&area);
|
||||
aWidth = area.Width();
|
||||
aHeight = area.Height();
|
||||
nsSize nsDeviceContext::GetDeviceSurfaceDimensions() {
|
||||
return GetRect().Size();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
nsRect nsDeviceContext::GetRect() {
|
||||
if (IsPrinterContext()) {
|
||||
return {0, 0, mWidth, mHeight};
|
||||
}
|
||||
RefPtr<widget::Screen> screen = FindScreen();
|
||||
if (!screen) {
|
||||
return {};
|
||||
}
|
||||
return LayoutDeviceIntRect::ToAppUnits(screen->GetRect(),
|
||||
AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
nsresult nsDeviceContext::GetRect(nsRect& aRect) {
|
||||
nsRect nsDeviceContext::GetClientRect() {
|
||||
if (IsPrinterContext()) {
|
||||
aRect.SetRect(0, 0, mWidth, mHeight);
|
||||
} else
|
||||
ComputeFullAreaUsingScreen(&aRect);
|
||||
|
||||
return NS_OK;
|
||||
return {0, 0, mWidth, mHeight};
|
||||
}
|
||||
|
||||
nsresult nsDeviceContext::GetClientRect(nsRect& aRect) {
|
||||
if (IsPrinterContext()) {
|
||||
aRect.SetRect(0, 0, mWidth, mHeight);
|
||||
} else
|
||||
ComputeClientRectUsingScreen(&aRect);
|
||||
|
||||
return NS_OK;
|
||||
RefPtr<widget::Screen> screen = FindScreen();
|
||||
if (!screen) {
|
||||
return {};
|
||||
}
|
||||
return LayoutDeviceIntRect::ToAppUnits(screen->GetAvailRect(),
|
||||
AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
nsresult nsDeviceContext::InitForPrinting(nsIDeviceContextSpec* aDevice) {
|
||||
@@ -358,33 +353,6 @@ nsresult nsDeviceContext::EndPage() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDeviceContext::ComputeClientRectUsingScreen(nsRect* outRect) {
|
||||
// we always need to recompute the clientRect
|
||||
// because the window may have moved onto a different screen. In the single
|
||||
// monitor case, we only need to do the computation if we haven't done it
|
||||
// once already, and remember that we have because we're assured it won't
|
||||
// change.
|
||||
if (RefPtr<widget::Screen> screen = FindScreen()) {
|
||||
*outRect = LayoutDeviceIntRect::ToAppUnits(screen->GetAvailRect(),
|
||||
AppUnitsPerDevPixel());
|
||||
}
|
||||
}
|
||||
|
||||
void nsDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect) {
|
||||
// if we have more than one screen, we always need to recompute the clientRect
|
||||
// because the window may have moved onto a different screen. In the single
|
||||
// monitor case, we only need to do the computation if we haven't done it
|
||||
// once already, and remember that we have because we're assured it won't
|
||||
// change.
|
||||
if (RefPtr<widget::Screen> screen = FindScreen()) {
|
||||
*outRect = LayoutDeviceIntRect::ToAppUnits(screen->GetRect(),
|
||||
AppUnitsPerDevPixel());
|
||||
mWidth = outRect->Width();
|
||||
mHeight = outRect->Height();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// FindScreen
|
||||
//
|
||||
// Determines which screen intersects the largest area of the given surface.
|
||||
|
||||
@@ -155,37 +155,26 @@ class nsDeviceContext final {
|
||||
bool GetScreenIsHDR();
|
||||
|
||||
/**
|
||||
* Get the size of the displayable area of the output device
|
||||
* in app units.
|
||||
* @param aWidth out parameter for width
|
||||
* @param aHeight out parameter for height
|
||||
* @return error status
|
||||
* Get the size of the displayable area of the output device in app units.
|
||||
*/
|
||||
nsresult GetDeviceSurfaceDimensions(nscoord& aWidth, nscoord& aHeight);
|
||||
nsSize GetDeviceSurfaceDimensions();
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app
|
||||
* units. This corresponds on a screen device, for instance, to
|
||||
* the entire screen.
|
||||
* @param aRect out parameter for full rect. Position (x,y) will
|
||||
* be (0,0) or relative to the primary monitor if
|
||||
* this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetRect(nsRect& aRect);
|
||||
nsRect GetRect();
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app
|
||||
* units. This corresponds on a screen device, for instance, to
|
||||
* the area reported by GetDeviceSurfaceDimensions, minus the
|
||||
* taskbar (Windows) or menubar (Macintosh).
|
||||
* @param aRect out parameter for client rect. Position (x,y) will
|
||||
* be (0,0) adjusted for any upper/left non-client
|
||||
* space if present or relative to the primary
|
||||
* monitor if this is not the primary.
|
||||
* @return error status
|
||||
* Position (x,y) will be (0,0) adjusted for any upper/left non-client space
|
||||
* if present or relative to the primary monitor if this is not the primary.
|
||||
*/
|
||||
nsresult GetClientRect(nsRect& aRect);
|
||||
nsRect GetClientRect();
|
||||
|
||||
/**
|
||||
* Returns true if we're currently between BeginDocument() and
|
||||
@@ -289,8 +278,6 @@ class nsDeviceContext final {
|
||||
bool aWantReferenceContext);
|
||||
|
||||
void SetDPI();
|
||||
void ComputeClientRectUsingScreen(nsRect* outRect);
|
||||
void ComputeFullAreaUsingScreen(nsRect* outRect);
|
||||
already_AddRefed<mozilla::widget::Screen> FindScreen();
|
||||
|
||||
// Return false if the surface is not right
|
||||
|
||||
@@ -5080,8 +5080,7 @@ already_AddRefed<SourceSurface> PresShell::PaintRangePaintInfo(
|
||||
// if the image should not be resized, scale must be 1
|
||||
float scale = 1.0;
|
||||
|
||||
nsRect maxSize;
|
||||
pc->DeviceContext()->GetClientRect(maxSize);
|
||||
const nsRect maxSize = pc->DeviceContext()->GetClientRect();
|
||||
|
||||
// check if the image should be resized
|
||||
bool resize = !!(aFlags & RenderImageFlags::AutoScale);
|
||||
|
||||
@@ -1543,9 +1543,8 @@ gfxSize nsPresContext::ScreenSizeInchesForFontInflation(bool* aChanged) {
|
||||
}
|
||||
|
||||
nsDeviceContext* dx = DeviceContext();
|
||||
nsRect clientRect;
|
||||
dx->GetClientRect(clientRect); // FIXME: GetClientRect looks expensive
|
||||
float unitsPerInch = dx->AppUnitsPerPhysicalInch();
|
||||
nsRect clientRect = dx->GetClientRect();
|
||||
gfxSize deviceSizeInches(float(clientRect.width) / unitsPerInch,
|
||||
float(clientRect.height) / unitsPerInch);
|
||||
|
||||
|
||||
@@ -1229,9 +1229,7 @@ nsresult nsPrintJob::SetRootView(nsPrintObject* aPO, bool& doReturn,
|
||||
canCreateScrollbars = false;
|
||||
}
|
||||
} else {
|
||||
nscoord pageWidth, pageHeight;
|
||||
mPrt->mPrintDC->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
|
||||
adjSize = nsSize(pageWidth, pageHeight);
|
||||
adjSize = mPrt->mPrintDC->GetDeviceSurfaceDimensions();
|
||||
documentIsTopLevel = true;
|
||||
parentView = GetParentViewForRoot();
|
||||
}
|
||||
|
||||
@@ -89,9 +89,7 @@ static nsSize GetDeviceSize(const Document& aDocument) {
|
||||
return pc->GetPageSize();
|
||||
}
|
||||
|
||||
nsSize size;
|
||||
pc->DeviceContext()->GetDeviceSurfaceDimensions(size.width, size.height);
|
||||
return size;
|
||||
return pc->DeviceContext()->GetDeviceSurfaceDimensions();
|
||||
}
|
||||
|
||||
bool Gecko_MediaFeatures_IsResourceDocument(const Document* aDocument) {
|
||||
|
||||
Reference in New Issue
Block a user