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 nsXBLBinding_h_
|
|
|
|
#define nsXBLBinding_h_
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2009-01-29 11:46:18 -08:00
|
|
|
#include "nsINodeList.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStyleRuleProcessor.h"
|
|
|
|
#include "nsClassHashtable.h"
|
|
|
|
#include "nsTArray.h"
|
2007-05-24 07:10:02 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2010-04-01 11:05:40 -07:00
|
|
|
#include "nsISupportsImpl.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsXBLPrototypeBinding;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsObjectHashtable;
|
|
|
|
class nsXBLInsertionPoint;
|
|
|
|
typedef nsTArray<nsRefPtr<nsXBLInsertionPoint> > nsInsertionPointList;
|
|
|
|
struct JSContext;
|
|
|
|
struct JSObject;
|
|
|
|
|
|
|
|
// *********************************************************************/
|
|
|
|
// The XBLBinding class
|
|
|
|
|
|
|
|
class nsXBLBinding
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXBLBinding(nsXBLPrototypeBinding* aProtoBinding);
|
|
|
|
~nsXBLBinding();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XBLBindings are refcounted. They are held onto in 3 ways:
|
|
|
|
* 1. The binding manager's binding table holds onto all bindings that are
|
|
|
|
* currently attached to a content node.
|
|
|
|
* 2. Bindings hold onto their base binding. This is important since
|
|
|
|
* the base binding itself may not be attached to anything.
|
|
|
|
* 3. The binding manager holds an additional reference to bindings
|
|
|
|
* which are queued to fire their constructors.
|
|
|
|
*/
|
|
|
|
|
2012-08-24 09:50:06 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsXBLBinding)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-24 07:10:02 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLBinding)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLPrototypeBinding* PrototypeBinding() { return mPrototypeBinding; }
|
|
|
|
nsIContent* GetAnonymousContent() { return mContent.get(); }
|
|
|
|
|
|
|
|
nsXBLBinding* GetBaseBinding() { return mNextBinding; }
|
|
|
|
void SetBaseBinding(nsXBLBinding *aBinding);
|
|
|
|
|
|
|
|
nsIContent* GetBoundElement() { return mBoundElement; }
|
|
|
|
void SetBoundElement(nsIContent *aElement);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsStyleBinding() const { return mIsStyleBinding; }
|
|
|
|
void SetIsStyleBinding(bool aIsStyle) { mIsStyleBinding = aIsStyle; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void MarkForDeath();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool MarkedForDeath() const { return mMarkedForDeath; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasStyleSheets() const;
|
|
|
|
bool InheritsStyle() const;
|
|
|
|
bool ImplementsInterface(REFNSIID aIID) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void GenerateAnonymousContent();
|
|
|
|
void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement);
|
2009-01-06 11:37:28 -08:00
|
|
|
static void UninstallAnonymousContent(nsIDocument* aDocument,
|
|
|
|
nsIContent* aAnonParent);
|
2008-03-14 16:08:57 -07:00
|
|
|
void InstallEventHandlers();
|
|
|
|
nsresult InstallImplementation();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ExecuteAttachedHandler();
|
|
|
|
void ExecuteDetachedHandler();
|
|
|
|
void UnhookEventHandlers();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIAtom* GetBaseTag(int32_t* aNameSpaceID);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLBinding* RootBinding();
|
|
|
|
nsXBLBinding* GetFirstStyleBinding();
|
|
|
|
|
2007-09-28 06:45:01 -07:00
|
|
|
// Resolve all the fields for this binding and all ancestor bindings on the
|
|
|
|
// object |obj|. False return means a JS exception was set.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ResolveAllFields(JSContext *cx, JSObject *obj) const;
|
2007-09-28 06:45:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Get the list of insertion points for aParent. The nsInsertionPointList
|
|
|
|
// is owned by the binding, you should not delete it.
|
2012-06-10 16:44:50 -07:00
|
|
|
void GetInsertionPointsFor(nsIContent* aParent,
|
|
|
|
nsInsertionPointList** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-21 15:26:48 -07:00
|
|
|
nsInsertionPointList* GetExistingInsertionPointsFor(nsIContent* aParent);
|
|
|
|
|
2009-01-29 11:46:20 -08:00
|
|
|
// XXXbz this aIndex has nothing to do with an index into the child
|
|
|
|
// list of the insertion parent or anything.
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIContent* GetInsertionPoint(const nsIContent* aChild, uint32_t* aIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIContent* GetSingleInsertionPoint(uint32_t* aIndex,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aMultipleInsertionPoints);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void AttributeChanged(nsIAtom* aAttribute, int32_t aNameSpaceID,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRemoveFlag, bool aNotify);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument);
|
|
|
|
|
|
|
|
void WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData);
|
|
|
|
|
2009-01-29 11:46:18 -08:00
|
|
|
nsINodeList* GetAnonymousNodes();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static nsresult DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
|
|
|
const nsAFlatCString& aClassName,
|
2007-09-28 06:45:01 -07:00
|
|
|
nsXBLPrototypeBinding* aProtoBinding,
|
2011-11-15 23:50:20 -08:00
|
|
|
JSObject** aClassObject);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AllowScripts(); // XXX make const
|
2007-05-21 15:26:48 -07:00
|
|
|
|
2007-10-12 04:07:29 -07:00
|
|
|
void RemoveInsertionParent(nsIContent* aParent);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasInsertionParent(nsIContent* aParent);
|
2007-10-12 04:07:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// MEMBER VARIABLES
|
|
|
|
protected:
|
2007-10-26 17:14:43 -07:00
|
|
|
|
2012-04-17 12:23:11 -07:00
|
|
|
bool mIsStyleBinding;
|
|
|
|
bool mMarkedForDeath;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
|
|
|
|
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
|
|
|
|
nsRefPtr<nsXBLBinding> mNextBinding; // Strong. The derived binding owns the base class bindings.
|
|
|
|
|
|
|
|
nsIContent* mBoundElement; // [WEAK] We have a reference, but we don't own it.
|
|
|
|
|
|
|
|
// A hash from nsIContent* -> (a sorted array of nsXBLInsertionPoint)
|
|
|
|
nsClassHashtable<nsISupportsHashKey, nsInsertionPointList>* mInsertionPointTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXBLBinding_h_
|