Bug 1483036 - Simplify the DocumentL10n::PromiseResolver handler. r=smaug
authorZibi Braniecki <zbraniecki@mozilla.com>
Tue, 26 Mar 2019 15:05:21 +0000
changeset 466184 ba00aeb3eb206deb6881bcbe16ac4da6f8351578
parent 466183 498699c9be80bd118c48335abc8fa689d66179f5
child 466185 6bfe0c0b681f079f1e769651af3db8a8d0183a3f
push id35762
push usercsabou@mozilla.com
push dateWed, 27 Mar 2019 04:44:00 +0000
treeherdermozilla-central@bc572aee49b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1483036
milestone68.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 1483036 - Simplify the DocumentL10n::PromiseResolver handler. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D24451
intl/l10n/DocumentL10n.cpp
intl/l10n/moz.build
--- a/intl/l10n/DocumentL10n.cpp
+++ b/intl/l10n/DocumentL10n.cpp
@@ -9,17 +9,16 @@
 #include "mozilla/dom/DocumentL10nBinding.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/PromiseNativeHandler.h"
 #include "nsQueryObject.h"
 #include "nsISupports.h"
 #include "nsImportModule.h"
 #include "nsContentUtils.h"
-#include "xpcprivate.h"
 
 #define INTL_APP_LOCALES_CHANGED "intl:app-locales-changed"
 
 #define L10N_PSEUDO_PREF "intl.l10n.pseudo"
 
 static const char* kObservedPrefs[] = {L10N_PSEUDO_PREF, nullptr};
 
 namespace mozilla {
@@ -31,42 +30,22 @@ NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(PromiseResolver)
 NS_IMPL_RELEASE(PromiseResolver)
 
 PromiseResolver::PromiseResolver(Promise* aPromise) { mPromise = aPromise; }
 
 void PromiseResolver::ResolvedCallback(JSContext* aCx,
                                        JS::Handle<JS::Value> aValue) {
-  JS::RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
-
-  AutoEntryScript aes(mPromise->GetParentObject(), "Promise resolution");
-  JSContext* cx = aes.cx();
-  JS::Rooted<JS::Value> value(cx, aValue);
-
-  xpc::StackScopedCloneOptions options;
-  StackScopedClone(cx, options, sourceScope, &value);
-
-  mPromise->MaybeResolve(cx, value);
-  mPromise = nullptr;
+  mPromise->MaybeResolveWithClone(aCx, aValue);
 }
 
 void PromiseResolver::RejectedCallback(JSContext* aCx,
                                        JS::Handle<JS::Value> aValue) {
-  JS::RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
-
-  AutoEntryScript aes(mPromise->GetParentObject(), "Promise rejection");
-  JSContext* cx = aes.cx();
-  JS::Rooted<JS::Value> value(cx, aValue);
-
-  xpc::StackScopedCloneOptions options;
-  StackScopedClone(cx, options, sourceScope, &value);
-
-  mPromise->MaybeReject(cx, value);
-  mPromise = nullptr;
+  mPromise->MaybeRejectWithClone(aCx, aValue);
 }
 
 PromiseResolver::~PromiseResolver() { mPromise = nullptr; }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DocumentL10n, mDocument, mDOMLocalization,
                                       mContentSink, mReady)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DocumentL10n)
--- a/intl/l10n/moz.build
+++ b/intl/l10n/moz.build
@@ -26,17 +26,16 @@ EXPORTS.mozilla.dom += [
 ]
 
 UNIFIED_SOURCES += [
     'DocumentL10n.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
-    '/js/xpconnect/src',
 ]
 
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']