Bug 1403318 - Remove mozIntl.PluralRules. r?anba draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 28 Sep 2017 15:00:32 +0200
changeset 673428 2ee3ef2f2df17f28fa13c97302dada8182663617
parent 673427 08d60a631041d297bcbb3729529251f2ef787eb1
child 734101 147dcab4dc6f15de1e73e6f6a21dc1be00f87a82
push id82575
push userbmo:gandalf@aviary.pl
push dateMon, 02 Oct 2017 15:47:25 +0000
reviewersanba
bugs1403318
milestone58.0a1
Bug 1403318 - Remove mozIntl.PluralRules. r?anba MozReview-Commit-ID: IqkGenuXYrv
toolkit/components/mozintl/MozIntlHelper.cpp
toolkit/components/mozintl/mozIMozIntl.idl
toolkit/components/mozintl/mozIMozIntlHelper.idl
toolkit/components/mozintl/mozIntl.js
toolkit/components/mozintl/test/test_mozintl.js
toolkit/components/mozintl/test/test_mozintlhelper.js
--- a/toolkit/components/mozintl/MozIntlHelper.cpp
+++ b/toolkit/components/mozintl/MozIntlHelper.cpp
@@ -57,37 +57,16 @@ MozIntlHelper::AddGetDisplayNames(JS::Ha
     JS_SELF_HOSTED_FN("getDisplayNames", "Intl_getDisplayNames", 2, 0),
     JS_FS_END
   };
 
   return AddFunctions(cx, val, funcs);
 }
 
 NS_IMETHODIMP
-MozIntlHelper::AddPluralRulesConstructor(JS::Handle<JS::Value> val, JSContext* cx)
-{
-  if (!val.isObject()) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
-  if (!realIntlObj) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  JSAutoCompartment ac(cx, realIntlObj);
-
-  if (!js::AddPluralRulesConstructor(cx, realIntlObj)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 MozIntlHelper::AddDateTimeFormatConstructor(JS::Handle<JS::Value> val, JSContext* cx)
 {
   if (!val.isObject()) {
     return NS_ERROR_INVALID_ARG;
   }
 
   JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
   if (!realIntlObj) {
--- a/toolkit/components/mozintl/mozIMozIntl.idl
+++ b/toolkit/components/mozintl/mozIMozIntl.idl
@@ -36,11 +36,10 @@
  */
 [scriptable, uuid(7f63279a-1a29-4ae6-9e7a-dc9684a23530)]
 interface mozIMozIntl : nsISupports
 {
   jsval getCalendarInfo([optional] in jsval locales);
   jsval getDisplayNames([optional] in jsval locales, [optional] in jsval options);
   jsval getLocaleInfo([optional] in jsval locales);
 
-  jsval createPluralRules([optional] in jsval locales, [optional] in jsval options);
   jsval createDateTimeFormat([optional] in jsval locales, [optional] in jsval options);
 };
--- a/toolkit/components/mozintl/mozIMozIntlHelper.idl
+++ b/toolkit/components/mozintl/mozIMozIntlHelper.idl
@@ -16,23 +16,16 @@
 [scriptable, uuid(189eaa7d-b29a-43a9-b1fb-7658990df940)]
 interface mozIMozIntlHelper : nsISupports
 {
   [implicit_jscontext] void addGetCalendarInfo(in jsval intlObject);
   [implicit_jscontext] void addGetDisplayNames(in jsval intlObject);
   [implicit_jscontext] void addGetLocaleInfo(in jsval intlObject);
 
   /**
-   * Adds a PluralRules constructor to the given object.  This function may only
-   * be called once within a realm/global object: calling it multiple times will
-   * throw.
-   */
-  [implicit_jscontext] void addPluralRulesConstructor(in jsval intlObject);
-
-  /**
    * Adds a MozDateTimeFormat contructor to the given object. This function may only
    * be called once within a realm/global object: calling it multiple times will
    * throw.
    *
    * The difference between regular Intl.DateTimeFormat and the method created here
    * is that we support two more options:
    *
    *    timeStyle: full | long | medium | short
--- a/toolkit/components/mozintl/mozIntl.js
+++ b/toolkit/components/mozintl/mozIntl.js
@@ -65,24 +65,16 @@ class MozIntl {
   getLocaleInfo(locales, ...args) {
     if (!this._cache.hasOwnProperty("getLocaleInfo")) {
       mozIntlHelper.addGetLocaleInfo(this._cache);
     }
 
     return this._cache.getLocaleInfo(getLocales(locales), ...args);
   }
 
-  createPluralRules(locales, ...args) {
-    if (!this._cache.hasOwnProperty("PluralRules")) {
-      mozIntlHelper.addPluralRulesConstructor(this._cache);
-    }
-
-    return new this._cache.PluralRules(getLocales(locales), ...args);
-  }
-
   createDateTimeFormat(locales, options, ...args) {
     if (!this._cache.hasOwnProperty("DateTimeFormat")) {
       mozIntlHelper.addDateTimeFormatConstructor(this._cache);
     }
 
     let resolvedLocales =
       this._cache.DateTimeFormat.supportedLocalesOf(getLocales(locales));
 
--- a/toolkit/components/mozintl/test/test_mozintl.js
+++ b/toolkit/components/mozintl/test/test_mozintl.js
@@ -10,20 +10,18 @@ function run_test() {
 
   ok(true);
 }
 
 function test_methods_presence(mozIntl) {
   equal(mozIntl.getCalendarInfo instanceof Function, true);
   equal(mozIntl.getDisplayNames instanceof Function, true);
   equal(mozIntl.getLocaleInfo instanceof Function, true);
-  equal(mozIntl.createPluralRules instanceof Function, true);
   equal(mozIntl.createDateTimeFormat instanceof Function, true);
 }
 
 function test_methods_calling(mozIntl) {
   mozIntl.getCalendarInfo("pl");
   mozIntl.getDisplayNames("ar");
   mozIntl.getLocaleInfo("de");
-  mozIntl.createPluralRules("fr");
   mozIntl.createDateTimeFormat("fr");
   ok(true);
 }
--- a/toolkit/components/mozintl/test/test_mozintlhelper.js
+++ b/toolkit/components/mozintl/test/test_mozintlhelper.js
@@ -31,28 +31,24 @@ function test_cross_global(miHelper) {
   equal(waivedX.getCalendarInfo() instanceof Object, false);
   equal(waivedX.getCalendarInfo() instanceof global.Object, true);
 }
 
 function test_methods_presence(miHelper) {
   equal(miHelper.addGetCalendarInfo instanceof Function, true);
   equal(miHelper.addGetDisplayNames instanceof Function, true);
   equal(miHelper.addGetLocaleInfo instanceof Function, true);
-  equal(miHelper.addPluralRulesConstructor instanceof Function, true);
   equal(miHelper.addDateTimeFormatConstructor instanceof Function, true);
 
   let x = {};
 
   miHelper.addGetCalendarInfo(x);
   equal(x.getCalendarInfo instanceof Function, true);
 
   miHelper.addGetDisplayNames(x);
   equal(x.getDisplayNames instanceof Function, true);
 
   miHelper.addGetLocaleInfo(x);
   equal(x.getLocaleInfo instanceof Function, true);
 
-  miHelper.addPluralRulesConstructor(x);
-  equal(x.PluralRules instanceof Function, true);
-
   miHelper.addDateTimeFormatConstructor(x);
   equal(x.DateTimeFormat instanceof Function, true);
 }