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