Backed out changeset 68ed52f7e45d (bug 1899241) for causing sccache misses (bug 19048...
[gecko.git] / intl / l10n / FluentResource.h
blob419ea4127bd8859a0cd725416665bd71e6ade762
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/. */
7 #ifndef mozilla_intl_l10n_FluentResource_h
8 #define mozilla_intl_l10n_FluentResource_h
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"
17 namespace mozilla {
19 namespace dom {
20 struct FluentTextElementItem;
21 } // namespace dom
23 namespace intl {
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)
30 FluentResource(nsISupports* aParent, const ffi::FluentResource* aRaw);
31 FluentResource(nsISupports* aParent, const nsACString& aSource);
33 static already_AddRefed<FluentResource> Constructor(
34 const dom::GlobalObject& aGlobal, const nsACString& aSource);
36 void TextElements(nsTArray<dom::FluentTextElementItem>& aElements,
37 ErrorResult& aRv);
39 JSObject* WrapObject(JSContext* aCx,
40 JS::Handle<JSObject*> aGivenProto) override;
41 nsISupports* GetParentObject() const { return mParent; }
43 const ffi::FluentResource* Raw() const { return mRaw; }
45 protected:
46 virtual ~FluentResource() = default;
48 nsCOMPtr<nsISupports> mParent;
49 RefPtr<const ffi::FluentResource> mRaw;
50 bool mHasErrors;
53 } // namespace intl
54 } // namespace mozilla
56 #endif