2001-11-13 04:09:56 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-11-13 04:09:56 +00:00
|
|
|
|
|
|
|
#ifndef nsXBLProtoImpl_h__
|
|
|
|
#define nsXBLProtoImpl_h__
|
|
|
|
|
|
|
|
#include "nsMemory.h"
|
2003-02-28 01:04:45 +00:00
|
|
|
#include "nsXBLPrototypeHandler.h"
|
2001-11-13 04:09:56 +00:00
|
|
|
#include "nsXBLProtoImplMember.h"
|
2007-09-28 13:45:01 +00:00
|
|
|
#include "nsXBLProtoImplField.h"
|
2013-02-08 14:24:20 +00:00
|
|
|
#include "nsXBLBinding.h"
|
2001-11-13 04:09:56 +00:00
|
|
|
|
2007-09-28 13:45:01 +00:00
|
|
|
class nsXBLPrototypeBinding;
|
|
|
|
class nsXBLProtoImplAnonymousMethod;
|
2005-06-09 15:42:19 +00:00
|
|
|
|
2014-03-04 17:49:39 +00:00
|
|
|
class nsXBLProtoImpl MOZ_FINAL
|
2001-11-13 04:09:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-08-12 11:09:14 +00:00
|
|
|
nsXBLProtoImpl()
|
2014-04-11 14:59:47 +00:00
|
|
|
: mPrecompiledMemberHolder(nullptr),
|
2012-07-30 14:20:58 +00:00
|
|
|
mMembers(nullptr),
|
|
|
|
mFields(nullptr),
|
|
|
|
mConstructor(nullptr),
|
|
|
|
mDestructor(nullptr)
|
2013-08-12 11:09:14 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsXBLProtoImpl);
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2013-08-12 11:09:14 +00:00
|
|
|
~nsXBLProtoImpl()
|
|
|
|
{
|
2004-09-10 15:29:19 +00:00
|
|
|
MOZ_COUNT_DTOR(nsXBLProtoImpl);
|
|
|
|
// Note: the constructor and destructor are in mMembers, so we'll
|
|
|
|
// clean them up automatically.
|
2007-09-28 13:45:01 +00:00
|
|
|
delete mMembers;
|
|
|
|
delete mFields;
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2013-08-12 11:09:14 +00:00
|
|
|
|
2014-01-06 19:54:42 +00:00
|
|
|
|
2013-02-08 14:24:20 +00:00
|
|
|
nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
|
2014-01-06 19:54:42 +00:00
|
|
|
|
|
|
|
private:
|
2013-08-09 16:25:13 +00:00
|
|
|
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
2013-08-12 11:09:14 +00:00
|
|
|
nsIContent* aBoundElement,
|
2013-04-05 13:21:03 +00:00
|
|
|
JS::MutableHandle<JSObject*> aTargetClassObject,
|
2013-02-08 14:24:20 +00:00
|
|
|
bool* aTargetIsNew);
|
2014-01-06 19:54:42 +00:00
|
|
|
|
|
|
|
public:
|
2003-03-06 23:59:18 +00:00
|
|
|
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
|
2001-11-13 04:09:56 +00:00
|
|
|
|
2013-11-11 08:04:41 +00:00
|
|
|
bool LookupMember(JSContext* aCx, nsString& aName, JS::Handle<jsid> aNameAsId,
|
|
|
|
JS::MutableHandle<JSPropertyDescriptor> aDesc,
|
2014-03-17 16:17:58 +00:00
|
|
|
JS::Handle<JSObject*> aClassObject);
|
2013-02-08 14:24:21 +00:00
|
|
|
|
2007-09-28 13:45:01 +00:00
|
|
|
void SetMemberList(nsXBLProtoImplMember* aMemberList)
|
|
|
|
{
|
|
|
|
delete mMembers;
|
|
|
|
mMembers = aMemberList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetFieldList(nsXBLProtoImplField* aFieldList)
|
|
|
|
{
|
|
|
|
delete mFields;
|
|
|
|
mFields = aFieldList;
|
|
|
|
}
|
2001-11-13 04:09:56 +00:00
|
|
|
|
2013-05-27 11:50:49 +00:00
|
|
|
void Trace(const TraceCallbacks& aCallbacks, void *aClosure);
|
2008-01-30 02:05:43 +00:00
|
|
|
void UnlinkJSObjects();
|
2007-09-28 13:45:01 +00:00
|
|
|
|
|
|
|
nsXBLProtoImplField* FindField(const nsString& aFieldName) const;
|
|
|
|
|
|
|
|
// Resolve all the fields for this implementation on the object |obj| False
|
|
|
|
// return means a JS exception was set.
|
2013-04-05 13:21:03 +00:00
|
|
|
bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
|
2007-05-24 14:10:02 +00:00
|
|
|
|
2007-10-20 04:22:43 +00:00
|
|
|
// Undefine all our fields from object |obj| (which should be a
|
|
|
|
// JSObject for a bound element).
|
2013-04-05 13:21:03 +00:00
|
|
|
void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const;
|
2007-10-20 04:22:43 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool CompiledMembers() const {
|
2014-04-11 14:59:47 +00:00
|
|
|
return mPrecompiledMemberHolder != nullptr;
|
2007-10-06 01:23:09 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 16:25:13 +00:00
|
|
|
nsresult Read(nsIObjectInputStream* aStream,
|
2013-08-09 16:25:14 +00:00
|
|
|
nsXBLPrototypeBinding* aBinding);
|
2013-08-09 16:25:13 +00:00
|
|
|
nsresult Write(nsIObjectOutputStream* aStream,
|
2011-11-03 20:39:08 +00:00
|
|
|
nsXBLPrototypeBinding* aBinding);
|
|
|
|
|
2004-01-27 21:18:00 +00:00
|
|
|
protected:
|
2011-11-03 20:39:08 +00:00
|
|
|
// used by Read to add each member
|
|
|
|
nsXBLProtoImplMember* AddMember(nsXBLProtoImplMember* aMember,
|
|
|
|
nsXBLProtoImplMember* aPreviousMember)
|
|
|
|
{
|
|
|
|
if (aPreviousMember)
|
|
|
|
aPreviousMember->SetNext(aMember);
|
|
|
|
else
|
|
|
|
mMembers = aMember;
|
|
|
|
return aMember;
|
|
|
|
}
|
|
|
|
|
2008-02-12 16:02:41 +00:00
|
|
|
void DestroyMembers();
|
2013-08-12 11:09:14 +00:00
|
|
|
|
2001-11-13 04:09:56 +00:00
|
|
|
public:
|
2013-08-12 11:09:14 +00:00
|
|
|
nsCString mClassName; // The name of the class.
|
2005-02-06 20:34:15 +00:00
|
|
|
|
|
|
|
protected:
|
2014-04-11 14:59:47 +00:00
|
|
|
JSObject* mPrecompiledMemberHolder; // The class object for the binding. We'll use this to pre-compile properties
|
2011-11-16 07:50:20 +00:00
|
|
|
// and methods for the binding.
|
2001-11-13 04:09:56 +00:00
|
|
|
|
|
|
|
nsXBLProtoImplMember* mMembers; // The members of an implementation are chained in this singly-linked list.
|
2007-09-28 13:45:01 +00:00
|
|
|
|
|
|
|
nsXBLProtoImplField* mFields; // Our fields
|
2013-08-12 11:09:14 +00:00
|
|
|
|
2005-02-06 20:34:15 +00:00
|
|
|
public:
|
2004-09-10 15:29:19 +00:00
|
|
|
nsXBLProtoImplAnonymousMethod* mConstructor; // Our class constructor.
|
|
|
|
nsXBLProtoImplAnonymousMethod* mDestructor; // Our class destructor.
|
2001-11-13 04:09:56 +00:00
|
|
|
};
|
|
|
|
|
2003-09-27 04:18:26 +00:00
|
|
|
nsresult
|
2013-08-12 11:09:14 +00:00
|
|
|
NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t* aClassName,
|
2003-09-27 04:18:26 +00:00
|
|
|
nsXBLProtoImpl** aResult);
|
2001-11-13 04:09:56 +00:00
|
|
|
|
|
|
|
#endif // nsXBLProtoImpl_h__
|