gecko/dom/xbl/nsXBLPrototypeBinding.h
Robert O'Callahan 19391253d9 Bug 946065. Part 4: Move content/xbl to dom/ and flatten away 'src' directory. r=Ms2ger
--HG--
rename : content/xbl/src/XBLChildrenElement.cpp => dom/xbl/XBLChildrenElement.cpp
rename : content/xbl/src/XBLChildrenElement.h => dom/xbl/XBLChildrenElement.h
rename : content/xbl/builtin/android/jar.mn => dom/xbl/builtin/android/jar.mn
rename : content/xbl/builtin/android/moz.build => dom/xbl/builtin/android/moz.build
rename : content/xbl/builtin/android/platformHTMLBindings.xml => dom/xbl/builtin/android/platformHTMLBindings.xml
rename : content/xbl/builtin/browser-base.inc => dom/xbl/builtin/browser-base.inc
rename : content/xbl/builtin/editor-base.inc => dom/xbl/builtin/editor-base.inc
rename : content/xbl/builtin/emacs/jar.mn => dom/xbl/builtin/emacs/jar.mn
rename : content/xbl/builtin/emacs/moz.build => dom/xbl/builtin/emacs/moz.build
rename : content/xbl/builtin/emacs/platformHTMLBindings.xml => dom/xbl/builtin/emacs/platformHTMLBindings.xml
rename : content/xbl/builtin/input-fields-base.inc => dom/xbl/builtin/input-fields-base.inc
rename : content/xbl/builtin/mac/jar.mn => dom/xbl/builtin/mac/jar.mn
rename : content/xbl/builtin/mac/moz.build => dom/xbl/builtin/mac/moz.build
rename : content/xbl/builtin/mac/platformHTMLBindings.xml => dom/xbl/builtin/mac/platformHTMLBindings.xml
rename : content/xbl/builtin/moz.build => dom/xbl/builtin/moz.build
rename : content/xbl/builtin/textareas-base.inc => dom/xbl/builtin/textareas-base.inc
rename : content/xbl/builtin/unix/jar.mn => dom/xbl/builtin/unix/jar.mn
rename : content/xbl/builtin/unix/moz.build => dom/xbl/builtin/unix/moz.build
rename : content/xbl/builtin/unix/platformHTMLBindings.xml => dom/xbl/builtin/unix/platformHTMLBindings.xml
rename : content/xbl/builtin/win/jar.mn => dom/xbl/builtin/win/jar.mn
rename : content/xbl/builtin/win/moz.build => dom/xbl/builtin/win/moz.build
rename : content/xbl/builtin/win/platformHTMLBindings.xml => dom/xbl/builtin/win/platformHTMLBindings.xml
rename : content/xbl/crashtests/205735-1.xhtml => dom/xbl/crashtests/205735-1.xhtml
rename : content/xbl/crashtests/223799-1.xul => dom/xbl/crashtests/223799-1.xul
rename : content/xbl/crashtests/226744-1.xhtml => dom/xbl/crashtests/226744-1.xhtml
rename : content/xbl/crashtests/232095-1.xul => dom/xbl/crashtests/232095-1.xul
rename : content/xbl/crashtests/277523-1.xhtml => dom/xbl/crashtests/277523-1.xhtml
rename : content/xbl/crashtests/277950-1.xhtml => dom/xbl/crashtests/277950-1.xhtml
rename : content/xbl/crashtests/336744-1-inner.html => dom/xbl/crashtests/336744-1-inner.html
rename : content/xbl/crashtests/336744-1.html => dom/xbl/crashtests/336744-1.html
rename : content/xbl/crashtests/336960-1-inner.xhtml => dom/xbl/crashtests/336960-1-inner.xhtml
rename : content/xbl/crashtests/336960-1.html => dom/xbl/crashtests/336960-1.html
rename : content/xbl/crashtests/342954-1.xhtml => dom/xbl/crashtests/342954-1.xhtml
rename : content/xbl/crashtests/342954-2-xbl.xml => dom/xbl/crashtests/342954-2-xbl.xml
rename : content/xbl/crashtests/342954-2.xhtml => dom/xbl/crashtests/342954-2.xhtml
rename : content/xbl/crashtests/368276-1.xhtml => dom/xbl/crashtests/368276-1.xhtml
rename : content/xbl/crashtests/368641-1.xhtml => dom/xbl/crashtests/368641-1.xhtml
rename : content/xbl/crashtests/378521-1.xhtml => dom/xbl/crashtests/378521-1.xhtml
rename : content/xbl/crashtests/382376-1.xhtml => dom/xbl/crashtests/382376-1.xhtml
rename : content/xbl/crashtests/382376-2.xhtml => dom/xbl/crashtests/382376-2.xhtml
rename : content/xbl/crashtests/397596-1.xhtml => dom/xbl/crashtests/397596-1.xhtml
rename : content/xbl/crashtests/404125-1.xhtml => dom/xbl/crashtests/404125-1.xhtml
rename : content/xbl/crashtests/406900-1.xul => dom/xbl/crashtests/406900-1.xul
rename : content/xbl/crashtests/406904-1.xhtml => dom/xbl/crashtests/406904-1.xhtml
rename : content/xbl/crashtests/406904-2.xhtml => dom/xbl/crashtests/406904-2.xhtml
rename : content/xbl/crashtests/415192-1.xul => dom/xbl/crashtests/415192-1.xul
rename : content/xbl/crashtests/415301-1.xul => dom/xbl/crashtests/415301-1.xul
rename : content/xbl/crashtests/418133-1.xhtml => dom/xbl/crashtests/418133-1.xhtml
rename : content/xbl/crashtests/420233-1.xhtml => dom/xbl/crashtests/420233-1.xhtml
rename : content/xbl/crashtests/421997-1.xhtml => dom/xbl/crashtests/421997-1.xhtml
rename : content/xbl/crashtests/432813-1-xbl.xml => dom/xbl/crashtests/432813-1-xbl.xml
rename : content/xbl/crashtests/432813-1.xhtml => dom/xbl/crashtests/432813-1.xhtml
rename : content/xbl/crashtests/454820-1.html => dom/xbl/crashtests/454820-1.html
rename : content/xbl/crashtests/460665-1.xhtml => dom/xbl/crashtests/460665-1.xhtml
rename : content/xbl/crashtests/463511-1.xhtml => dom/xbl/crashtests/463511-1.xhtml
rename : content/xbl/crashtests/464863-1.xhtml => dom/xbl/crashtests/464863-1.xhtml
rename : content/xbl/crashtests/472260-1.xhtml => dom/xbl/crashtests/472260-1.xhtml
rename : content/xbl/crashtests/477878-1.html => dom/xbl/crashtests/477878-1.html
rename : content/xbl/crashtests/492978-1.xul => dom/xbl/crashtests/492978-1.xul
rename : content/xbl/crashtests/493123-1.xhtml => dom/xbl/crashtests/493123-1.xhtml
rename : content/xbl/crashtests/495354-1.xhtml => dom/xbl/crashtests/495354-1.xhtml
rename : content/xbl/crashtests/507628-1.xhtml => dom/xbl/crashtests/507628-1.xhtml
rename : content/xbl/crashtests/507991-1.xhtml => dom/xbl/crashtests/507991-1.xhtml
rename : content/xbl/crashtests/830614-1.xul => dom/xbl/crashtests/830614-1.xul
rename : content/xbl/crashtests/895805-1.xhtml => dom/xbl/crashtests/895805-1.xhtml
rename : content/xbl/crashtests/crashtests.list => dom/xbl/crashtests/crashtests.list
rename : content/xbl/crashtests/set-field-bad-this.xhtml => dom/xbl/crashtests/set-field-bad-this.xhtml
rename : content/xbl/src/moz.build => dom/xbl/moz.build
rename : content/xbl/src/nsBindingManager.cpp => dom/xbl/nsBindingManager.cpp
rename : content/xbl/src/nsBindingManager.h => dom/xbl/nsBindingManager.h
rename : content/xbl/src/nsXBLBinding.cpp => dom/xbl/nsXBLBinding.cpp
rename : content/xbl/src/nsXBLBinding.h => dom/xbl/nsXBLBinding.h
rename : content/xbl/src/nsXBLContentSink.cpp => dom/xbl/nsXBLContentSink.cpp
rename : content/xbl/src/nsXBLContentSink.h => dom/xbl/nsXBLContentSink.h
rename : content/xbl/src/nsXBLDocumentInfo.cpp => dom/xbl/nsXBLDocumentInfo.cpp
rename : content/xbl/src/nsXBLDocumentInfo.h => dom/xbl/nsXBLDocumentInfo.h
rename : content/xbl/src/nsXBLEventHandler.cpp => dom/xbl/nsXBLEventHandler.cpp
rename : content/xbl/src/nsXBLEventHandler.h => dom/xbl/nsXBLEventHandler.h
rename : content/xbl/src/nsXBLMaybeCompiled.h => dom/xbl/nsXBLMaybeCompiled.h
rename : content/xbl/src/nsXBLProtoImpl.cpp => dom/xbl/nsXBLProtoImpl.cpp
rename : content/xbl/src/nsXBLProtoImpl.h => dom/xbl/nsXBLProtoImpl.h
rename : content/xbl/src/nsXBLProtoImplField.cpp => dom/xbl/nsXBLProtoImplField.cpp
rename : content/xbl/src/nsXBLProtoImplField.h => dom/xbl/nsXBLProtoImplField.h
rename : content/xbl/src/nsXBLProtoImplMember.h => dom/xbl/nsXBLProtoImplMember.h
rename : content/xbl/src/nsXBLProtoImplMethod.cpp => dom/xbl/nsXBLProtoImplMethod.cpp
rename : content/xbl/src/nsXBLProtoImplMethod.h => dom/xbl/nsXBLProtoImplMethod.h
rename : content/xbl/src/nsXBLProtoImplProperty.cpp => dom/xbl/nsXBLProtoImplProperty.cpp
rename : content/xbl/src/nsXBLProtoImplProperty.h => dom/xbl/nsXBLProtoImplProperty.h
rename : content/xbl/src/nsXBLPrototypeBinding.cpp => dom/xbl/nsXBLPrototypeBinding.cpp
rename : content/xbl/src/nsXBLPrototypeBinding.h => dom/xbl/nsXBLPrototypeBinding.h
rename : content/xbl/src/nsXBLPrototypeHandler.cpp => dom/xbl/nsXBLPrototypeHandler.cpp
rename : content/xbl/src/nsXBLPrototypeHandler.h => dom/xbl/nsXBLPrototypeHandler.h
rename : content/xbl/src/nsXBLPrototypeResources.cpp => dom/xbl/nsXBLPrototypeResources.cpp
rename : content/xbl/src/nsXBLPrototypeResources.h => dom/xbl/nsXBLPrototypeResources.h
rename : content/xbl/src/nsXBLResourceLoader.cpp => dom/xbl/nsXBLResourceLoader.cpp
rename : content/xbl/src/nsXBLResourceLoader.h => dom/xbl/nsXBLResourceLoader.h
rename : content/xbl/src/nsXBLSerialize.cpp => dom/xbl/nsXBLSerialize.cpp
rename : content/xbl/src/nsXBLSerialize.h => dom/xbl/nsXBLSerialize.h
rename : content/xbl/src/nsXBLService.cpp => dom/xbl/nsXBLService.cpp
rename : content/xbl/src/nsXBLService.h => dom/xbl/nsXBLService.h
rename : content/xbl/src/nsXBLWindowKeyHandler.cpp => dom/xbl/nsXBLWindowKeyHandler.cpp
rename : content/xbl/src/nsXBLWindowKeyHandler.h => dom/xbl/nsXBLWindowKeyHandler.h
rename : content/xbl/test/bug310107-resource.xhtml => dom/xbl/test/bug310107-resource.xhtml
rename : content/xbl/test/chrome.ini => dom/xbl/test/chrome.ini
rename : content/xbl/test/file_bug372769.xhtml => dom/xbl/test/file_bug372769.xhtml
rename : content/xbl/test/file_bug379959_cross.html => dom/xbl/test/file_bug379959_cross.html
rename : content/xbl/test/file_bug379959_data.html => dom/xbl/test/file_bug379959_data.html
rename : content/xbl/test/file_bug379959_xbl.xml => dom/xbl/test/file_bug379959_xbl.xml
rename : content/xbl/test/file_bug397934.xhtml => dom/xbl/test/file_bug397934.xhtml
rename : content/xbl/test/file_bug481558.xbl => dom/xbl/test/file_bug481558.xbl
rename : content/xbl/test/file_bug481558css.sjs => dom/xbl/test/file_bug481558css.sjs
rename : content/xbl/test/file_bug591198_inner.html => dom/xbl/test/file_bug591198_inner.html
rename : content/xbl/test/file_bug591198_xbl.xml => dom/xbl/test/file_bug591198_xbl.xml
rename : content/xbl/test/file_bug821850.xhtml => dom/xbl/test/file_bug821850.xhtml
rename : content/xbl/test/file_bug844783.xhtml => dom/xbl/test/file_bug844783.xhtml
rename : content/xbl/test/file_bug944407.html => dom/xbl/test/file_bug944407.html
rename : content/xbl/test/file_bug944407.xml => dom/xbl/test/file_bug944407.xml
rename : content/xbl/test/file_bug950909.html => dom/xbl/test/file_bug950909.html
rename : content/xbl/test/file_bug950909.xml => dom/xbl/test/file_bug950909.xml
rename : content/xbl/test/mochitest.ini => dom/xbl/test/mochitest.ini
rename : content/xbl/test/moz.build => dom/xbl/test/moz.build
rename : content/xbl/test/test_bug310107.html => dom/xbl/test/test_bug310107.html
rename : content/xbl/test/test_bug366770.html => dom/xbl/test/test_bug366770.html
rename : content/xbl/test/test_bug371724.xhtml => dom/xbl/test/test_bug371724.xhtml
rename : content/xbl/test/test_bug372769.html => dom/xbl/test/test_bug372769.html
rename : content/xbl/test/test_bug378518.xul => dom/xbl/test/test_bug378518.xul
rename : content/xbl/test/test_bug378866.xhtml => dom/xbl/test/test_bug378866.xhtml
rename : content/xbl/test/test_bug379959.html => dom/xbl/test/test_bug379959.html
rename : content/xbl/test/test_bug389322.xhtml => dom/xbl/test/test_bug389322.xhtml
rename : content/xbl/test/test_bug397934.html => dom/xbl/test/test_bug397934.html
rename : content/xbl/test/test_bug398135.xul => dom/xbl/test/test_bug398135.xul
rename : content/xbl/test/test_bug398492.xul => dom/xbl/test/test_bug398492.xul
rename : content/xbl/test/test_bug400705.xhtml => dom/xbl/test/test_bug400705.xhtml
rename : content/xbl/test/test_bug401907.xhtml => dom/xbl/test/test_bug401907.xhtml
rename : content/xbl/test/test_bug403162.xhtml => dom/xbl/test/test_bug403162.xhtml
rename : content/xbl/test/test_bug468210.xhtml => dom/xbl/test/test_bug468210.xhtml
rename : content/xbl/test/test_bug481558.html => dom/xbl/test/test_bug481558.html
rename : content/xbl/test/test_bug526178.xhtml => dom/xbl/test/test_bug526178.xhtml
rename : content/xbl/test/test_bug542406.xhtml => dom/xbl/test/test_bug542406.xhtml
rename : content/xbl/test/test_bug591198.html => dom/xbl/test/test_bug591198.html
rename : content/xbl/test/test_bug639338.xhtml => dom/xbl/test/test_bug639338.xhtml
rename : content/xbl/test/test_bug721452.xul => dom/xbl/test/test_bug721452.xul
rename : content/xbl/test/test_bug723676.xul => dom/xbl/test/test_bug723676.xul
rename : content/xbl/test/test_bug772966.xul => dom/xbl/test/test_bug772966.xul
rename : content/xbl/test/test_bug790265.xhtml => dom/xbl/test/test_bug790265.xhtml
rename : content/xbl/test/test_bug821850.html => dom/xbl/test/test_bug821850.html
rename : content/xbl/test/test_bug844783.html => dom/xbl/test/test_bug844783.html
rename : content/xbl/test/test_bug944407.xul => dom/xbl/test/test_bug944407.xul
rename : content/xbl/test/test_bug950909.xul => dom/xbl/test/test_bug950909.xul
extra : rebase_source : 44ab05088f70826c70dee3af30221e628ec1e4e8
2014-01-10 16:03:25 +13:00

335 lines
12 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef nsXBLPrototypeBinding_h__
#define nsXBLPrototypeBinding_h__
#include "nsClassHashtable.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsICSSLoaderObserver.h"
#include "nsInterfaceHashtable.h"
#include "nsWeakReference.h"
#include "nsXBLDocumentInfo.h"
#include "nsXBLProtoImpl.h"
#include "nsXBLProtoImplMethod.h"
#include "nsXBLPrototypeHandler.h"
#include "nsXBLPrototypeResources.h"
class nsIAtom;
class nsIContent;
class nsIDocument;
class nsSupportsHashtable;
class nsXBLProtoImplField;
class nsXBLBinding;
class nsCSSStyleSheet;
// *********************************************************************/
// The XBLPrototypeBinding class
// Instances of this class are owned by the nsXBLDocumentInfo object returned
// by XBLDocumentInfo(). Consumers who want to refcount things should refcount
// that.
class nsXBLPrototypeBinding
{
public:
nsIContent* GetBindingElement() const { return mBinding; }
void SetBindingElement(nsIContent* aElement);
nsIURI* BindingURI() const { return mBindingURI; }
nsIURI* AlternateBindingURI() const { return mAlternateBindingURI; }
nsIURI* DocURI() const { return mXBLDocInfoWeak->DocumentURI(); }
nsIURI* GetBaseBindingURI() const { return mBaseBindingURI; }
// Checks if aURI refers to this binding by comparing to both possible
// binding URIs.
bool CompareBindingURI(nsIURI* aURI) const;
bool GetAllowScripts() const;
nsresult BindingAttached(nsIContent* aBoundElement);
nsresult BindingDetached(nsIContent* aBoundElement);
bool LoadResources();
nsresult AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
bool InheritsStyle() const { return mInheritStyle; }
void SetInheritsStyle(bool aInheritStyle) { mInheritStyle = aInheritStyle; }
nsXBLPrototypeHandler* GetPrototypeHandlers() { return mPrototypeHandler; }
void SetPrototypeHandlers(nsXBLPrototypeHandler* aHandler) { mPrototypeHandler = aHandler; }
nsXBLProtoImplAnonymousMethod* GetConstructor();
nsresult SetConstructor(nsXBLProtoImplAnonymousMethod* aConstructor);
nsXBLProtoImplAnonymousMethod* GetDestructor();
nsresult SetDestructor(nsXBLProtoImplAnonymousMethod* aDestructor);
nsXBLProtoImplField* FindField(const nsString& aFieldName) const
{
return mImplementation ? mImplementation->FindField(aFieldName) : nullptr;
}
// Resolve all the fields for this binding on the object |obj|.
// False return means a JS exception was set.
bool ResolveAllFields(JSContext* cx, JS::Handle<JSObject*> obj) const
{
return !mImplementation || mImplementation->ResolveAllFields(cx, obj);
}
// Undefine all our fields from object |obj| (which should be a
// JSObject for a bound element).
void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const {
if (mImplementation) {
mImplementation->UndefineFields(cx, obj);
}
}
const nsCString& ClassName() const {
return mImplementation ? mImplementation->mClassName : EmptyCString();
}
nsresult InitClass(const nsCString& aClassName, JSContext * aContext,
JS::Handle<JSObject*> aGlobal,
JS::Handle<JSObject*> aScriptObject,
JS::MutableHandle<JSObject*> aClassObject,
bool* aNew);
nsresult ConstructInterfaceTable(const nsAString& aImpls);
void SetImplementation(nsXBLProtoImpl* aImpl) { mImplementation = aImpl; }
nsXBLProtoImpl* GetImplementation() { return mImplementation; }
nsresult InstallImplementation(nsXBLBinding* aBinding);
bool HasImplementation() const { return mImplementation != nullptr; }
void AttributeChanged(nsIAtom* aAttribute, int32_t aNameSpaceID,
bool aRemoveFlag, nsIContent* aChangedElement,
nsIContent* aAnonymousContent, bool aNotify);
void SetBasePrototype(nsXBLPrototypeBinding* aBinding);
nsXBLPrototypeBinding* GetBasePrototype() { return mBaseBinding; }
nsXBLDocumentInfo* XBLDocumentInfo() const { return mXBLDocInfoWeak; }
bool IsChrome() { return mXBLDocInfoWeak->IsChrome(); }
void SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent);
nsIStyleRuleProcessor* GetRuleProcessor();
nsXBLPrototypeResources::sheet_array_type* GetOrCreateStyleSheets();
nsXBLPrototypeResources::sheet_array_type* GetStyleSheets();
bool HasStyleSheets() {
return mResources && mResources->mStyleSheetList.Length() > 0;
}
nsresult FlushSkinSheets();
nsIAtom* GetBaseTag(int32_t* aNamespaceID);
void SetBaseTag(int32_t aNamespaceID, nsIAtom* aTag);
bool ImplementsInterface(REFNSIID aIID) const;
nsresult AddResourceListener(nsIContent* aBoundElement);
void Initialize();
nsresult ResolveBaseBinding();
const nsCOMArray<nsXBLKeyEventHandler>* GetKeyEventHandlers()
{
if (!mKeyHandlersRegistered) {
CreateKeyHandlers();
mKeyHandlersRegistered = true;
}
return &mKeyHandlers;
}
/**
* Read this binding from the stream aStream into the xbl document aDocument.
* aDocInfo should be the xbl document info for the binding document.
* aFlags can contain XBLBinding_Serialize_InheritStyle to indicate that
* mInheritStyle flag should be set, and XBLBinding_Serialize_IsFirstBinding
* to indicate the first binding in a document.
* XBLBinding_Serialize_ChromeOnlyContent indicates that
* nsXBLPrototypeBinding::mChromeOnlyContent should be true.
*/
nsresult Read(nsIObjectInputStream* aStream,
nsXBLDocumentInfo* aDocInfo,
nsIDocument* aDocument,
uint8_t aFlags);
/**
* Write this binding to the stream.
*/
nsresult Write(nsIObjectOutputStream* aStream);
/**
* Read a content node from aStream and return it in aChild.
* aDocument and aNim are the document and node info manager for the document
* the child will be inserted into.
*/
nsresult ReadContentNode(nsIObjectInputStream* aStream,
nsIDocument* aDocument,
nsNodeInfoManager* aNim,
nsIContent** aChild);
/**
* Write the content node aNode to aStream.
*
* This method is called recursively for each child descendant. For the topmost
* call, aNode must be an element.
*
* Text, CDATA and comment nodes are serialized as:
* the constant XBLBinding_Serialize_TextNode, XBLBinding_Serialize_CDATANode
* or XBLBinding_Serialize_CommentNode
* the text for the node
* Elements are serialized in the following format:
* node's namespace, written with WriteNamespace
* node's namespace prefix
* node's tag
* 32-bit attribute count
* table of attributes:
* attribute's namespace, written with WriteNamespace
* attribute's namespace prefix
* attribute's tag
* attribute's value
* attribute forwarding table:
* source namespace
* source attribute
* destination namespace
* destination attribute
* the constant XBLBinding_Serialize_NoMoreAttributes
* 32-bit count of the number of child nodes
* each child node is serialized in the same manner in sequence
* the constant XBLBinding_Serialize_NoContent
*/
nsresult WriteContentNode(nsIObjectOutputStream* aStream, nsIContent* aNode);
/**
* Read or write a namespace id from or to aStream. If the namespace matches
* one of the built-in ones defined in nsINameSpaceManager.h, it will be written as
* a single byte with that value. Otherwise, XBLBinding_Serialize_CustomNamespace is
* written out, followed by a string written with writeWStringZ.
*/
nsresult ReadNamespace(nsIObjectInputStream* aStream, int32_t& aNameSpaceID);
nsresult WriteNamespace(nsIObjectOutputStream* aStream, int32_t aNameSpaceID);
public:
nsXBLPrototypeBinding();
~nsXBLPrototypeBinding();
// Init must be called after construction to initialize the prototype
// binding. It may well throw errors (eg on out-of-memory). Do not confuse
// this with the Initialize() method, which must be called after the
// binding's handlers, properties, etc are all set.
nsresult Init(const nsACString& aRef,
nsXBLDocumentInfo* aInfo,
nsIContent* aElement,
bool aFirstBinding = false);
void Traverse(nsCycleCollectionTraversalCallback &cb) const;
void UnlinkJSObjects();
void Trace(const TraceCallbacks& aCallbacks, void *aClosure) const;
// Internal member functions.
public:
/**
* GetImmediateChild locates the immediate child of our binding element which
* has the localname given by aTag and is in the XBL namespace.
*/
nsIContent* GetImmediateChild(nsIAtom* aTag);
nsIContent* LocateInstance(nsIContent* aBoundElt,
nsIContent* aTemplRoot,
nsIContent* aCopyRoot,
nsIContent* aTemplChild);
bool ChromeOnlyContent() { return mChromeOnlyContent; }
protected:
// Ensure that mAttributeTable has been created.
void EnsureAttributeTable();
// Ad an entry to the attribute table
void AddToAttributeTable(int32_t aSourceNamespaceID, nsIAtom* aSourceTag,
int32_t aDestNamespaceID, nsIAtom* aDestTag,
nsIContent* aContent);
void ConstructAttributeTable(nsIContent* aElement);
void CreateKeyHandlers();
// MEMBER VARIABLES
protected:
nsCOMPtr<nsIURI> mBindingURI;
nsCOMPtr<nsIURI> mAlternateBindingURI; // Alternate id-less URI that is only non-null on the first binding.
nsCOMPtr<nsIContent> mBinding; // Strong. We own a ref to our content element in the binding doc.
nsAutoPtr<nsXBLPrototypeHandler> mPrototypeHandler; // Strong. DocInfo owns us, and we own the handlers.
// the url of the base binding
nsCOMPtr<nsIURI> mBaseBindingURI;
nsXBLProtoImpl* mImplementation; // Our prototype implementation (includes methods, properties, fields,
// the constructor, and the destructor).
nsXBLPrototypeBinding* mBaseBinding; // Weak. The docinfo will own our base binding.
bool mInheritStyle;
bool mCheckedBaseProto;
bool mKeyHandlersRegistered;
bool mChromeOnlyContent;
nsXBLPrototypeResources* mResources; // If we have any resources, this will be non-null.
nsXBLDocumentInfo* mXBLDocInfoWeak; // A pointer back to our doc info. Weak, since it owns us.
nsObjectHashtable* mAttributeTable; // A table for attribute containers. Namespace IDs are used as
// keys in the table. Containers are nsObjectHashtables.
// This table is used to efficiently handle attribute changes.
class IIDHashKey : public PLDHashEntryHdr
{
public:
typedef const nsIID& KeyType;
typedef const nsIID* KeyTypePointer;
IIDHashKey(const nsIID* aKey)
: mKey(*aKey)
{}
IIDHashKey(const IIDHashKey& aOther)
: mKey(aOther.GetKey())
{}
~IIDHashKey()
{}
KeyType GetKey() const
{
return mKey;
}
bool KeyEquals(const KeyTypePointer aKey) const
{
return mKey.Equals(*aKey);
}
static KeyTypePointer KeyToPointer(KeyType aKey)
{
return &aKey;
}
static PLDHashNumber HashKey(const KeyTypePointer aKey)
{
// Just use the 32-bit m0 field.
return aKey->m0;
}
enum { ALLOW_MEMMOVE = true };
private:
nsIID mKey;
};
nsInterfaceHashtable<IIDHashKey, nsIContent> mInterfaceTable; // A table of cached interfaces that we support.
int32_t mBaseNameSpaceID; // If we extend a tagname/namespace, then that information will
nsCOMPtr<nsIAtom> mBaseTag; // be stored in here.
nsCOMArray<nsXBLKeyEventHandler> mKeyHandlers;
};
#endif