зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1882900 - Fix build failures in widget/uikit. r=nika
This only really takes care of making it compile, although there are still missing pieces for other directories to rely on it. This is enough to unblock a bunch of other work. While here, remove `virtual` on methods with `override`. Differential Revision: https://phabricator.services.mozilla.com/D203198
This commit is contained in:
Родитель
c24d2947b3
Коммит
cd082e3e9b
|
@ -1562,7 +1562,7 @@ UniquePtr<ScrollbarDrawing> Theme::ScrollbarStyle() {
|
|||
return MakeUnique<ScrollbarDrawingWin11>();
|
||||
}
|
||||
return MakeUnique<ScrollbarDrawingWin>();
|
||||
#elif MOZ_WIDGET_COCOA
|
||||
#elif defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
|
||||
return MakeUnique<ScrollbarDrawingCocoa>();
|
||||
#elif MOZ_WIDGET_GTK
|
||||
return MakeUnique<ScrollbarDrawingGTK>();
|
||||
|
|
|
@ -17,9 +17,19 @@ GfxInfo::GfxInfo() {}
|
|||
|
||||
GfxInfo::~GfxInfo() {}
|
||||
|
||||
nsresult GfxInfo::GetD2DEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetD2DEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
|
||||
|
||||
nsresult GfxInfo::GetDWriteEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetDWriteEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetEmbeddedInFirefoxReality(bool* aEmbeddedInFirefoxReality) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetHasBattery(bool* aHasBattery) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetDWriteVersion(nsAString& aDwriteVersion) {
|
||||
|
@ -31,6 +41,14 @@ GfxInfo::GetCleartypeParameters(nsAString& aCleartypeParams) {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetWindowProtocol(nsAString& aWindowProtocol) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetTestType(nsAString& aTestType) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDescription(nsAString& aAdapterDescription) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -47,6 +65,16 @@ GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) { return NS_ERROR_FAILURE; }
|
|||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterRAM2(uint32_t* aAdapterRAM) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDriverVendor(nsAString& aAdapterDriverVendor) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDriverVendor2(nsAString& aAdapterDriverVendor2) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDriver(nsAString& aAdapterDriver) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -90,7 +118,6 @@ GfxInfo::GetAdapterVendorID2(nsAString& aAdapterVendorID) {
|
|||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDeviceID(nsAString& aAdapterDeviceID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -111,12 +138,18 @@ GfxInfo::GetAdapterSubsysID2(nsAString& aAdapterSubsysID) {
|
|||
NS_IMETHODIMP
|
||||
GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
GfxInfo::GetDrmRenderDevice(nsACString& aDrmRenderDevice) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
|
||||
if (sDriverInfo->IsEmpty()) {
|
||||
APPEND_TO_DRIVER_BLOCKLIST2(
|
||||
OperatingSystem::Ios, DeviceFamily::All,
|
||||
nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK,
|
||||
DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions);
|
||||
DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions,
|
||||
"FEATURE_OK_FORCE_OPENGL");
|
||||
}
|
||||
|
||||
return *sDriverInfo;
|
||||
|
@ -124,7 +157,7 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
|
|||
|
||||
nsresult GfxInfo::GetFeatureStatusImpl(
|
||||
int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
|
||||
const nsTArray<GfxDriverInfo>& aDriverInfo,
|
||||
const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
|
||||
OperatingSystem* aOS /* = nullptr */) {
|
||||
NS_ENSURE_ARG_POINTER(aStatus);
|
||||
aSuggestedDriverVersion.SetIsVoid(true);
|
||||
|
@ -145,7 +178,7 @@ nsresult GfxInfo::GetFeatureStatusImpl(
|
|||
}
|
||||
|
||||
return GfxInfoBase::GetFeatureStatusImpl(
|
||||
aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aOS);
|
||||
aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, aOS);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -29,18 +29,26 @@ class GfxInfo : public GfxInfoBase {
|
|||
public:
|
||||
GfxInfo();
|
||||
|
||||
OperatingSystem GetOperatingSystem() override { return OperatingSystem::Ios; }
|
||||
|
||||
// We only declare the subset of nsIGfxInfo that we actually implement. The
|
||||
// rest is brought forward from GfxInfoBase.
|
||||
NS_IMETHOD GetD2DEnabled(bool* aD2DEnabled) override;
|
||||
NS_IMETHOD GetDWriteEnabled(bool* aDWriteEnabled) override;
|
||||
NS_IMETHOD GetEmbeddedInFirefoxReality(
|
||||
bool* aEmbeddedInFirefoxReality) override;
|
||||
NS_IMETHOD GetHasBattery(bool* aHasBattery) override;
|
||||
NS_IMETHOD GetDWriteVersion(nsAString& aDwriteVersion) override;
|
||||
NS_IMETHOD GetCleartypeParameters(nsAString& aCleartypeParams) override;
|
||||
NS_IMETHOD GetWindowProtocol(nsAString& aWindowProtocol) override;
|
||||
NS_IMETHOD GetTestType(nsAString& aTestType) override;
|
||||
NS_IMETHOD GetAdapterDescription(nsAString& aAdapterDescription) override;
|
||||
NS_IMETHOD GetAdapterDriver(nsAString& aAdapterDriver) override;
|
||||
NS_IMETHOD GetAdapterVendorID(nsAString& aAdapterVendorID) override;
|
||||
NS_IMETHOD GetAdapterDeviceID(nsAString& aAdapterDeviceID) override;
|
||||
NS_IMETHOD GetAdapterSubsysID(nsAString& aAdapterSubsysID) override;
|
||||
NS_IMETHOD GetAdapterRAM(uint32_t* aAdapterRAM) override;
|
||||
NS_IMETHOD GetAdapterDriverVendor(nsAString& aAdapterDriverVendor) override;
|
||||
NS_IMETHOD GetAdapterDriverVersion(nsAString& aAdapterDriverVersion) override;
|
||||
NS_IMETHOD GetAdapterDriverDate(nsAString& aAdapterDriverDate) override;
|
||||
NS_IMETHOD GetAdapterDescription2(nsAString& aAdapterDescription) override;
|
||||
|
@ -49,10 +57,12 @@ class GfxInfo : public GfxInfoBase {
|
|||
NS_IMETHOD GetAdapterDeviceID2(nsAString& aAdapterDeviceID) override;
|
||||
NS_IMETHOD GetAdapterSubsysID2(nsAString& aAdapterSubsysID) override;
|
||||
NS_IMETHOD GetAdapterRAM2(uint32_t* aAdapterRAM) override;
|
||||
NS_IMETHOD GetAdapterDriverVendor2(nsAString& aAdapterDriverVendor) override;
|
||||
NS_IMETHOD GetAdapterDriverVersion2(
|
||||
nsAString& aAdapterDriverVersion) override;
|
||||
NS_IMETHOD GetAdapterDriverDate2(nsAString& aAdapterDriverDate) override;
|
||||
NS_IMETHOD GetIsGPU2Active(bool* aIsGPU2Active) override;
|
||||
NS_IMETHOD GetDrmRenderDevice(nsACString& aDrmRenderDevice) override;
|
||||
using GfxInfoBase::GetFeatureStatus;
|
||||
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
|
||||
|
||||
|
@ -62,11 +72,12 @@ class GfxInfo : public GfxInfoBase {
|
|||
#endif
|
||||
|
||||
protected:
|
||||
virtual nsresult GetFeatureStatusImpl(
|
||||
int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
|
||||
const nsTArray<GfxDriverInfo>& aDriverInfo,
|
||||
OperatingSystem* aOS = nullptr);
|
||||
virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo();
|
||||
nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
|
||||
nsAString& aSuggestedDriverVersion,
|
||||
const nsTArray<GfxDriverInfo>& aDriverInfo,
|
||||
nsACString& aFailureId,
|
||||
OperatingSystem* aOS = nullptr) override;
|
||||
const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() override;
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
Headers = '/widget/uikit/nsWidgetFactory.h',
|
||||
|
||||
InitFunc = 'nsWidgetUIKitModuleCtor'
|
||||
UnloadFunc = 'nsWidgetUIKitModuleDtor'
|
||||
|
||||
Classes = [
|
||||
{
|
||||
'name': 'GfxInfo',
|
||||
'cid': '{d755a760-9f27-11df-0800-200c9a664242}',
|
||||
'contract_ids': ['@mozilla.org/gfx/info;1'],
|
||||
'type': 'mozilla::widget::GfxInfo',
|
||||
'headers': ['/widget/uikit/GfxInfo.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'cid': '{2d96b3df-c051-11d1-a827-0040959a28c9}',
|
||||
'contract_ids': ['@mozilla.org/widget/appshell/uikit;1'],
|
||||
'legacy_constructor': 'nsAppShellConstructor',
|
||||
'headers': ['/widget/uikit/nsWidgetFactory.h'],
|
||||
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS,
|
||||
},
|
||||
]
|
|
@ -11,7 +11,6 @@ SOURCES += [
|
|||
"GfxInfo.cpp",
|
||||
"nsAppShell.mm",
|
||||
"nsLookAndFeel.mm",
|
||||
"nsScreenManager.mm",
|
||||
"nsWidgetFactory.mm",
|
||||
"nsWindow.mm",
|
||||
]
|
||||
|
@ -22,3 +21,7 @@ FINAL_LIBRARY = "xul"
|
|||
LOCAL_INCLUDES += [
|
||||
"/widget",
|
||||
]
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
"components.conf",
|
||||
]
|
||||
|
|
|
@ -41,8 +41,8 @@ class nsAppShell : public nsBaseAppShell {
|
|||
virtual ~nsAppShell();
|
||||
|
||||
static void ProcessGeckoEvents(void* aInfo);
|
||||
virtual void ScheduleNativeEventCallback();
|
||||
virtual bool ProcessNextNativeEvent(bool aMayWait);
|
||||
void ScheduleNativeEventCallback() override;
|
||||
bool ProcessNextNativeEvent(bool aMayWait) override;
|
||||
|
||||
NSAutoreleasePool* mAutoreleasePool;
|
||||
AppShellDelegate* mDelegate;
|
||||
|
|
|
@ -14,13 +14,13 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
virtual ~nsLookAndFeel();
|
||||
|
||||
void NativeInit() final;
|
||||
virtual void RefreshImpl();
|
||||
nsresult NativeGetImpl(IntID aID, int32_t& aResult) override;
|
||||
void RefreshImpl() override;
|
||||
nsresult NativeGetInt(IntID aID, int32_t& aResult) override;
|
||||
nsresult NativeGetFloat(FloatID aID, float& aResult) override;
|
||||
nsresult NativeGetColor(ColorID, ColorScheme, nscolor& aResult) override;
|
||||
bool NativeGetFont(FontID aID, nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle) override;
|
||||
virtual char16_t GetPasswordCharacterImpl() {
|
||||
char16_t GetPasswordCharacterImpl() override {
|
||||
// unicode value for the bullet character, used for password textfields.
|
||||
return 0x2022;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
static bool UseOverlayScrollbars() { return true; }
|
||||
|
||||
private:
|
||||
nscolor mColorTextSelectForeground;
|
||||
nscolor mColorDarkText;
|
||||
|
||||
bool mInitialized;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "gfxFont.h"
|
||||
#include "gfxFontConstants.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() : mInitialized(false) {}
|
||||
|
||||
nsLookAndFeel::~nsLookAndFeel() {}
|
||||
|
@ -41,7 +43,8 @@ void nsLookAndFeel::RefreshImpl() {
|
|||
mInitialized = false;
|
||||
}
|
||||
|
||||
nsresult nsLookAndFeel::NativeGetColor(ColorID, ColorScheme, nscolor& aResult) {
|
||||
nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme,
|
||||
nscolor& aResult) {
|
||||
EnsureInit();
|
||||
|
||||
nsresult res = NS_OK;
|
||||
|
@ -55,7 +58,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID, ColorScheme, nscolor& aResult) {
|
|||
break;
|
||||
case ColorID::Highlighttext:
|
||||
case ColorID::MozMenuhovertext:
|
||||
aResult = mColorTextSelectForeground;
|
||||
aResult = NS_SAME_AS_FOREGROUND_COLOR;
|
||||
break;
|
||||
case ColorID::IMESelectedRawTextBackground:
|
||||
case ColorID::IMESelectedConvertedTextBackground:
|
||||
|
@ -154,11 +157,11 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID, ColorScheme, nscolor& aResult) {
|
|||
aResult = NS_RGB(0xaa, 0xaa, 0xaa);
|
||||
break;
|
||||
case ColorID::Window:
|
||||
case ColorID::MozField:
|
||||
case ColorID::Field:
|
||||
case ColorID::MozCombobox:
|
||||
aResult = NS_RGB(0xff, 0xff, 0xff);
|
||||
break;
|
||||
case ColorID::MozFieldtext:
|
||||
case ColorID::Fieldtext:
|
||||
case ColorID::MozComboboxtext:
|
||||
aResult = mColorDarkText;
|
||||
break;
|
||||
|
@ -175,12 +178,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID, ColorScheme, nscolor& aResult) {
|
|||
case ColorID::MozMacFocusring:
|
||||
aResult = NS_RGB(0x3F, 0x98, 0xDD);
|
||||
break;
|
||||
case ColorID::MozMacMenutextdisable:
|
||||
aResult = NS_RGB(0x88, 0x88, 0x88);
|
||||
break;
|
||||
case ColorID::MozMacMenutextselect:
|
||||
aResult = NS_RGB(0xaa, 0xaa, 0xaa);
|
||||
break;
|
||||
case ColorID::MozMacDisabledtoolbartext:
|
||||
aResult = NS_RGB(0x3F, 0x3F, 0x3F);
|
||||
break;
|
||||
|
@ -260,6 +257,19 @@ nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
|||
case IntID::ScrollArrowStyle:
|
||||
aResult = eScrollArrow_None;
|
||||
break;
|
||||
case IntID::UseOverlayScrollbars:
|
||||
case IntID::AllowOverlayScrollbarsOverlap:
|
||||
aResult = 1;
|
||||
break;
|
||||
case IntID::ScrollbarDisplayOnMouseMove:
|
||||
aResult = 0;
|
||||
break;
|
||||
case IntID::ScrollbarFadeBeginDelay:
|
||||
aResult = 450;
|
||||
break;
|
||||
case IntID::ScrollbarFadeDuration:
|
||||
aResult = 200;
|
||||
break;
|
||||
case IntID::TreeOpenDelay:
|
||||
aResult = 1000;
|
||||
break;
|
||||
|
@ -326,10 +336,10 @@ nsLookAndFeel::NativeGetFloat(FloatID aID, float& aResult) {
|
|||
bool nsLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName,
|
||||
gfxFontStyle& aFontStyle) {
|
||||
// hack for now
|
||||
if (aID == FontID::Window || aID == FontID::Document) {
|
||||
aFontStyle.style = FontSlantStyle::Normal();
|
||||
aFontStyle.weight = FontWeight::Normal();
|
||||
aFontStyle.stretch = FontStretch::Normal();
|
||||
if (aID == FontID::Caption || aID == FontID::Menu) {
|
||||
aFontStyle.style = FontSlantStyle::NORMAL;
|
||||
aFontStyle.weight = FontWeight::NORMAL;
|
||||
aFontStyle.stretch = FontStretch::NORMAL;
|
||||
aFontStyle.size = 14;
|
||||
aFontStyle.systemFont = true;
|
||||
|
||||
|
@ -347,14 +357,6 @@ void nsLookAndFeel::EnsureInit() {
|
|||
}
|
||||
mInitialized = true;
|
||||
|
||||
nscolor color;
|
||||
GetColor(ColorID::TextSelectBackground, color);
|
||||
if (color == 0x000000) {
|
||||
mColorTextSelectForeground = NS_RGB(0xff, 0xff, 0xff);
|
||||
} else {
|
||||
mColorTextSelectForeground = NS_SAME_AS_FOREGROUND_COLOR;
|
||||
}
|
||||
|
||||
mColorDarkText = GetColorFromUIColor([UIColor darkTextColor]);
|
||||
|
||||
RecordTelemetry();
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 nsScreenManager_h_
|
||||
#define nsScreenManager_h_
|
||||
|
||||
#include "nsBaseScreen.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
@class UIScreen;
|
||||
|
||||
class UIKitScreen : public nsBaseScreen {
|
||||
public:
|
||||
explicit UIKitScreen(UIScreen* screen);
|
||||
~UIKitScreen() {}
|
||||
|
||||
NS_IMETHOD GetId(uint32_t* outId) override {
|
||||
*outId = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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 GetRectDisplayPix(int32_t* aLeft, int32_t* aTop, int32_t* aWidth,
|
||||
int32_t* aHeight) override;
|
||||
NS_IMETHOD GetAvailRectDisplayPix(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;
|
||||
NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
|
||||
NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override {
|
||||
return GetContentsScaleFactor(aScaleFactor);
|
||||
}
|
||||
|
||||
private:
|
||||
UIScreen* mScreen;
|
||||
};
|
||||
|
||||
class UIKitScreenManager : public nsIScreenManager {
|
||||
public:
|
||||
UIKitScreenManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
static LayoutDeviceIntRect GetBounds();
|
||||
|
||||
private:
|
||||
virtual ~UIKitScreenManager() {}
|
||||
// TODO: support >1 screen, iPad supports external displays
|
||||
nsCOMPtr<nsIScreen> mScreen;
|
||||
};
|
||||
|
||||
#endif // nsScreenManager_h_
|
|
@ -1,104 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#import <UIKit/UIScreen.h>
|
||||
|
||||
#include "gfxPoint.h"
|
||||
#include "nsScreenManager.h"
|
||||
#include "nsAppShell.h"
|
||||
|
||||
static LayoutDeviceIntRect gScreenBounds;
|
||||
static bool gScreenBoundsSet = false;
|
||||
|
||||
UIKitScreen::UIKitScreen(UIScreen* aScreen) { mScreen = [aScreen retain]; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetRect(int32_t* outX, int32_t* outY, int32_t* outWidth,
|
||||
int32_t* outHeight) {
|
||||
return GetRectDisplayPix(outX, outY, outWidth, outHeight);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetAvailRect(int32_t* outX, int32_t* outY, int32_t* outWidth,
|
||||
int32_t* outHeight) {
|
||||
return GetAvailRectDisplayPix(outX, outY, outWidth, outHeight);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetRectDisplayPix(int32_t* outX, int32_t* outY, int32_t* outWidth,
|
||||
int32_t* outHeight) {
|
||||
nsIntRect rect = UIKitScreenManager::GetBounds();
|
||||
*outX = rect.x;
|
||||
*outY = rect.y;
|
||||
*outWidth = rect.width;
|
||||
*outHeight = rect.height;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetAvailRectDisplayPix(int32_t* outX, int32_t* outY,
|
||||
int32_t* outWidth, int32_t* outHeight) {
|
||||
CGRect rect = [mScreen applicationFrame];
|
||||
CGFloat scale = [mScreen scale];
|
||||
|
||||
*outX = rect.origin.x * scale;
|
||||
*outY = rect.origin.y * scale;
|
||||
*outWidth = rect.size.width * scale;
|
||||
*outHeight = rect.size.height * scale;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetPixelDepth(int32_t* aPixelDepth) {
|
||||
// Close enough.
|
||||
*aPixelDepth = 24;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetColorDepth(int32_t* aColorDepth) {
|
||||
return GetPixelDepth(aColorDepth);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreen::GetContentsScaleFactor(double* aContentsScaleFactor) {
|
||||
*aContentsScaleFactor = [mScreen scale];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(UIKitScreenManager, nsIScreenManager)
|
||||
|
||||
UIKitScreenManager::UIKitScreenManager()
|
||||
: mScreen(new UIKitScreen([UIScreen mainScreen])) {}
|
||||
|
||||
LayoutDeviceIntRect UIKitScreenManager::GetBounds() {
|
||||
if (!gScreenBoundsSet) {
|
||||
CGRect rect = [[UIScreen mainScreen] bounds];
|
||||
CGFloat scale = [[UIScreen mainScreen] scale];
|
||||
gScreenBounds.x = rect.origin.x * scale;
|
||||
gScreenBounds.y = rect.origin.y * scale;
|
||||
gScreenBounds.width = rect.size.width * scale;
|
||||
gScreenBounds.height = rect.size.height * scale;
|
||||
gScreenBoundsSet = true;
|
||||
}
|
||||
printf("UIKitScreenManager::GetBounds: %d %d %d %d\n", gScreenBounds.x,
|
||||
gScreenBounds.y, gScreenBounds.width, gScreenBounds.height);
|
||||
return gScreenBounds;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreenManager::GetPrimaryScreen(nsIScreen** outScreen) {
|
||||
NS_IF_ADDREF(*outScreen = mScreen.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UIKitScreenManager::ScreenForRect(int32_t inLeft, int32_t inTop,
|
||||
int32_t inWidth, int32_t inHeight,
|
||||
nsIScreen** outScreen) {
|
||||
return GetPrimaryScreen(outScreen);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
||||
*/
|
||||
/* 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 widget_uikit_nsWidgetFactory_h
|
||||
#define widget_uikit_nsWidgetFactory_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsID.h"
|
||||
|
||||
class nsISupports;
|
||||
|
||||
nsresult nsAppShellConstructor(const nsIID& iid, void** result);
|
||||
|
||||
void nsWidgetUIKitModuleCtor();
|
||||
void nsWidgetUIKitModuleDtor();
|
||||
|
||||
#endif // defined widget_uikit_nsWidgetFactory_h
|
|
@ -3,51 +3,18 @@
|
|||
* 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 "nsISupports.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsAppShellSingleton.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "nsScreenManager.h"
|
||||
#include "nsWidgetFactory.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(UIKitScreenManager)
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#include "GfxInfo.h"
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
// This constructor should really be shared with all platforms.
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
void nsWidgetUIKitModuleCtor() { nsAppShellInit(); }
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor},
|
||||
{&kNS_SCREENMANAGER_CID, false, nullptr, UIKitScreenManagerConstructor},
|
||||
{&kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor},
|
||||
{nullptr}};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
{"@mozilla.org/widget/appshell/uikit;1", &kNS_APPSHELL_CID},
|
||||
{"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID},
|
||||
{"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID},
|
||||
{nullptr}};
|
||||
|
||||
static void nsWidgetUIKitModuleDtor() {
|
||||
void nsWidgetUIKitModuleDtor() {
|
||||
WidgetUtils::Shutdown();
|
||||
nsLookAndFeel::Shutdown();
|
||||
nsAppShellShutdown();
|
||||
}
|
||||
|
||||
extern const mozilla::Module kWidgetModule = {mozilla::Module::kVersion,
|
||||
kWidgetCIDs,
|
||||
kWidgetContracts,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nsAppShellInit,
|
||||
nsWidgetUIKitModuleDtor};
|
||||
|
|
|
@ -27,49 +27,47 @@ class nsWindow final : public nsBaseWidget {
|
|||
// nsIWidget
|
||||
//
|
||||
|
||||
[[nodiscard]] virtual nsresult Create(
|
||||
[[nodiscard]] nsresult Create(
|
||||
nsIWidget* aParent, nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
widget::InitData* aInitData = nullptr) override;
|
||||
virtual void Destroy() override;
|
||||
virtual void Show(bool aState) override;
|
||||
virtual void Enable(bool aState) override {}
|
||||
virtual bool IsEnabled() const override { return true; }
|
||||
virtual bool IsVisible() const override { return mVisible; }
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
mozilla::widget::InitData* aInitData = nullptr) override;
|
||||
void Destroy() override;
|
||||
void Show(bool aState) override;
|
||||
void Enable(bool aState) override {}
|
||||
bool IsEnabled() const override { return true; }
|
||||
bool IsVisible() const override { return mVisible; }
|
||||
void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
|
||||
virtual void SetBackgroundColor(const nscolor& aColor) override;
|
||||
virtual void* GetNativeData(uint32_t aDataType) override;
|
||||
void SetBackgroundColor(const nscolor& aColor) override;
|
||||
void* GetNativeData(uint32_t aDataType) override;
|
||||
|
||||
virtual void Move(double aX, double aY) override;
|
||||
virtual nsSizeMode SizeMode() override { return mSizeMode; }
|
||||
virtual void SetSizeMode(nsSizeMode aMode) override;
|
||||
void Move(double aX, double aY) override;
|
||||
nsSizeMode SizeMode() override { return mSizeMode; }
|
||||
void SetSizeMode(nsSizeMode aMode) override;
|
||||
void EnteredFullScreen(bool aFullScreen);
|
||||
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
|
||||
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
|
||||
bool aRepaint) override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
void Resize(double aWidth, double aHeight, bool aRepaint) override;
|
||||
void Resize(double aX, double aY, double aWidth, double aHeight,
|
||||
bool aRepaint) override;
|
||||
LayoutDeviceIntRect GetScreenBounds() override;
|
||||
void ReportMoveEvent();
|
||||
void ReportSizeEvent();
|
||||
void ReportSizeModeEvent(nsSizeMode aMode);
|
||||
|
||||
CGFloat BackingScaleFactor();
|
||||
void BackingScaleFactorChanged();
|
||||
virtual float GetDPI() override {
|
||||
float GetDPI() override {
|
||||
// XXX: terrible
|
||||
return 326.0f;
|
||||
}
|
||||
virtual double GetDefaultScaleInternal() override {
|
||||
return BackingScaleFactor();
|
||||
}
|
||||
virtual int32_t RoundsWidgetCoordinatesTo() override;
|
||||
double GetDefaultScaleInternal() override { return BackingScaleFactor(); }
|
||||
int32_t RoundsWidgetCoordinatesTo() override;
|
||||
|
||||
virtual nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; }
|
||||
nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; }
|
||||
|
||||
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
||||
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
nsEventStatus& aStatus) override;
|
||||
void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
||||
nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
nsEventStatus& aStatus) override;
|
||||
|
||||
void WillPaintWindow();
|
||||
bool PaintWindow(LayoutDeviceIntRegion aRegion);
|
||||
|
@ -78,9 +76,9 @@ class nsWindow final : public nsBaseWidget {
|
|||
|
||||
// virtual nsresult
|
||||
// NotifyIME(const IMENotification& aIMENotification) override;
|
||||
virtual void SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction);
|
||||
virtual InputContext GetInputContext();
|
||||
void SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) override;
|
||||
InputContext GetInputContext() override;
|
||||
/*
|
||||
virtual bool ExecuteNativeKeyBinding(
|
||||
NativeKeyBindingsType aType,
|
||||
|
|
|
@ -17,18 +17,17 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "nsWindow.h"
|
||||
#include "nsScreenManager.h"
|
||||
#include "nsAppShell.h"
|
||||
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxContext.h"
|
||||
#include "nsRegion.h"
|
||||
#include "Layers.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "mozilla/BasicEvents.h"
|
||||
|
@ -36,10 +35,12 @@
|
|||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/MouseEventBinding.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::layers;
|
||||
using mozilla::dom::Touch;
|
||||
|
||||
#define ALOG(args...) \
|
||||
fprintf(stderr, args); \
|
||||
|
@ -144,9 +145,8 @@ class nsAutoRetainUIKitObject {
|
|||
|
||||
event.mRefPoint = aPoint;
|
||||
event.mClickCount = 1;
|
||||
event.button = MouseButton::ePrimary;
|
||||
event.mTime = PR_IntervalNow();
|
||||
event.inputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
|
||||
event.mButton = MouseButton::ePrimary;
|
||||
event.mInputSource = mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
|
||||
|
||||
nsEventStatus status;
|
||||
aWindow->DispatchEvent(&event, status);
|
||||
|
@ -169,20 +169,20 @@ class nsAutoRetainUIKitObject {
|
|||
WidgetTouchEvent event(true, aType, aWindow);
|
||||
// XXX: I think nativeEvent.timestamp * 1000 is probably usable here but
|
||||
// I don't care that much right now.
|
||||
event.mTime = PR_IntervalNow();
|
||||
event.mTouches.SetCapacity(aTouches.count);
|
||||
for (UITouch* touch in aTouches) {
|
||||
LayoutDeviceIntPoint loc = UIKitPointsToDevPixels(
|
||||
[touch locationInView:self], [self contentScaleFactor]);
|
||||
LayoutDeviceIntPoint radius =
|
||||
UIKitPointsToDevPixels([touch majorRadius], [touch majorRadius]);
|
||||
LayoutDeviceIntPoint radius = UIKitPointsToDevPixels(
|
||||
CGPointMake([touch majorRadius], [touch majorRadius]),
|
||||
[self contentScaleFactor]);
|
||||
void* value;
|
||||
if (!CFDictionaryGetValueIfPresent(mTouches, touch, (const void**)&value)) {
|
||||
// This shouldn't happen.
|
||||
NS_ASSERTION(false, "Got a touch that we didn't know about");
|
||||
continue;
|
||||
}
|
||||
int id = reinterpret_cast<int>(value);
|
||||
int id = [value intValue];
|
||||
RefPtr<Touch> t = new Touch(id, loc, radius, 0.0f, 1.0f);
|
||||
event.mRefPoint = loc;
|
||||
event.mTouches.AppendElement(t);
|
||||
|
@ -326,7 +326,8 @@ class nsAutoRetainUIKitObject {
|
|||
CGContextScaleCTM(aContext, 1.0 / scale, 1.0 / scale);
|
||||
|
||||
CGSize viewSize = [self bounds].size;
|
||||
gfx::IntSize backingSize(viewSize.width * scale, viewSize.height * scale);
|
||||
gfx::IntSize backingSize(NSToIntRound(viewSize.width * scale),
|
||||
NSToIntRound(viewSize.height * scale));
|
||||
|
||||
CGContextSaveGState(aContext);
|
||||
|
||||
|
@ -339,13 +340,12 @@ class nsAutoRetainUIKitObject {
|
|||
// Create Cairo objects.
|
||||
RefPtr<gfxQuartzSurface> targetSurface;
|
||||
|
||||
UniquePtrPtr<gfxContext> targetContext;
|
||||
UniquePtr<gfxContext> targetContext;
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(
|
||||
gfx::BackendType::CAIRO)) {
|
||||
// This is dead code unless you mess with prefs, but keep it around for
|
||||
// debugging.
|
||||
targetSurface = new gfxQuartzSurface(aContext, backingSize);
|
||||
targetSurface->SetAllowUseAsSource(false);
|
||||
RefPtr<gfx::DrawTarget> dt =
|
||||
gfxPlatform::CreateDrawTargetForSurface(targetSurface, backingSize);
|
||||
if (!dt || !dt->IsValid()) {
|
||||
|
@ -442,20 +442,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
if (parent == nullptr && nativeParent) parent = nativeParent->mGeckoChild;
|
||||
if (parent && nativeParent == nullptr) nativeParent = parent->mNativeView;
|
||||
|
||||
// for toplevel windows, bounds are fixed to full screen size
|
||||
if (parent == nullptr) {
|
||||
if (nsAppShell::gWindow == nil) {
|
||||
mBounds = UIKitScreenManager::GetBounds();
|
||||
} else {
|
||||
CGRect cgRect = [nsAppShell::gWindow bounds];
|
||||
mBounds.x = cgRect.origin.x;
|
||||
mBounds.y = cgRect.origin.y;
|
||||
mBounds.width = cgRect.size.width;
|
||||
mBounds.height = cgRect.size.height;
|
||||
}
|
||||
} else {
|
||||
mBounds = aRect;
|
||||
}
|
||||
mBounds = aRect;
|
||||
|
||||
ALOG("nsWindow[%p]::Create bounds: %d %d %d %d", (void*)this, mBounds.x,
|
||||
mBounds.y, mBounds.width, mBounds.height);
|
||||
|
@ -507,8 +494,6 @@ void nsWindow::Destroy() {
|
|||
TearDownView();
|
||||
|
||||
nsBaseWidget::OnDestroy();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsWindow::Show(bool aState) {
|
||||
|
@ -595,16 +580,12 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) {
|
|||
void nsWindow::Invalidate(const LayoutDeviceIntRect& aRect) {
|
||||
if (!mNativeView || !mVisible) return;
|
||||
|
||||
MOZ_RELEASE_ASSERT(
|
||||
GetLayerManager()->GetBackendType() != LayersBackend::LAYERS_WR,
|
||||
"Shouldn't need to invalidate with accelerated OMTC layers!");
|
||||
|
||||
[mNativeView setNeedsLayout];
|
||||
[mNativeView setNeedsDisplayInRect:DevPixelsToUIKitPoints(
|
||||
mBounds, BackingScaleFactor())];
|
||||
}
|
||||
|
||||
void nsWindow::SetFocus(Raise) {
|
||||
void nsWindow::SetFocus(Raise, mozilla::dom::CallerType) {
|
||||
[[mNativeView window] makeKeyWindow];
|
||||
[mNativeView becomeFirstResponder];
|
||||
}
|
||||
|
@ -672,8 +653,8 @@ LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset() {
|
|||
temp = [nsAppShell::gWindow convertPoint:temp toWindow:nil];
|
||||
}
|
||||
|
||||
offset.x += temp.x;
|
||||
offset.y += temp.y;
|
||||
offset.x += static_cast<int32_t>(temp.x);
|
||||
offset.y += static_cast<int32_t>(temp.y);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче