Merge autoland to mozilla-central. a=merge

This commit is contained in:
smolnar 2021-03-23 11:41:50 +02:00
Родитель 0a79b0bd42 7eba371387
Коммит 1758450798
13 изменённых файлов: 950 добавлений и 697 удалений

Просмотреть файл

@ -206,6 +206,12 @@ namespace IOUtils {
Promise<boolean> exists(DOMString path);
};
[Exposed=Window]
partial namespace IOUtils {
[Throws]
readonly attribute any profileBeforeChange;
};
/**
* Options to be passed to the |IOUtils.readUTF8| method.
*/

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -14,12 +14,14 @@
#include "mozilla/DataMutex.h"
#include "mozilla/MozPromise.h"
#include "mozilla/Result.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/IOUtilsBinding.h"
#include "mozilla/dom/TypedArray.h"
#include "nsIAsyncShutdown.h"
#include "nsISerialEventTarget.h"
#include "nsPrintfCString.h"
#include "nsProxyRelease.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
@ -119,6 +121,10 @@ class IOUtils final {
static already_AddRefed<Promise> Exists(GlobalObject& aGlobal,
const nsAString& aPath);
static void GetProfileBeforeChange(GlobalObject& aGlobal,
JS::MutableHandle<JS::Value>,
ErrorResult& aRv);
class JsBuffer;
/**
@ -142,27 +148,20 @@ class IOUtils final {
struct InternalFileInfo;
struct InternalWriteOpts;
class MozLZ4;
class EventQueue;
class State;
static StaticDataMutex<StaticRefPtr<nsISerialEventTarget>>
sBackgroundEventTarget;
static StaticRefPtr<nsIAsyncShutdownClient> sBarrier;
static Atomic<bool> sShutdownStarted;
template <typename OkT, typename Fn, typename... Args>
static RefPtr<IOUtils::IOPromise<OkT>> InvokeToIOPromise(Fn aFunc,
Args... aArgs);
static already_AddRefed<nsIAsyncShutdownClient> GetShutdownBarrier();
static already_AddRefed<nsISerialEventTarget> GetBackgroundEventTarget();
static void SetShutdownHooks();
/**
* Dispatch a task on the event queue and resolve or reject the associated
* promise based on the result.
*
* @param aPromise The promise corresponding to the task running on the event
* queue.
* @param aFunc The task to run.
*/
template <typename OkT, typename Fn>
static RefPtr<IOPromise<OkT>> RunOnBackgroundThread(Fn aFunc);
template <typename OkT, typename Fn>
static void RunOnBackgroundThreadAndResolve(Promise* aPromise, Fn aFunc);
static void DispatchAndResolve(EventQueue* aQueue, Promise* aPromise,
Fn aFunc);
/**
* Creates a new JS Promise.
@ -176,16 +175,6 @@ class IOUtils final {
const InternalFileInfo& aInternalFileInfo,
JS::MutableHandle<JS::Value> aValue);
/**
* Resolves |aPromise| with an appropriate JS value for |aValue|.
*/
template <typename T>
static void ResolveJSPromise(Promise* aPromise, T&& aValue);
/**
* Rejects |aPromise| with an appropriate |DOMException| describing |aError|.
*/
static void RejectJSPromise(Promise* aPromise, const IOError& aError);
/**
* Attempts to read the entire file at |aPath| into a buffer.
*
@ -369,6 +358,80 @@ class IOUtils final {
* @return Whether or not the file exists.
*/
static Result<bool, IOError> ExistsSync(nsIFile* aFile);
enum class EventQueueStatus {
Uninitialized,
Initialized,
Shutdown,
};
enum class ShutdownBlockerStatus {
Uninitialized,
Initialized,
Failed,
};
/**
* Internal IOUtils state.
*/
class State {
public:
StaticAutoPtr<EventQueue> mEventQueue;
EventQueueStatus mQueueStatus = EventQueueStatus::Uninitialized;
ShutdownBlockerStatus mBlockerStatus = ShutdownBlockerStatus::Uninitialized;
/**
* Set up shutdown hooks to free our internals at shutdown.
*
* NB: Must be called on main thread.
*/
void SetShutdownHooks();
};
using StateMutex = StaticDataMutex<State>;
/**
* Lock the state mutex and return a handle. If shutdown has not yet
* finished, the internals will be constructed if necessary.
*
* @returns A handle to the internal state, which can be used to retrieve the
* event queue.
* If |Some| is returned, |mEventQueue| is guaranteed to be
* initialized. If shutdown has finished, |Nothing| is returned.
*/
static Maybe<StateMutex::AutoLock> GetState();
static StateMutex sState;
};
/**
* The IOUtils event queue.
*/
class IOUtils::EventQueue final {
friend void IOUtils::State::SetShutdownHooks();
public:
EventQueue();
EventQueue(const EventQueue&) = delete;
EventQueue(EventQueue&&) = delete;
EventQueue& operator=(const EventQueue&) = delete;
EventQueue& operator=(EventQueue&&) = delete;
template <typename OkT, typename Fn>
RefPtr<IOPromise<OkT>> Dispatch(Fn aFunc);
Result<already_AddRefed<nsIAsyncShutdownClient>, nsresult>
GetProfileBeforeChangeClient();
Result<already_AddRefed<nsIAsyncShutdownBarrier>, nsresult>
GetProfileBeforeChangeBarrier();
private:
nsresult SetShutdownHooks();
nsCOMPtr<nsISerialEventTarget> mBackgroundEventTarget;
nsCOMPtr<nsIAsyncShutdownBarrier> mProfileBeforeChangeBarrier;
};
/**
@ -481,13 +544,25 @@ class IOUtils::MozLZ4 {
Span<const uint8_t> aFileContents, IOUtils::BufferKind);
};
class IOUtilsShutdownBlocker : public nsIAsyncShutdownBlocker {
class IOUtilsShutdownBlocker : public nsIAsyncShutdownBlocker,
public nsIAsyncShutdownCompletionCallback {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIASYNCSHUTDOWNBLOCKER
NS_DECL_NSIASYNCSHUTDOWNCOMPLETIONCALLBACK
enum Phase {
ProfileBeforeChange,
XpcomWillShutdown,
};
explicit IOUtilsShutdownBlocker(Phase aPhase) : mPhase(aPhase) {}
private:
virtual ~IOUtilsShutdownBlocker() = default;
Phase mPhase;
RefPtr<nsIAsyncShutdownClient> mParentClient;
};
/**

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/RefPtr.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/StaticPrefs_gfx.h"
using namespace mozilla;
@ -84,6 +85,11 @@ already_AddRefed<MacIOSurface> MacIOSurface::CreateIOSurface(
CFTypeRefPtr<IOSurfaceRef>::WrapUnderCreateRule(
::IOSurfaceCreate(props.get()));
if (StaticPrefs::gfx_color_management_native_srgb()) {
IOSurfaceSetValue(surfaceRef.get(), CFSTR("IOSurfaceColorSpace"),
kCGColorSpaceSRGB);
}
if (!surfaceRef) {
return nullptr;
}

Просмотреть файл

@ -17,17 +17,22 @@ SourceSurfaceD2D1::SourceSurfaceD2D1(ID2D1Image* aImage,
: mImage(aImage),
mDC(aDC),
mDevice(Factory::GetD2D1Device()),
mDrawTarget(aDT) {
mFormat(aFormat),
mSize(aSize),
mDrawTarget(aDT),
mOwnsCopy(false) {
aImage->QueryInterface((ID2D1Bitmap1**)getter_AddRefs(mRealizedBitmap));
mFormat = aFormat;
mSize = aSize;
if (aDT) {
mSnapshotLock = aDT->mSnapshotLock;
}
}
SourceSurfaceD2D1::~SourceSurfaceD2D1() {}
SourceSurfaceD2D1::~SourceSurfaceD2D1() {
if (mOwnsCopy) {
DrawTargetD2D1::mVRAMUsageSS -=
mSize.width * mSize.height * BytesPerPixel(mFormat);
}
}
bool SourceSurfaceD2D1::IsValid() const {
return mDevice == Factory::GetD2D1Device();
@ -145,6 +150,7 @@ void SourceSurfaceD2D1::DrawTargetWillChange() {
DrawTargetD2D1::mVRAMUsageSS +=
mSize.width * mSize.height * BytesPerPixel(mFormat);
mOwnsCopy = true;
// Ensure the object stays alive for the duration of MarkIndependent.
RefPtr<SourceSurfaceD2D1> deathGrip = this;

Просмотреть файл

@ -62,10 +62,11 @@ class SourceSurfaceD2D1 : public SourceSurface {
// Keep this around to verify whether out image is still valid in the future.
RefPtr<ID2D1Device> mDevice;
SurfaceFormat mFormat;
IntSize mSize;
const SurfaceFormat mFormat;
const IntSize mSize;
DrawTargetD2D1* mDrawTarget;
std::shared_ptr<Mutex> mSnapshotLock;
bool mOwnsCopy;
};
class DataSourceSurfaceD2D1 : public DataSourceSurface {

Просмотреть файл

@ -164,6 +164,10 @@ CFTypeRefPtr<IOSurfaceRef> SurfacePoolCA::LockedPool::ObtainSurfaceFromPool(cons
(__bridge NSString*)kIOSurfaceBytesPerElement : @(4),
}));
if (surface) {
if (StaticPrefs::gfx_color_management_native_srgb()) {
IOSurfaceSetValue(surface.get(), CFSTR("IOSurfaceColorSpace"),
kCGColorSpaceSRGB);
}
// Create a new entry in mInUseEntries.
MutateEntryStorage("Create", aSize, [&]() {
mInUseEntries.insert({surface, SurfacePoolEntry{aSize, surface, {}}});

Просмотреть файл

@ -2152,7 +2152,8 @@ void gfxPlatform::InitializeCMS() {
of this preference, which means nsIPrefBranch::GetBoolPref will
typically throw (and leave its out-param untouched).
*/
if (StaticPrefs::gfx_color_management_force_srgb()) {
if (StaticPrefs::gfx_color_management_force_srgb() ||
StaticPrefs::gfx_color_management_native_srgb()) {
gCMSOutputProfile = gCMSsRGBProfile;
}

Просмотреть файл

@ -933,7 +933,7 @@ class TextInputDelegateTest : BaseSessionTest() {
val ic = mainSession.textInput.onCreateInputConnection(EditorInfo())!!
commitText(ic, "foo", 1)
setSelection(ic, 0, 3)
ic.setSelection(0, 3)
mainSession.evaluateJS("""
input_event_count = 0;

Просмотреть файл

@ -4191,6 +4191,15 @@
value: false
mirror: always
- name: gfx.color_management.native_srgb
type: RelaxedAtomicBool
#if defined(XP_MACOSX)
value: true
#else
value: false
#endif
mirror: always
- name: gfx.color_management.enablev4
type: RelaxedAtomicBool
value: false

Просмотреть файл

@ -297,7 +297,7 @@ var ClientIDImpl = {
try {
await IOUtils.makeDirectory(gDatareportingPath);
} catch (ex) {
if (ex.name != "NotAllowedError") {
if (!(ex instanceof DOMException) || ex.name !== "AbortError") {
throw ex;
}
}

Просмотреть файл

@ -57,23 +57,17 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
nscolor mColorTextSelectBackgroundDisabled;
nscolor mColorHighlight;
nscolor mColorTextSelectForeground;
nscolor mColorMenuHoverText;
nscolor mColorButtonText;
nscolor mColorButtonHoverText;
nscolor mColorAlternateSelectedControlText;
nscolor mColorControlText;
nscolor mColorText;
nscolor mColorWindowText;
nscolor mColorActiveCaption;
nscolor mColorGrid;
nscolor mColorActiveBorder;
nscolor mColorGrayText;
nscolor mColorInactiveBorder;
nscolor mColorInactiveCaption;
nscolor mColorControlBackground;
nscolor mColorScrollbar;
nscolor mColorThreeDHighlight;
nscolor mColorMenu;
nscolor mColorWindowFrame;
nscolor mColorFieldText;
nscolor mColorDialog;
nscolor mColorDialogText;
nscolor mColorDragTargetZone;
nscolor mColorChromeActive;
nscolor mColorChromeInactive;

Просмотреть файл

@ -60,23 +60,17 @@ nsLookAndFeel::nsLookAndFeel(const LookAndFeelCache* aCache)
mColorTextSelectBackgroundDisabled(0),
mColorHighlight(0),
mColorTextSelectForeground(0),
mColorMenuHoverText(0),
mColorButtonText(0),
mColorButtonHoverText(0),
mColorAlternateSelectedControlText(0),
mColorControlText(0),
mColorText(0),
mColorWindowText(0),
mColorActiveCaption(0),
mColorGrid(0),
mColorActiveBorder(0),
mColorGrayText(0),
mColorInactiveBorder(0),
mColorInactiveCaption(0),
mColorControlBackground(0),
mColorScrollbar(0),
mColorThreeDHighlight(0),
mColorMenu(0),
mColorWindowFrame(0),
mColorFieldText(0),
mColorDialog(0),
mColorDialogText(0),
mColorDragTargetZone(0),
mColorChromeActive(0),
mColorChromeInactive(0),
@ -222,7 +216,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
case ColorID::Highlighttext: // CSS2 color
case ColorID::MozAccentColorForeground:
case ColorID::MozMenuhovertext:
aColor = mColorMenuHoverText;
aColor = mColorAlternateSelectedControlText;
break;
case ColorID::IMESelectedRawTextBackground:
case ColorID::IMESelectedConvertedTextBackground:
@ -261,11 +255,11 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
//
case ColorID::MozMacButtonactivetext:
case ColorID::MozMacDefaultbuttontext:
aColor = mColorButtonText;
aColor = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Buttontext:
case ColorID::MozButtonhovertext:
aColor = mColorButtonHoverText;
aColor = mColorControlText;
break;
case ColorID::Captiontext:
case ColorID::Menutext:
@ -277,7 +271,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
aColor = mColorWindowText;
break;
case ColorID::Activecaption:
aColor = mColorActiveCaption;
aColor = mColorGrid;
break;
case ColorID::Activeborder:
aColor = mColorActiveBorder;
@ -302,10 +296,8 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
aColor = mColorGrayText;
break;
case ColorID::Inactiveborder:
aColor = mColorInactiveBorder;
break;
case ColorID::Inactivecaption:
aColor = mColorInactiveCaption;
aColor = mColorControlBackground;
break;
case ColorID::Inactivecaptiontext:
aColor = NS_RGB(0x45, 0x45, 0x45);
@ -329,10 +321,10 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
aColor = NS_RGB(0xDA, 0xDA, 0xDA);
break;
case ColorID::Menu:
aColor = mColorMenu;
aColor = mColorAlternateSelectedControlText;
break;
case ColorID::Windowframe:
aColor = mColorWindowFrame;
aColor = mColorGrid;
break;
case ColorID::Window:
case ColorID::Field:
@ -341,7 +333,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
break;
case ColorID::Fieldtext:
case ColorID::MozComboboxtext:
aColor = mColorFieldText;
aColor = mColorControlText;
break;
case ColorID::MozDialog:
aColor = mColorDialog;
@ -351,7 +343,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
case ColorID::MozHtmlCellhighlighttext:
case ColorID::MozColheadertext:
case ColorID::MozColheaderhovertext:
aColor = mColorDialogText;
aColor = mColorControlText;
break;
case ColorID::MozDragtargetzone:
aColor = mColorDragTargetZone;
@ -697,21 +689,15 @@ mozilla::widget::LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
ColorID::TextSelectBackground,
ColorID::TextSelectBackgroundDisabled,
ColorID::TextSelectForeground,
ColorID::MozMacDefaultbuttontext,
ColorID::MozButtonhovertext,
ColorID::Windowtext,
ColorID::Activecaption,
ColorID::Activeborder,
ColorID::Graytext,
ColorID::Inactiveborder,
ColorID::Inactivecaption,
ColorID::Scrollbar,
ColorID::Threedhighlight,
ColorID::Menu,
ColorID::Windowframe,
ColorID::Fieldtext,
ColorID::MozDialog,
ColorID::MozDialogtext,
ColorID::MozDragtargetzone,
ColorID::MozMacChromeActive,
ColorID::MozMacChromeInactive,
@ -777,7 +763,7 @@ void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) {
case ColorID::Highlight:
return mColorHighlight;
case ColorID::Highlighttext:
return mColorMenuHoverText;
return mColorAlternateSelectedControlText;
case ColorID::Menutext:
return mColorText;
case ColorID::TextSelectBackground:
@ -786,36 +772,24 @@ void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) {
return mColorTextSelectBackgroundDisabled;
case ColorID::TextSelectForeground:
return mColorTextSelectForeground;
case ColorID::MozMacDefaultbuttontext:
return mColorButtonText;
case ColorID::MozButtonhovertext:
return mColorButtonHoverText;
case ColorID::Windowtext:
return mColorWindowText;
case ColorID::Activecaption:
return mColorActiveCaption;
return mColorGrid;
case ColorID::Activeborder:
return mColorActiveBorder;
case ColorID::Graytext:
return mColorGrayText;
case ColorID::Inactiveborder:
return mColorInactiveBorder;
case ColorID::Inactivecaption:
return mColorInactiveCaption;
return mColorControlBackground;
case ColorID::Scrollbar:
return mColorScrollbar;
case ColorID::Threedhighlight:
return mColorThreeDHighlight;
case ColorID::Menu:
return mColorMenu;
case ColorID::Windowframe:
return mColorWindowFrame;
case ColorID::Fieldtext:
return mColorFieldText;
return mColorControlText;
case ColorID::MozDialog:
return mColorDialog;
case ColorID::MozDialogtext:
return mColorDialogText;
case ColorID::MozDragtargetzone:
return mColorDragTargetZone;
case ColorID::MozMacChromeActive:
@ -893,25 +867,20 @@ void nsLookAndFeel::EnsureInit() {
mColorTextSelectForeground = NS_DONT_CHANGE_COLOR;
}
mColorMenuHoverText = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
mColorAlternateSelectedControlText =
GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
mColorButtonText = NS_RGB(0xFF, 0xFF, 0xFF);
mColorButtonHoverText = GetColorFromNSColor([NSColor controlTextColor]);
mColorControlText = GetColorFromNSColor([NSColor controlTextColor]);
mColorText = GetColorFromNSColor([NSColor textColor]);
mColorWindowText = GetColorFromNSColor([NSColor windowFrameTextColor]);
mColorActiveCaption = GetColorFromNSColor([NSColor gridColor]);
mColorGrid = GetColorFromNSColor([NSColor gridColor]);
mColorActiveBorder = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]);
NSColor* disabledColor = [NSColor disabledControlTextColor];
mColorGrayText = GetColorFromNSColorWithAlpha(disabledColor, [disabledColor alphaComponent]);
mColorInactiveBorder = GetColorFromNSColor([NSColor controlBackgroundColor]);
mColorInactiveCaption = GetColorFromNSColor([NSColor controlBackgroundColor]);
mColorControlBackground = GetColorFromNSColor([NSColor controlBackgroundColor]);
mColorScrollbar = GetColorFromNSColor([NSColor scrollBarColor]);
mColorThreeDHighlight = GetColorFromNSColor([NSColor highlightColor]);
mColorMenu = GetColorFromNSColor([NSColor alternateSelectedControlTextColor]);
mColorWindowFrame = GetColorFromNSColor([NSColor gridColor]);
mColorFieldText = GetColorFromNSColor([NSColor controlTextColor]);
mColorDialog = GetColorFromNSColor([NSColor controlHighlightColor]);
mColorDialogText = GetColorFromNSColor([NSColor controlTextColor]);
mColorDragTargetZone = GetColorFromNSColor([NSColor selectedControlColor]);
int grey = NativeGreyColorAsInt(toolbarFillGrey, true);