Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/0001-Use-remoting-name-for-GDK-application-names.patch b/0001-Use-remoting-name-for-GDK-application-names.patch
- index 165a532..8c361fa 100644
- --- a/0001-Use-remoting-name-for-GDK-application-names.patch
- +++ b/0001-Use-remoting-name-for-GDK-application-names.patch
- @@ -25,10 +25,8 @@ index 984b998133bd..b6c9f013940c 100644
- // Initialize GTK here for splash.
- -diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
- -index 0daa78fdbbad..49038d0bb1c8 100644
- ---- a/widget/gtk/nsAppShell.cpp
- -+++ b/widget/gtk/nsAppShell.cpp
- +--- a/widget/gtk/nsAppShell.cpp.orig 2020-05-29 09:02:46.000000000 +0300
- ++++ b/widget/gtk/nsAppShell.cpp 2020-06-02 21:27:17.464209460 +0300
- @@ -24,6 +24,7 @@
- # include "WakeLockListener.h"
- #endif
- @@ -37,19 +35,16 @@ index 0daa78fdbbad..49038d0bb1c8 100644
- #include "ScreenHelperGTK.h"
- #include "HeadlessScreenHelper.h"
- #include "mozilla/widget/ScreenManager.h"
- -@@ -175,10 +176,8 @@ nsresult nsAppShell::Init() {
- - // option when program uses gdk_set_program_class().
- - //
- - // See https://bugzilla.gnome.org/show_bug.cgi?id=747634
- -- nsAutoString brandName;
- -- mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
- -- if (!brandName.IsEmpty()) {
- -- gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
- +@@ -178,10 +179,8 @@
- + // creating top-level windows. (At this point, a child process hasn't
- + // received the list of registered chrome packages, so the
- + // GetBrandShortName call would fail anyway.)
- +- nsAutoString brandName;
- +- mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
- +- if (!brandName.IsEmpty()) {
- +- gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
- + if (gAppData) {
- + gdk_set_program_class(gAppData->remotingName);
- + }
- }
- }
- -
- ---
- -2.24.0
- -
- diff --git a/PKGBUILD b/PKGBUILD
- index 3660dad..7134d14 100644
- --- a/PKGBUILD
- +++ b/PKGBUILD
- @@ -7,7 +7,7 @@
- pkgname=firefox-appmenu
- _pkgname=firefox
- -pkgver=76.0.1
- +pkgver=77.0
- pkgrel=1
- pkgdesc="Firefox from extra with appmenu patch"
- arch=(x86_64)
- @@ -29,12 +29,14 @@ options=(!emptydirs !makeflags !strip)
- source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
- 0001-Use-remoting-name-for-GDK-application-names.patch
- $_pkgname.desktop
- - unity-menubar.patch)
- -sha256sums=('f61761e32774a6bdfedd5937c4992fbe5e24c3df057c2b9a559fcd0d038777c3'
- + unity-menubar.patch
- + reverse_killing_autoptr.patch)
- +sha256sums=('b534794c493d8698dfb6c852af52b49540afdf88dc50451f42d6591de93291e8'
- 'SKIP'
- - '5f7ac724a5c5afd9322b1e59006f4170ea5354ca1e0e60dab08b7784c2d8463c'
- + '38f9f646f84f6669b15f097ac8f1c31831d95bfe66494d39c5f0ed05aad6fc5b'
- '34514a657d6907a159594c51e674eeb81297c431ec26a736417c2fdb995c2c0c'
- - '3e5e34b8d45b9cc48e78e9c474f2450cc597451bbb331fb5a4e8f3a3ba5e3a70')
- + '3e5e34b8d45b9cc48e78e9c474f2450cc597451bbb331fb5a4e8f3a3ba5e3a70'
- + SKIP)
- validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases <release@mozilla.com>
- # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
- @@ -59,6 +61,7 @@ prepare() {
- # actual appmenu patch from ubuntu repos
- # http://archive.ubuntu.com/ubuntu/pool/main/f/firefox/firefox_76.0+build2-0ubuntu0.18.04.1.debian.tar.xz
- patch -Np1 -i ../unity-menubar.patch
- + patch -Np1 -i ../reverse_killing_autoptr.patch
- echo -n "$_google_api_key" >google-api-key
- echo -n "$_mozilla_api_key" >mozilla-api-key
- diff --git a/reverse_killing_autoptr.patch b/reverse_killing_autoptr.patch
- new file mode 100644
- index 0000000..405ad66
- --- /dev/null
- +++ b/reverse_killing_autoptr.patch
- @@ -0,0 +1,972 @@
- +--- b/xpcom/base/moz.build
- ++++ a/xpcom/base/moz.build
- +@@ -1,240 +1,241 @@
- + # -*- 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/.
- +
- + XPIDL_SOURCES += [
- + 'nsIConsoleListener.idl',
- + 'nsIConsoleMessage.idl',
- + 'nsIConsoleService.idl',
- + 'nsICycleCollectorListener.idl',
- + 'nsIDebug2.idl',
- + 'nsIErrorService.idl',
- + 'nsIException.idl',
- + 'nsIGZFileWriter.idl',
- + 'nsIInterfaceRequestor.idl',
- + 'nsIMemory.idl',
- + 'nsIMemoryInfoDumper.idl',
- + 'nsIMemoryReporter.idl',
- + 'nsIMessageLoop.idl',
- + 'nsISecurityConsoleMessage.idl',
- + 'nsISupports.idl',
- + 'nsIUUIDGenerator.idl',
- + 'nsIVersionComparator.idl',
- + 'nsIWeakReference.idl',
- + 'nsrootidl.idl',
- + ]
- +
- + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
- + XPIDL_SOURCES += [
- + 'nsIMacPreferencesReader.idl',
- + 'nsIMacUtils.idl',
- + ]
- + EXPORTS.mozilla += [
- + 'MacHelpers.h',
- + 'MacStringHelpers.h',
- + 'nsMacPreferencesReader.h',
- + ]
- + UNIFIED_SOURCES += [
- + 'MacHelpers.mm',
- + 'MacStringHelpers.mm',
- + 'nsMacPreferencesReader.mm',
- + ]
- +
- + XPIDL_MODULE = 'xpcom_base'
- +
- + XPCOM_MANIFESTS += [
- + 'components.conf',
- + ]
- +
- + EXPORTS += [
- + '!ErrorList.h',
- + '!ErrorNamesInternal.h',
- + 'CodeAddressService.h',
- + 'nsAlgorithm.h',
- ++ 'nsAutoPtr.h',
- + 'nsAutoRef.h',
- + 'nsCom.h',
- + 'nsCOMPtr.h',
- + 'nscore.h',
- + 'nsCRTGlue.h',
- + 'nsCycleCollectionNoteChild.h',
- + 'nsCycleCollectionNoteRootCallback.h',
- + 'nsCycleCollectionParticipant.h',
- + 'nsCycleCollectionTraversalCallback.h',
- + 'nsCycleCollector.h',
- + 'nsDebug.h',
- + 'nsDebugImpl.h',
- + 'nsDumpUtils.h',
- + 'nsError.h',
- + 'nsErrorService.h',
- + 'nsGZFileWriter.h',
- + 'nsIClassInfoImpl.h',
- + 'nsID.h',
- + 'nsIInterfaceRequestorUtils.h',
- + 'nsINIParser.h',
- + 'nsInterfaceRequestorAgg.h',
- + 'nsISizeOf.h',
- + 'nsISupportsBase.h',
- + 'nsISupportsImpl.h',
- + 'nsISupportsUtils.h',
- + 'nsIWeakReferenceUtils.h',
- + 'nsMaybeWeakPtr.h',
- + 'nsMemory.h',
- + 'nsObjCExceptions.h',
- + 'nsQueryObject.h',
- + 'nsSystemInfo.h',
- + 'nsTraceRefcnt.h',
- + 'nsVersionComparator.h',
- + 'nsWeakReference.h',
- + ]
- +
- + if CONFIG['OS_ARCH'] == 'WINNT':
- + EXPORTS += [
- + 'nsWindowsHelpers.h',
- + ]
- + if CONFIG['CC_TYPE'] not in ('gcc', 'clang'):
- + OS_LIBS += [
- + 'wscapi',
- + ]
- +
- + EXPORTS.mozilla += [
- + 'AppShutdown.h',
- + 'AutoRestore.h',
- + 'AvailableMemoryTracker.h',
- + 'ClearOnShutdown.h',
- + 'CountingAllocatorBase.h',
- + 'CycleCollectedJSContext.h',
- + 'CycleCollectedJSRuntime.h',
- + 'Debug.h',
- + 'DebuggerOnGCRunnable.h',
- + 'DeferredFinalize.h',
- + 'EnumeratedArrayCycleCollection.h',
- + 'ErrorNames.h',
- + 'GkRustUtils.h',
- + 'HoldDropJSObjects.h',
- + 'IntentionalCrash.h',
- + 'JSObjectHolder.h',
- + 'Logging.h',
- + 'MemoryInfo.h',
- + 'MemoryMapping.h',
- + 'MemoryReportingProcess.h',
- + 'MemoryTelemetry.h',
- + 'nsMemoryInfoDumper.h',
- + 'NSPRLogModulesParser.h',
- + 'OwningNonNull.h',
- + 'ShutdownPhase.h',
- + 'SizeOfState.h',
- + 'StaticLocalPtr.h',
- + 'StaticMonitor.h',
- + 'StaticMutex.h',
- + 'StaticPtr.h',
- + 'TupleCycleCollection.h',
- + ]
- +
- + SOURCES += [
- + # nsDebugImpl isn't unified because we disable PGO so that NS_ABORT_OOM isn't
- + # optimized away oddly.
- + 'nsDebugImpl.cpp',
- + # nsDumpUtils.cpp includes SpecialSystemDirectory.h which includes
- + # nsLocalFileMac.h which upsets other files in this dir that have a different
- + # idea about what `TextRange` means.
- + 'nsDumpUtils.cpp',
- + ]
- + SOURCES['nsDebugImpl.cpp'].no_pgo = True
- +
- + UNIFIED_SOURCES += [
- + 'AppShutdown.cpp',
- + 'AvailableMemoryTracker.cpp',
- + 'ClearOnShutdown.cpp',
- + 'CycleCollectedJSContext.cpp',
- + 'CycleCollectedJSRuntime.cpp',
- + 'Debug.cpp',
- + 'DebuggerOnGCRunnable.cpp',
- + 'DeferredFinalize.cpp',
- + 'ErrorNames.cpp',
- + 'GkRustUtils.cpp',
- + 'HoldDropJSObjects.cpp',
- + 'JSObjectHolder.cpp',
- + 'LogCommandLineHandler.cpp',
- + 'Logging.cpp',
- + 'LogModulePrefWatcher.cpp',
- + 'MemoryTelemetry.cpp',
- + 'nsClassInfoImpl.cpp',
- + 'nsCOMPtr.cpp',
- + 'nsConsoleMessage.cpp',
- + 'nsConsoleService.cpp',
- + 'nsCRTGlue.cpp',
- + 'nsCycleCollectionParticipant.cpp',
- + 'nsCycleCollector.cpp',
- + 'nsCycleCollectorTraceJSHelpers.cpp',
- + 'nsErrorService.cpp',
- + 'nsGZFileWriter.cpp',
- + 'nsID.cpp',
- + 'nsIInterfaceRequestorUtils.cpp',
- + 'nsINIParser.cpp',
- + 'nsInterfaceRequestorAgg.cpp',
- + 'nsISupportsImpl.cpp',
- + 'nsMemory.cpp',
- + 'nsMemoryImpl.cpp',
- + 'nsMemoryInfoDumper.cpp',
- + 'nsMemoryReporterManager.cpp',
- + 'nsMessageLoop.cpp',
- + 'NSPRLogModulesParser.cpp',
- + 'nsSecurityConsoleMessage.cpp',
- + 'nsSystemInfo.cpp',
- + 'nsTraceRefcnt.cpp',
- + 'nsUUIDGenerator.cpp',
- + 'nsVersionComparator.cpp',
- + 'nsVersionComparatorImpl.cpp',
- + 'nsWeakReference.cpp',
- + ]
- +
- + if CONFIG['OS_TARGET'] in ('Linux', 'Android'):
- + UNIFIED_SOURCES += [
- + 'MemoryMapping.cpp',
- + ]
- +
- + if CONFIG['OS_TARGET'] == 'WINNT':
- + UNIFIED_SOURCES += [
- + 'MemoryInfo.cpp',
- + ]
- +
- + GeneratedFile("ErrorList.h", script="ErrorList.py", entry_point="error_list_h")
- + GeneratedFile("ErrorNamesInternal.h", script="ErrorList.py",
- + entry_point="error_names_internal_h")
- + GeneratedFile("error_list.rs", script="ErrorList.py",
- + entry_point="error_list_rs")
- +
- + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
- + SOURCES += [
- + 'nsMacUtilsImpl.cpp',
- + ]
- + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
- + SOURCES += [
- + 'nsCrashOnException.cpp',
- + ]
- +
- + if CONFIG['COMPILE_ENVIRONMENT']:
- + EXPORTS.mozilla += [
- + '!gk_rust_utils_ffi_generated.h',
- + ]
- +
- + GeneratedFile('gk_rust_utils_ffi_generated.h',
- + script='/build/RunCbindgen.py',
- + entry_point='generate', inputs=['/xpcom/rust/gkrust_utils'])
- +
- + include('/ipc/chromium/chromium-config.mozbuild')
- +
- + FINAL_LIBRARY = 'xul'
- +
- + LOCAL_INCLUDES += [
- + '../build',
- + '/dom/base',
- + '/mfbt',
- + '/netwerk/base',
- + '/xpcom/ds',
- + ]
- +
- + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
- + CXXFLAGS += CONFIG['TK_CFLAGS']
- +--- /dev/null
- ++++ a/xpcom/base/nsAutoPtr.h
- +@@ -0,0 +1,366 @@
- ++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
- ++/* vim: set ts=8 sts=2 et sw=2 tw=80: */
- ++/* 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 nsAutoPtr_h
- ++#define nsAutoPtr_h
- ++
- ++#include <type_traits>
- ++
- ++#include "nsCOMPtr.h"
- ++#include "mozilla/RefPtr.h"
- ++
- ++#include "nsCycleCollectionNoteChild.h"
- ++#include "mozilla/MemoryReporting.h"
- ++
- ++/*****************************************************************************/
- ++
- ++// template <class T> class nsAutoPtrGetterTransfers;
- ++
- ++template <class T>
- ++class nsAutoPtr {
- ++ private:
- ++ static_assert(!std::is_scalar_v<T>,
- ++ "If you are using "
- ++ "nsAutoPtr to hold an array, use UniquePtr<T[]> instead");
- ++
- ++ void** begin_assignment() {
- ++ assign(0);
- ++ return reinterpret_cast<void**>(&mRawPtr);
- ++ }
- ++
- ++ void assign(T* aNewPtr) {
- ++ T* oldPtr = mRawPtr;
- ++
- ++ if (aNewPtr && aNewPtr == oldPtr) {
- ++ MOZ_CRASH("Logic flaw in the caller");
- ++ }
- ++
- ++ mRawPtr = aNewPtr;
- ++ delete oldPtr;
- ++ }
- ++
- ++ // |class Ptr| helps us prevent implicit "copy construction"
- ++ // through |operator T*() const| from a |const nsAutoPtr<T>|
- ++ // because two implicit conversions in a row aren't allowed.
- ++ // It still allows assignment from T* through implicit conversion
- ++ // from |T*| to |nsAutoPtr<T>::Ptr|
- ++ class Ptr {
- ++ public:
- ++ MOZ_IMPLICIT Ptr(T* aPtr) : mPtr(aPtr) {}
- ++
- ++ operator T*() const { return mPtr; }
- ++
- ++ private:
- ++ T* MOZ_NON_OWNING_REF mPtr;
- ++ };
- ++
- ++ private:
- ++ T* MOZ_OWNING_REF mRawPtr;
- ++
- ++ public:
- ++ typedef T element_type;
- ++
- ++ ~nsAutoPtr() { delete mRawPtr; }
- ++
- ++ // Constructors
- ++
- ++ nsAutoPtr()
- ++ : mRawPtr(0)
- ++ // default constructor
- ++ {}
- ++
- ++ MOZ_IMPLICIT nsAutoPtr(Ptr aRawPtr)
- ++ : mRawPtr(aRawPtr)
- ++ // construct from a raw pointer (of the right type)
- ++ {}
- ++
- ++ // This constructor shouldn't exist; we should just use the &&
- ++ // constructor.
- ++ nsAutoPtr(nsAutoPtr<T>& aSmartPtr)
- ++ : mRawPtr(aSmartPtr.forget())
- ++ // Construct by transferring ownership from another smart pointer.
- ++ {}
- ++
- ++ template <typename I>
- ++ MOZ_IMPLICIT nsAutoPtr(nsAutoPtr<I>& aSmartPtr)
- ++ : mRawPtr(aSmartPtr.forget())
- ++ // Construct by transferring ownership from another smart pointer.
- ++ {}
- ++
- ++ nsAutoPtr(nsAutoPtr<T>&& aSmartPtr)
- ++ : mRawPtr(aSmartPtr.forget())
- ++ // Construct by transferring ownership from another smart pointer.
- ++ {}
- ++
- ++ template <typename I>
- ++ MOZ_IMPLICIT nsAutoPtr(nsAutoPtr<I>&& aSmartPtr)
- ++ : mRawPtr(aSmartPtr.forget())
- ++ // Construct by transferring ownership from another smart pointer.
- ++ {}
- ++
- ++ // Assignment operators
- ++
- ++ nsAutoPtr<T>& operator=(T* aRhs)
- ++ // assign from a raw pointer (of the right type)
- ++ {
- ++ assign(aRhs);
- ++ return *this;
- ++ }
- ++
- ++ nsAutoPtr<T>& operator=(nsAutoPtr<T>& aRhs)
- ++ // assign by transferring ownership from another smart pointer.
- ++ {
- ++ assign(aRhs.forget());
- ++ return *this;
- ++ }
- ++
- ++ template <typename I>
- ++ nsAutoPtr<T>& operator=(nsAutoPtr<I>& aRhs)
- ++ // assign by transferring ownership from another smart pointer.
- ++ {
- ++ assign(aRhs.forget());
- ++ return *this;
- ++ }
- ++
- ++ nsAutoPtr<T>& operator=(nsAutoPtr<T>&& aRhs) {
- ++ assign(aRhs.forget());
- ++ return *this;
- ++ }
- ++
- ++ template <typename I>
- ++ nsAutoPtr<T>& operator=(nsAutoPtr<I>&& aRhs) {
- ++ assign(aRhs.forget());
- ++ return *this;
- ++ }
- ++
- ++ // Other pointer operators
- ++
- ++ T* get() const
- ++ /*
- ++ Prefer the implicit conversion provided automatically by
- ++ |operator T*() const|. Use |get()| _only_ to resolve
- ++ ambiguity.
- ++ */
- ++ {
- ++ return mRawPtr;
- ++ }
- ++
- ++ operator T*() const
- ++ /*
- ++ ...makes an |nsAutoPtr| act like its underlying raw pointer
- ++ type whenever it is used in a context where a raw pointer
- ++ is expected. It is this operator that makes an |nsAutoPtr|
- ++ substitutable for a raw pointer.
- ++
- ++ Prefer the implicit use of this operator to calling |get()|,
- ++ except where necessary to resolve ambiguity.
- ++ */
- ++ {
- ++ return get();
- ++ }
- ++
- ++ T* forget() {
- ++ T* temp = mRawPtr;
- ++ mRawPtr = 0;
- ++ return temp;
- ++ }
- ++
- ++ T* operator->() const {
- ++ MOZ_ASSERT(mRawPtr != 0,
- ++ "You can't dereference a NULL nsAutoPtr with operator->().");
- ++ return get();
- ++ }
- ++
- ++ template <typename R, typename... Args>
- ++ class Proxy {
- ++ typedef R (T::*member_function)(Args...);
- ++ T* mRawPtr;
- ++ member_function mFunction;
- ++
- ++ public:
- ++ Proxy(T* aRawPtr, member_function aFunction)
- ++ : mRawPtr(aRawPtr), mFunction(aFunction) {}
- ++ template <typename... ActualArgs>
- ++ R operator()(ActualArgs&&... aArgs) {
- ++ return ((*mRawPtr).*mFunction)(std::forward<ActualArgs>(aArgs)...);
- ++ }
- ++ };
- ++
- ++ template <typename R, typename C, typename... Args>
- ++ Proxy<R, Args...> operator->*(R (C::*aFptr)(Args...)) const {
- ++ MOZ_ASSERT(mRawPtr != 0,
- ++ "You can't dereference a NULL nsAutoPtr with operator->*().");
- ++ return Proxy<R, Args...>(get(), aFptr);
- ++ }
- ++
- ++ nsAutoPtr<T>* get_address()
- ++ // This is not intended to be used by clients. See |address_of|
- ++ // below.
- ++ {
- ++ return this;
- ++ }
- ++
- ++ const nsAutoPtr<T>* get_address() const
- ++ // This is not intended to be used by clients. See |address_of|
- ++ // below.
- ++ {
- ++ return this;
- ++ }
- ++
- ++ public:
- ++ T& operator*() const {
- ++ MOZ_ASSERT(mRawPtr != 0,
- ++ "You can't dereference a NULL nsAutoPtr with operator*().");
- ++ return *get();
- ++ }
- ++
- ++ T** StartAssignment() {
- ++#ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
- ++ return reinterpret_cast<T**>(begin_assignment());
- ++#else
- ++ assign(0);
- ++ return reinterpret_cast<T**>(&mRawPtr);
- ++#endif
- ++ }
- ++};
- ++
- ++template <class T>
- ++inline nsAutoPtr<T>* address_of(nsAutoPtr<T>& aPtr) {
- ++ return aPtr.get_address();
- ++}
- ++
- ++template <class T>
- ++inline const nsAutoPtr<T>* address_of(const nsAutoPtr<T>& aPtr) {
- ++ return aPtr.get_address();
- ++}
- ++
- ++template <class T>
- ++class nsAutoPtrGetterTransfers
- ++/*
- ++ ...
- ++
- ++ This class is designed to be used for anonymous temporary objects in the
- ++ argument list of calls that return COM interface pointers, e.g.,
- ++
- ++ nsAutoPtr<IFoo> fooP;
- ++ ...->GetTransferedPointer(getter_Transfers(fooP))
- ++
- ++ DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_Transfers()| instead.
- ++
- ++ When initialized with a |nsAutoPtr|, as in the example above, it returns
- ++ a |void**|, a |T**|, or an |nsISupports**| as needed, that the
- ++ outer call (|GetTransferedPointer| in this case) can fill in.
- ++
- ++ This type should be a nested class inside |nsAutoPtr<T>|.
- ++*/
- ++{
- ++ public:
- ++ explicit nsAutoPtrGetterTransfers(nsAutoPtr<T>& aSmartPtr)
- ++ : mTargetSmartPtr(aSmartPtr) {
- ++ // nothing else to do
- ++ }
- ++
- ++ operator void**() {
- ++ return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
- ++ }
- ++
- ++ operator T**() { return mTargetSmartPtr.StartAssignment(); }
- ++
- ++ T*& operator*() { return *(mTargetSmartPtr.StartAssignment()); }
- ++
- ++ private:
- ++ nsAutoPtr<T>& mTargetSmartPtr;
- ++};
- ++
- ++template <class T>
- ++inline nsAutoPtrGetterTransfers<T> getter_Transfers(nsAutoPtr<T>& aSmartPtr)
- ++/*
- ++ Used around a |nsAutoPtr| when
- ++ ...makes the class |nsAutoPtrGetterTransfers<T>| invisible.
- ++*/
- ++{
- ++ return nsAutoPtrGetterTransfers<T>(aSmartPtr);
- ++}
- ++
- ++// Comparing two |nsAutoPtr|s
- ++
- ++template <class T, class U>
- ++inline bool operator==(const nsAutoPtr<T>& aLhs, const nsAutoPtr<U>& aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get());
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator!=(const nsAutoPtr<T>& aLhs, const nsAutoPtr<U>& aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get());
- ++}
- ++
- ++// Comparing an |nsAutoPtr| to a raw pointer
- ++
- ++template <class T, class U>
- ++inline bool operator==(const nsAutoPtr<T>& aLhs, const U* aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs);
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator==(const U* aLhs, const nsAutoPtr<T>& aRhs) {
- ++ return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator!=(const nsAutoPtr<T>& aLhs, const U* aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs);
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator!=(const U* aLhs, const nsAutoPtr<T>& aRhs) {
- ++ return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator==(const nsAutoPtr<T>& aLhs, U* aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs);
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator==(U* aLhs, const nsAutoPtr<T>& aRhs) {
- ++ return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator!=(const nsAutoPtr<T>& aLhs, U* aRhs) {
- ++ return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs);
- ++}
- ++
- ++template <class T, class U>
- ++inline bool operator!=(U* aLhs, const nsAutoPtr<T>& aRhs) {
- ++ return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
- ++}
- ++
- ++// Comparing an |nsAutoPtr| to |nullptr|
- ++
- ++template <class T>
- ++inline bool operator==(const nsAutoPtr<T>& aLhs, decltype(nullptr)) {
- ++ return aLhs.get() == nullptr;
- ++}
- ++
- ++template <class T>
- ++inline bool operator==(decltype(nullptr), const nsAutoPtr<T>& aRhs) {
- ++ return nullptr == aRhs.get();
- ++}
- ++
- ++template <class T>
- ++inline bool operator!=(const nsAutoPtr<T>& aLhs, decltype(nullptr)) {
- ++ return aLhs.get() != nullptr;
- ++}
- ++
- ++template <class T>
- ++inline bool operator!=(decltype(nullptr), const nsAutoPtr<T>& aRhs) {
- ++ return nullptr != aRhs.get();
- ++}
- ++
- ++/*****************************************************************************/
- ++
- ++#endif // !defined(nsAutoPtr_h)
- +--- /dev/null
- ++++ a/xpcom/tests/gtest/TestAutoPtr.cpp
- +@@ -0,0 +1,202 @@
- ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
- ++// vim:cindent:ts=4:et:sw=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/. */
- ++
- ++#include "nsAutoPtr.h"
- ++#include "gtest/gtest.h"
- ++
- ++class TestObjectBaseA {
- ++ public:
- ++ // Virtual dtor for deleting through base class pointer
- ++ virtual ~TestObjectBaseA() = default;
- ++ void MemberFunction(int, int*, int&) {}
- ++ virtual void VirtualMemberFunction(int, int*, int&){};
- ++ virtual void VirtualConstMemberFunction(int, int*, int&) const {};
- ++ int fooA;
- ++};
- ++
- ++class TestObjectBaseB {
- ++ public:
- ++ // Virtual dtor for deleting through base class pointer
- ++ virtual ~TestObjectBaseB() = default;
- ++ int fooB;
- ++};
- ++
- ++class TestObject : public TestObjectBaseA, public TestObjectBaseB {
- ++ public:
- ++ TestObject() = default;
- ++
- ++ // Virtual dtor for deleting through base class pointer
- ++ virtual ~TestObject() { destructed++; }
- ++
- ++ virtual void VirtualMemberFunction(int, int*, int&) override {}
- ++ virtual void VirtualConstMemberFunction(int, int*, int&) const override {}
- ++
- ++ static int destructed;
- ++ static const void* last_ptr;
- ++};
- ++
- ++int TestObject::destructed = 0;
- ++const void* TestObject::last_ptr = nullptr;
- ++
- ++static void CreateTestObject(TestObject** aResult) {
- ++ *aResult = new TestObject();
- ++}
- ++
- ++static void DoSomethingWithTestObject(TestObject* aIn) {
- ++ TestObject::last_ptr = static_cast<void*>(aIn);
- ++}
- ++
- ++static void DoSomethingWithConstTestObject(const TestObject* aIn) {
- ++ TestObject::last_ptr = static_cast<const void*>(aIn);
- ++}
- ++
- ++static void DoSomethingWithTestObjectBaseB(TestObjectBaseB* aIn) {
- ++ TestObject::last_ptr = static_cast<void*>(aIn);
- ++}
- ++
- ++static void DoSomethingWithConstTestObjectBaseB(const TestObjectBaseB* aIn) {
- ++ TestObject::last_ptr = static_cast<const void*>(aIn);
- ++}
- ++
- ++TEST(AutoPtr, Assignment)
- ++{
- ++ TestObject::destructed = 0;
- ++
- ++ { nsAutoPtr<TestObject> pobj(new TestObject()); }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++
- ++ {
- ++ nsAutoPtr<TestObject> pobj(new TestObject());
- ++ pobj = new TestObject();
- ++ ASSERT_EQ(2, TestObject::destructed);
- ++ }
- ++
- ++ ASSERT_EQ(3, TestObject::destructed);
- ++}
- ++
- ++TEST(AutoPtr, getter_Transfers)
- ++{
- ++ TestObject::destructed = 0;
- ++
- ++ {
- ++ nsAutoPtr<TestObject> ptr;
- ++ CreateTestObject(getter_Transfers(ptr));
- ++ }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++}
- ++
- ++TEST(AutoPtr, Casting)
- ++{
- ++ // This comparison is always false, as it should be. The extra parens
- ++ // suppress a -Wunreachable-code warning about printf being unreachable.
- ++ ASSERT_NE(((void*)(TestObject*)0x1000),
- ++ ((void*)(TestObjectBaseB*)(TestObject*)0x1000));
- ++
- ++ {
- ++ nsAutoPtr<TestObject> p1(new TestObject());
- ++ TestObjectBaseB* p2 = p1;
- ++ ASSERT_NE(static_cast<void*>(p1), static_cast<void*>(p2));
- ++ ASSERT_EQ(p1, p2);
- ++ ASSERT_FALSE(p1 != p2);
- ++ ASSERT_EQ(p2, p1);
- ++ ASSERT_FALSE(p2 != p1);
- ++ }
- ++
- ++ {
- ++ TestObject* p1 = new TestObject();
- ++ nsAutoPtr<TestObjectBaseB> p2(p1);
- ++ ASSERT_EQ(p1, p2);
- ++ ASSERT_FALSE(p1 != p2);
- ++ ASSERT_EQ(p2, p1);
- ++ ASSERT_FALSE(p2 != p1);
- ++ }
- ++}
- ++
- ++TEST(AutoPtr, Forget)
- ++{
- ++ TestObject::destructed = 0;
- ++
- ++ {
- ++ nsAutoPtr<TestObject> pobj(new TestObject());
- ++ nsAutoPtr<TestObject> pobj2(pobj.forget());
- ++ ASSERT_EQ(0, TestObject::destructed);
- ++ }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++}
- ++
- ++TEST(AutoPtr, Construction)
- ++{
- ++ TestObject::destructed = 0;
- ++
- ++ { nsAutoPtr<TestObject> pobj(new TestObject()); }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++}
- ++
- ++TEST(AutoPtr, ImplicitConversion)
- ++{
- ++ // This test is basically successful if it builds. We add a few assertions
- ++ // to make gtest happy.
- ++ TestObject::destructed = 0;
- ++
- ++ {
- ++ nsAutoPtr<TestObject> pobj(new TestObject());
- ++ DoSomethingWithTestObject(pobj);
- ++ DoSomethingWithConstTestObject(pobj);
- ++ }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++
- ++ {
- ++ nsAutoPtr<TestObject> pobj(new TestObject());
- ++ DoSomethingWithTestObjectBaseB(pobj);
- ++ DoSomethingWithConstTestObjectBaseB(pobj);
- ++ }
- ++
- ++ ASSERT_EQ(2, TestObject::destructed);
- ++
- ++ {
- ++ const nsAutoPtr<TestObject> pobj(new TestObject());
- ++ DoSomethingWithTestObject(pobj);
- ++ DoSomethingWithConstTestObject(pobj);
- ++ }
- ++
- ++ ASSERT_EQ(3, TestObject::destructed);
- ++
- ++ {
- ++ const nsAutoPtr<TestObject> pobj(new TestObject());
- ++ DoSomethingWithTestObjectBaseB(pobj);
- ++ DoSomethingWithConstTestObjectBaseB(pobj);
- ++ }
- ++
- ++ ASSERT_EQ(4, TestObject::destructed);
- ++}
- ++
- ++TEST(AutoPtr, ArrowOperator)
- ++{
- ++ // This test is basically successful if it builds. We add a few assertions
- ++ // to make gtest happy.
- ++ TestObject::destructed = 0;
- ++
- ++ {
- ++ int test = 1;
- ++ void (TestObjectBaseA::*fPtr)(int, int*, int&) =
- ++ &TestObjectBaseA::MemberFunction;
- ++ void (TestObjectBaseA::*fVPtr)(int, int*, int&) =
- ++ &TestObjectBaseA::VirtualMemberFunction;
- ++ void (TestObjectBaseA::*fVCPtr)(int, int*, int&) const =
- ++ &TestObjectBaseA::VirtualConstMemberFunction;
- ++ nsAutoPtr<TestObjectBaseA> pobj(new TestObject());
- ++ (pobj->*fPtr)(test, &test, test);
- ++ (pobj->*fVPtr)(test, &test, test);
- ++ (pobj->*fVCPtr)(test, &test, test);
- ++ }
- ++
- ++ ASSERT_EQ(1, TestObject::destructed);
- ++}
- +--- b/xpcom/tests/gtest/moz.build
- ++++ a/xpcom/tests/gtest/moz.build
- +@@ -1,138 +1,139 @@
- + # -*- 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/.
- +
- + UNIFIED_SOURCES += [
- + 'Helpers.cpp',
- + 'TestArenaAllocator.cpp',
- + 'TestArrayAlgorithm.cpp',
- + 'TestAtoms.cpp',
- ++ 'TestAutoPtr.cpp',
- + 'TestAutoRef.cpp',
- + 'TestAutoRefCnt.cpp',
- + 'TestBase64.cpp',
- + 'TestCallTemplates.cpp',
- + 'TestCloneInputStream.cpp',
- + 'TestCOMPtrEq.cpp',
- + 'TestCRT.cpp',
- + 'TestDafsa.cpp',
- + 'TestEncoding.cpp',
- + 'TestEscape.cpp',
- + 'TestEventPriorities.cpp',
- + 'TestEventTargetQI.cpp',
- + 'TestExpirationTracker.cpp',
- + 'TestFile.cpp',
- + 'TestGCPostBarriers.cpp',
- + 'TestID.cpp',
- + 'TestInputStreamLengthHelper.cpp',
- + 'TestLogCommandLineHandler.cpp',
- + 'TestMoveString.cpp',
- + 'TestMozPromise.cpp',
- + 'TestMruCache.cpp',
- + 'TestMultiplexInputStream.cpp',
- + 'TestNonBlockingAsyncInputStream.cpp',
- + 'TestNsDeque.cpp',
- + 'TestNSPRLogModulesParser.cpp',
- + 'TestObserverArray.cpp',
- + 'TestObserverService.cpp',
- + 'TestPLDHash.cpp',
- + 'TestPriorityQueue.cpp',
- + 'TestRacingServiceManager.cpp',
- + 'TestRecursiveMutex.cpp',
- + 'TestRWLock.cpp',
- + 'TestSlicedInputStream.cpp',
- + 'TestSnappyStreams.cpp',
- + 'TestStateWatching.cpp',
- + 'TestStorageStream.cpp',
- + 'TestStrings.cpp',
- + 'TestStringStream.cpp',
- + 'TestSynchronization.cpp',
- + 'TestTArray.cpp',
- + 'TestTArray2.cpp',
- + 'TestTaskQueue.cpp',
- + 'TestTextFormatter.cpp',
- + 'TestThreadManager.cpp',
- + 'TestThreadMetrics.cpp',
- + 'TestThreadPool.cpp',
- + 'TestThreadPoolListener.cpp',
- + 'TestThrottledEventQueue.cpp',
- + 'TestTimeStamp.cpp',
- + 'TestTokenizer.cpp',
- + 'TestUTF.cpp',
- + ]
- +
- + if CONFIG['OS_TARGET'] != 'Android':
- + UNIFIED_SOURCES += [
- + 'TestPipes.cpp',
- + 'TestThreads.cpp',
- + ]
- +
- + # skip the test on windows10-aarch64 due to perma-fail, bug 1422219
- + if not(CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64'):
- + UNIFIED_SOURCES += [
- + 'TestThreadUtils.cpp'
- + ]
- +
- + # skip the test on windows10-aarch64 and Android, aarch64 due to bug 1545670
- + if CONFIG['OS_TARGET'] != 'Android' and not(CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64'):
- + UNIFIED_SOURCES += [
- + 'TestTimers.cpp'
- + ]
- +
- +
- + if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT') and CONFIG['OS_TARGET'] != 'Android':
- + # FIXME bug 523392: TestDeadlockDetector doesn't like Windows
- + # Bug 1054249: Doesn't work on Android
- + UNIFIED_SOURCES += [
- + 'TestDeadlockDetector.cpp',
- + 'TestDeadlockDetectorScalability.cpp',
- + ]
- +
- + if CONFIG['OS_TARGET'] == 'WINNT':
- + UNIFIED_SOURCES += [
- + 'TestFilePreferencesWin.cpp',
- + ]
- + else:
- + UNIFIED_SOURCES += [
- + 'TestFilePreferencesUnix.cpp',
- + ]
- +
- + if CONFIG['WRAP_STL_INCLUDES'] and CONFIG['CC_TYPE'] != 'clang-cl' and CONFIG['OS_TARGET'] != 'Android':
- + UNIFIED_SOURCES += [
- + 'TestSTLWrappers.cpp',
- + ]
- +
- + # Compile TestAllocReplacement separately so Windows headers don't pollute
- + # the global namespace for other files.
- + SOURCES += [
- + 'TestAllocReplacement.cpp',
- + 'TestCOMArray.cpp',
- + 'TestCOMPtr.cpp', # Redefines IFoo and IBar
- + 'TestHashtables.cpp', # Redefines IFoo
- + 'TestNsRefPtr.cpp', # Redefines Foo
- + ]
- +
- + LOCAL_INCLUDES += [
- + '../../base',
- + ]
- +
- + GeneratedFile('dafsa_test_1.inc',
- + script='../../ds/tools/make_dafsa.py',
- + inputs=['dafsa_test_1.dat'])
- +
- + TEST_HARNESS_FILES.gtest += [
- + 'wikipedia/ar.txt',
- + 'wikipedia/de-edit.txt',
- + 'wikipedia/de.txt',
- + 'wikipedia/ja.txt',
- + 'wikipedia/ko.txt',
- + 'wikipedia/ru.txt',
- + 'wikipedia/th.txt',
- + 'wikipedia/tr.txt',
- + 'wikipedia/vi.txt',
- + ]
- +
- + FINAL_LIBRARY = 'xul-gtest'
- +
- + include('/ipc/chromium/chromium-config.mozbuild')
- +--- a/mfbt/NotNull.h 2020-06-03 16:41:08.546678524 +0300
- ++++ b/mfbt/NotNull.h 2020-06-03 16:41:26.656493988 +0300
- +@@ -183,9 +183,6 @@
- + "mBasePtr must have zero offset.");
- + }
- +
- +- // Disallow null checks, which are unnecessary for this type.
- +- explicit operator bool() const = delete;
- +-
- + // Explicit conversion to a base pointer. Use only to resolve ambiguity or to
- + // get a castable pointer.
- + constexpr T* get() const MOZ_NONNULL_RETURN { return mBasePtr; }
Add Comment
Please, Sign In to add comment