michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsXBLProtoImplMember_h__ michael@0: #define nsXBLProtoImplMember_h__ michael@0: michael@0: #include "nsIAtom.h" michael@0: #include "nsString.h" michael@0: #include "nsString.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsContentUtils.h" // For NS_CONTENT_DELETE_LIST_MEMBER. michael@0: #include "nsCycleCollectionParticipant.h" michael@0: michael@0: class nsIContent; michael@0: class nsIObjectOutputStream; michael@0: michael@0: struct nsXBLTextWithLineNumber michael@0: { michael@0: char16_t* mText; michael@0: uint32_t mLineNumber; michael@0: michael@0: nsXBLTextWithLineNumber() : michael@0: mText(nullptr), michael@0: mLineNumber(0) michael@0: { michael@0: MOZ_COUNT_CTOR(nsXBLTextWithLineNumber); michael@0: } michael@0: michael@0: ~nsXBLTextWithLineNumber() { michael@0: MOZ_COUNT_DTOR(nsXBLTextWithLineNumber); michael@0: if (mText) { michael@0: nsMemory::Free(mText); michael@0: } michael@0: } michael@0: michael@0: void AppendText(const nsAString& aText) { michael@0: if (mText) { michael@0: char16_t* temp = mText; michael@0: mText = ToNewUnicode(nsDependentString(temp) + aText); michael@0: nsMemory::Free(temp); michael@0: } else { michael@0: mText = ToNewUnicode(aText); michael@0: } michael@0: } michael@0: michael@0: char16_t* GetText() { michael@0: return mText; michael@0: } michael@0: michael@0: void SetLineNumber(uint32_t aLineNumber) { michael@0: mLineNumber = aLineNumber; michael@0: } michael@0: michael@0: uint32_t GetLineNumber() { michael@0: return mLineNumber; michael@0: } michael@0: }; michael@0: michael@0: class nsXBLProtoImplMember michael@0: { michael@0: public: michael@0: nsXBLProtoImplMember(const char16_t* aName) michael@0: : mNext(nullptr) michael@0: , mExposeToUntrustedContent(false) michael@0: { michael@0: mName = ToNewUnicode(nsDependentString(aName)); michael@0: } michael@0: virtual ~nsXBLProtoImplMember() { michael@0: nsMemory::Free(mName); michael@0: NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext); michael@0: } michael@0: michael@0: nsXBLProtoImplMember* GetNext() { return mNext; } michael@0: void SetNext(nsXBLProtoImplMember* aNext) { mNext = aNext; } michael@0: bool ShouldExposeToUntrustedContent() { return mExposeToUntrustedContent; } michael@0: void SetExposeToUntrustedContent(bool aExpose) { mExposeToUntrustedContent = aExpose; } michael@0: const char16_t* GetName() { return mName; } michael@0: michael@0: virtual nsresult InstallMember(JSContext* aCx, michael@0: JS::Handle aTargetClassObject) = 0; michael@0: virtual nsresult CompileMember(const nsCString& aClassStr, michael@0: JS::Handle aClassObject) = 0; michael@0: michael@0: virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0; michael@0: michael@0: virtual nsresult Write(nsIObjectOutputStream* aStream) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: protected: michael@0: nsXBLProtoImplMember* mNext; // The members of an implementation are chained. michael@0: char16_t* mName; // The name of the field, method, or property. michael@0: michael@0: bool mExposeToUntrustedContent; // If this binding is installed on an element michael@0: // in an untrusted scope, should this michael@0: // implementation member be accessible to the michael@0: // content? michael@0: }; michael@0: michael@0: #endif // nsXBLProtoImplMember_h__