зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575097 Part 2: Make nsScreen::GetRDMScreenSize accept a CSSIntSize instead of an nsRect. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D42743 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5dccfe286b
Коммит
ea3e370cf2
|
@ -116,7 +116,12 @@ nsresult nsScreen::GetAvailRect(nsRect& aRect) {
|
|||
// Here we manipulate the value of aRect to represent the screen avail size,
|
||||
// if in RDM.
|
||||
if (IsInRDMPane()) {
|
||||
return GetRDMScreenSize(aRect);
|
||||
mozilla::CSSIntSize size;
|
||||
if (NS_SUCCEEDED(GetRDMScreenSize(size))) {
|
||||
aRect.SetRect(0, 0, size.width, size.height);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsDeviceContext* context = GetDeviceContext();
|
||||
|
@ -145,9 +150,7 @@ nsresult nsScreen::GetAvailRect(nsRect& aRect) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsScreen::GetRDMScreenSize(nsRect& aRect) {
|
||||
GetWindowInnerRect(aRect);
|
||||
|
||||
nsresult nsScreen::GetRDMScreenSize(mozilla::CSSIntSize& aSize) {
|
||||
// GetOwner(), GetDocShell(), and GetPresContext() can potentially return
|
||||
// nullptr, so to be safe let's make sure we check these before proceeding.
|
||||
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
|
||||
|
@ -156,11 +159,11 @@ nsresult nsScreen::GetRDMScreenSize(nsRect& aRect) {
|
|||
if (docShell) {
|
||||
RefPtr<nsPresContext> presContext = docShell->GetPresContext();
|
||||
if (presContext) {
|
||||
nsRect rect;
|
||||
GetWindowInnerRect(rect);
|
||||
float zoom = presContext->GetDeviceFullZoom();
|
||||
int32_t width = std::round(aRect.Width() * zoom);
|
||||
int32_t height = std::round(aRect.Height() * zoom);
|
||||
aRect.SetHeight(height);
|
||||
aRect.SetWidth(width);
|
||||
aSize.width = std::round(rect.Width() * zoom);
|
||||
aSize.height = std::round(rect.Height() * zoom);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ class nsScreen : public mozilla::DOMEventTargetHelper {
|
|||
}
|
||||
|
||||
int32_t GetWidth(ErrorResult& aRv) {
|
||||
nsRect rect;
|
||||
if (IsDeviceSizePageSize()) {
|
||||
if (IsInRDMPane()) {
|
||||
GetRDMScreenSize(rect);
|
||||
return rect.Width();
|
||||
mozilla::CSSIntSize size;
|
||||
GetRDMScreenSize(size);
|
||||
return size.width;
|
||||
}
|
||||
|
||||
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
||||
|
@ -60,16 +60,17 @@ class nsScreen : public mozilla::DOMEventTargetHelper {
|
|||
}
|
||||
}
|
||||
|
||||
nsRect rect;
|
||||
aRv = GetRect(rect);
|
||||
return rect.Width();
|
||||
}
|
||||
|
||||
int32_t GetHeight(ErrorResult& aRv) {
|
||||
nsRect rect;
|
||||
if (IsDeviceSizePageSize()) {
|
||||
if (IsInRDMPane()) {
|
||||
GetRDMScreenSize(rect);
|
||||
return rect.Height();
|
||||
mozilla::CSSIntSize size;
|
||||
GetRDMScreenSize(size);
|
||||
return size.height;
|
||||
}
|
||||
|
||||
if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
|
||||
|
@ -79,6 +80,7 @@ class nsScreen : public mozilla::DOMEventTargetHelper {
|
|||
}
|
||||
}
|
||||
|
||||
nsRect rect;
|
||||
aRv = GetRect(rect);
|
||||
return rect.Height();
|
||||
}
|
||||
|
@ -146,7 +148,7 @@ class nsScreen : public mozilla::DOMEventTargetHelper {
|
|||
nsresult GetRect(nsRect& aRect);
|
||||
nsresult GetAvailRect(nsRect& aRect);
|
||||
nsresult GetWindowInnerRect(nsRect& aRect);
|
||||
nsresult GetRDMScreenSize(nsRect& aRect);
|
||||
nsresult GetRDMScreenSize(mozilla::CSSIntSize& aSize);
|
||||
|
||||
private:
|
||||
explicit nsScreen(nsPIDOMWindowInner* aWindow);
|
||||
|
|
Загрузка…
Ссылка в новой задаче