Bumping manifests a=b2g-bump
[gecko.git] / dom / xbl / nsXBLProtoImplMember.h
blobeebffb880f6a79281981bffce58640b5e835cfe7
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsXBLProtoImplMember_h__
7 #define nsXBLProtoImplMember_h__
9 #include "nsIAtom.h"
10 #include "nsString.h"
11 #include "nsString.h"
12 #include "nsIServiceManager.h"
13 #include "nsContentUtils.h" // For NS_CONTENT_DELETE_LIST_MEMBER.
14 #include "nsCycleCollectionParticipant.h"
16 class nsIContent;
17 class nsIObjectOutputStream;
19 struct nsXBLTextWithLineNumber
21 char16_t* mText;
22 uint32_t mLineNumber;
24 nsXBLTextWithLineNumber() :
25 mText(nullptr),
26 mLineNumber(0)
28 MOZ_COUNT_CTOR(nsXBLTextWithLineNumber);
31 ~nsXBLTextWithLineNumber() {
32 MOZ_COUNT_DTOR(nsXBLTextWithLineNumber);
33 if (mText) {
34 nsMemory::Free(mText);
38 void AppendText(const nsAString& aText) {
39 if (mText) {
40 char16_t* temp = mText;
41 mText = ToNewUnicode(nsDependentString(temp) + aText);
42 nsMemory::Free(temp);
43 } else {
44 mText = ToNewUnicode(aText);
48 char16_t* GetText() {
49 return mText;
52 void SetLineNumber(uint32_t aLineNumber) {
53 mLineNumber = aLineNumber;
56 uint32_t GetLineNumber() {
57 return mLineNumber;
61 class nsXBLProtoImplMember
63 public:
64 explicit nsXBLProtoImplMember(const char16_t* aName)
65 : mNext(nullptr)
66 , mExposeToUntrustedContent(false)
68 mName = ToNewUnicode(nsDependentString(aName));
70 virtual ~nsXBLProtoImplMember() {
71 nsMemory::Free(mName);
72 NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext);
75 nsXBLProtoImplMember* GetNext() { return mNext; }
76 void SetNext(nsXBLProtoImplMember* aNext) { mNext = aNext; }
77 bool ShouldExposeToUntrustedContent() { return mExposeToUntrustedContent; }
78 void SetExposeToUntrustedContent(bool aExpose) { mExposeToUntrustedContent = aExpose; }
79 const char16_t* GetName() { return mName; }
81 virtual nsresult InstallMember(JSContext* aCx,
82 JS::Handle<JSObject*> aTargetClassObject) = 0;
83 virtual nsresult CompileMember(mozilla::dom::AutoJSAPI& jsapi, const nsCString& aClassStr,
84 JS::Handle<JSObject*> aClassObject) = 0;
86 virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0;
88 virtual nsresult Write(nsIObjectOutputStream* aStream)
90 return NS_OK;
93 protected:
94 nsXBLProtoImplMember* mNext; // The members of an implementation are chained.
95 char16_t* mName; // The name of the field, method, or property.
97 bool mExposeToUntrustedContent; // If this binding is installed on an element
98 // in an untrusted scope, should this
99 // implementation member be accessible to the
100 // content?
103 #endif // nsXBLProtoImplMember_h__