Bug 1455649 - DocumentL10n, part 4 - Add mozIDOMLocalization API.
In order to use DOMLocalization from C++ we need an XPIDL interface.
mozIDOMLocalization exposes the class and functionality allowing DocumentL10n
to hook into it.
MozReview-Commit-ID: GPMhw61LPEg
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -357,16 +357,19 @@
@RESPATH@/components/TestInterfaceJSMaplike.js
#endif
#if defined(MOZ_DEBUG) || defined(MOZ_DEV_EDITION) || defined(NIGHTLY_BUILD)
@RESPATH@/browser/components/testComponents.manifest
@RESPATH@/browser/components/startupRecorder.js
#endif
+@RESPATH@/components/mozDOMLocalization.js
+@RESPATH@/components/mozDOMLocalization.manifest
+
; [Extensions]
@RESPATH@/components/extensions-toolkit.manifest
@RESPATH@/components/extension-process-script.js
@RESPATH@/browser/components/extensions-browser.manifest
; Modules
@RESPATH@/browser/modules/*
@RESPATH@/modules/*
--- a/intl/l10n/moz.build
+++ b/intl/l10n/moz.build
@@ -6,16 +6,27 @@
EXTRA_JS_MODULES += [
'DOMLocalization.jsm',
'L10nRegistry.jsm',
'Localization.jsm',
'MessageContext.jsm',
]
+XPIDL_SOURCES += [
+ 'mozIDOMLocalization.idl',
+]
+
+XPIDL_MODULE = 'locale'
+
+EXTRA_COMPONENTS += [
+ 'mozDOMLocalization.js',
+ 'mozDOMLocalization.manifest',
+]
+
XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell.ini']
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
JAR_MANIFESTS += ['jar.mn']
SPHINX_TREES['l10n'] = 'docs'
new file mode 100644
--- /dev/null
+++ b/intl/l10n/mozDOMLocalization.js
@@ -0,0 +1,12 @@
+const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
+const { DOMLocalization } = ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
+
+class mozDOMLocalization extends DOMLocalization {}
+
+
+mozDOMLocalization.prototype.classID =
+ Components.ID("{29cc3895-8835-4c5b-b53a-0c0d1a458dee}");
+mozDOMLocalization.prototype.QueryInterface =
+ ChromeUtils.generateQI([Ci.mozIDOMLocalization]);
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([mozDOMLocalization]);
new file mode 100644
--- /dev/null
+++ b/intl/l10n/mozDOMLocalization.manifest
@@ -0,0 +1,2 @@
+component {29cc3895-8835-4c5b-b53a-0c0d1a458dee} mozDOMLocalization.js
+contract @mozilla.org/intl/domlocalization;1 {29cc3895-8835-4c5b-b53a-0c0d1a458dee}
new file mode 100644
--- /dev/null
+++ b/intl/l10n/mozIDOMLocalization.idl
@@ -0,0 +1,30 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "nsISupports.idl"
+
+webidl Document;
+webidl Element;
+
+[scriptable, uuid(7c468500-541f-4fe0-98c9-92a53b63ec8d)]
+interface mozIDOMLocalization : nsISupports
+{
+ void onDocumentParsed(in Document document);
+ void unregisterObservers();
+
+ unsigned long addResourceIds([array, size_is(aLength)] in string resourceIds, in unsigned long aLength);
+ unsigned long removeResourceIds([array, size_is(aLength)] in string resourceIds, in unsigned long aLength);
+
+ Promise formatMessages([array, size_is(aLength)] in jsval aKeys, in unsigned long aLength);
+ Promise formatValues([array, size_is(aLength)] in jsval aKeys, in unsigned long aLength);
+ Promise formatValue(in DOMString aId, [optional] in jsval aArgs);
+
+ Promise translateFragment(in Element aElement);
+ Promise translateElements([array, size_is(aLength)] in Element aElements, in unsigned long aLength);
+
+ void connectRoot(in Element aElement);
+ Promise translateRoots();
+ readonly attribute Promise ready;
+};