2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsXBLProtoImplMember_h__
|
|
|
|
#define nsXBLProtoImplMember_h__
|
|
|
|
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2013-02-01 02:56:02 -08:00
|
|
|
#include "nsContentUtils.h" // For NS_CONTENT_DELETE_LIST_MEMBER.
|
2007-10-29 06:45:07 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-01 16:45:59 -07:00
|
|
|
class nsIContent;
|
2013-03-17 00:55:15 -07:00
|
|
|
class nsIObjectOutputStream;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct nsXBLTextWithLineNumber
|
|
|
|
{
|
2014-01-04 07:02:17 -08:00
|
|
|
char16_t* mText;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLineNumber;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsXBLTextWithLineNumber() :
|
2012-07-30 07:20:58 -07:00
|
|
|
mText(nullptr),
|
2007-03-22 10:30:00 -07:00
|
|
|
mLineNumber(0)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsXBLTextWithLineNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsXBLTextWithLineNumber() {
|
|
|
|
MOZ_COUNT_DTOR(nsXBLTextWithLineNumber);
|
|
|
|
if (mText) {
|
|
|
|
nsMemory::Free(mText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppendText(const nsAString& aText) {
|
|
|
|
if (mText) {
|
2014-01-04 07:02:17 -08:00
|
|
|
char16_t* temp = mText;
|
2007-03-22 10:30:00 -07:00
|
|
|
mText = ToNewUnicode(nsDependentString(temp) + aText);
|
|
|
|
nsMemory::Free(temp);
|
|
|
|
} else {
|
|
|
|
mText = ToNewUnicode(aText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
char16_t* GetText() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mText;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetLineNumber(uint32_t aLineNumber) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mLineNumber = aLineNumber;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetLineNumber() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mLineNumber;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsXBLProtoImplMember
|
|
|
|
{
|
|
|
|
public:
|
2014-01-04 07:02:17 -08:00
|
|
|
nsXBLProtoImplMember(const char16_t* aName)
|
2013-11-01 07:31:56 -07:00
|
|
|
: mNext(nullptr)
|
|
|
|
, mExposeToUntrustedContent(false)
|
|
|
|
{
|
|
|
|
mName = ToNewUnicode(nsDependentString(aName));
|
|
|
|
}
|
2008-12-15 03:33:56 -08:00
|
|
|
virtual ~nsXBLProtoImplMember() {
|
|
|
|
nsMemory::Free(mName);
|
|
|
|
NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
nsXBLProtoImplMember* GetNext() { return mNext; }
|
|
|
|
void SetNext(nsXBLProtoImplMember* aNext) { mNext = aNext; }
|
2013-11-01 07:31:56 -07:00
|
|
|
bool ShouldExposeToUntrustedContent() { return mExposeToUntrustedContent; }
|
|
|
|
void SetExposeToUntrustedContent(bool aExpose) { mExposeToUntrustedContent = aExpose; }
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* GetName() { return mName; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-08 06:24:21 -08:00
|
|
|
virtual nsresult InstallMember(JSContext* aCx,
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Handle<JSObject*> aTargetClassObject) = 0;
|
2013-08-09 09:25:13 -07:00
|
|
|
virtual nsresult CompileMember(const nsCString& aClassStr,
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Handle<JSObject*> aClassObject) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-27 04:50:49 -07:00
|
|
|
virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0;
|
2007-05-24 07:10:02 -07:00
|
|
|
|
2013-08-09 09:25:13 -07:00
|
|
|
virtual nsresult Write(nsIObjectOutputStream* aStream)
|
2011-11-03 13:39:08 -07:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsXBLProtoImplMember* mNext; // The members of an implementation are chained.
|
2014-01-04 07:02:17 -08:00
|
|
|
char16_t* mName; // The name of the field, method, or property.
|
2013-11-01 07:31:56 -07:00
|
|
|
|
|
|
|
bool mExposeToUntrustedContent; // If this binding is installed on an element
|
|
|
|
// in an untrusted scope, should this
|
|
|
|
// implementation member be accessible to the
|
|
|
|
// content?
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXBLProtoImplMember_h__
|