Guest User

Untitled

a guest
Jun 3rd, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.70 KB | None | 0 0
  1. diff --git a/0001-Use-remoting-name-for-GDK-application-names.patch b/0001-Use-remoting-name-for-GDK-application-names.patch
  2. index 165a532..8c361fa 100644
  3. --- a/0001-Use-remoting-name-for-GDK-application-names.patch
  4. +++ b/0001-Use-remoting-name-for-GDK-application-names.patch
  5. @@ -25,10 +25,8 @@ index 984b998133bd..b6c9f013940c 100644
  6.  
  7. // Initialize GTK here for splash.
  8.  
  9. -diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
  10. -index 0daa78fdbbad..49038d0bb1c8 100644
  11. ---- a/widget/gtk/nsAppShell.cpp
  12. -+++ b/widget/gtk/nsAppShell.cpp
  13. +--- a/widget/gtk/nsAppShell.cpp.orig 2020-05-29 09:02:46.000000000 +0300
  14. ++++ b/widget/gtk/nsAppShell.cpp 2020-06-02 21:27:17.464209460 +0300
  15. @@ -24,6 +24,7 @@
  16. # include "WakeLockListener.h"
  17. #endif
  18. @@ -37,19 +35,16 @@ index 0daa78fdbbad..49038d0bb1c8 100644
  19. #include "ScreenHelperGTK.h"
  20. #include "HeadlessScreenHelper.h"
  21. #include "mozilla/widget/ScreenManager.h"
  22. -@@ -175,10 +176,8 @@ nsresult nsAppShell::Init() {
  23. - // option when program uses gdk_set_program_class().
  24. - //
  25. - // See https://bugzilla.gnome.org/show_bug.cgi?id=747634
  26. -- nsAutoString brandName;
  27. -- mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
  28. -- if (!brandName.IsEmpty()) {
  29. -- gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
  30. +@@ -178,10 +179,8 @@
  31. + // creating top-level windows. (At this point, a child process hasn't
  32. + // received the list of registered chrome packages, so the
  33. + // GetBrandShortName call would fail anyway.)
  34. +- nsAutoString brandName;
  35. +- mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
  36. +- if (!brandName.IsEmpty()) {
  37. +- gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
  38. + if (gAppData) {
  39. + gdk_set_program_class(gAppData->remotingName);
  40. + }
  41. }
  42. }
  43. -
  44. ---
  45. -2.24.0
  46. -
  47. diff --git a/PKGBUILD b/PKGBUILD
  48. index 3660dad..7134d14 100644
  49. --- a/PKGBUILD
  50. +++ b/PKGBUILD
  51. @@ -7,7 +7,7 @@
  52.  
  53. pkgname=firefox-appmenu
  54. _pkgname=firefox
  55. -pkgver=76.0.1
  56. +pkgver=77.0
  57. pkgrel=1
  58. pkgdesc="Firefox from extra with appmenu patch"
  59. arch=(x86_64)
  60. @@ -29,12 +29,14 @@ options=(!emptydirs !makeflags !strip)
  61. source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
  62. 0001-Use-remoting-name-for-GDK-application-names.patch
  63. $_pkgname.desktop
  64. - unity-menubar.patch)
  65. -sha256sums=('f61761e32774a6bdfedd5937c4992fbe5e24c3df057c2b9a559fcd0d038777c3'
  66. + unity-menubar.patch
  67. + reverse_killing_autoptr.patch)
  68. +sha256sums=('b534794c493d8698dfb6c852af52b49540afdf88dc50451f42d6591de93291e8'
  69. 'SKIP'
  70. - '5f7ac724a5c5afd9322b1e59006f4170ea5354ca1e0e60dab08b7784c2d8463c'
  71. + '38f9f646f84f6669b15f097ac8f1c31831d95bfe66494d39c5f0ed05aad6fc5b'
  72. '34514a657d6907a159594c51e674eeb81297c431ec26a736417c2fdb995c2c0c'
  73. - '3e5e34b8d45b9cc48e78e9c474f2450cc597451bbb331fb5a4e8f3a3ba5e3a70')
  74. + '3e5e34b8d45b9cc48e78e9c474f2450cc597451bbb331fb5a4e8f3a3ba5e3a70'
  75. + SKIP)
  76. validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases <release@mozilla.com>
  77.  
  78. # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
  79. @@ -59,6 +61,7 @@ prepare() {
  80. # actual appmenu patch from ubuntu repos
  81. # http://archive.ubuntu.com/ubuntu/pool/main/f/firefox/firefox_76.0+build2-0ubuntu0.18.04.1.debian.tar.xz
  82. patch -Np1 -i ../unity-menubar.patch
  83. + patch -Np1 -i ../reverse_killing_autoptr.patch
  84.  
  85. echo -n "$_google_api_key" >google-api-key
  86. echo -n "$_mozilla_api_key" >mozilla-api-key
  87. diff --git a/reverse_killing_autoptr.patch b/reverse_killing_autoptr.patch
  88. new file mode 100644
  89. index 0000000..405ad66
  90. --- /dev/null
  91. +++ b/reverse_killing_autoptr.patch
  92. @@ -0,0 +1,972 @@
  93. +--- b/xpcom/base/moz.build
  94. ++++ a/xpcom/base/moz.build
  95. +@@ -1,240 +1,241 @@
  96. + # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  97. + # vim: set filetype=python:
  98. + # This Source Code Form is subject to the terms of the Mozilla Public
  99. + # License, v. 2.0. If a copy of the MPL was not distributed with this
  100. + # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  101. +
  102. + XPIDL_SOURCES += [
  103. + 'nsIConsoleListener.idl',
  104. + 'nsIConsoleMessage.idl',
  105. + 'nsIConsoleService.idl',
  106. + 'nsICycleCollectorListener.idl',
  107. + 'nsIDebug2.idl',
  108. + 'nsIErrorService.idl',
  109. + 'nsIException.idl',
  110. + 'nsIGZFileWriter.idl',
  111. + 'nsIInterfaceRequestor.idl',
  112. + 'nsIMemory.idl',
  113. + 'nsIMemoryInfoDumper.idl',
  114. + 'nsIMemoryReporter.idl',
  115. + 'nsIMessageLoop.idl',
  116. + 'nsISecurityConsoleMessage.idl',
  117. + 'nsISupports.idl',
  118. + 'nsIUUIDGenerator.idl',
  119. + 'nsIVersionComparator.idl',
  120. + 'nsIWeakReference.idl',
  121. + 'nsrootidl.idl',
  122. + ]
  123. +
  124. + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
  125. + XPIDL_SOURCES += [
  126. + 'nsIMacPreferencesReader.idl',
  127. + 'nsIMacUtils.idl',
  128. + ]
  129. + EXPORTS.mozilla += [
  130. + 'MacHelpers.h',
  131. + 'MacStringHelpers.h',
  132. + 'nsMacPreferencesReader.h',
  133. + ]
  134. + UNIFIED_SOURCES += [
  135. + 'MacHelpers.mm',
  136. + 'MacStringHelpers.mm',
  137. + 'nsMacPreferencesReader.mm',
  138. + ]
  139. +
  140. + XPIDL_MODULE = 'xpcom_base'
  141. +
  142. + XPCOM_MANIFESTS += [
  143. + 'components.conf',
  144. + ]
  145. +
  146. + EXPORTS += [
  147. + '!ErrorList.h',
  148. + '!ErrorNamesInternal.h',
  149. + 'CodeAddressService.h',
  150. + 'nsAlgorithm.h',
  151. ++ 'nsAutoPtr.h',
  152. + 'nsAutoRef.h',
  153. + 'nsCom.h',
  154. + 'nsCOMPtr.h',
  155. + 'nscore.h',
  156. + 'nsCRTGlue.h',
  157. + 'nsCycleCollectionNoteChild.h',
  158. + 'nsCycleCollectionNoteRootCallback.h',
  159. + 'nsCycleCollectionParticipant.h',
  160. + 'nsCycleCollectionTraversalCallback.h',
  161. + 'nsCycleCollector.h',
  162. + 'nsDebug.h',
  163. + 'nsDebugImpl.h',
  164. + 'nsDumpUtils.h',
  165. + 'nsError.h',
  166. + 'nsErrorService.h',
  167. + 'nsGZFileWriter.h',
  168. + 'nsIClassInfoImpl.h',
  169. + 'nsID.h',
  170. + 'nsIInterfaceRequestorUtils.h',
  171. + 'nsINIParser.h',
  172. + 'nsInterfaceRequestorAgg.h',
  173. + 'nsISizeOf.h',
  174. + 'nsISupportsBase.h',
  175. + 'nsISupportsImpl.h',
  176. + 'nsISupportsUtils.h',
  177. + 'nsIWeakReferenceUtils.h',
  178. + 'nsMaybeWeakPtr.h',
  179. + 'nsMemory.h',
  180. + 'nsObjCExceptions.h',
  181. + 'nsQueryObject.h',
  182. + 'nsSystemInfo.h',
  183. + 'nsTraceRefcnt.h',
  184. + 'nsVersionComparator.h',
  185. + 'nsWeakReference.h',
  186. + ]
  187. +
  188. + if CONFIG['OS_ARCH'] == 'WINNT':
  189. + EXPORTS += [
  190. + 'nsWindowsHelpers.h',
  191. + ]
  192. + if CONFIG['CC_TYPE'] not in ('gcc', 'clang'):
  193. + OS_LIBS += [
  194. + 'wscapi',
  195. + ]
  196. +
  197. + EXPORTS.mozilla += [
  198. + 'AppShutdown.h',
  199. + 'AutoRestore.h',
  200. + 'AvailableMemoryTracker.h',
  201. + 'ClearOnShutdown.h',
  202. + 'CountingAllocatorBase.h',
  203. + 'CycleCollectedJSContext.h',
  204. + 'CycleCollectedJSRuntime.h',
  205. + 'Debug.h',
  206. + 'DebuggerOnGCRunnable.h',
  207. + 'DeferredFinalize.h',
  208. + 'EnumeratedArrayCycleCollection.h',
  209. + 'ErrorNames.h',
  210. + 'GkRustUtils.h',
  211. + 'HoldDropJSObjects.h',
  212. + 'IntentionalCrash.h',
  213. + 'JSObjectHolder.h',
  214. + 'Logging.h',
  215. + 'MemoryInfo.h',
  216. + 'MemoryMapping.h',
  217. + 'MemoryReportingProcess.h',
  218. + 'MemoryTelemetry.h',
  219. + 'nsMemoryInfoDumper.h',
  220. + 'NSPRLogModulesParser.h',
  221. + 'OwningNonNull.h',
  222. + 'ShutdownPhase.h',
  223. + 'SizeOfState.h',
  224. + 'StaticLocalPtr.h',
  225. + 'StaticMonitor.h',
  226. + 'StaticMutex.h',
  227. + 'StaticPtr.h',
  228. + 'TupleCycleCollection.h',
  229. + ]
  230. +
  231. + SOURCES += [
  232. + # nsDebugImpl isn't unified because we disable PGO so that NS_ABORT_OOM isn't
  233. + # optimized away oddly.
  234. + 'nsDebugImpl.cpp',
  235. + # nsDumpUtils.cpp includes SpecialSystemDirectory.h which includes
  236. + # nsLocalFileMac.h which upsets other files in this dir that have a different
  237. + # idea about what `TextRange` means.
  238. + 'nsDumpUtils.cpp',
  239. + ]
  240. + SOURCES['nsDebugImpl.cpp'].no_pgo = True
  241. +
  242. + UNIFIED_SOURCES += [
  243. + 'AppShutdown.cpp',
  244. + 'AvailableMemoryTracker.cpp',
  245. + 'ClearOnShutdown.cpp',
  246. + 'CycleCollectedJSContext.cpp',
  247. + 'CycleCollectedJSRuntime.cpp',
  248. + 'Debug.cpp',
  249. + 'DebuggerOnGCRunnable.cpp',
  250. + 'DeferredFinalize.cpp',
  251. + 'ErrorNames.cpp',
  252. + 'GkRustUtils.cpp',
  253. + 'HoldDropJSObjects.cpp',
  254. + 'JSObjectHolder.cpp',
  255. + 'LogCommandLineHandler.cpp',
  256. + 'Logging.cpp',
  257. + 'LogModulePrefWatcher.cpp',
  258. + 'MemoryTelemetry.cpp',
  259. + 'nsClassInfoImpl.cpp',
  260. + 'nsCOMPtr.cpp',
  261. + 'nsConsoleMessage.cpp',
  262. + 'nsConsoleService.cpp',
  263. + 'nsCRTGlue.cpp',
  264. + 'nsCycleCollectionParticipant.cpp',
  265. + 'nsCycleCollector.cpp',
  266. + 'nsCycleCollectorTraceJSHelpers.cpp',
  267. + 'nsErrorService.cpp',
  268. + 'nsGZFileWriter.cpp',
  269. + 'nsID.cpp',
  270. + 'nsIInterfaceRequestorUtils.cpp',
  271. + 'nsINIParser.cpp',
  272. + 'nsInterfaceRequestorAgg.cpp',
  273. + 'nsISupportsImpl.cpp',
  274. + 'nsMemory.cpp',
  275. + 'nsMemoryImpl.cpp',
  276. + 'nsMemoryInfoDumper.cpp',
  277. + 'nsMemoryReporterManager.cpp',
  278. + 'nsMessageLoop.cpp',
  279. + 'NSPRLogModulesParser.cpp',
  280. + 'nsSecurityConsoleMessage.cpp',
  281. + 'nsSystemInfo.cpp',
  282. + 'nsTraceRefcnt.cpp',
  283. + 'nsUUIDGenerator.cpp',
  284. + 'nsVersionComparator.cpp',
  285. + 'nsVersionComparatorImpl.cpp',
  286. + 'nsWeakReference.cpp',
  287. + ]
  288. +
  289. + if CONFIG['OS_TARGET'] in ('Linux', 'Android'):
  290. + UNIFIED_SOURCES += [
  291. + 'MemoryMapping.cpp',
  292. + ]
  293. +
  294. + if CONFIG['OS_TARGET'] == 'WINNT':
  295. + UNIFIED_SOURCES += [
  296. + 'MemoryInfo.cpp',
  297. + ]
  298. +
  299. + GeneratedFile("ErrorList.h", script="ErrorList.py", entry_point="error_list_h")
  300. + GeneratedFile("ErrorNamesInternal.h", script="ErrorList.py",
  301. + entry_point="error_names_internal_h")
  302. + GeneratedFile("error_list.rs", script="ErrorList.py",
  303. + entry_point="error_list_rs")
  304. +
  305. + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
  306. + SOURCES += [
  307. + 'nsMacUtilsImpl.cpp',
  308. + ]
  309. + elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
  310. + SOURCES += [
  311. + 'nsCrashOnException.cpp',
  312. + ]
  313. +
  314. + if CONFIG['COMPILE_ENVIRONMENT']:
  315. + EXPORTS.mozilla += [
  316. + '!gk_rust_utils_ffi_generated.h',
  317. + ]
  318. +
  319. + GeneratedFile('gk_rust_utils_ffi_generated.h',
  320. + script='/build/RunCbindgen.py',
  321. + entry_point='generate', inputs=['/xpcom/rust/gkrust_utils'])
  322. +
  323. + include('/ipc/chromium/chromium-config.mozbuild')
  324. +
  325. + FINAL_LIBRARY = 'xul'
  326. +
  327. + LOCAL_INCLUDES += [
  328. + '../build',
  329. + '/dom/base',
  330. + '/mfbt',
  331. + '/netwerk/base',
  332. + '/xpcom/ds',
  333. + ]
  334. +
  335. + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
  336. + CXXFLAGS += CONFIG['TK_CFLAGS']
  337. +--- /dev/null
  338. ++++ a/xpcom/base/nsAutoPtr.h
  339. +@@ -0,0 +1,366 @@
  340. ++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  341. ++/* vim: set ts=8 sts=2 et sw=2 tw=80: */
  342. ++/* This Source Code Form is subject to the terms of the Mozilla Public
  343. ++ * License, v. 2.0. If a copy of the MPL was not distributed with this
  344. ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  345. ++
  346. ++#ifndef nsAutoPtr_h
  347. ++#define nsAutoPtr_h
  348. ++
  349. ++#include <type_traits>
  350. ++
  351. ++#include "nsCOMPtr.h"
  352. ++#include "mozilla/RefPtr.h"
  353. ++
  354. ++#include "nsCycleCollectionNoteChild.h"
  355. ++#include "mozilla/MemoryReporting.h"
  356. ++
  357. ++/*****************************************************************************/
  358. ++
  359. ++// template <class T> class nsAutoPtrGetterTransfers;
  360. ++
  361. ++template <class T>
  362. ++class nsAutoPtr {
  363. ++ private:
  364. ++ static_assert(!std::is_scalar_v<T>,
  365. ++ "If you are using "
  366. ++ "nsAutoPtr to hold an array, use UniquePtr<T[]> instead");
  367. ++
  368. ++ void** begin_assignment() {
  369. ++ assign(0);
  370. ++ return reinterpret_cast<void**>(&mRawPtr);
  371. ++ }
  372. ++
  373. ++ void assign(T* aNewPtr) {
  374. ++ T* oldPtr = mRawPtr;
  375. ++
  376. ++ if (aNewPtr && aNewPtr == oldPtr) {
  377. ++ MOZ_CRASH("Logic flaw in the caller");
  378. ++ }
  379. ++
  380. ++ mRawPtr = aNewPtr;
  381. ++ delete oldPtr;
  382. ++ }
  383. ++
  384. ++ // |class Ptr| helps us prevent implicit "copy construction"
  385. ++ // through |operator T*() const| from a |const nsAutoPtr<T>|
  386. ++ // because two implicit conversions in a row aren't allowed.
  387. ++ // It still allows assignment from T* through implicit conversion
  388. ++ // from |T*| to |nsAutoPtr<T>::Ptr|
  389. ++ class Ptr {
  390. ++ public:
  391. ++ MOZ_IMPLICIT Ptr(T* aPtr) : mPtr(aPtr) {}
  392. ++
  393. ++ operator T*() const { return mPtr; }
  394. ++
  395. ++ private:
  396. ++ T* MOZ_NON_OWNING_REF mPtr;
  397. ++ };
  398. ++
  399. ++ private:
  400. ++ T* MOZ_OWNING_REF mRawPtr;
  401. ++
  402. ++ public:
  403. ++ typedef T element_type;
  404. ++
  405. ++ ~nsAutoPtr() { delete mRawPtr; }
  406. ++
  407. ++ // Constructors
  408. ++
  409. ++ nsAutoPtr()
  410. ++ : mRawPtr(0)
  411. ++ // default constructor
  412. ++ {}
  413. ++
  414. ++ MOZ_IMPLICIT nsAutoPtr(Ptr aRawPtr)
  415. ++ : mRawPtr(aRawPtr)
  416. ++ // construct from a raw pointer (of the right type)
  417. ++ {}
  418. ++
  419. ++ // This constructor shouldn't exist; we should just use the &&
  420. ++ // constructor.
  421. ++ nsAutoPtr(nsAutoPtr<T>& aSmartPtr)
  422. ++ : mRawPtr(aSmartPtr.forget())
  423. ++ // Construct by transferring ownership from another smart pointer.
  424. ++ {}
  425. ++
  426. ++ template <typename I>
  427. ++ MOZ_IMPLICIT nsAutoPtr(nsAutoPtr<I>& aSmartPtr)
  428. ++ : mRawPtr(aSmartPtr.forget())
  429. ++ // Construct by transferring ownership from another smart pointer.
  430. ++ {}
  431. ++
  432. ++ nsAutoPtr(nsAutoPtr<T>&& aSmartPtr)
  433. ++ : mRawPtr(aSmartPtr.forget())
  434. ++ // Construct by transferring ownership from another smart pointer.
  435. ++ {}
  436. ++
  437. ++ template <typename I>
  438. ++ MOZ_IMPLICIT nsAutoPtr(nsAutoPtr<I>&& aSmartPtr)
  439. ++ : mRawPtr(aSmartPtr.forget())
  440. ++ // Construct by transferring ownership from another smart pointer.
  441. ++ {}
  442. ++
  443. ++ // Assignment operators
  444. ++
  445. ++ nsAutoPtr<T>& operator=(T* aRhs)
  446. ++ // assign from a raw pointer (of the right type)
  447. ++ {
  448. ++ assign(aRhs);
  449. ++ return *this;
  450. ++ }
  451. ++
  452. ++ nsAutoPtr<T>& operator=(nsAutoPtr<T>& aRhs)
  453. ++ // assign by transferring ownership from another smart pointer.
  454. ++ {
  455. ++ assign(aRhs.forget());
  456. ++ return *this;
  457. ++ }
  458. ++
  459. ++ template <typename I>
  460. ++ nsAutoPtr<T>& operator=(nsAutoPtr<I>& aRhs)
  461. ++ // assign by transferring ownership from another smart pointer.
  462. ++ {
  463. ++ assign(aRhs.forget());
  464. ++ return *this;
  465. ++ }
  466. ++
  467. ++ nsAutoPtr<T>& operator=(nsAutoPtr<T>&& aRhs) {
  468. ++ assign(aRhs.forget());
  469. ++ return *this;
  470. ++ }
  471. ++
  472. ++ template <typename I>
  473. ++ nsAutoPtr<T>& operator=(nsAutoPtr<I>&& aRhs) {
  474. ++ assign(aRhs.forget());
  475. ++ return *this;
  476. ++ }
  477. ++
  478. ++ // Other pointer operators
  479. ++
  480. ++ T* get() const
  481. ++ /*
  482. ++ Prefer the implicit conversion provided automatically by
  483. ++ |operator T*() const|. Use |get()| _only_ to resolve
  484. ++ ambiguity.
  485. ++ */
  486. ++ {
  487. ++ return mRawPtr;
  488. ++ }
  489. ++
  490. ++ operator T*() const
  491. ++ /*
  492. ++ ...makes an |nsAutoPtr| act like its underlying raw pointer
  493. ++ type whenever it is used in a context where a raw pointer
  494. ++ is expected. It is this operator that makes an |nsAutoPtr|
  495. ++ substitutable for a raw pointer.
  496. ++
  497. ++ Prefer the implicit use of this operator to calling |get()|,
  498. ++ except where necessary to resolve ambiguity.
  499. ++ */
  500. ++ {
  501. ++ return get();
  502. ++ }
  503. ++
  504. ++ T* forget() {
  505. ++ T* temp = mRawPtr;
  506. ++ mRawPtr = 0;
  507. ++ return temp;
  508. ++ }
  509. ++
  510. ++ T* operator->() const {
  511. ++ MOZ_ASSERT(mRawPtr != 0,
  512. ++ "You can't dereference a NULL nsAutoPtr with operator->().");
  513. ++ return get();
  514. ++ }
  515. ++
  516. ++ template <typename R, typename... Args>
  517. ++ class Proxy {
  518. ++ typedef R (T::*member_function)(Args...);
  519. ++ T* mRawPtr;
  520. ++ member_function mFunction;
  521. ++
  522. ++ public:
  523. ++ Proxy(T* aRawPtr, member_function aFunction)
  524. ++ : mRawPtr(aRawPtr), mFunction(aFunction) {}
  525. ++ template <typename... ActualArgs>
  526. ++ R operator()(ActualArgs&&... aArgs) {
  527. ++ return ((*mRawPtr).*mFunction)(std::forward<ActualArgs>(aArgs)...);
  528. ++ }
  529. ++ };
  530. ++
  531. ++ template <typename R, typename C, typename... Args>
  532. ++ Proxy<R, Args...> operator->*(R (C::*aFptr)(Args...)) const {
  533. ++ MOZ_ASSERT(mRawPtr != 0,
  534. ++ "You can't dereference a NULL nsAutoPtr with operator->*().");
  535. ++ return Proxy<R, Args...>(get(), aFptr);
  536. ++ }
  537. ++
  538. ++ nsAutoPtr<T>* get_address()
  539. ++ // This is not intended to be used by clients. See |address_of|
  540. ++ // below.
  541. ++ {
  542. ++ return this;
  543. ++ }
  544. ++
  545. ++ const nsAutoPtr<T>* get_address() const
  546. ++ // This is not intended to be used by clients. See |address_of|
  547. ++ // below.
  548. ++ {
  549. ++ return this;
  550. ++ }
  551. ++
  552. ++ public:
  553. ++ T& operator*() const {
  554. ++ MOZ_ASSERT(mRawPtr != 0,
  555. ++ "You can't dereference a NULL nsAutoPtr with operator*().");
  556. ++ return *get();
  557. ++ }
  558. ++
  559. ++ T** StartAssignment() {
  560. ++#ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
  561. ++ return reinterpret_cast<T**>(begin_assignment());
  562. ++#else
  563. ++ assign(0);
  564. ++ return reinterpret_cast<T**>(&mRawPtr);
  565. ++#endif
  566. ++ }
  567. ++};
  568. ++
  569. ++template <class T>
  570. ++inline nsAutoPtr<T>* address_of(nsAutoPtr<T>& aPtr) {
  571. ++ return aPtr.get_address();
  572. ++}
  573. ++
  574. ++template <class T>
  575. ++inline const nsAutoPtr<T>* address_of(const nsAutoPtr<T>& aPtr) {
  576. ++ return aPtr.get_address();
  577. ++}
  578. ++
  579. ++template <class T>
  580. ++class nsAutoPtrGetterTransfers
  581. ++/*
  582. ++ ...
  583. ++
  584. ++ This class is designed to be used for anonymous temporary objects in the
  585. ++ argument list of calls that return COM interface pointers, e.g.,
  586. ++
  587. ++ nsAutoPtr<IFoo> fooP;
  588. ++ ...->GetTransferedPointer(getter_Transfers(fooP))
  589. ++
  590. ++ DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_Transfers()| instead.
  591. ++
  592. ++ When initialized with a |nsAutoPtr|, as in the example above, it returns
  593. ++ a |void**|, a |T**|, or an |nsISupports**| as needed, that the
  594. ++ outer call (|GetTransferedPointer| in this case) can fill in.
  595. ++
  596. ++ This type should be a nested class inside |nsAutoPtr<T>|.
  597. ++*/
  598. ++{
  599. ++ public:
  600. ++ explicit nsAutoPtrGetterTransfers(nsAutoPtr<T>& aSmartPtr)
  601. ++ : mTargetSmartPtr(aSmartPtr) {
  602. ++ // nothing else to do
  603. ++ }
  604. ++
  605. ++ operator void**() {
  606. ++ return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
  607. ++ }
  608. ++
  609. ++ operator T**() { return mTargetSmartPtr.StartAssignment(); }
  610. ++
  611. ++ T*& operator*() { return *(mTargetSmartPtr.StartAssignment()); }
  612. ++
  613. ++ private:
  614. ++ nsAutoPtr<T>& mTargetSmartPtr;
  615. ++};
  616. ++
  617. ++template <class T>
  618. ++inline nsAutoPtrGetterTransfers<T> getter_Transfers(nsAutoPtr<T>& aSmartPtr)
  619. ++/*
  620. ++ Used around a |nsAutoPtr| when
  621. ++ ...makes the class |nsAutoPtrGetterTransfers<T>| invisible.
  622. ++*/
  623. ++{
  624. ++ return nsAutoPtrGetterTransfers<T>(aSmartPtr);
  625. ++}
  626. ++
  627. ++// Comparing two |nsAutoPtr|s
  628. ++
  629. ++template <class T, class U>
  630. ++inline bool operator==(const nsAutoPtr<T>& aLhs, const nsAutoPtr<U>& aRhs) {
  631. ++ return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get());
  632. ++}
  633. ++
  634. ++template <class T, class U>
  635. ++inline bool operator!=(const nsAutoPtr<T>& aLhs, const nsAutoPtr<U>& aRhs) {
  636. ++ return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get());
  637. ++}
  638. ++
  639. ++// Comparing an |nsAutoPtr| to a raw pointer
  640. ++
  641. ++template <class T, class U>
  642. ++inline bool operator==(const nsAutoPtr<T>& aLhs, const U* aRhs) {
  643. ++ return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs);
  644. ++}
  645. ++
  646. ++template <class T, class U>
  647. ++inline bool operator==(const U* aLhs, const nsAutoPtr<T>& aRhs) {
  648. ++ return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
  649. ++}
  650. ++
  651. ++template <class T, class U>
  652. ++inline bool operator!=(const nsAutoPtr<T>& aLhs, const U* aRhs) {
  653. ++ return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs);
  654. ++}
  655. ++
  656. ++template <class T, class U>
  657. ++inline bool operator!=(const U* aLhs, const nsAutoPtr<T>& aRhs) {
  658. ++ return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
  659. ++}
  660. ++
  661. ++template <class T, class U>
  662. ++inline bool operator==(const nsAutoPtr<T>& aLhs, U* aRhs) {
  663. ++ return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs);
  664. ++}
  665. ++
  666. ++template <class T, class U>
  667. ++inline bool operator==(U* aLhs, const nsAutoPtr<T>& aRhs) {
  668. ++ return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
  669. ++}
  670. ++
  671. ++template <class T, class U>
  672. ++inline bool operator!=(const nsAutoPtr<T>& aLhs, U* aRhs) {
  673. ++ return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs);
  674. ++}
  675. ++
  676. ++template <class T, class U>
  677. ++inline bool operator!=(U* aLhs, const nsAutoPtr<T>& aRhs) {
  678. ++ return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
  679. ++}
  680. ++
  681. ++// Comparing an |nsAutoPtr| to |nullptr|
  682. ++
  683. ++template <class T>
  684. ++inline bool operator==(const nsAutoPtr<T>& aLhs, decltype(nullptr)) {
  685. ++ return aLhs.get() == nullptr;
  686. ++}
  687. ++
  688. ++template <class T>
  689. ++inline bool operator==(decltype(nullptr), const nsAutoPtr<T>& aRhs) {
  690. ++ return nullptr == aRhs.get();
  691. ++}
  692. ++
  693. ++template <class T>
  694. ++inline bool operator!=(const nsAutoPtr<T>& aLhs, decltype(nullptr)) {
  695. ++ return aLhs.get() != nullptr;
  696. ++}
  697. ++
  698. ++template <class T>
  699. ++inline bool operator!=(decltype(nullptr), const nsAutoPtr<T>& aRhs) {
  700. ++ return nullptr != aRhs.get();
  701. ++}
  702. ++
  703. ++/*****************************************************************************/
  704. ++
  705. ++#endif // !defined(nsAutoPtr_h)
  706. +--- /dev/null
  707. ++++ a/xpcom/tests/gtest/TestAutoPtr.cpp
  708. +@@ -0,0 +1,202 @@
  709. ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  710. ++// vim:cindent:ts=4:et:sw=4:
  711. ++/* This Source Code Form is subject to the terms of the Mozilla Public
  712. ++ * License, v. 2.0. If a copy of the MPL was not distributed with this
  713. ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  714. ++
  715. ++#include "nsAutoPtr.h"
  716. ++#include "gtest/gtest.h"
  717. ++
  718. ++class TestObjectBaseA {
  719. ++ public:
  720. ++ // Virtual dtor for deleting through base class pointer
  721. ++ virtual ~TestObjectBaseA() = default;
  722. ++ void MemberFunction(int, int*, int&) {}
  723. ++ virtual void VirtualMemberFunction(int, int*, int&){};
  724. ++ virtual void VirtualConstMemberFunction(int, int*, int&) const {};
  725. ++ int fooA;
  726. ++};
  727. ++
  728. ++class TestObjectBaseB {
  729. ++ public:
  730. ++ // Virtual dtor for deleting through base class pointer
  731. ++ virtual ~TestObjectBaseB() = default;
  732. ++ int fooB;
  733. ++};
  734. ++
  735. ++class TestObject : public TestObjectBaseA, public TestObjectBaseB {
  736. ++ public:
  737. ++ TestObject() = default;
  738. ++
  739. ++ // Virtual dtor for deleting through base class pointer
  740. ++ virtual ~TestObject() { destructed++; }
  741. ++
  742. ++ virtual void VirtualMemberFunction(int, int*, int&) override {}
  743. ++ virtual void VirtualConstMemberFunction(int, int*, int&) const override {}
  744. ++
  745. ++ static int destructed;
  746. ++ static const void* last_ptr;
  747. ++};
  748. ++
  749. ++int TestObject::destructed = 0;
  750. ++const void* TestObject::last_ptr = nullptr;
  751. ++
  752. ++static void CreateTestObject(TestObject** aResult) {
  753. ++ *aResult = new TestObject();
  754. ++}
  755. ++
  756. ++static void DoSomethingWithTestObject(TestObject* aIn) {
  757. ++ TestObject::last_ptr = static_cast<void*>(aIn);
  758. ++}
  759. ++
  760. ++static void DoSomethingWithConstTestObject(const TestObject* aIn) {
  761. ++ TestObject::last_ptr = static_cast<const void*>(aIn);
  762. ++}
  763. ++
  764. ++static void DoSomethingWithTestObjectBaseB(TestObjectBaseB* aIn) {
  765. ++ TestObject::last_ptr = static_cast<void*>(aIn);
  766. ++}
  767. ++
  768. ++static void DoSomethingWithConstTestObjectBaseB(const TestObjectBaseB* aIn) {
  769. ++ TestObject::last_ptr = static_cast<const void*>(aIn);
  770. ++}
  771. ++
  772. ++TEST(AutoPtr, Assignment)
  773. ++{
  774. ++ TestObject::destructed = 0;
  775. ++
  776. ++ { nsAutoPtr<TestObject> pobj(new TestObject()); }
  777. ++
  778. ++ ASSERT_EQ(1, TestObject::destructed);
  779. ++
  780. ++ {
  781. ++ nsAutoPtr<TestObject> pobj(new TestObject());
  782. ++ pobj = new TestObject();
  783. ++ ASSERT_EQ(2, TestObject::destructed);
  784. ++ }
  785. ++
  786. ++ ASSERT_EQ(3, TestObject::destructed);
  787. ++}
  788. ++
  789. ++TEST(AutoPtr, getter_Transfers)
  790. ++{
  791. ++ TestObject::destructed = 0;
  792. ++
  793. ++ {
  794. ++ nsAutoPtr<TestObject> ptr;
  795. ++ CreateTestObject(getter_Transfers(ptr));
  796. ++ }
  797. ++
  798. ++ ASSERT_EQ(1, TestObject::destructed);
  799. ++}
  800. ++
  801. ++TEST(AutoPtr, Casting)
  802. ++{
  803. ++ // This comparison is always false, as it should be. The extra parens
  804. ++ // suppress a -Wunreachable-code warning about printf being unreachable.
  805. ++ ASSERT_NE(((void*)(TestObject*)0x1000),
  806. ++ ((void*)(TestObjectBaseB*)(TestObject*)0x1000));
  807. ++
  808. ++ {
  809. ++ nsAutoPtr<TestObject> p1(new TestObject());
  810. ++ TestObjectBaseB* p2 = p1;
  811. ++ ASSERT_NE(static_cast<void*>(p1), static_cast<void*>(p2));
  812. ++ ASSERT_EQ(p1, p2);
  813. ++ ASSERT_FALSE(p1 != p2);
  814. ++ ASSERT_EQ(p2, p1);
  815. ++ ASSERT_FALSE(p2 != p1);
  816. ++ }
  817. ++
  818. ++ {
  819. ++ TestObject* p1 = new TestObject();
  820. ++ nsAutoPtr<TestObjectBaseB> p2(p1);
  821. ++ ASSERT_EQ(p1, p2);
  822. ++ ASSERT_FALSE(p1 != p2);
  823. ++ ASSERT_EQ(p2, p1);
  824. ++ ASSERT_FALSE(p2 != p1);
  825. ++ }
  826. ++}
  827. ++
  828. ++TEST(AutoPtr, Forget)
  829. ++{
  830. ++ TestObject::destructed = 0;
  831. ++
  832. ++ {
  833. ++ nsAutoPtr<TestObject> pobj(new TestObject());
  834. ++ nsAutoPtr<TestObject> pobj2(pobj.forget());
  835. ++ ASSERT_EQ(0, TestObject::destructed);
  836. ++ }
  837. ++
  838. ++ ASSERT_EQ(1, TestObject::destructed);
  839. ++}
  840. ++
  841. ++TEST(AutoPtr, Construction)
  842. ++{
  843. ++ TestObject::destructed = 0;
  844. ++
  845. ++ { nsAutoPtr<TestObject> pobj(new TestObject()); }
  846. ++
  847. ++ ASSERT_EQ(1, TestObject::destructed);
  848. ++}
  849. ++
  850. ++TEST(AutoPtr, ImplicitConversion)
  851. ++{
  852. ++ // This test is basically successful if it builds. We add a few assertions
  853. ++ // to make gtest happy.
  854. ++ TestObject::destructed = 0;
  855. ++
  856. ++ {
  857. ++ nsAutoPtr<TestObject> pobj(new TestObject());
  858. ++ DoSomethingWithTestObject(pobj);
  859. ++ DoSomethingWithConstTestObject(pobj);
  860. ++ }
  861. ++
  862. ++ ASSERT_EQ(1, TestObject::destructed);
  863. ++
  864. ++ {
  865. ++ nsAutoPtr<TestObject> pobj(new TestObject());
  866. ++ DoSomethingWithTestObjectBaseB(pobj);
  867. ++ DoSomethingWithConstTestObjectBaseB(pobj);
  868. ++ }
  869. ++
  870. ++ ASSERT_EQ(2, TestObject::destructed);
  871. ++
  872. ++ {
  873. ++ const nsAutoPtr<TestObject> pobj(new TestObject());
  874. ++ DoSomethingWithTestObject(pobj);
  875. ++ DoSomethingWithConstTestObject(pobj);
  876. ++ }
  877. ++
  878. ++ ASSERT_EQ(3, TestObject::destructed);
  879. ++
  880. ++ {
  881. ++ const nsAutoPtr<TestObject> pobj(new TestObject());
  882. ++ DoSomethingWithTestObjectBaseB(pobj);
  883. ++ DoSomethingWithConstTestObjectBaseB(pobj);
  884. ++ }
  885. ++
  886. ++ ASSERT_EQ(4, TestObject::destructed);
  887. ++}
  888. ++
  889. ++TEST(AutoPtr, ArrowOperator)
  890. ++{
  891. ++ // This test is basically successful if it builds. We add a few assertions
  892. ++ // to make gtest happy.
  893. ++ TestObject::destructed = 0;
  894. ++
  895. ++ {
  896. ++ int test = 1;
  897. ++ void (TestObjectBaseA::*fPtr)(int, int*, int&) =
  898. ++ &TestObjectBaseA::MemberFunction;
  899. ++ void (TestObjectBaseA::*fVPtr)(int, int*, int&) =
  900. ++ &TestObjectBaseA::VirtualMemberFunction;
  901. ++ void (TestObjectBaseA::*fVCPtr)(int, int*, int&) const =
  902. ++ &TestObjectBaseA::VirtualConstMemberFunction;
  903. ++ nsAutoPtr<TestObjectBaseA> pobj(new TestObject());
  904. ++ (pobj->*fPtr)(test, &test, test);
  905. ++ (pobj->*fVPtr)(test, &test, test);
  906. ++ (pobj->*fVCPtr)(test, &test, test);
  907. ++ }
  908. ++
  909. ++ ASSERT_EQ(1, TestObject::destructed);
  910. ++}
  911. +--- b/xpcom/tests/gtest/moz.build
  912. ++++ a/xpcom/tests/gtest/moz.build
  913. +@@ -1,138 +1,139 @@
  914. + # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
  915. + # vim: set filetype=python:
  916. + # This Source Code Form is subject to the terms of the Mozilla Public
  917. + # License, v. 2.0. If a copy of the MPL was not distributed with this
  918. + # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  919. +
  920. + UNIFIED_SOURCES += [
  921. + 'Helpers.cpp',
  922. + 'TestArenaAllocator.cpp',
  923. + 'TestArrayAlgorithm.cpp',
  924. + 'TestAtoms.cpp',
  925. ++ 'TestAutoPtr.cpp',
  926. + 'TestAutoRef.cpp',
  927. + 'TestAutoRefCnt.cpp',
  928. + 'TestBase64.cpp',
  929. + 'TestCallTemplates.cpp',
  930. + 'TestCloneInputStream.cpp',
  931. + 'TestCOMPtrEq.cpp',
  932. + 'TestCRT.cpp',
  933. + 'TestDafsa.cpp',
  934. + 'TestEncoding.cpp',
  935. + 'TestEscape.cpp',
  936. + 'TestEventPriorities.cpp',
  937. + 'TestEventTargetQI.cpp',
  938. + 'TestExpirationTracker.cpp',
  939. + 'TestFile.cpp',
  940. + 'TestGCPostBarriers.cpp',
  941. + 'TestID.cpp',
  942. + 'TestInputStreamLengthHelper.cpp',
  943. + 'TestLogCommandLineHandler.cpp',
  944. + 'TestMoveString.cpp',
  945. + 'TestMozPromise.cpp',
  946. + 'TestMruCache.cpp',
  947. + 'TestMultiplexInputStream.cpp',
  948. + 'TestNonBlockingAsyncInputStream.cpp',
  949. + 'TestNsDeque.cpp',
  950. + 'TestNSPRLogModulesParser.cpp',
  951. + 'TestObserverArray.cpp',
  952. + 'TestObserverService.cpp',
  953. + 'TestPLDHash.cpp',
  954. + 'TestPriorityQueue.cpp',
  955. + 'TestRacingServiceManager.cpp',
  956. + 'TestRecursiveMutex.cpp',
  957. + 'TestRWLock.cpp',
  958. + 'TestSlicedInputStream.cpp',
  959. + 'TestSnappyStreams.cpp',
  960. + 'TestStateWatching.cpp',
  961. + 'TestStorageStream.cpp',
  962. + 'TestStrings.cpp',
  963. + 'TestStringStream.cpp',
  964. + 'TestSynchronization.cpp',
  965. + 'TestTArray.cpp',
  966. + 'TestTArray2.cpp',
  967. + 'TestTaskQueue.cpp',
  968. + 'TestTextFormatter.cpp',
  969. + 'TestThreadManager.cpp',
  970. + 'TestThreadMetrics.cpp',
  971. + 'TestThreadPool.cpp',
  972. + 'TestThreadPoolListener.cpp',
  973. + 'TestThrottledEventQueue.cpp',
  974. + 'TestTimeStamp.cpp',
  975. + 'TestTokenizer.cpp',
  976. + 'TestUTF.cpp',
  977. + ]
  978. +
  979. + if CONFIG['OS_TARGET'] != 'Android':
  980. + UNIFIED_SOURCES += [
  981. + 'TestPipes.cpp',
  982. + 'TestThreads.cpp',
  983. + ]
  984. +
  985. + # skip the test on windows10-aarch64 due to perma-fail, bug 1422219
  986. + if not(CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64'):
  987. + UNIFIED_SOURCES += [
  988. + 'TestThreadUtils.cpp'
  989. + ]
  990. +
  991. + # skip the test on windows10-aarch64 and Android, aarch64 due to bug 1545670
  992. + if CONFIG['OS_TARGET'] != 'Android' and not(CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64'):
  993. + UNIFIED_SOURCES += [
  994. + 'TestTimers.cpp'
  995. + ]
  996. +
  997. +
  998. + if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT') and CONFIG['OS_TARGET'] != 'Android':
  999. + # FIXME bug 523392: TestDeadlockDetector doesn't like Windows
  1000. + # Bug 1054249: Doesn't work on Android
  1001. + UNIFIED_SOURCES += [
  1002. + 'TestDeadlockDetector.cpp',
  1003. + 'TestDeadlockDetectorScalability.cpp',
  1004. + ]
  1005. +
  1006. + if CONFIG['OS_TARGET'] == 'WINNT':
  1007. + UNIFIED_SOURCES += [
  1008. + 'TestFilePreferencesWin.cpp',
  1009. + ]
  1010. + else:
  1011. + UNIFIED_SOURCES += [
  1012. + 'TestFilePreferencesUnix.cpp',
  1013. + ]
  1014. +
  1015. + if CONFIG['WRAP_STL_INCLUDES'] and CONFIG['CC_TYPE'] != 'clang-cl' and CONFIG['OS_TARGET'] != 'Android':
  1016. + UNIFIED_SOURCES += [
  1017. + 'TestSTLWrappers.cpp',
  1018. + ]
  1019. +
  1020. + # Compile TestAllocReplacement separately so Windows headers don't pollute
  1021. + # the global namespace for other files.
  1022. + SOURCES += [
  1023. + 'TestAllocReplacement.cpp',
  1024. + 'TestCOMArray.cpp',
  1025. + 'TestCOMPtr.cpp', # Redefines IFoo and IBar
  1026. + 'TestHashtables.cpp', # Redefines IFoo
  1027. + 'TestNsRefPtr.cpp', # Redefines Foo
  1028. + ]
  1029. +
  1030. + LOCAL_INCLUDES += [
  1031. + '../../base',
  1032. + ]
  1033. +
  1034. + GeneratedFile('dafsa_test_1.inc',
  1035. + script='../../ds/tools/make_dafsa.py',
  1036. + inputs=['dafsa_test_1.dat'])
  1037. +
  1038. + TEST_HARNESS_FILES.gtest += [
  1039. + 'wikipedia/ar.txt',
  1040. + 'wikipedia/de-edit.txt',
  1041. + 'wikipedia/de.txt',
  1042. + 'wikipedia/ja.txt',
  1043. + 'wikipedia/ko.txt',
  1044. + 'wikipedia/ru.txt',
  1045. + 'wikipedia/th.txt',
  1046. + 'wikipedia/tr.txt',
  1047. + 'wikipedia/vi.txt',
  1048. + ]
  1049. +
  1050. + FINAL_LIBRARY = 'xul-gtest'
  1051. +
  1052. + include('/ipc/chromium/chromium-config.mozbuild')
  1053. +--- a/mfbt/NotNull.h 2020-06-03 16:41:08.546678524 +0300
  1054. ++++ b/mfbt/NotNull.h 2020-06-03 16:41:26.656493988 +0300
  1055. +@@ -183,9 +183,6 @@
  1056. + "mBasePtr must have zero offset.");
  1057. + }
  1058. +
  1059. +- // Disallow null checks, which are unnecessary for this type.
  1060. +- explicit operator bool() const = delete;
  1061. +-
  1062. + // Explicit conversion to a base pointer. Use only to resolve ambiguity or to
  1063. + // get a castable pointer.
  1064. + constexpr T* get() const MOZ_NONNULL_RETURN { return mBasePtr; }
Add Comment
Please, Sign In to add comment