Bug 1434686 part 1. Introduce a mozilla::IgnoreErrors which can be used as a temporary to pass to an ErrorResult& arg when the error should be ignored. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 01 Feb 2018 14:21:14 -0500
changeset 454606 27018abb80f8dec9412757f215b738de751385b9
parent 454605 ae73697f72b7df48bc399c0934c353fa928257e8
child 454607 f4719d1d3ec32274549f2258bbc72d1c19f2b3e1
push id8799
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 16:46:23 +0000
treeherdermozilla-beta@15334014dc67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1434686, 1434689
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434686 part 1. Introduce a mozilla::IgnoreErrors which can be used as a temporary to pass to an ErrorResult& arg when the error should be ignored. r=mystor Once bug 1434689 is fixed, we can mark this thing as being required to be a temporary. MozReview-Commit-ID: 7VX0XSYVOc4
dom/bindings/ErrorResult.h
js/src/devtools/rootAnalysis/annotations.js
--- a/dom/bindings/ErrorResult.h
+++ b/dom/bindings/ErrorResult.h
@@ -597,16 +597,31 @@ binding_danger::TErrorResult<CleanupPoli
 // A class for use when an ErrorResult should just automatically be ignored.
 // This doesn't inherit from ErrorResult so we don't make two separate calls to
 // SuppressException.
 class IgnoredErrorResult :
     public binding_danger::TErrorResult<binding_danger::JustSuppressCleanupPolicy>
 {
 };
 
+// A class for use when an ErrorResult should just automatically be
+// ignored.  This is designed to be passed as a temporary only, like
+// so:
+//
+//    foo->Bar(IgnoreErrors());
+class IgnoreErrors {
+public:
+  operator ErrorResult&() && { return mInner; }
+private:
+  // We don't use an ErrorResult member here so we don't make two separate calls
+  // to SuppressException (one from us, one from the ErrorResult destructor
+  // after asserting).
+  binding_danger::TErrorResult<binding_danger::JustSuppressCleanupPolicy> mInner;
+};
+
 namespace dom {
 namespace binding_detail {
 class FastErrorResult :
     public mozilla::binding_danger::TErrorResult<
       mozilla::binding_danger::JustAssertCleanupPolicy>
 {
 };
 } // namespace binding_detail
--- a/js/src/devtools/rootAnalysis/annotations.js
+++ b/js/src/devtools/rootAnalysis/annotations.js
@@ -331,16 +331,17 @@ function extraRootedPointers()
 
         // These are not actually rooted, but are only used in the context of
         // AutoKeepAtoms.
         'js::frontend::TokenStream',
         'js::frontend::TokenStreamAnyChars',
 
         'mozilla::ErrorResult',
         'mozilla::IgnoredErrorResult',
+        'mozilla::IgnoreErrors',
         'mozilla::dom::binding_detail::FastErrorResult',
     ];
 }
 
 function isRootedGCPointerTypeName(name)
 {
     name = stripUCSAndNamespace(name);