1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_IntlUtils_h
7 #define mozilla_dom_IntlUtils_h
8 
9 #include "mozilla/dom/IntlUtilsBinding.h"
10 #include "nsWrapperCache.h"
11 #include "xpcprivate.h"
12 
13 class nsPIDOMWindowInner;
14 
15 namespace mozilla {
16 namespace dom {
17 
18 #ifdef XP_WIN
19 #  undef GetLocaleInfo
20 #endif
21 
22 class IntlUtils final : public nsISupports, public nsWrapperCache {
23  public:
24   explicit IntlUtils(nsPIDOMWindowInner* aWindow);
25 
26   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IntlUtils)27   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IntlUtils)
28 
29   nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
30 
31   JSObject* WrapObject(JSContext* aCx,
32                        JS::Handle<JSObject*> aGivenProto) override;
33 
34   void GetDisplayNames(const Sequence<nsString>& aLocales,
35                        const mozilla::dom::DisplayNameOptions& aOptions,
36                        mozilla::dom::DisplayNameResult& aResult,
37                        mozilla::ErrorResult& aError);
38 
39   void GetLocaleInfo(const Sequence<nsString>& aLocales,
40                      mozilla::dom::LocaleInfo& aResult,
41                      mozilla::ErrorResult& aError);
42 
43   bool IsAppLocaleRTL();
44 
45  private:
46   ~IntlUtils();
47 
48   nsCOMPtr<nsPIDOMWindowInner> mWindow;
49 };
50 
51 }  // namespace dom
52 }  // namespace mozilla
53 #endif
54