зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475875 - Use ScreenManager on Android r=esawin
This makes sure things work under e10s, but also results in simplified code since we weren't actually using the features of nsScreenManagerAndroid any more. MozReview-Commit-ID: 1zghxZuLqr3
This commit is contained in:
Родитель
0992c716bf
Коммит
e20b654b18
|
@ -322,23 +322,6 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
|||
return !!text;
|
||||
}
|
||||
|
||||
int
|
||||
AndroidBridge::GetDPI()
|
||||
{
|
||||
static int sDPI = 0;
|
||||
if (sDPI)
|
||||
return sDPI;
|
||||
|
||||
const int DEFAULT_DPI = 160;
|
||||
|
||||
sDPI = GeckoAppShell::GetDpi();
|
||||
if (!sDPI) {
|
||||
return DEFAULT_DPI;
|
||||
}
|
||||
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
int
|
||||
AndroidBridge::GetScreenDepth()
|
||||
{
|
||||
|
@ -358,6 +341,7 @@ AndroidBridge::GetScreenDepth()
|
|||
|
||||
return sDepth;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern)
|
||||
{
|
||||
|
|
|
@ -116,7 +116,6 @@ public:
|
|||
|
||||
bool GetClipboardText(nsAString& aText);
|
||||
|
||||
int GetDPI();
|
||||
int GetScreenDepth();
|
||||
|
||||
void Vibrate(const nsTArray<uint32_t>& aPattern);
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set sw=4 ts=4 expandtab:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ScreenHelperAndroid.h"
|
||||
#include "AndroidRect.h"
|
||||
#include "GeneratedJNINatives.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include <mozilla/jni/Refs.h>
|
||||
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::java;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
static already_AddRefed<Screen>
|
||||
MakePrimaryScreen() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
if (!jni::IsAvailable()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
java::sdk::Rect::LocalRef rect = GeckoAppShell::GetScreenSize();
|
||||
LayoutDeviceIntRect bounds = LayoutDeviceIntRect(rect->Left(), rect->Top(),
|
||||
rect->Width(), rect->Height());
|
||||
uint32_t depth = GeckoAppShell::GetScreenDepth();
|
||||
float density = GeckoAppShell::GetDensity();
|
||||
float dpi = GeckoAppShell::GetDpi();
|
||||
RefPtr<Screen> screen = new Screen(bounds, bounds, depth, depth,
|
||||
DesktopToLayoutDeviceScale(density),
|
||||
CSSToLayoutDeviceScale(1.0f),
|
||||
dpi);
|
||||
return screen.forget();
|
||||
}
|
||||
|
||||
void
|
||||
ScreenHelperAndroid::Refresh() {
|
||||
AutoTArray<RefPtr<Screen>, 1> screenList;
|
||||
RefPtr<Screen> screen = MakePrimaryScreen();
|
||||
if (screen) {
|
||||
screenList.AppendElement(screen);
|
||||
}
|
||||
|
||||
ScreenManager& manager = ScreenManager::GetSingleton();
|
||||
manager.Refresh(std::move(screenList));
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: ts=4 sw=4 expandtab:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef ScreenHelperAndroid_h___
|
||||
#define ScreenHelperAndroid_h___
|
||||
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
|
||||
class ScreenHelperAndroid final : public mozilla::widget::ScreenManager::Helper
|
||||
{
|
||||
public:
|
||||
ScreenHelperAndroid() {
|
||||
Refresh();
|
||||
}
|
||||
|
||||
~ScreenHelperAndroid() {
|
||||
}
|
||||
|
||||
void Refresh();
|
||||
};
|
||||
|
||||
#endif /* ScreenHelperAndroid_h___ */
|
|
@ -58,9 +58,9 @@ UNIFIED_SOURCES += [
|
|||
'nsLookAndFeel.cpp',
|
||||
'nsNativeThemeAndroid.cpp',
|
||||
'nsPrintSettingsServiceAndroid.cpp',
|
||||
'nsScreenManagerAndroid.cpp',
|
||||
'nsWidgetFactory.cpp',
|
||||
'nsWindow.cpp',
|
||||
'ScreenHelperAndroid.cpp',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/intl/OSPreferences.h"
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
|
@ -70,6 +71,7 @@
|
|||
#include "fennec/MemoryMonitor.h"
|
||||
#include "fennec/Telemetry.h"
|
||||
#include "fennec/ThumbnailHelper.h"
|
||||
#include "ScreenHelperAndroid.h"
|
||||
|
||||
#ifdef DEBUG_ANDROID_EVENTS
|
||||
#define EVLOG(args...) ALOG(args)
|
||||
|
@ -78,6 +80,7 @@
|
|||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
nsIGeolocationUpdate *gLocationCallback = nullptr;
|
||||
|
||||
|
@ -415,6 +418,10 @@ nsAppShell::nsAppShell()
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
ScreenManager& screenManager = ScreenManager::GetSingleton();
|
||||
screenManager.SetHelper(mozilla::MakeUnique<ScreenHelperAndroid>());
|
||||
|
||||
if (jni::IsAvailable()) {
|
||||
// Initialize JNI and Set the corresponding state in GeckoThread.
|
||||
AndroidBridge::ConstructBridge();
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set sw=4 ts=4 expandtab:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
|
||||
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "nsScreenManagerAndroid.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "AndroidRect.h"
|
||||
#include "GeneratedJNINatives.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <mozilla/jni/Refs.h>
|
||||
|
||||
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "nsScreenManagerAndroid", ## args)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::java;
|
||||
|
||||
static uint32_t sScreenId = 0;
|
||||
const uint32_t PRIMARY_SCREEN_ID = 0;
|
||||
|
||||
nsScreenAndroid::nsScreenAndroid(DisplayType aDisplayType, nsIntRect aRect)
|
||||
: mId(sScreenId++)
|
||||
, mDisplayType(aDisplayType)
|
||||
, mRect(aRect)
|
||||
, mDensity(0.0)
|
||||
{
|
||||
// ensure that the ID of the primary screen would be PRIMARY_SCREEN_ID.
|
||||
if (mDisplayType == DisplayType::DISPLAY_PRIMARY) {
|
||||
mId = PRIMARY_SCREEN_ID;
|
||||
}
|
||||
}
|
||||
|
||||
nsScreenAndroid::~nsScreenAndroid()
|
||||
{
|
||||
}
|
||||
|
||||
float
|
||||
nsScreenAndroid::GetDensity() {
|
||||
if (mDensity != 0.0) {
|
||||
return mDensity;
|
||||
}
|
||||
if (mDisplayType == DisplayType::DISPLAY_PRIMARY) {
|
||||
mDensity = mozilla::jni::IsAvailable() ? GeckoAppShell::GetDensity()
|
||||
: 1.0; // xpcshell most likely
|
||||
return mDensity;
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
||||
{
|
||||
if (mDisplayType != DisplayType::DISPLAY_PRIMARY) {
|
||||
*outLeft = mRect.x;
|
||||
*outTop = mRect.y;
|
||||
*outWidth = mRect.width;
|
||||
*outHeight = mRect.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mozilla::jni::IsAvailable()) {
|
||||
// xpcshell most likely
|
||||
*outLeft = *outTop = *outWidth = *outHeight = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
java::sdk::Rect::LocalRef rect = java::GeckoAppShell::GetScreenSize();
|
||||
*outLeft = rect->Left();
|
||||
*outTop = rect->Top();
|
||||
*outWidth = rect->Width();
|
||||
*outHeight = rect->Height();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
||||
{
|
||||
return GetRect(outLeft, outTop, outWidth, outHeight);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth)
|
||||
{
|
||||
if (!mozilla::jni::IsAvailable()) {
|
||||
// xpcshell most likely
|
||||
*aPixelDepth = 16;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aPixelDepth = java::GeckoAppShell::GetScreenDepth();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
|
||||
{
|
||||
return GetPixelDepth(aColorDepth);
|
||||
}
|
||||
|
||||
class nsScreenManagerAndroid::ScreenManagerHelperSupport final
|
||||
: public ScreenManagerHelper::Natives<ScreenManagerHelperSupport>
|
||||
{
|
||||
public:
|
||||
typedef ScreenManagerHelper::Natives<ScreenManagerHelperSupport> Base;
|
||||
|
||||
static int32_t AddDisplay(int32_t aDisplayType, int32_t aWidth, int32_t aHeight, float aDensity) {
|
||||
int32_t screenId = -1; // return value
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction(
|
||||
"nsScreenManagerAndroid::ScreenManagerHelperSupport::AddDisplay",
|
||||
[&aDisplayType, &aWidth, &aHeight, &aDensity, &screenId] {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
nsCOMPtr<nsIScreenManager> screenMgr =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager");
|
||||
|
||||
RefPtr<nsScreenManagerAndroid> screenMgrAndroid =
|
||||
(nsScreenManagerAndroid*) screenMgr.get();
|
||||
RefPtr<nsScreenAndroid> screen =
|
||||
screenMgrAndroid->AddScreen(static_cast<DisplayType>(aDisplayType),
|
||||
nsIntRect(0, 0, aWidth, aHeight));
|
||||
MOZ_ASSERT(screen);
|
||||
screen->SetDensity(aDensity);
|
||||
screenId = static_cast<int32_t>(screen->GetId());
|
||||
}).take());
|
||||
return screenId;
|
||||
}
|
||||
|
||||
static void RemoveDisplay(int32_t aScreenId) {
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction(
|
||||
"nsScreenManagerAndroid::ScreenManagerHelperSupport::RemoveDisplay",
|
||||
[&aScreenId] {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
nsCOMPtr<nsIScreenManager> screenMgr =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager");
|
||||
|
||||
RefPtr<nsScreenManagerAndroid> screenMgrAndroid =
|
||||
(nsScreenManagerAndroid*) screenMgr.get();
|
||||
screenMgrAndroid->RemoveScreen(aScreenId);
|
||||
}).take());
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsScreenManagerAndroid, nsIScreenManager)
|
||||
|
||||
nsScreenManagerAndroid::nsScreenManagerAndroid()
|
||||
{
|
||||
if (mozilla::jni::IsAvailable()) {
|
||||
ScreenManagerHelperSupport::Base::Init();
|
||||
}
|
||||
nsCOMPtr<nsIScreen> screen = AddScreen(DisplayType::DISPLAY_PRIMARY);
|
||||
MOZ_ASSERT(screen);
|
||||
}
|
||||
|
||||
nsScreenManagerAndroid::~nsScreenManagerAndroid()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerAndroid::GetPrimaryScreen(nsIScreen **outScreen)
|
||||
{
|
||||
RefPtr<nsScreenAndroid> screen = ScreenForId(PRIMARY_SCREEN_ID);
|
||||
if (screen) {
|
||||
screen.forget(outScreen);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsScreenAndroid>
|
||||
nsScreenManagerAndroid::ScreenForId(uint32_t aId)
|
||||
{
|
||||
for (size_t i = 0; i < mScreens.Length(); ++i) {
|
||||
if (aId == mScreens[i]->GetId()) {
|
||||
RefPtr<nsScreenAndroid> screen = mScreens[i];
|
||||
return screen.forget();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerAndroid::ScreenForRect(int32_t inLeft,
|
||||
int32_t inTop,
|
||||
int32_t inWidth,
|
||||
int32_t inHeight,
|
||||
nsIScreen **outScreen)
|
||||
{
|
||||
// Not support to query non-primary screen with rect.
|
||||
return GetPrimaryScreen(outScreen);
|
||||
}
|
||||
|
||||
already_AddRefed<nsScreenAndroid>
|
||||
nsScreenManagerAndroid::AddScreen(DisplayType aDisplayType, nsIntRect aRect)
|
||||
{
|
||||
ALOG("nsScreenManagerAndroid: add %s screen",
|
||||
(aDisplayType == DisplayType::DISPLAY_PRIMARY ? "PRIMARY" :
|
||||
(aDisplayType == DisplayType::DISPLAY_EXTERNAL ? "EXTERNAL" :
|
||||
"VIRTUAL")));
|
||||
RefPtr<nsScreenAndroid> screen = new nsScreenAndroid(aDisplayType, aRect);
|
||||
mScreens.AppendElement(screen);
|
||||
return screen.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsScreenManagerAndroid::RemoveScreen(uint32_t aScreenId)
|
||||
{
|
||||
for (size_t i = 0; i < mScreens.Length(); i++) {
|
||||
if (aScreenId == mScreens[i]->GetId()) {
|
||||
mScreens.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: ts=4 sw=4 expandtab:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsScreenManagerAndroid_h___
|
||||
#define nsScreenManagerAndroid_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsBaseScreen.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsRect.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
|
||||
class nsScreenAndroid final : public nsBaseScreen
|
||||
{
|
||||
public:
|
||||
nsScreenAndroid(DisplayType aDisplayType, nsIntRect aRect);
|
||||
~nsScreenAndroid();
|
||||
|
||||
NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
|
||||
NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
|
||||
NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
|
||||
NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
|
||||
|
||||
uint32_t GetId() const { return mId; };
|
||||
DisplayType GetDisplayType() const { return mDisplayType; }
|
||||
|
||||
void SetDensity(double aDensity) { mDensity = aDensity; }
|
||||
float GetDensity();
|
||||
|
||||
private:
|
||||
uint32_t mId;
|
||||
DisplayType mDisplayType;
|
||||
nsIntRect mRect;
|
||||
float mDensity;
|
||||
};
|
||||
|
||||
class nsScreenManagerAndroid final : public nsIScreenManager
|
||||
{
|
||||
private:
|
||||
~nsScreenManagerAndroid();
|
||||
|
||||
public:
|
||||
class ScreenManagerHelperSupport;
|
||||
|
||||
nsScreenManagerAndroid();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
already_AddRefed<nsScreenAndroid> ScreenForId(uint32_t aId);
|
||||
already_AddRefed<nsScreenAndroid> AddScreen(DisplayType aDisplayType,
|
||||
nsIntRect aRect = nsIntRect());
|
||||
void RemoveScreen(uint32_t aScreenId);
|
||||
|
||||
protected:
|
||||
nsTArray<RefPtr<nsScreenAndroid>> mScreens;
|
||||
};
|
||||
|
||||
#endif /* nsScreenManagerAndroid_h___ */
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsWindow.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "nsAppShellSingleton.h"
|
||||
#include "nsScreenManagerAndroid.h"
|
||||
|
||||
#include "nsIdleServiceAndroid.h"
|
||||
#include "nsClipboard.h"
|
||||
|
@ -31,8 +30,13 @@
|
|||
#include "AndroidAlerts.h"
|
||||
#include "nsNativeThemeAndroid.h"
|
||||
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerAndroid)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceAndroid, nsIdleServiceAndroid::GetInstance)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
|
||||
|
@ -95,7 +99,8 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
|||
{ &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
|
||||
{ &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
|
||||
{ &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
|
||||
{ &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerAndroidConstructor },
|
||||
{ &kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor,
|
||||
mozilla::Module::MAIN_PROCESS_ONLY },
|
||||
{ &kNS_THEMERENDERER_CID, false, nullptr, nsNativeThemeAndroidConstructor },
|
||||
{ &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceAndroidConstructor },
|
||||
{ &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
|
||||
|
@ -116,7 +121,8 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
|||
{ "@mozilla.org/widgets/window/android;1", &kNS_WINDOW_CID },
|
||||
{ "@mozilla.org/widgets/child_window/android;1", &kNS_CHILD_CID },
|
||||
{ "@mozilla.org/widget/appshell/android;1", &kNS_APPSHELL_CID },
|
||||
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
|
||||
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
|
||||
mozilla::Module::MAIN_PROCESS_ONLY },
|
||||
{ "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
|
||||
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
|
||||
{ "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
|
||||
|
|
|
@ -1524,19 +1524,25 @@ nsWindow::GetParent()
|
|||
float
|
||||
nsWindow::GetDPI()
|
||||
{
|
||||
if (AndroidBridge::Bridge())
|
||||
return AndroidBridge::Bridge()->GetDPI();
|
||||
return 160.0f;
|
||||
nsCOMPtr<nsIScreen> screen = GetWidgetScreen();
|
||||
if (!screen) {
|
||||
return 160.0f;
|
||||
}
|
||||
|
||||
float dpi;
|
||||
screen->GetDpi(&dpi);
|
||||
return dpi;
|
||||
}
|
||||
|
||||
double
|
||||
nsWindow::GetDefaultScaleInternal()
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIScreen> screen = GetWidgetScreen();
|
||||
MOZ_ASSERT(screen);
|
||||
RefPtr<nsScreenAndroid> screenAndroid = (nsScreenAndroid*) screen.get();
|
||||
return screenAndroid->GetDensity();
|
||||
|
||||
double scale;
|
||||
screen->GetContentsScaleFactor(&scale);
|
||||
return scale;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2278,9 +2284,9 @@ nsWindow::GetWidgetScreen()
|
|||
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager");
|
||||
|
||||
RefPtr<nsScreenManagerAndroid> screenMgrAndroid =
|
||||
(nsScreenManagerAndroid*) screenMgr.get();
|
||||
return screenMgrAndroid->ScreenForId(mScreenId);
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
return screen.forget();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче