2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
The base XUL element class and associates.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsXULElement_h__
|
|
|
|
#define nsXULElement_h__
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
// XXX because nsEventListenerManager has broken includes
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMEvent.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsIControllers.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2007-05-14 02:11:38 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMXULElement.h"
|
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
2011-06-23 19:18:01 -07:00
|
|
|
#include "nsEventListenerManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIRDFCompositeDataSource.h"
|
|
|
|
#include "nsIRDFResource.h"
|
|
|
|
#include "nsBindingManager.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsIXULTemplateBuilder.h"
|
|
|
|
#include "nsIBoxObject.h"
|
|
|
|
#include "nsLayoutCID.h"
|
|
|
|
#include "nsAttrAndChildArray.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2010-02-23 20:37:46 -08:00
|
|
|
#include "nsStyledElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDOMScriptObjectHolder.h"
|
2008-03-21 04:18:10 -07:00
|
|
|
#include "nsIFrameLoader.h"
|
2011-10-29 13:12:47 -07:00
|
|
|
#include "jspubtd.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIDocument;
|
|
|
|
class nsString;
|
|
|
|
class nsIDocShell;
|
|
|
|
|
|
|
|
class nsIObjectInputStream;
|
|
|
|
class nsIObjectOutputStream;
|
|
|
|
class nsIScriptGlobalObjectOwner;
|
2008-10-08 04:41:52 -07:00
|
|
|
class nsXULPrototypeNode;
|
|
|
|
typedef nsTArray<nsRefPtr<nsXULPrototypeNode> > nsPrototypeArray;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-10 18:48:57 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
class StyleRule;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
|
|
|
|
#define XUL_PROTOTYPE_ATTRIBUTE_METER(counter) (nsXULPrototypeAttribute::counter++)
|
|
|
|
#else
|
|
|
|
#define XUL_PROTOTYPE_ATTRIBUTE_METER(counter) ((void) 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
A prototype attribute for an nsXULPrototypeElement.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsXULPrototypeAttribute
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXULPrototypeAttribute()
|
2012-07-19 02:18:01 -07:00
|
|
|
: mName(nsGkAtoms::id) // XXX this is a hack, but names have to have a value
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
XUL_PROTOTYPE_ATTRIBUTE_METER(gNumAttributes);
|
|
|
|
MOZ_COUNT_CTOR(nsXULPrototypeAttribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsXULPrototypeAttribute();
|
|
|
|
|
|
|
|
nsAttrName mName;
|
|
|
|
nsAttrValue mValue;
|
|
|
|
|
|
|
|
#ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t gNumElements;
|
|
|
|
static uint32_t gNumAttributes;
|
|
|
|
static uint32_t gNumCacheTests;
|
|
|
|
static uint32_t gNumCacheHits;
|
|
|
|
static uint32_t gNumCacheSets;
|
|
|
|
static uint32_t gNumCacheFills;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* !XUL_PROTOTYPE_ATTRIBUTE_METERING */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
A prototype content model element that holds the "primordial" values
|
2012-07-19 02:18:01 -07:00
|
|
|
that have been parsed from the original XUL document.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2012-08-24 09:50:06 -07:00
|
|
|
class nsXULPrototypeNode
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type { eType_Element, eType_Script, eType_Text, eType_PI };
|
|
|
|
|
|
|
|
Type mType;
|
|
|
|
|
|
|
|
virtual ~nsXULPrototypeNode() {}
|
|
|
|
virtual nsresult Serialize(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos) = 0;
|
|
|
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos) = 0;
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual const char* ClassName() = 0;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ClassSize() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2007-07-05 15:40:26 -07:00
|
|
|
/**
|
|
|
|
* The prototype document must call ReleaseSubtree when it is going
|
|
|
|
* away. This makes the parents through the tree stop owning their
|
|
|
|
* children, whether or not the parent's reference count is zero.
|
|
|
|
* Individual elements may still own individual prototypes, but
|
|
|
|
* those prototypes no longer remember their children to allow them
|
|
|
|
* to be constructed.
|
|
|
|
*/
|
2008-10-08 04:41:52 -07:00
|
|
|
virtual void ReleaseSubtree() { }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-24 09:50:06 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsXULPrototypeNode)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsXULPrototypeNode)
|
2007-05-24 07:10:02 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsXULPrototypeNode(Type aType)
|
2008-10-08 04:41:52 -07:00
|
|
|
: mType(aType) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsXULPrototypeElement : public nsXULPrototypeNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXULPrototypeElement()
|
|
|
|
: nsXULPrototypeNode(eType_Element),
|
|
|
|
mNumAttributes(0),
|
2011-10-17 07:59:28 -07:00
|
|
|
mHasIdAttribute(false),
|
|
|
|
mHasClassAttribute(false),
|
|
|
|
mHasStyleAttribute(false),
|
2012-07-30 07:20:58 -07:00
|
|
|
mAttributes(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsXULPrototypeElement()
|
|
|
|
{
|
2007-10-29 06:45:07 -07:00
|
|
|
Unlink();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual const char* ClassName() { return "nsXULPrototypeElement"; }
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ClassSize() { return sizeof(*this); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual void ReleaseSubtree()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = mChildren.Length() - 1; i >= 0; i--) {
|
2008-10-08 04:41:52 -07:00
|
|
|
if (mChildren[i].get())
|
|
|
|
mChildren[i]->ReleaseSubtree();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-10-08 04:41:52 -07:00
|
|
|
mChildren.Clear();
|
|
|
|
nsXULPrototypeNode::ReleaseSubtree();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult Serialize(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult SetAttrAt(uint32_t aPos, const nsAString& aValue, nsIURI* aDocumentURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-29 06:45:07 -07:00
|
|
|
void Unlink();
|
|
|
|
|
2008-10-08 04:41:52 -07:00
|
|
|
nsPrototypeArray mChildren;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> mNodeInfo; // [OWNER]
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mNumAttributes:29;
|
|
|
|
uint32_t mHasIdAttribute:1;
|
|
|
|
uint32_t mHasClassAttribute:1;
|
|
|
|
uint32_t mHasStyleAttribute:1;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXULPrototypeAttribute* mAttributes; // [OWNER]
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsXULDocument;
|
|
|
|
|
|
|
|
class nsXULPrototypeScript : public nsXULPrototypeNode
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsXULPrototypeScript(uint32_t aLineNo, uint32_t version);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsXULPrototypeScript();
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual const char* ClassName() { return "nsXULPrototypeScript"; }
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ClassSize() { return sizeof(*this); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsresult Serialize(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
nsresult SerializeOutOfLine(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal);
|
|
|
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
nsresult DeserializeOutOfLine(nsIObjectInputStream* aInput,
|
|
|
|
nsIScriptGlobalObject* aGlobal);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult Compile(const PRUnichar* aText, int32_t aTextLength,
|
|
|
|
nsIURI* aURI, uint32_t aLineNo,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDocument* aDocument,
|
|
|
|
nsIScriptGlobalObjectOwner* aGlobalOwner);
|
|
|
|
|
2011-08-11 06:29:50 -07:00
|
|
|
void UnlinkJSObjects();
|
2007-10-29 06:45:07 -07:00
|
|
|
|
2011-12-18 02:05:12 -08:00
|
|
|
void Set(nsScriptObjectHolder<JSScript>& aHolder)
|
2007-10-29 06:45:07 -07:00
|
|
|
{
|
2011-12-18 02:05:12 -08:00
|
|
|
Set(aHolder.get());
|
2007-10-29 06:45:07 -07:00
|
|
|
}
|
2011-10-29 13:13:31 -07:00
|
|
|
void Set(JSScript* aObject);
|
2007-10-29 06:45:07 -07:00
|
|
|
|
|
|
|
struct ScriptObjectHolder
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
ScriptObjectHolder() : mObject(nullptr)
|
2007-10-29 06:45:07 -07:00
|
|
|
{
|
|
|
|
}
|
2011-10-29 13:12:47 -07:00
|
|
|
JSScript* mObject;
|
2007-10-29 06:45:07 -07:00
|
|
|
};
|
2012-04-24 15:31:28 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIURI> mSrcURI;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLineNo;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSrcLoading;
|
|
|
|
bool mOutOfLine;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXULDocument* mSrcLoadWaiters; // [OWNER] but not COMPtr
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLangVersion;
|
2007-10-29 06:45:07 -07:00
|
|
|
ScriptObjectHolder mScriptObject;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsXULPrototypeText : public nsXULPrototypeNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXULPrototypeText()
|
|
|
|
: nsXULPrototypeNode(eType_Text)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsXULPrototypeText()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual const char* ClassName() { return "nsXULPrototypeText"; }
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ClassSize() { return sizeof(*this); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsresult Serialize(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
|
|
|
|
nsString mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsXULPrototypePI : public nsXULPrototypeNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXULPrototypePI()
|
|
|
|
: nsXULPrototypeNode(eType_PI)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsXULPrototypePI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual const char* ClassName() { return "nsXULPrototypePI"; }
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t ClassSize() { return sizeof(*this); }
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual nsresult Serialize(nsIObjectOutputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
virtual nsresult Deserialize(nsIObjectInputStream* aStream,
|
|
|
|
nsIScriptGlobalObject* aGlobal,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
const nsCOMArray<nsINodeInfo> *aNodeInfos);
|
|
|
|
|
|
|
|
nsString mTarget;
|
|
|
|
nsString mData;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
The XUL element.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-06-18 09:23:04 -07:00
|
|
|
#define XUL_ELEMENT_TEMPLATE_GENERATED (1 << ELEMENT_TYPE_SPECIFIC_BITS_OFFSET)
|
2010-06-18 09:23:04 -07:00
|
|
|
|
|
|
|
// Make sure we have space for our bit
|
2010-06-18 09:23:04 -07:00
|
|
|
PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET < 32);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsScriptEventHandlerOwnerTearoff;
|
|
|
|
|
2010-02-23 20:37:46 -08:00
|
|
|
class nsXULElement : public nsStyledElement, public nsIDOMXULElement
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/** Typesafe, non-refcounting cast from nsIContent. Cheaper than QI. **/
|
|
|
|
static nsXULElement* FromContent(nsIContent *aContent)
|
|
|
|
{
|
2009-08-24 13:02:07 -07:00
|
|
|
if (aContent->IsXUL())
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsXULElement*>(aContent);
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-07-23 02:49:57 -07:00
|
|
|
nsXULElement(already_AddRefed<nsINodeInfo> aNodeInfo);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsresult
|
|
|
|
Create(nsXULPrototypeElement* aPrototype, nsIDocument* aDocument,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsScriptable, mozilla::dom::Element** aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-05-24 07:10:02 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXULElement,
|
|
|
|
nsGenericElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsINode
|
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
|
|
|
|
|
|
|
// nsIContent
|
2008-03-21 04:18:10 -07:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCompileEventHandlers);
|
|
|
|
virtual void UnbindFromTree(bool aDeep, bool aNullParent);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
|
2007-11-30 09:57:03 -08:00
|
|
|
virtual void DestroyContent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void List(FILE* out, int32_t aIndent) const;
|
|
|
|
virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
|
|
|
bool aIsTrustedEvent);
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult ClickWithInputSource(uint16_t aInputSource);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nsIContent *GetBindingParent() const;
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const;
|
|
|
|
virtual bool IsFocusable(int32_t *aTabIndex = nullptr, bool aWithMouse = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
|
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType) const;
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// XUL element methods
|
2008-10-20 08:36:05 -07:00
|
|
|
/**
|
|
|
|
* The template-generated flag is used to indicate that a
|
|
|
|
* template-generated element has already had its children generated.
|
|
|
|
*/
|
|
|
|
void SetTemplateGenerated() { SetFlags(XUL_ELEMENT_TEMPLATE_GENERATED); }
|
|
|
|
void ClearTemplateGenerated() { UnsetFlags(XUL_ELEMENT_TEMPLATE_GENERATED); }
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetTemplateGenerated() { return HasFlag(XUL_ELEMENT_TEMPLATE_GENERATED); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIDOMNode
|
|
|
|
NS_FORWARD_NSIDOMNODE(nsGenericElement::)
|
|
|
|
|
|
|
|
// nsIDOMElement
|
|
|
|
NS_FORWARD_NSIDOMELEMENT(nsGenericElement::)
|
|
|
|
|
|
|
|
// nsIDOMXULElement
|
|
|
|
NS_DECL_NSIDOMXULELEMENT
|
|
|
|
|
|
|
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
2010-10-20 04:26:32 -07:00
|
|
|
virtual nsEventStates IntrinsicState() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-03-21 04:18:10 -07:00
|
|
|
nsresult GetFrameLoader(nsIFrameLoader** aFrameLoader);
|
2009-10-20 14:33:59 -07:00
|
|
|
already_AddRefed<nsFrameLoader> GetFrameLoader();
|
2008-08-11 01:38:43 -07:00
|
|
|
nsresult SwapFrameLoaders(nsIFrameLoaderOwner* aOtherOwner);
|
2008-03-21 04:18:10 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void RecompileScriptEventListeners();
|
|
|
|
|
2007-05-15 18:13:47 -07:00
|
|
|
// This function should ONLY be used by BindToTree implementations.
|
2007-05-21 15:22:51 -07:00
|
|
|
// The function exists solely because XUL elements store the binding
|
|
|
|
// parent as a member instead of in the slots, as nsGenericElement does.
|
2007-05-15 18:13:47 -07:00
|
|
|
void SetXULBindingParent(nsIContent* aBindingParent)
|
|
|
|
{
|
|
|
|
mBindingParent = aBindingParent;
|
|
|
|
}
|
|
|
|
|
2010-07-23 02:49:57 -07:00
|
|
|
virtual nsXPCClassInfo* GetClassInfo();
|
2012-04-25 06:47:30 -07:00
|
|
|
|
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
2008-08-04 17:58:16 -07:00
|
|
|
// This can be removed if EnsureContentsGenerated dies.
|
|
|
|
friend class nsNSElementTearoff;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Implementation methods
|
|
|
|
nsresult EnsureContentsGenerated(void) const;
|
|
|
|
|
|
|
|
nsresult ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsAString& attrName);
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
ExecuteJSCode(nsIDOMElement* anElement, nsEvent* aEvent);
|
|
|
|
|
|
|
|
// Helper routine that crawls a parent chain looking for a tree element.
|
|
|
|
NS_IMETHOD GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement);
|
|
|
|
|
|
|
|
nsresult AddPopupListener(nsIAtom* aName);
|
|
|
|
|
|
|
|
class nsXULSlots : public nsGenericElement::nsDOMSlots
|
|
|
|
{
|
|
|
|
public:
|
2011-08-28 07:07:24 -07:00
|
|
|
nsXULSlots();
|
|
|
|
virtual ~nsXULSlots();
|
2008-03-21 04:18:10 -07:00
|
|
|
|
2011-08-28 07:07:24 -07:00
|
|
|
void Traverse(nsCycleCollectionTraversalCallback &cb);
|
|
|
|
|
|
|
|
nsRefPtr<nsFrameLoader> mFrameLoader;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual nsINode::nsSlots* CreateSlots();
|
|
|
|
|
2008-03-21 04:18:10 -07:00
|
|
|
nsresult LoadSrc();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* The nearest enclosing content node with a binding
|
|
|
|
* that created us. [Weak]
|
|
|
|
*/
|
|
|
|
nsIContent* mBindingParent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abandon our prototype linkage, and copy all attributes locally
|
|
|
|
*/
|
2012-07-14 08:28:54 -07:00
|
|
|
nsresult MakeHeavyweight(nsXULPrototypeElement* aPrototype);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2012-02-13 18:00:56 -08:00
|
|
|
const nsAttrValueOrString* aValue,
|
|
|
|
bool aNotify);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2012-02-13 18:00:56 -08:00
|
|
|
const nsAttrValue* aValue, bool aNotify);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void UpdateEditableState(bool aNotify);
|
2011-05-31 18:46:57 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult);
|
|
|
|
|
2011-07-29 12:37:17 -07:00
|
|
|
virtual nsEventListenerManager*
|
2011-09-28 23:19:26 -07:00
|
|
|
GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a listener for the specified attribute, if appropriate.
|
|
|
|
*/
|
|
|
|
void AddListenerFor(const nsAttrName& aName,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCompileEventHandlers);
|
2007-03-22 10:30:00 -07:00
|
|
|
void MaybeAddPopupListener(nsIAtom* aLocalName);
|
|
|
|
|
2009-10-21 00:05:34 -07:00
|
|
|
nsIWidget* GetWindowWidget();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-24 19:01:07 -07:00
|
|
|
// attribute setters for widget
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult HideWindowChrome(bool aShouldHide);
|
2012-02-13 18:00:56 -08:00
|
|
|
void SetChromeMargins(const nsAttrValue* aValue);
|
2010-06-24 19:01:07 -07:00
|
|
|
void ResetChromeMargins();
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetTitlebarColor(nscolor aColor, bool aActive);
|
2007-10-29 21:03:42 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetDrawsInTitlebar(bool aState);
|
2009-10-21 00:05:34 -07:00
|
|
|
|
2008-01-29 07:12:34 -08:00
|
|
|
void RemoveBroadcaster(const nsAString & broadcasterId);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
// Internal accessor. This shadows the 'Slots', and returns
|
|
|
|
// appropriate value.
|
|
|
|
nsIControllers *Controllers() {
|
|
|
|
nsDOMSlots* slots = GetExistingDOMSlots();
|
2012-07-30 07:20:58 -07:00
|
|
|
return slots ? slots->mControllers : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void UnregisterAccessKey(const nsAString& aOldValue);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool BoolAttrIsTrue(nsIAtom* aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
friend nsresult
|
|
|
|
NS_NewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
|
2010-08-19 16:12:46 -07:00
|
|
|
friend void
|
|
|
|
NS_TrustedNewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static already_AddRefed<nsXULElement>
|
|
|
|
Create(nsXULPrototypeElement* aPrototype, nsINodeInfo *aNodeInfo,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsScriptable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-31 18:46:57 -07:00
|
|
|
bool IsReadWriteTextElement() const
|
|
|
|
{
|
|
|
|
const nsIAtom* tag = Tag();
|
|
|
|
return
|
|
|
|
GetNameSpaceID() == kNameSpaceID_XUL &&
|
|
|
|
(tag == nsGkAtoms::textbox || tag == nsGkAtoms::textarea) &&
|
|
|
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::readonly);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsXULElement_h__
|