tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FluentResource.h (1747B)


      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 
      7 #ifndef mozilla_intl_l10n_FluentResource_h
      8 #define mozilla_intl_l10n_FluentResource_h
      9 
     10 #include "mozilla/ErrorResult.h"
     11 #include "mozilla/dom/BindingDeclarations.h"
     12 #include "nsCycleCollectionParticipant.h"
     13 #include "nsWrapperCache.h"
     14 #include "mozilla/dom/FluentBinding.h"
     15 #include "mozilla/intl/FluentBindings.h"
     16 
     17 namespace mozilla {
     18 
     19 namespace dom {
     20 struct FluentTextElementItem;
     21 }  // namespace dom
     22 
     23 namespace intl {
     24 
     25 class FluentResource : public nsWrapperCache {
     26 public:
     27  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(FluentResource)
     28  NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(FluentResource)
     29 
     30  FluentResource(nsISupports* aParent, const ffi::FluentResource* aRaw);
     31  FluentResource(nsISupports* aParent, const nsACString& aSource);
     32 
     33  static already_AddRefed<FluentResource> Constructor(
     34      const dom::GlobalObject& aGlobal, const nsACString& aSource);
     35 
     36  void TextElements(nsTArray<dom::FluentTextElementItem>& aElements,
     37                    ErrorResult& aRv);
     38 
     39  JSObject* WrapObject(JSContext* aCx,
     40                       JS::Handle<JSObject*> aGivenProto) override;
     41  nsISupports* GetParentObject() const { return mParent; }
     42 
     43  const ffi::FluentResource* Raw() const { return mRaw; }
     44 
     45 protected:
     46  virtual ~FluentResource() = default;
     47 
     48  nsCOMPtr<nsISupports> mParent;
     49  RefPtr<const ffi::FluentResource> mRaw;
     50  bool mHasErrors;
     51 };
     52 
     53 }  // namespace intl
     54 }  // namespace mozilla
     55 
     56 #endif