Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsXULElement Class Reference

#include <nsXULElement.h>

Inheritance diagram for nsXULElement:
Inheritance graph
[legend]
Collaboration diagram for nsXULElement:
Collaboration graph
[legend]

List of all members.

Public Types

enum  LazyState { eChildrenMustBeRebuilt = 0x1, eTemplateContentsBuilt = 0x2, eContainerContentsBuilt = 0x4 }
 These flags are used to maintain bookkeeping information for partially- constructed content. More...
enum  {
  eTEXT = 0x00000001, eELEMENT = 0x00000002, eHTML = 0x00000004, eHTML_FORM_CONTROL = 0x00000008,
  eXUL = 0x00000010, ePROCESSING_INSTRUCTION = 0x00000020, eSVG = 0x00000040, eCOMMENT = 0x00000080
}
 Bit-flags to pass (or'ed together) to IsContentOfType() More...
enum  ETabFocusType { eTabFocus_formElementsMask = (1<<1), eTabFocus_linksMask = (1<<2), eTabFocus_any = 1 + (1<<1) + (1<<2) }

Public Member Functions

virtual
NS_DECL_ISUPPORTS_INHERITED
nsresult 
BindToTree (nsIDocument *aDocument, nsIContent *aParent, nsIContent *aBindingParent, PRBool aCompileEventHandlers)
 Bind this content node to a tree.
virtual void UnbindFromTree (PRBool aDeep=PR_TRUE, PRBool aNullParent=PR_TRUE)
 Unbind this content node from a tree.
virtual PRBool IsNativeAnonymous () const
 Get whether this content is C++-generated anonymous content.
virtual PRUint32 GetChildCount () const
 Get the number of children.
virtual nsIContentGetChildAt (PRUint32 aIndex) const
 Get a child by index.
virtual PRInt32 IndexOf (nsIContent *aPossibleChild) const
 Get the index of a child within this content.
virtual nsresult InsertChildAt (nsIContent *aKid, PRUint32 aIndex, PRBool aNotify)
 Insert a content node at a particular index.
virtual nsresult AppendChildTo (nsIContent *aKid, PRBool aNotify)
 Append a content node to the end of the child list.
virtual nsresult RemoveChildAt (PRUint32 aIndex, PRBool aNotify)
 Remove a child from this content node.
virtual nsIAtomGetIDAttributeName () const
 Returns an atom holding the name of the attribute of type ID on this content node (if applicable).
virtual nsIAtomGetClassAttributeName () const
 Returns an atom holding the name of the "class" attribute on this content node (if applicable).
nsresult SetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, const nsAString &aValue, PRBool aNotify)
 Set attribute values.
virtual nsresult SetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, nsIAtom *aPrefix, const nsAString &aValue, PRBool aNotify)
 Set attribute values.
virtual nsresult GetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, nsAString &aResult) const
 Get the current value of the attribute.
virtual PRBool HasAttr (PRInt32 aNameSpaceID, nsIAtom *aName) const
 Determine if an attribute has been set (empty string or otherwise).
virtual nsresult UnsetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, PRBool aNotify)
 Remove an attribute so that it is no longer explicitly specified.
virtual nsresult GetAttrNameAt (PRUint32 aIndex, PRInt32 *aNameSpaceID, nsIAtom **aName, nsIAtom **aPrefix) const
 Get the namespace / name / prefix of a given attribute.
virtual PRUint32 GetAttrCount () const
 Get the number of all specified attributes.
virtual nsresult HandleDOMEvent (nsPresContext *aPresContext, nsEvent *aEvent, nsIDOMEvent **aDOMEvent, PRUint32 aFlags, nsEventStatus *aEventStatus)
 Handle a DOM event for this piece of content.
virtual PRUint32 ContentID () const
 Get a unique ID for this piece of content.
virtual void SetContentID (PRUint32 aID)
 Set the unique content ID for this content.
virtual nsresult RangeAdd (nsIDOMRange *aRange)
 Inform content of range ownership changes.
virtual void RangeRemove (nsIDOMRange *aRange)
 Inform content that it no longer owns either range endpoint.
virtual const nsVoidArrayGetRangeList () const
 Get the list of ranges that have either endpoint in this content item.
virtual void SetFocus (nsPresContext *aPresContext)
 Set the focus on this content.
virtual void RemoveFocus (nsPresContext *aPresContext)
 Remove the focus on this content.
virtual nsIContentGetBindingParent () const
 Gets content node with the binding responsible for our construction (and existence).
virtual PRBool IsContentOfType (PRUint32 aFlags) const
 API for doing a quick check if a content object is of a given type, such as HTML, XUL, Text, ...
virtual nsresult GetListenerManager (nsIEventListenerManager **aResult)
 Get the event listener manager, the guy you talk to to register for events on this element.
virtual PRBool IsFocusable (PRInt32 *aTabIndex=nsnull)
 Check if this content is focusable and in the current tab order.
NS_IMETHOD MaybeTriggerAutoLink (nsIDocShell *aShell)
 Give this element a chance to fire links that should be fired automatically when loaded.
virtual nsIAtomGetID () const
 XXX GetID must be defined here because nsXUL element does not inherit from nsGenericElement.
virtual const nsAttrValueGetClasses () const
 NS_IMETHOD_ (PRBool) HasClass(nsIAtom *aClass
NS_IMETHOD WalkContentStyleRules (nsRuleWalker *aRuleWalker)
virtual nsICSSStyleRuleGetInlineStyleRule ()
NS_IMETHOD SetInlineStyleRule (nsICSSStyleRule *aStyleRule, PRBool aNotify)
virtual nsChangeHint GetAttributeChangeHint (const nsIAtom *aAttribute, PRInt32 aModType) const
 Get a hint that tells the style system what to do when an attribute on this node changes, if something needs to happen in response to the change other than the result of what is mapped into style data via any type of style rule.
 NS_IMETHOD_ (PRBool) IsAttributeMapped(const nsIAtom *aAttribute) const
 Is the attribute named stored in the mapped attributes?
PRUint32 PeekChildCount () const
void SetLazyState (LazyState aFlags)
void ClearLazyState (LazyState aFlags)
PRBool GetLazyState (LazyState aFlag)
 NS_HIDDEN_ (nsresult) AddScriptEventListener(nsIAtom *aName
NS_DECL_NSIDOMXULELEMENT nsresult CompileEventHandler (nsIScriptContext *aContext, void *aTarget, nsIAtom *aName, const nsAString &aBody, const char *aURL, PRUint32 aLineNo, void **aHandler)
 Compile the specified event handler, and bind it to aTarget using aContext.
nsresult GetCompiledEventHandler (nsIAtom *aName, void **aHandler)
 Retrieve an already-compiled event handler that can be bound to a target object using a script context.
NS_DECL_ISUPPORTS nsresult PostQueryInterface (REFNSIID aIID, void **aInstancePtr)
 Called during QueryInterface to give the binding manager a chance to get an interface for this element.
virtual nsIDOMGCParticipantGetSCCIndex ()
 During the Mark phase of the GC, we need to mark all of the preserved wrappers that are reachable via DOM APIs.
virtual void AppendReachableList (nsCOMArray< nsIDOMGCParticipant > &aArray)
 Append the list of nsIDOMGCPartipants reachable from this one via C++ getters exposed to script that return a different result from |GetSCCIndex|.
nsIDocumentGetDocument () const
 DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.
PRBool IsInDoc () const
 Returns true if the content has an ancestor that is a document.
nsIDocumentGetOwnerDoc () const
 Get the ownerDocument for this content.
virtual void SetNativeAnonymous (PRBool aAnonymous)
 Set whether this content is anonymous.
virtual PRInt32 GetNameSpaceID () const
 Get the namespace that this element's tag is defined in.
virtual nsIAtomTag () const
 Get the tag for this element.
virtual nsINodeInfoGetNodeInfo () const
 Get the NodeInfo for this element.
virtual already_AddRefed
< nsINodeInfo
GetExistingAttrNameFromQName (const nsAString &aStr) const
 Normalizes an attribute name and returns it as a nodeinfo if an attribute with that name exists.
virtual already_AddRefed< nsIURIGetBaseURI () const
 Get the base URI for any relative URIs within this piece of content.
virtual voidGetProperty (nsIAtom *aPropertyName, nsresult *aStatus=nsnull) const
virtual nsresult SetProperty (nsIAtom *aPropertyName, void *aValue, NSPropertyDtorFunc aDtor)
virtual nsresult DeleteProperty (nsIAtom *aPropertyName)
virtual voidUnsetProperty (nsIAtom *aPropertyName, nsresult *aStatus=nsnull)
virtual void SetMayHaveFrame (PRBool aMayHaveFrame)
 Call to let the content node know that it may now have a frame.
virtual PRBool MayHaveFrame () const
 Returns PR_TRUE if there is a chance that the content node has a frame, PR_FALSE otherwise.
 IsAttributeMapped (const nsIAtom *aAttribute) const
NS_IMETHOD GetNodeName (nsAString &aNodeName)
NS_IMETHOD GetLocalName (nsAString &aLocalName)
NS_IMETHOD GetNodeValue (nsAString &aNodeValue)
NS_IMETHOD SetNodeValue (const nsAString &aNodeValue)
NS_IMETHOD GetNodeType (PRUint16 *aNodeType)
NS_IMETHOD GetParentNode (nsIDOMNode **aParentNode)
NS_IMETHOD GetAttributes (nsIDOMNamedNodeMap **aAttributes)
NS_IMETHOD GetPreviousSibling (nsIDOMNode **aPreviousSibling)
NS_IMETHOD GetNextSibling (nsIDOMNode **aNextSibling)
NS_IMETHOD GetOwnerDocument (nsIDOMDocument **aOwnerDocument)
NS_IMETHOD GetNamespaceURI (nsAString &aNamespaceURI)
NS_IMETHOD GetPrefix (nsAString &aPrefix)
NS_IMETHOD SetPrefix (const nsAString &aPrefix)
NS_IMETHOD Normalize ()
NS_IMETHOD IsSupported (const nsAString &aFeature, const nsAString &aVersion, PRBool *aReturn)
NS_IMETHOD HasAttributes (PRBool *aHasAttributes)
NS_IMETHOD GetChildNodes (nsIDOMNodeList **aChildNodes)
NS_IMETHOD HasChildNodes (PRBool *aHasChildNodes)
NS_IMETHOD GetFirstChild (nsIDOMNode **aFirstChild)
NS_IMETHOD GetLastChild (nsIDOMNode **aLastChild)
NS_IMETHOD InsertBefore (nsIDOMNode *aNewChild, nsIDOMNode *aRefChild, nsIDOMNode **aReturn)
NS_IMETHOD ReplaceChild (nsIDOMNode *aNewChild, nsIDOMNode *aOldChild, nsIDOMNode **aReturn)
NS_IMETHOD RemoveChild (nsIDOMNode *aOldChild, nsIDOMNode **aReturn)
NS_IMETHOD AppendChild (nsIDOMNode *aNewChild, nsIDOMNode **aReturn)
NS_IMETHOD GetTagName (nsAString &aTagName)
NS_IMETHOD GetAttribute (const nsAString &aName, nsAString &aReturn)
NS_IMETHOD SetAttribute (const nsAString &aName, const nsAString &aValue)
NS_IMETHOD RemoveAttribute (const nsAString &aName)
NS_IMETHOD GetAttributeNode (const nsAString &aName, nsIDOMAttr **aReturn)
NS_IMETHOD SetAttributeNode (nsIDOMAttr *aNewAttr, nsIDOMAttr **aReturn)
NS_IMETHOD RemoveAttributeNode (nsIDOMAttr *aOldAttr, nsIDOMAttr **aReturn)
NS_IMETHOD GetElementsByTagName (const nsAString &aTagname, nsIDOMNodeList **aReturn)
NS_IMETHOD GetAttributeNS (const nsAString &aNamespaceURI, const nsAString &aLocalName, nsAString &aReturn)
NS_IMETHOD SetAttributeNS (const nsAString &aNamespaceURI, const nsAString &aQualifiedName, const nsAString &aValue)
NS_IMETHOD RemoveAttributeNS (const nsAString &aNamespaceURI, const nsAString &aLocalName)
NS_IMETHOD GetAttributeNodeNS (const nsAString &aNamespaceURI, const nsAString &aLocalName, nsIDOMAttr **aReturn)
NS_IMETHOD SetAttributeNodeNS (nsIDOMAttr *aNewAttr, nsIDOMAttr **aReturn)
NS_IMETHOD GetElementsByTagNameNS (const nsAString &aNamespaceURI, const nsAString &aLocalName, nsIDOMNodeList **aReturn)
NS_IMETHOD HasAttribute (const nsAString &aName, PRBool *aReturn)
NS_IMETHOD HasAttributeNS (const nsAString &aNamespaceURI, const nsAString &aLocalName, PRBool *aReturn)
nsresult AddScriptEventListener (nsIAtom *aAttribute, const nsAString &aValue)
 Add a script event listener with the given attr name (like onclick) and with the value as JS.
nsresult TriggerLink (nsPresContext *aPresContext, nsLinkVerb aVerb, nsIURI *aLinkURI, const nsAFlatString &aTargetSpec, PRBool aClick, PRBool aIsUserTriggered)
 Trigger a link with uri aLinkURI.
nsresult LeaveLink (nsPresContext *aPresContext)
 Do whatever needs to be done when the mouse leaves a link.
nsresult JoinTextNodes (nsIContent *aFirst, nsIContent *aSecond)
 Take two text nodes and append the second to the first.
nsIDocumentGetCurrentDoc () const
 Get the document that this content is currently in, if any.
nsIContentGetParent () const
 Get the parent content for this content.
virtual void DoneCreatingElement ()
 This method is called when the parser finishes creating the element.
virtual void BeginAddingChildren ()
 This method is called when the parser begins creating the element's children, if any are present.
virtual void DoneAddingChildren ()
 This method is called when the parser finishes creating the element's children, if any are present.
virtual PRBool IsDoneAddingChildren ()
 For HTML textarea, select, applet, and object elements, returns PR_TRUE if all children have been added OR if the element was not created by the parser.
virtual PRInt32 IntrinsicState () const
 Method to get the intrinsic content state of this content node.
void focus ()
void blur ()
void click ()
void doCommand ()
nsIDOMNodeList getElementsByAttribute (in DOMString name, in DOMString value)
DOMString getAttribute (in DOMString name)
void setAttribute (in DOMString name, in DOMString value) raises (DOMException)
void removeAttribute (in DOMString name) raises (DOMException)
nsIDOMAttr getAttributeNode (in DOMString name)
nsIDOMAttr setAttributeNode (in nsIDOMAttr newAttr) raises (DOMException)
nsIDOMAttr removeAttributeNode (in nsIDOMAttr oldAttr) raises (DOMException)
nsIDOMNodeList getElementsByTagName (in DOMString name)
DOMString getAttributeNS (in DOMString namespaceURI, in DOMString localName)
void setAttributeNS (in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises (DOMException)
void removeAttributeNS (in DOMString namespaceURI, in DOMString localName) raises (DOMException)
nsIDOMAttr getAttributeNodeNS (in DOMString namespaceURI, in DOMString localName)
nsIDOMAttr setAttributeNodeNS (in nsIDOMAttr newAttr) raises (DOMException)
nsIDOMNodeList getElementsByTagNameNS (in DOMString namespaceURI, in DOMString localName)
boolean hasAttribute (in DOMString name)
boolean hasAttributeNS (in DOMString namespaceURI, in DOMString localName)
nsIDOMNode insertBefore (in nsIDOMNode newChild, in nsIDOMNode refChild) raises (DOMException)
nsIDOMNode replaceChild (in nsIDOMNode newChild, in nsIDOMNode oldChild) raises (DOMException)
nsIDOMNode removeChild (in nsIDOMNode oldChild) raises (DOMException)
nsIDOMNode appendChild (in nsIDOMNode newChild) raises (DOMException)
boolean hasChildNodes ()
nsIDOMNode cloneNode (in boolean deep)
void normalize ()
boolean isSupported (in DOMString feature, in DOMString version)
boolean hasAttributes ()
void handleChromeEvent (in nsPresContext aPresContext, in nsEventPtr aEvent, out nsIDOMEvent aDOMEvent, in unsigned long aFlags, inout nsEventStatus aStatus)
 Handle a chrome DOM event.

Static Public Member Functions

static nsXULElementFromContent (nsIContent *aContent)
 Typesafe, non-refcounting cast from nsIContent.
static nsIXBLServiceGetXBLService ()
static void ReleaseGlobals ()
static nsresult Create (nsXULPrototypeElement *aPrototype, nsIDocument *aDocument, PRBool aIsScriptable, nsIContent **aResult)
static void Shutdown ()
 Free globals, to be called from module destructor.
static PRBool FindAttributeDependence (const nsIAtom *aAttribute, const MappedAttributeEntry *const aMaps[], PRUint32 aMapCount)
 A common method where you can just pass in a list of maps to check for attribute dependence.
static void SetDocumentInChildrenOf (nsIContent *aContent, nsIDocument *aDocument, PRBool aCompileEventHandlers)
 Set .document in the immediate children of said content (but not in content itself).
static nsresult InternalIsSupported (nsISupports *aObject, const nsAString &aFeature, const nsAString &aVersion, PRBool *aReturn)
 Check whether a spec feature/version is supported.
static nsresult InternalGetFeature (nsISupports *aObject, const nsAString &aFeature, const nsAString &aVersion, nsISupports **aReturn)
static already_AddRefed
< nsIDOMNSFeatureFactory
GetDOMFeatureFactory (const nsAString &aFeature, const nsAString &aVersion)
static PRBool HasMutationListeners (nsIContent *aContent, PRUint32 aType)
 Quick helper to determine whether there are any mutation listeners of a given type that apply to this content (are at or above it).
static PRBool ShouldFocus (nsIContent *aContent)
static nsresult doReplaceOrInsertBefore (PRBool aReplace, nsIDOMNode *aNewChild, nsIDOMNode *aRefChild, nsIContent *aParent, nsIDocument *aDocument, nsAttrAndChildArray &aChildArray, nsIDOMNode **aReturn)
 Actual implementation of the DOM InsertBefore and ReplaceChild methods.
static nsresult InitHashes ()

Public Attributes

PRBool aCaseSensitive const
const nsAString & aValue
attribute DOMString id
attribute DOMString className
attribute DOMString align
attribute DOMString dir
attribute DOMString flex
attribute DOMString flexGroup
attribute DOMString ordinal
attribute DOMString orient
attribute DOMString pack
attribute boolean hidden
attribute boolean collapsed
attribute DOMString observes
attribute DOMString menu
attribute DOMString contextMenu
attribute DOMString tooltip
attribute DOMString width
attribute DOMString height
attribute DOMString minWidth
attribute DOMString minHeight
attribute DOMString maxWidth
attribute DOMString maxHeight
attribute DOMString persist
attribute DOMString left
attribute DOMString top
attribute DOMString datasources
attribute DOMString ref
attribute DOMString tooltipText
attribute DOMString statusText
attribute boolean allowEvents
readonly attribute
nsIDOMCSSStyleDeclaration 
style
readonly attribute
nsIRDFCompositeDataSource 
database
readonly attribute
nsIXULTemplateBuilder 
builder
readonly attribute nsIRDFResource resource
readonly attribute nsIControllers controllers
readonly attribute nsIBoxObject boxObject
readonly attribute DOMString tagName
const unsigned short ELEMENT_NODE = 1
const unsigned short ATTRIBUTE_NODE = 2
const unsigned short TEXT_NODE = 3
const unsigned short CDATA_SECTION_NODE = 4
const unsigned short ENTITY_REFERENCE_NODE = 5
const unsigned short ENTITY_NODE = 6
const unsigned short PROCESSING_INSTRUCTION_NODE = 7
const unsigned short COMMENT_NODE = 8
const unsigned short DOCUMENT_NODE = 9
const unsigned short DOCUMENT_TYPE_NODE = 10
const unsigned short DOCUMENT_FRAGMENT_NODE = 11
const unsigned short NOTATION_NODE = 12
readonly attribute DOMString nodeName
attribute DOMString nodeValue
readonly attribute unsigned short nodeType
readonly attribute nsIDOMNode parentNode
readonly attribute nsIDOMNodeList childNodes
readonly attribute nsIDOMNode firstChild
readonly attribute nsIDOMNode lastChild
readonly attribute nsIDOMNode previousSibling
readonly attribute nsIDOMNode nextSibling
readonly attribute
nsIDOMNamedNodeMap 
attributes
readonly attribute nsIDOMDocument ownerDocument
readonly attribute DOMString namespaceURI
attribute DOMString prefix
readonly attribute DOMString localName

Static Public Attributes

static PLDHashTable sEventListenerManagersHash
static PLDHashTable sRangeListsHash
static PRInt32 sTabFocusModel = eTabFocus_any
static PRBool sTabFocusModelAppliesToXUL = PR_FALSE

Protected Types

enum  { kParentBitMask = 0x3 }
typedef PRWord PtrBits

Protected Member Functions

 nsXULElement (nsINodeInfo *aNodeInfo)
virtual ~nsXULElement (void)
nsresult EnsureContentsGenerated (void) const
nsresult ExecuteOnBroadcastHandler (nsIDOMElement *anElement, const nsAString &attrName)
NS_IMETHOD GetParentTree (nsIDOMXULMultiSelectControlElement **aTreeElement)
nsresult AddPopupListener (nsIAtom *aName)
nsresult MakeHeavyweight ()
 Abandon our prototype linkage, and copy all attributes locally.
const nsAttrValueFindLocalOrProtoAttr (PRInt32 aNameSpaceID, nsIAtom *aName) const
nsXULPrototypeAttributeFindPrototypeAttribute (PRInt32 aNameSpaceID, nsIAtom *aName) const
 Return our prototype's attribute, if one exists.
void AddListenerFor (const nsAttrName &aName, PRBool aCompileEventHandlers)
 Add a listener for the specified attribute, if appropriate.
void MaybeAddPopupListener (nsIAtom *aLocalName)
nsresult HideWindowChrome (PRBool aShouldHide)
nsresult SetAttrAndNotify (PRInt32 aNamespaceID, nsIAtom *aAttribute, nsIAtom *aPrefix, const nsAString &aOldValue, nsAttrValue &aParsedValue, PRBool aModification, PRBool aFireMutation, PRBool aNotify)
const nsAttrNameInternalGetExistingAttrNameFromQName (const nsAString &aStr) const
 Internal hook for converting an attribute name-string to an atomized name.
nsIControllersControllers ()
void UnregisterAccessKey (const nsAString &aOldValue)
PRBool BoolAttrIsTrue (nsIAtom *aName)
nsresult CopyInnerTo (nsGenericElement *aDest, PRBool aDeep)
 Copy attributes and children from another content object.
PRBool HasDOMSlots () const
nsDOMSlotsGetDOMSlots ()
nsDOMSlotsGetExistingDOMSlots () const
PtrBits GetFlags () const
void SetFlags (PtrBits aFlagsToSet)
void UnsetFlags (PtrBits aFlagsToUnset)
PRBool HasRangeList () const
PRBool HasEventListenerManager () const
PRBool HasProperties () const
void GetContentsAsText (nsAString &aText)
 GetContentsAsText will take all the textnodes that are children of |this| and concatenate the text in them into aText.
PRBool IsAnonymousForEvents () const
 Returns PR_TRUE if this content is anonymous for event handling.

Static Protected Member Functions

static nsresult ExecuteJSCode (nsIDOMElement *anElement, nsEvent *aEvent)

Protected Attributes

nsXULPrototypeElementmPrototype
nsCOMPtr< nsIEventListenerManagermListenerManager
nsIContentmBindingParent
 The nearest enclosing content node with a binding that created us.
nsCOMPtr< nsINodeInfomNodeInfo
 Information about this type of node.
PtrBits mFlagsOrSlots
 Used for either storing flags for this element or a pointer to this elements nsDOMSlots.
nsAttrAndChildArray mAttrsAndChildren
 Array containing all attributes and children for this element.
PtrBits mParentPtrBits

Static Protected Attributes

static nsIXBLServicegXBLService = nsnull
static nsICSSOMFactorygCSSOMFactory = nsnull

Friends

nsresult NS_NewXULElement (nsIContent **aResult, nsINodeInfo *aNodeInfo)

Detailed Description

Definition at line 407 of file nsXULElement.h.


Member Typedef Documentation

typedef PRWord nsIContent::PtrBits [protected, inherited]

Reimplemented in nsGenericDOMDataNode.

Definition at line 726 of file nsIContent.h.


Member Enumeration Documentation

anonymous enum [inherited]

Bit-flags to pass (or'ed together) to IsContentOfType()

Enumerator:
eTEXT 

text elements

eELEMENT 

dom elements

eHTML 

html elements

eHTML_FORM_CONTROL 

form controls

eXUL 

XUL elements.

ePROCESSING_INSTRUCTION 

xml processing instructions

eSVG 

svg elements

eCOMMENT 

comment nodes

Definition at line 524 of file nsIContent.h.

       {
    eTEXT                = 0x00000001,
    eELEMENT             = 0x00000002,
    eHTML                = 0x00000004,
    eHTML_FORM_CONTROL   = 0x00000008,
    eXUL                 = 0x00000010,
    ePROCESSING_INSTRUCTION = 0x00000020,
    eSVG                 = 0x00000040,
    eCOMMENT             = 0x00000080
  };
anonymous enum [protected, inherited]
Enumerator:
kParentBitMask 

Definition at line 729 of file nsIContent.h.

{ kParentBitMask = 0x3 };
enum nsIContent::ETabFocusType [inherited]
Enumerator:
eTabFocus_formElementsMask 
eTabFocus_linksMask 
eTabFocus_any 

Definition at line 711 of file nsIContent.h.

                     {
  //eTabFocus_textControlsMask = (1<<0),  // unused - textboxes always tabbable
    eTabFocus_formElementsMask = (1<<1),  // non-text form elements
    eTabFocus_linksMask = (1<<2),         // links
    eTabFocus_any = 1 + (1<<1) + (1<<2)   // everything that can be focused
  };

These flags are used to maintain bookkeeping information for partially- constructed content.

eChildrenMustBeRebuilt The element's children are invalid or unconstructed, and should be reconstructed.

eTemplateContentsBuilt Child content that is built from a XUL template has been constructed.

eContainerContentsBuilt Child content that is built by following the ``containment'' property in a XUL template has been built.

Enumerator:
eChildrenMustBeRebuilt 
eTemplateContentsBuilt 
eContainerContentsBuilt 

Definition at line 429 of file nsXULElement.h.


Constructor & Destructor Documentation

nsXULElement::nsXULElement ( nsINodeInfo aNodeInfo) [protected]

Definition at line 295 of file nsXULElement.cpp.

Here is the caller graph for this function:

nsXULElement::~nsXULElement ( void  ) [protected, virtual]

Definition at line 303 of file nsXULElement.cpp.

{
    //XXX UnbindFromTree is not called always before dtor.
    //XXX Related to templates or overlays?
    //XXXbz probably related to the cloning thing!
    if (IsInDoc()) {
      UnbindFromTree();
    }

    nsDOMSlots* slots = GetExistingDOMSlots();
    if (slots) {
      NS_IF_RELEASE(slots->mControllers); // Forces release
    }

    if (mPrototype)
        mPrototype->Release();
}

Here is the call graph for this function:


Member Function Documentation

void nsXULElement::AddListenerFor ( const nsAttrName aName,
PRBool  aCompileEventHandlers 
) [protected]

Add a listener for the specified attribute, if appropriate.

Definition at line 786 of file nsXULElement.cpp.

{
    // If appropriate, add a popup listener and/or compile the event
    // handler. Called when we change the element's document, create a
    // new element, change an attribute's value, etc.
    // Eventlistenener-attributes are always in the null namespace
    if (aName.IsAtom()) {
        nsIAtom *attr = aName.Atom();
        MaybeAddPopupListener(attr);
        if (aCompileEventHandlers && IsEventHandler(attr)) {
            nsAutoString value;
            GetAttr(kNameSpaceID_None, attr, value);
            AddScriptEventListener(attr, value);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2859 of file nsXULElement.cpp.

{
    // Add a popup listener to the element
    nsresult rv;

    nsCOMPtr<nsIXULPopupListener> popupListener =
        do_CreateInstance(kXULPopupListenerCID, &rv);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to create an instance of the popup listener object.");
    if (NS_FAILED(rv)) return rv;

    XULPopupType popupType;
    if (aName == nsXULAtoms::context || aName == nsXULAtoms::contextmenu) {
        popupType = eXULPopupType_context;
    }
    else {
        popupType = eXULPopupType_popup;
    }

    // Add a weak reference to the node.
    popupListener->Init(this, popupType);

    // Add the popup as a listener on this element.
    nsCOMPtr<nsIDOMEventListener> eventListener = do_QueryInterface(popupListener);
    nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
    NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
    target->AddEventListener(NS_LITERAL_STRING("mousedown"), eventListener, PR_FALSE);
    target->AddEventListener(NS_LITERAL_STRING("contextmenu"), eventListener, PR_FALSE);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericElement::AddScriptEventListener ( nsIAtom aAttribute,
const nsAString &  aValue 
) [inherited]

Add a script event listener with the given attr name (like onclick) and with the value as JS.

Parameters:
aAttributethe event listener name
aValuethe JS to attach

Definition at line 3788 of file nsGenericElement.cpp.

{
  nsresult rv = NS_OK;
  nsISupports *target = NS_STATIC_CAST(nsIContent *, this);
  PRBool defer = PR_TRUE;

  nsCOMPtr<nsIEventListenerManager> manager;

  // Attributes on the body and frameset tags get set on the global object
  if (mNodeInfo->Equals(nsHTMLAtoms::body) ||
      mNodeInfo->Equals(nsHTMLAtoms::frameset)) {
    nsIScriptGlobalObject *sgo;

    // If we have a document, and it has a script global, add the
    // event listener on the global. If not, proceed as normal.
    // XXXbz should we instead use GetCurrentDoc() here, override
    // BindToTree for those classes and munge event listeners there?
    nsIDocument *document = GetOwnerDoc();
    nsCOMPtr<nsPIDOMWindow> win;
    if (document && (sgo = document->GetScriptGlobalObject()) &&
        (win = do_QueryInterface(sgo)) && win->IsInnerWindow()) {
      nsCOMPtr<nsIDOMEventReceiver> receiver(do_QueryInterface(sgo));
      NS_ENSURE_TRUE(receiver, NS_ERROR_FAILURE);

      receiver->GetListenerManager(getter_AddRefs(manager));

      target = sgo;
      defer = PR_FALSE;
    }
  } else {
    GetListenerManager(getter_AddRefs(manager));
  }

  if (manager) {
    nsIDocument *ownerDoc = GetOwnerDoc();

    rv =
      manager->AddScriptEventListener(target, aAttribute, aValue, defer,
                                      !nsContentUtils::IsChromeDoc(ownerDoc));
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMNode nsIDOMNode::appendChild ( in nsIDOMNode  newChild) raises (DOMException) [inherited]
NS_IMETHOD nsGenericElement::AppendChild ( nsIDOMNode aNewChild,
nsIDOMNode **  aReturn 
) [inline, inherited]

Reimplemented in nsDocumentFragment.

Definition at line 585 of file nsGenericElement.h.

  {
    return InsertBefore(aNewChild, nsnull, aReturn);
  }

Here is the call graph for this function:

nsresult nsXULElement::AppendChildTo ( nsIContent aKid,
PRBool  aNotify 
) [virtual]

Append a content node to the end of the child list.

Parameters:
aKidthe content to append
aNotifywhether to notify the document and appropriate mutation event listeners that the replace has occurred

Reimplemented from nsGenericElement.

Definition at line 1153 of file nsXULElement.cpp.

{
    nsresult rv = EnsureContentsGenerated();
    NS_ENSURE_SUCCESS(rv, rv);

    NS_PRECONDITION((nsnull != aKid) && (aKid != NS_STATIC_CAST(nsIStyledContent*, this)), "null ptr");

    nsIDocument* doc = GetCurrentDoc();
    mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);

    rv = mAttrsAndChildren.AppendChild(aKid);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = aKid->BindToTree(doc, this, nsnull, PR_TRUE);
    if (NS_FAILED(rv)) {
        mAttrsAndChildren.RemoveChildAt(GetChildCount() - 1);
        aKid->UnbindFromTree();
        return rv;
    }
    // ranges don't need adjustment since new child is at end of list

    // The kid may have removed us from the document, so recheck that we're
    // still in the document before proceeding.  Also, the kid may have just
    // removed itself, in which case we don't really want to fire
    // ContentAppended or a mutation event.
    // XXXbz What if the kid just moved us in the document?  Scripts suck.  We
    // really need to stop running them while we're in the middle of modifying
    // the DOM....
    if (doc && doc == GetCurrentDoc() && aKid->GetParent() == this) {
        if (aNotify) {
            doc->ContentAppended(this, mAttrsAndChildren.ChildCount() - 1);
        }

        if (HasMutationListeners(this,
                                 NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
            nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
            mutation.mRelatedNode =
                do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this));

            nsEventStatus status = nsEventStatus_eIgnore;
            aKid->HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status);
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

Append the list of nsIDOMGCPartipants reachable from this one via C++ getters exposed to script that return a different result from |GetSCCIndex|.

The caller is responsible for taking the transitive closure of |AppendReachableList|.

This will only be called on objects that are returned by GetSCCIndex.

null pointers may be appended; they will be ignored by the caller.

Implements nsIDOMGCParticipant.

Definition at line 1045 of file nsGenericElement.cpp.

{
  NS_ASSERTION(GetCurrentDoc() == nsnull,
               "shouldn't be an SCC index if we're in a doc");

  // This node is the root of a subtree that's been removed from the
  // document (since AppendReachableList is only called on SCC index
  // nodes).  The document is reachable from it (through
  // .ownerDocument), but it's not reachable from the document.
  nsCOMPtr<nsIDOMGCParticipant> participant = do_QueryInterface(GetOwnerDoc());
  aArray.AppendObject(participant);
}

Here is the call graph for this function:

virtual void nsIContent::BeginAddingChildren ( ) [inline, virtual, inherited]

This method is called when the parser begins creating the element's children, if any are present.

This is only called for XTF elements currently.

Reimplemented in nsXTFElementWrapper.

Definition at line 626 of file nsIContent.h.

  {
  }
nsresult nsXULElement::BindToTree ( nsIDocument aDocument,
nsIContent aParent,
nsIContent aBindingParent,
PRBool  aCompileEventHandlers 
) [virtual]

Bind this content node to a tree.

If this method throws, the caller must call UnbindFromTree() on the node. In the typical case of a node being appended to a parent, this will be called after the node has been added to the parent's child list and before nsIDocumentObserver notifications for the addition are dispatched.

Parameters:
aDocumentThe new document for the content node. Must match the current document of aParent, if aParent is not null. May not be null if aParent is null.
aParentThe new parent for the content node. May be null if the node is being bound as a direct child of the document.
aBindingParentThe new binding parent for the content node. This is allowed to be null. In that case, the binding parent of aParent, if any, will be used.
aCompileEventHandlerswhether to initialize the event handlers in the document (used by nsXULElement)
Note:
either aDocument or aParent must be non-null. If both are null, this method will crash.
This method must not be called by consumers of nsIContent on a node that is already bound to a tree. Call UnbindFromTree first.
This method will handle rebinding descendants appropriately (eg changing their binding parent as needed).
This method does not add the content node to aParent's child list
Exceptions:
NS_ERROR_OUT_OF_MEMORYif that happens

Reimplemented from nsGenericElement.

Definition at line 825 of file nsXULElement.cpp.

{
    NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
    // XXXbz XUL elements are confused about their current doc when they're
    // cloned, so we don't assert if aParent is a XUL element and aDocument is
    // null, even if aParent->GetCurrentDoc() is non-null
    //  NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
    //                  "aDocument must be current doc of aParent");
    NS_PRECONDITION(!aParent ||
                    (aParent->IsContentOfType(eXUL) && aDocument == nsnull) ||
                    aDocument == aParent->GetCurrentDoc(),
                    "aDocument must be current doc of aParent");
    // XXXbz we'd like to assert that GetCurrentDoc() is null, but the cloning
    // mess makes that impossible.  We can't even assert that aDocument ==
    // GetCurrentDoc() when GetCurrentDoc() is non-null, since we may be
    // getting inserted into a different document.  :(
    //    NS_PRECONDITION(!GetCurrentDoc(),
    //                    "Already have a document.  Unbind first!");

    // Note that as we recurse into the kids, they'll have a non-null
    // parent.  So only assert if our parent is _changing_ while we
    // have a parent.
    NS_PRECONDITION(!GetParent() || aParent == GetParent(),
                    "Already have a parent.  Unbind first!");
    NS_PRECONDITION(!GetBindingParent() ||
                    aBindingParent == GetBindingParent() ||
                    (!aBindingParent && aParent &&
                     aParent->GetBindingParent() == GetBindingParent()),
                    "Already have a binding parent.  Unbind first!");

    if (!aBindingParent && aParent) {
        aBindingParent = aParent->GetBindingParent();
    }

    // First set the binding parent
    mBindingParent = aBindingParent;
    
    // Now set the parent; make sure to preserve the bits we have
    // stashed there Note that checking whether aParent == GetParent()
    // is probably not worth it here.
    PtrBits new_bits = NS_REINTERPRET_CAST(PtrBits, aParent);
    new_bits |= mParentPtrBits & nsIContent::kParentBitMask;
    mParentPtrBits = new_bits;

    nsIDocument *oldOwnerDocument = GetOwnerDoc();
    nsIDocument *newOwnerDocument;
    nsNodeInfoManager* nodeInfoManager;

    // XXXbz sXBL/XBL2 issue!

    // Finally, set the document
    if (aDocument) {
        // Notify XBL- & nsIAnonymousContentCreator-generated
        // anonymous content that the document is changing.  XXXbz
        // ordering issues here?  Probably not, since
        // ChangeDocumentFor is just pretty broken anyway....  Need to
        // get it working.

        // XXXbz XBL doesn't handle this (asserts), and we don't really want
        // to be doing this during parsing anyway... sort this out.    
        //    aDocument->BindingManager()->ChangeDocumentFor(this, nsnull,
        //                                                   aDocument);

        // Being added to a document.
        mParentPtrBits |= PARENT_BIT_INDOCUMENT;

        newOwnerDocument = aDocument;
        nodeInfoManager = newOwnerDocument->NodeInfoManager();
    } else {
        newOwnerDocument = aParent->GetOwnerDoc();
        nodeInfoManager = aParent->GetNodeInfo()->NodeInfoManager();
    }

    // Handle a change in our owner document.

    if (oldOwnerDocument && oldOwnerDocument != newOwnerDocument) {
        // Remove all properties.
        nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(oldOwnerDocument);
        if (nsDoc) {
            nsDoc->SetBoxObjectFor(this, nsnull);
        }
        oldOwnerDocument->PropertyTable()->DeleteAllPropertiesFor(this);
    }

    nsresult rv;
    if (mNodeInfo->NodeInfoManager() != nodeInfoManager) {
        nsCOMPtr<nsINodeInfo> newNodeInfo;
        rv = nodeInfoManager->GetNodeInfo(mNodeInfo->NameAtom(),
                                          mNodeInfo->GetPrefixAtom(),
                                          mNodeInfo->NamespaceID(),
                                          getter_AddRefs(newNodeInfo));
        NS_ENSURE_SUCCESS(rv, rv);
        NS_ASSERTION(newNodeInfo, "GetNodeInfo lies");
        mNodeInfo.swap(newNodeInfo);
    }

    if (newOwnerDocument) {
        // we need to (re-)initialize several attributes that are dependant on
        // the document. Do that now.
        // XXXbz why do we have attributes depending on the current document?
        // Shouldn't they depend on the owner document?  Or is this code just
        // misplaced, basically?
        
        PRInt32 count = mAttrsAndChildren.AttrCount();
        PRBool haveLocalAttributes = (count > 0);
        PRInt32 i;
        for (i = 0; i < count; i++) {
            AddListenerFor(*mAttrsAndChildren.GetSafeAttrNameAt(i),
                           aCompileEventHandlers);
        }

        if (mPrototype) {
            PRInt32 count = mPrototype->mNumAttributes;
            for (i = 0; i < count; i++) {
                nsXULPrototypeAttribute *protoattr =
                    &mPrototype->mAttributes[i];

                // Don't clobber a locally modified attribute.
                if (haveLocalAttributes &&
                    mAttrsAndChildren.GetAttr(protoattr->mName.LocalName(), 
                                              protoattr->mName.NamespaceID())) {
                    continue;
                }

                AddListenerFor(protoattr->mName, aCompileEventHandlers);
            }
        }
    }

    // Now recurse into our kids
    PRUint32 i;
    for (i = 0; i < GetChildCount(); ++i) {
        // The child can remove itself from the parent in BindToTree.
        nsCOMPtr<nsIContent> child = mAttrsAndChildren.ChildAt(i);
        nsresult rv = child->BindToTree(aDocument, this, aBindingParent,
                                        aCompileEventHandlers);
        NS_ENSURE_SUCCESS(rv, rv);
    }

    // XXXbz script execution during binding can trigger some of these
    // postcondition asserts....  But we do want that, since things will
    // generally be quite broken when that happens.
    // XXXbz we'd like to assert that we have the right GetCurrentDoc(), but
    // we may be being bound to a null document while we already have a
    // current doc, due to the cloneNode hack...  So can't assert that yet.
    //    NS_POSTCONDITION(aDocument == GetCurrentDoc(),
    //                     "Bound to wrong document");
    NS_POSTCONDITION(aParent == GetParent(), "Bound to wrong parent");
    NS_POSTCONDITION(aBindingParent == GetBindingParent(),
                     "Bound to wrong binding parent");

    return NS_OK;
}

Here is the call graph for this function:

void nsIDOMXULElement::blur ( ) [inherited]
PRBool nsXULElement::BoolAttrIsTrue ( nsIAtom aName) [protected]

Definition at line 3027 of file nsXULElement.cpp.

{
    const nsAttrValue* attr =
        FindLocalOrProtoAttr(kNameSpaceID_None, aName);

    return attr && attr->Type() == nsAttrValue::eAtom &&
           attr->GetAtomValue() == nsXULAtoms::_true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 544 of file nsXULElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDOMXULElement::click ( ) [inherited]
nsIDOMNode nsIDOMNode::cloneNode ( in boolean  deep) [inherited]
nsresult nsXULElement::CompileEventHandler ( nsIScriptContext aContext,
void aTarget,
nsIAtom aName,
const nsAString &  aBody,
const char *  aURL,
PRUint32  aLineNo,
void **  aHandler 
) [virtual]

Compile the specified event handler, and bind it to aTarget using aContext.

Parameters:
aContextthe context to use when creating event handler
aTargetthe object to which to bind the event handler
aNamethe name of the handler
aBodythe handler script body
aURLthe URL or filename for error messages
aLineNothe starting line number of the script for error messages
aHandlerthe compiled, bound handler object

Implements nsIScriptEventHandlerOwner.

Definition at line 695 of file nsXULElement.cpp.

{
    nsresult rv;
    JSObject* scopeObject;

    XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheSets);

    nsIScriptContext *context;
    if (mPrototype) {
        // It'll be shared among the instances of the prototype.
        // Use null for the scope object when precompiling shared
        // prototype scripts.
        scopeObject = nsnull;

        // Use the prototype document's special context.  Because
        // scopeObject is null, the JS engine has no other source of
        // <the-new-shared-event-handler>.__proto__ than to look in
        // cx->globalObject for Function.prototype.  That prototype
        // keeps the global object alive, so if we use this document's
        // global object, we'll be putting something in the prototype
        // that protects this document's global object from GC.
        // XXX sXBL/XBL2 issue! Owner or current document?
        nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(GetOwnerDoc());
        NS_ENSURE_TRUE(xuldoc, NS_ERROR_UNEXPECTED);

        nsCOMPtr<nsIXULPrototypeDocument> protodoc;
        rv = xuldoc->GetMasterPrototype(getter_AddRefs(protodoc));
        NS_ENSURE_SUCCESS(rv, rv);
        NS_ENSURE_TRUE(protodoc, NS_ERROR_UNEXPECTED);

        nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner =
            do_QueryInterface(protodoc);
        nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject();
        NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);

        context = global->GetContext();
    }
    else {
        // We don't have a prototype; do a one-off compile.
        NS_ASSERTION(aTarget != nsnull, "no prototype and no target?!");
        scopeObject = NS_REINTERPRET_CAST(JSObject*, aTarget);
        context = aContext;
    }

    // Compile the event handler
    const char *eventName = nsContentUtils::GetEventArgName(kNameSpaceID_XUL);
    rv = context->CompileEventHandler(scopeObject, aName, eventName, aBody,
                                      aURL, aLineNo, !scopeObject,
                                      aHandler);
    if (NS_FAILED(rv)) return rv;

    if (! scopeObject) {
        // If it's a shared handler, we need to bind the shared
        // function object to the real target.

        // XXX: Shouldn't this use context and not aContext?
        rv = aContext->BindCompiledEventHandler(aTarget, aName, *aHandler);
        if (NS_FAILED(rv)) return rv;
    }

    nsXULPrototypeAttribute *attr =
        FindPrototypeAttribute(kNameSpaceID_None, aName);
    if (attr) {
        XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheFills);
        attr->mEventHandler = *aHandler;

        if (attr->mEventHandler) {
            JSContext *cx = (JSContext*) context->GetNativeContext();
            if (!cx)
                return NS_ERROR_UNEXPECTED;

            rv = nsContentUtils::AddJSGCRoot(&attr->mEventHandler,
                                             "nsXULPrototypeAttribute::mEventHandler");
            if (NS_FAILED(rv)) {
                attr->mEventHandler = nsnull;
                return rv;
            }
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

PRUint32 nsXULElement::ContentID ( ) const [virtual]

Get a unique ID for this piece of content.

This ID is used as a key to store state information about this content object and its associated frame object. The state information is stored in a dictionary that is manipulated by the frame manager (nsIFrameManager) inside layout. An opaque pointer to this dictionary is passed to the session history as a handle associated with the current document's state

These methods are DEPRECATED, DON'T USE THEM!!!

Reimplemented from nsGenericElement.

Definition at line 2307 of file nsXULElement.cpp.

{
    return 0;
}
nsIControllers* nsXULElement::Controllers ( ) [inline, protected]

Definition at line 640 of file nsXULElement.h.

                                  {
      nsDOMSlots* slots = GetExistingDOMSlots();
      return slots ? slots->mControllers : nsnull; 
    }

Here is the call graph for this function:

nsresult nsGenericElement::CopyInnerTo ( nsGenericElement aDest,
PRBool  aDeep 
) [protected, inherited]

Copy attributes and children from another content object.

Parameters:
aSrcContentthe object to copy from
aDeepwhether to copy children

Reimplemented in nsGenericHTMLElement.

Definition at line 3844 of file nsGenericElement.cpp.

{
  nsresult rv;
  PRUint32 i, count = mAttrsAndChildren.AttrCount();
  for (i = 0; i < count; ++i) {
    const nsAttrName* name = mAttrsAndChildren.GetSafeAttrNameAt(i);
    const nsAttrValue* value = mAttrsAndChildren.AttrAt(i);
    nsAutoString valStr;
    value->ToString(valStr);
    rv = aDst->SetAttr(name->NamespaceID(), name->LocalName(),
                       name->GetPrefix(), valStr, PR_FALSE);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  if (!aDeep) {
    return NS_OK;
  }

  count = mAttrsAndChildren.ChildCount();
  for (i = 0; i < count; ++i) {
    nsCOMPtr<nsIDOMNode> node =
      do_QueryInterface(mAttrsAndChildren.ChildAt(i));
    NS_ASSERTION(node, "child doesn't implement nsIDOMNode");

    nsCOMPtr<nsIDOMNode> newNode;
    rv = node->CloneNode(PR_TRUE, getter_AddRefs(newNode));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIContent> newContent = do_QueryInterface(newNode);
    rv = aDst->AppendChildTo(newContent, PR_FALSE);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULElement::Create ( nsXULPrototypeElement aPrototype,
nsIDocument aDocument,
PRBool  aIsScriptable,
nsIContent **  aResult 
) [static]

Definition at line 323 of file nsXULElement.cpp.

{
    // Create an nsXULElement from a prototype
    NS_PRECONDITION(aPrototype != nsnull, "null ptr");
    if (! aPrototype)
        return NS_ERROR_NULL_POINTER;

    NS_PRECONDITION(aResult != nsnull, "null ptr");
    if (! aResult)
        return NS_ERROR_NULL_POINTER;

    nsCOMPtr<nsINodeInfo> nodeInfo;
    nsresult rv;
    if (aDocument) {
        nsINodeInfo* ni = aPrototype->mNodeInfo;
        rv = aDocument->NodeInfoManager()->GetNodeInfo(ni->NameAtom(),
                                                       ni->GetPrefixAtom(),
                                                       ni->NamespaceID(),
                                                       getter_AddRefs(nodeInfo));
        NS_ENSURE_SUCCESS(rv, rv);
    }
    else {
      nodeInfo = aPrototype->mNodeInfo;
    }

    nsRefPtr<nsXULElement> element = new nsXULElement(nodeInfo);

    if (! element)
        return NS_ERROR_OUT_OF_MEMORY;

    element->mPrototype = aPrototype;

    aPrototype->AddRef();

    if (aIsScriptable) {
        // Check each attribute on the prototype to see if we need to do
        // any additional processing and hookup that would otherwise be
        // done 'automagically' by SetAttr().
        for (PRUint32 i = 0; i < aPrototype->mNumAttributes; ++i)
            element->AddListenerFor(aPrototype->mAttributes[i].mName, PR_TRUE);
    }

    NS_ADDREF(*aResult = element.get());
    return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericElement::DeleteProperty ( nsIAtom aPropertyName) [virtual, inherited]

Reimplemented from nsIContent.

Definition at line 4375 of file nsGenericElement.cpp.

{
  nsIDocument *doc = GetOwnerDoc();
  if (!doc)
    return nsnull;

  return doc->PropertyTable()->DeleteProperty(this, aPropertyName);
}

Here is the call graph for this function:

virtual void nsIContent::DoneAddingChildren ( ) [inline, virtual, inherited]

This method is called when the parser finishes creating the element's children, if any are present.

NOTE: this is currently only called for textarea, select, applet, and object elements in the HTML content sink. If you want to call it on your element, modify the content sink of your choice to do so. This is an efficiency measure.

If you also need to determine whether the parser is the one creating your element (through createElement() or cloneNode() generally) then add a boolean aFromParser to the NS_NewXXX() constructor for your element and have the parser pass true. See nsHTMLInputElement.cpp and nsHTMLContentSink::MakeContentObject().

Reimplemented in nsHTMLSelectElement, nsHTMLTextAreaElement, nsXTFElementWrapper, nsHTMLObjectElement, and nsHTMLAppletElement.

Definition at line 645 of file nsIContent.h.

  {
  }

Here is the caller graph for this function:

virtual void nsIContent::DoneCreatingElement ( ) [inline, virtual, inherited]

This method is called when the parser finishes creating the element.

This particularly means that it has done everything you would expect it to have done after it encounters the > at the end of the tag (for HTML or XML). This includes setting the attributes, setting the document / form, and placing the element into the tree at its proper place.

For container elements, this is called before any of the children are created or added into the tree.

NOTE: this is currently only called for input and button, in the HTML content sink. If you want to call it on your element, modify the content sink of your choice to do so. This is an efficiency measure.

If you also need to determine whether the parser is the one creating your element (through createElement() or cloneNode() generally) then add a boolean aFromParser to the NS_NewXXX() constructor for your element and have the parser pass true. See nsHTMLInputElement.cpp and nsHTMLContentSink::MakeContentObject().

DO NOT USE THIS METHOD to get around the fact that it's hard to deal with attributes dynamically. If you make attributes affect your element from this method, it will only happen on initialization and JavaScript will not be able to create elements (which requires them to first create the element and then call setAttribute() directly, at which point DoneCreatingElement() has already been called and is out of the picture).

Reimplemented in nsHTMLInputElement.

Definition at line 598 of file nsIContent.h.

  {
  }
nsresult nsGenericElement::doReplaceOrInsertBefore ( PRBool  aReplace,
nsIDOMNode aNewChild,
nsIDOMNode aRefChild,
nsIContent aParent,
nsIDocument aDocument,
nsAttrAndChildArray aChildArray,
nsIDOMNode **  aReturn 
) [static, inherited]

Actual implementation of the DOM InsertBefore and ReplaceChild methods.

Shared by nsDocument. When called from nsDocument, aParent will be null.

Parameters:
aReplaceTrue if aNewChild should replace aRefChild. False if aNewChild should be inserted before aRefChild.
aNewChildThe child to insert
aRefChildThe child to insert before or replace
aParentThe parent to use for the new child
aDocumentThe document to use for the new child. Must be non-null, if aParent is null and must match aParent->GetCurrentDoc() if aParent is not null.
aChildArrayThe child array to work with
aReturn[out] the child we insert

Definition at line 3357 of file nsGenericElement.cpp.

{
  NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
  NS_PRECONDITION(!aParent || aParent->GetCurrentDoc() == aDocument,
                  "Incorrect aDocument");

  *aReturn = nsnull;

  if (!aNewChild || (aReplace && !aRefChild)) {
    return NS_ERROR_NULL_POINTER;
  }

  // Keep a strong reference to the node that we'll return to ensure it
  // doesn't go away.
  nsCOMPtr<nsIDOMNode> returnVal = aReplace ? aRefChild : aNewChild;

  nsCOMPtr<nsIContent> refContent;
  nsresult res = NS_OK;
  PRInt32 insPos;

  nsContentOrDocument container(aParent, aDocument);

  // Figure out which index to insert at
  if (aRefChild) {
    refContent = do_QueryInterface(aRefChild);
    insPos = container.IndexOf(refContent);
    if (insPos < 0) {
      return NS_ERROR_DOM_NOT_FOUND_ERR;
    }

    if (aRefChild == aNewChild) {
      NS_ADDREF(*aReturn = aNewChild);

      return NS_OK;
    }
  } else {
    insPos = container.GetChildCount();
  }

  nsCOMPtr<nsIContent> newContent = do_QueryInterface(aNewChild);
  if (!newContent) {
    return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
  }

  PRUint16 nodeType = 0;
  res = aNewChild->GetNodeType(&nodeType);
  NS_ENSURE_SUCCESS(res, res);

  // Make sure that the inserted node is allowed as a child of its new parent.
  if (!IsAllowedAsChild(newContent, nodeType, aParent, aDocument, aReplace,
                        refContent)) {
    return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
  }

  nsIDocument* old_doc = newContent->GetOwnerDoc();

  // XXXbz The document code and content code have two totally different
  // security checks here.  Why?  Because I'm afraid to change such things this
  // close to 1.8.  But which should we do here, really?  Or both?  For example
  // what should a caller with UniversalBrowserRead/Write/whatever be able to
  // do, exactly?  Do we need to be more careful with documents because random
  // callers _can_ get access to them?  That might be....
  if (old_doc && old_doc != container.GetOwnerDoc()) {
    if (aParent) {
      if (!nsContentUtils::CanCallerAccess(aNewChild)) {
        return NS_ERROR_DOM_SECURITY_ERR;
      }
    } else {
      nsCOMPtr<nsIDOMNode> doc(do_QueryInterface(aDocument));
      if (NS_FAILED(nsContentUtils::CheckSameOrigin(doc, aNewChild))) {
        return NS_ERROR_DOM_SECURITY_ERR;
      }
    }
  }

  // We want an update batch when we expect several mutations to be performed,
  // which is when we're replacing a node, or when we're inserting a fragment.
  mozAutoDocUpdate updateBatch(aDocument, UPDATE_CONTENT_MODEL,
    aReplace || nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE);

  // If we're replacing
  if (aReplace) {
    // Getting (and addrefing) the following child here is sort of wasteful
    // in the common case, but really, it's not that expensive. Get over it.
    refContent = container.GetChildAt(insPos + 1);

    nsMutationGuard guard;

    res = container.RemoveChildAt(insPos, PR_TRUE);
    NS_ENSURE_SUCCESS(res, res);

    if (guard.Mutated(1)) {
      insPos = refContent ? container.IndexOf(refContent) :
                            container.GetChildCount();
      if (insPos < 0) {
        return NS_ERROR_DOM_NOT_FOUND_ERR;
      }

      // Passing PR_FALSE for aIsReplace since we now have removed the node
      // to be replaced.
      if (!IsAllowedAsChild(newContent, nodeType, aParent, aDocument,
                            PR_FALSE, refContent)) {
        return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
      }
    }
  }

  /*
   * Check if we're inserting a document fragment. If we are, we need
   * to remove the children of the document fragment and add them
   * individually (i.e. we don't add the actual document fragment).
   */
  if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
    PRUint32 count = newContent->GetChildCount();
    PRBool do_notify = refContent || !aParent;

    // Copy the children into a separate array to avoid having to deal with
    // mutations to the fragment while we're inserting.
    nsCOMArray<nsIContent> fragChildren;
    PRUint32 i;
    for (i = 0; i < count; i++) {
      nsIContent* child = newContent->GetChildAt(i);
      NS_ASSERTION(child->GetCurrentDoc() == nsnull,
                   "How did we get a child with a current doc?");
      if (!fragChildren.AppendObject(child)) {
        return NS_ERROR_OUT_OF_MEMORY;
      }
    }

    // Remove the children from the fragment and flag for possible mutations.
    PRBool mutated = PR_FALSE;
    for (i = count; i > 0;) {
      // We don't need to update i if someone mutates the DOM. The only thing
      // that'd happen is that the resulting child list might be unexpected,
      // but we should never crash since RemoveChildAt is out-of-bounds safe.
      nsMutationGuard guard;
      newContent->RemoveChildAt(--i, PR_TRUE);
      mutated = mutated || guard.Mutated(1);
    }

    nsRefPtr<nsFragmentObserver> fragmentObs;
    if (count && !do_notify) {
      fragmentObs = new nsFragmentObserver(container.GetChildCount(), aParent, aDocument);
      NS_ENSURE_TRUE(fragmentObs, NS_ERROR_OUT_OF_MEMORY);
      fragmentObs->Connect();
    }

    // If do_notify is true, then we don't have to handle the notifications
    // ourselves...  Also, if count is 0 there will be no updates.  So we only
    // want an update batch to happen if count is nonzero and do_notify is not
    // true.
    mozAutoDocUpdate updateBatch(aDocument, UPDATE_CONTENT_MODEL,
                                 count && !do_notify);
    
    // Iterate through the fragment's children, and insert them in the new
    // parent
    for (i = 0; i < count; ++i) {
      // Get the n:th child from the array.
      nsIContent* childContent = fragChildren[i];

      // If we've had any unexpeted mutations so far we need to recheck that
      // the child can still be inserted.
      if (mutated) {
        // We really only need to update insPos if we *just* got an unexpected
        // mutation as opposed to 3 insertions ago. But this is an edgecase so
        // no need to over optimize.
        insPos = refContent ? container.IndexOf(refContent) :
                              container.GetChildCount();
        if (insPos < 0) {
          // Someone seriously messed up the childlist. We have no idea
          // where to insert the remaining children, so just bail.
          res = NS_ERROR_DOM_NOT_FOUND_ERR;
          break;
        }

        nsCOMPtr<nsIDOMNode> tmpNode = do_QueryInterface(childContent);
        PRUint16 tmpType = 0;
        tmpNode->GetNodeType(&tmpType);

        if (childContent->GetParent() || childContent->IsInDoc() ||
            !IsAllowedAsChild(childContent, tmpType, aParent, aDocument, PR_FALSE,
                              refContent)) {
          res = NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
          break;
        }
      }

      nsMutationGuard guard;

      // XXXbz how come no reparenting here?  That seems odd...
      // Insert the child.
      res = container.InsertChildAt(childContent, insPos, do_notify,
                                    aChildArray);

      if (NS_FAILED(res)) {
        break;
      }

      if (fragmentObs) {
        fragmentObs->ChildBound();
      }

      // Check to see if any evil mutation events mucked around with the
      // child list.
      mutated = mutated || guard.Mutated(1);

      ++insPos;
    }

    if (NS_FAILED(res)) {
      if (fragmentObs) {
        fragmentObs->Disconnect();
      }

      // We could try to put the nodes back into the fragment here if we
      // really cared.

      return res;
    }

    if (fragmentObs) {
      NS_ASSERTION(count && !do_notify, "Unexpected state");
      fragmentObs->Finish();
    }

  }
  else {
    PRBool newContentIsXUL = newContent->IsContentOfType(eXUL);

    // Remove the element from the old parent if one exists
    nsIDocument* oldParentDoc = nsnull;
    nsIContent* oldParentCont = newContent->GetParent();
    if (!oldParentCont) {
      oldParentDoc = newContent->GetCurrentDoc();

      // See bug 53901. Crappy XUL sometimes lies about being in the document
      if (oldParentDoc && newContentIsXUL && oldParentDoc->IndexOf(newContent) < 0) {
        oldParentDoc = nsnull;
      }
    }
    if (oldParentCont || oldParentDoc) {
      nsContentOrDocument oldParent(oldParentCont, oldParentDoc);
      PRInt32 removeIndex = oldParent.IndexOf(newContent);

      if (removeIndex < 0) {
        // newContent is anonymous.  We can't deal with this, so just bail
        return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
      }
      
      NS_ASSERTION(!(oldParent.Equals(container) && removeIndex == insPos),
                   "invalid removeIndex");

      nsMutationGuard guard;

      res = oldParent.RemoveChildAt(removeIndex, PR_TRUE);
      NS_ENSURE_SUCCESS(res, res);

      // Adjust insert index if the node we ripped out was a sibling
      // of the node we're inserting before
      if (oldParent.Equals(container) && removeIndex < insPos) {
        --insPos;
      }

      if (guard.Mutated(1)) {
        insPos = refContent ? container.IndexOf(refContent) :
                              container.GetChildCount();
        if (insPos < 0) {
          // Someone seriously messed up the childlist. We have no idea
          // where to insert the new child, so just bail.
          return NS_ERROR_DOM_NOT_FOUND_ERR;
        }

        if (newContent->GetParent() || newContent->IsInDoc() ||
            !IsAllowedAsChild(newContent, nodeType, aParent, aDocument, PR_FALSE,
                              refContent)) {
          return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
        }
      }
    }

    if (!newContentIsXUL) {
      nsContentUtils::ReparentContentWrapper(newContent, aParent,
                                             container.GetOwnerDoc(),
                                             old_doc);
    }

    res = container.InsertChildAt(newContent, insPos, PR_TRUE, aChildArray);
    NS_ENSURE_SUCCESS(res, res);
  }

  returnVal.swap(*aReturn);

  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2396 of file nsXULElement.cpp.

{
    if (GetFlags() & XUL_ELEMENT_CHILDREN_MUST_BE_REBUILT) {
        // Ensure that the element is actually _in_ the document tree;
        // otherwise, somebody is trying to generate children for a node
        // that's not currently in the content model.
        NS_PRECONDITION(IsInDoc(), "element not in tree");
        if (!IsInDoc())
            return NS_ERROR_NOT_INITIALIZED;

        // XXX hack because we can't use "mutable"
        nsXULElement* unconstThis = NS_CONST_CAST(nsXULElement*, this);

        // Clear this value *first*, so we can re-enter the nsIContent
        // getters if needed.
        unconstThis->ClearLazyState(eChildrenMustBeRebuilt);

        // Walk up our ancestor chain, looking for an element with a
        // XUL content model builder attached to it.
        nsIContent* element = unconstThis;

        do {
            nsCOMPtr<nsIDOMXULElement> xulele = do_QueryInterface(element);
            if (xulele) {
                nsCOMPtr<nsIXULTemplateBuilder> builder;
                xulele->GetBuilder(getter_AddRefs(builder));
                if (builder) {
                    if (HasAttr(kNameSpaceID_None, nsXULAtoms::xulcontentsgenerated)) {
                        unconstThis->ClearLazyState(eChildrenMustBeRebuilt);
                        return NS_OK;
                    }

                    return builder->CreateContents(unconstThis);
                }
            }

            element = element->GetParent();
        } while (element);

        NS_ERROR("lazy state set with no XUL content builder in ancestor chain");
        return NS_ERROR_UNEXPECTED;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult nsXULElement::ExecuteJSCode ( nsIDOMElement anElement,
nsEvent aEvent 
) [static, protected]
nsresult nsXULElement::ExecuteOnBroadcastHandler ( nsIDOMElement anElement,
const nsAString &  attrName 
) [protected]
PRBool nsGenericElement::FindAttributeDependence ( const nsIAtom aAttribute,
const MappedAttributeEntry *const  aMaps[],
PRUint32  aMapCount 
) [static, inherited]

A common method where you can just pass in a list of maps to check for attribute dependence.

Most implementations of IsAttributeMapped should use this function as a default handler.

Definition at line 2440 of file nsGenericElement.cpp.

{
  for (PRUint32 mapindex = 0; mapindex < aMapCount; ++mapindex) {
    for (const MappedAttributeEntry* map = aMaps[mapindex];
         map->attribute; ++map) {
      if (aAttribute == *map->attribute) {
        return PR_TRUE;
      }
    }
  }

  return PR_FALSE;
}
const nsAttrValue * nsXULElement::FindLocalOrProtoAttr ( PRInt32  aNameSpaceID,
nsIAtom aName 
) const [protected]

Definition at line 2908 of file nsXULElement.cpp.

{

    const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNamespaceID);
    if (val) {
        return val;
    }

    nsXULPrototypeAttribute *protoattr =
        FindPrototypeAttribute(aNamespaceID, aName);
    if (protoattr) {
        return &protoattr->mValue;
    }

    return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsXULPrototypeAttribute * nsXULElement::FindPrototypeAttribute ( PRInt32  aNameSpaceID,
nsIAtom aName 
) const [protected]

Return our prototype's attribute, if one exists.

Definition at line 2927 of file nsXULElement.cpp.

{
    if (!mPrototype) {
        return nsnull;
    }

    PRUint32 i, count = mPrototype->mNumAttributes;
    if (aNamespaceID == kNameSpaceID_None) {
        // Common case so optimize for this
        for (i = 0; i < count; ++i) {
            nsXULPrototypeAttribute *protoattr = &mPrototype->mAttributes[i];
            if (protoattr->mName.Equals(aLocalName)) {
                return protoattr;
            }
        }
    }
    else {
        for (i = 0; i < count; ++i) {
            nsXULPrototypeAttribute *protoattr = &mPrototype->mAttributes[i];
            if (protoattr->mName.Equals(aLocalName, aNamespaceID)) {
                return protoattr;
            }
        }
    }

    return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIDOMXULElement::focus ( ) [inherited]
static nsXULElement* nsXULElement::FromContent ( nsIContent aContent) [inline, static]

Typesafe, non-refcounting cast from nsIContent.

Cheaper than QI.

Definition at line 436 of file nsXULElement.h.

    {
        if (aContent->IsContentOfType(eXUL))
            return NS_STATIC_CAST(nsXULElement*, aContent);
        return nsnull;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULElement::GetAttr ( PRInt32  aNameSpaceID,
nsIAtom aName,
nsAString &  aResult 
) const [virtual]

Get the current value of the attribute.

This returns a form that is suitable for passing back into SetAttr.

Parameters:
aNameSpaceIDthe namespace of the attr
aNamethe name of the attr
aResultthe value (may legitimately be the empty string) [OUT]
Exceptions:
NS_CONTENT_ATTR_NOT_THEREif the attribute is not set and has no default value
NS_CONTENT_ATTR_NO_VALUEif the attribute exists but has no value
NS_CONTENT_ATTR_HAS_VALUEif the attribute exists and has a non-empty value (==NS_OK)

Reimplemented from nsGenericElement.

Definition at line 1549 of file nsXULElement.cpp.

{
    NS_ASSERTION(nsnull != aName, "must have attribute name");
    NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
                 "must have a real namespace ID!");

    const nsAttrValue* val = FindLocalOrProtoAttr(aNameSpaceID, aName);

    if (!val) {
        // Since we are returning a success code we'd better do
        // something about the out parameters (someone may have
        // given us a non-empty string).
        aResult.Truncate();
        return NS_CONTENT_ATTR_NOT_THERE;
    }

    val->ToString(aResult);

    return aResult.IsEmpty() ? NS_CONTENT_ATTR_NO_VALUE :
                               NS_CONTENT_ATTR_HAS_VALUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsXULElement::GetAttrCount ( ) const [virtual]

Get the number of all specified attributes.

Returns:
the number of attributes

Reimplemented from nsGenericElement.

Definition at line 1784 of file nsXULElement.cpp.

{
    PRBool haveLocalAttributes;

    PRUint32 count = mAttrsAndChildren.AttrCount();
    haveLocalAttributes = count > 0;

#ifdef DEBUG_ATTRIBUTE_STATS
    int dups = 0;
#endif

    if (mPrototype) {
        for (PRUint32 i = 0; i < mPrototype->mNumAttributes; i++) {
            nsAttrName* attrName = &mPrototype->mAttributes[i].mName;
            
            if (!haveLocalAttributes ||
                !mAttrsAndChildren.GetAttr(attrName->LocalName(),
                                           attrName->NamespaceID())) {
                ++count;
#ifdef DEBUG_ATTRIBUTE_STATS
            } else {
                dups++;
#endif
            }
        }
    }

#ifdef DEBUG_ATTRIBUTE_STATS
    {
        int local = mAttrsAndChildren.AttrCount();
        int proto = mPrototype ? mPrototype->mNumAttributes : 0;
        nsAutoString tagstr;
        mNodeInfo->GetName(tagstr);
        char *tagcstr = ToNewCString(tagstr);

        fprintf(stderr, "GAC: %p has %d+%d-%d=%d <%s%s>\n", (void *)this,
                local, proto, dups, count, mPrototype ? "" : "*", tagcstr);
        nsMemory::Free(tagcstr);
    }
#endif

    return count;
}

Here is the call graph for this function:

DOMString nsIDOMElement::getAttribute ( in DOMString  name) [inherited]
nsresult nsGenericElement::GetAttribute ( const nsAString &  aName,
nsAString &  aReturn 
) [inherited]

Reimplemented in nsXTFElementWrapper.

Definition at line 1458 of file nsGenericElement.cpp.

{
  const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);

  if (!name) {
    if (mNodeInfo->NamespaceID() == kNameSpaceID_XUL) {
      // XXX should be SetDOMStringToNull(aReturn);
      // See bug 232598
      aReturn.Truncate();
    }
    else {
      SetDOMStringToNull(aReturn);
    }

    return NS_OK;
  }

  GetAttr(name->NamespaceID(), name->LocalName(), aReturn);

  return NS_OK;
}

Here is the call graph for this function:

nsChangeHint nsXULElement::GetAttributeChangeHint ( const nsIAtom aAttribute,
PRInt32  aModType 
) const [virtual]

Get a hint that tells the style system what to do when an attribute on this node changes, if something needs to happen in response to the change other than the result of what is mapped into style data via any type of style rule.

Reimplemented from nsGenericElement.

Definition at line 2529 of file nsXULElement.cpp.

{
    nsChangeHint retval(NS_STYLE_HINT_NONE);

    if (aAttribute == nsXULAtoms::value &&
        (aModType == nsIDOMMutationEvent::REMOVAL ||
         aModType == nsIDOMMutationEvent::ADDITION)) {
      nsIAtom *tag = Tag();
      if (tag == nsXULAtoms::label || tag == nsXULAtoms::description)
        // Label and description dynamically morph between a normal
        // block and a cropping single-line XUL text frame.  If the
        // value attribute is being added or removed, then we need to
        // return a hint of frame change.  (See bugzilla bug 95475 for
        // details.)
        retval = NS_STYLE_HINT_FRAMECHANGE;
    } else {
        // if left or top changes we reflow. This will happen in xul
        // containers that manage positioned children such as a
        // bulletinboard.
        if (nsXULAtoms::left == aAttribute || nsXULAtoms::top == aAttribute)
            retval = NS_STYLE_HINT_REFLOW;
    }

    return retval;
}

Here is the call graph for this function:

nsIDOMAttr nsIDOMElement::getAttributeNode ( in DOMString  name) [inherited]
nsresult nsGenericElement::GetAttributeNode ( const nsAString &  aName,
nsIDOMAttr **  aReturn 
) [inherited]

Definition at line 1519 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);
  *aReturn = nsnull;

  nsCOMPtr<nsIDOMNamedNodeMap> map;
  nsresult rv = GetAttributes(getter_AddRefs(map));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMNode> node;
  rv = map->GetNamedItem(aName, getter_AddRefs(node));

  if (NS_SUCCEEDED(rv) && node) {
    rv = CallQueryInterface(node, aReturn);
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMAttr nsIDOMElement::getAttributeNodeNS ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]
nsresult nsGenericElement::GetAttributeNodeNS ( const nsAString &  aNamespaceURI,
const nsAString &  aLocalName,
nsIDOMAttr **  aReturn 
) [inherited]

Definition at line 1667 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);

  *aReturn = nsnull;

  nsCOMPtr<nsIDOMNamedNodeMap> map;
  nsresult rv = GetAttributes(getter_AddRefs(map));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIDOMNode> node;
  rv = map->GetNamedItemNS(aNamespaceURI, aLocalName, getter_AddRefs(node));

  if (NS_SUCCEEDED(rv) && node) {
    rv = CallQueryInterface(node, aReturn);
  }

  return rv;
}

Here is the call graph for this function:

DOMString nsIDOMElement::getAttributeNS ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]
nsresult nsGenericElement::GetAttributeNS ( const nsAString &  aNamespaceURI,
const nsAString &  aLocalName,
nsAString &  aReturn 
) [inherited]

Definition at line 1608 of file nsGenericElement.cpp.

{
  PRInt32 nsid;
  nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, &nsid);

  if (nsid == kNameSpaceID_Unknown) {
    // Unknown namespace means no attr...

    aReturn.Truncate();

    return NS_OK;
  }

  nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
  GetAttr(nsid, name, aReturn);

  return NS_OK;
}

Here is the call graph for this function:

Reimplemented in nsDocumentFragment.

Definition at line 1369 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aAttributes);
  nsDOMSlots *slots = GetDOMSlots();

  if (!slots) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (!slots->mAttributeMap) {
    slots->mAttributeMap = new nsDOMAttributeMap(this);
    if (!slots->mAttributeMap) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
    if (!slots->mAttributeMap->Init()) {
      slots->mAttributeMap = nsnull;
      return NS_ERROR_FAILURE;
    }
  }

  NS_ADDREF(*aAttributes = slots->mAttributeMap);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULElement::GetAttrNameAt ( PRUint32  aIndex,
PRInt32 aNameSpaceID,
nsIAtom **  aName,
nsIAtom **  aPrefix 
) const [virtual]

Get the namespace / name / prefix of a given attribute.

Parameters:
aIndexthe index of the attribute name
aNameSpacethe name space ID of the attribute name [OUT]
aNamethe attribute name [OUT]
aPrefixthe attribute prefix [OUT]

Reimplemented from nsGenericElement.

Definition at line 1719 of file nsXULElement.cpp.

{
#ifdef DEBUG_ATTRIBUTE_STATS
    int proto = mPrototype ? mPrototype->mNumAttributes : 0;
    fprintf(stderr, "GANA: %p[%d] of %d/%d:", (void *)this, aIndex,
            mAttrsAndChildren.AttrCount(), proto);
#endif

    PRUint32 localAttrCount = mAttrsAndChildren.AttrCount();
    if (aIndex < localAttrCount) {
        const nsAttrName* name = mAttrsAndChildren.GetSafeAttrNameAt(aIndex);

        *aNameSpaceID = name->NamespaceID();
        NS_ADDREF(*aName = name->LocalName());
        NS_IF_ADDREF(*aPrefix = name->GetPrefix());
#ifdef DEBUG_ATTRIBUTE_STATS
        fprintf(stderr, " local!\n");
#endif
        return NS_OK;
    }

    aIndex -= localAttrCount;

    if (mPrototype && aIndex < mPrototype->mNumAttributes) {
        // XXX This code looks very wrong. See bug 232639.

        PRBool skip;
        nsXULPrototypeAttribute* attr;
        do {
            attr = &mPrototype->mAttributes[aIndex];
            skip = localAttrCount &&
                   mAttrsAndChildren.GetAttr(attr->mName.LocalName(),
                                             attr->mName.NamespaceID());
#ifdef DEBUG_ATTRIBUTE_STATS
            if (skip)
                fprintf(stderr, " [skip %d/%d]", aIndex, aIndex + localAttrCount);
#endif
        } while (skip && aIndex++ < mPrototype->mNumAttributes);

        if (aIndex <= mPrototype->mNumAttributes) {
#ifdef DEBUG_ATTRIBUTE_STATS
            fprintf(stderr, " proto[%d]!\n", aIndex);
#endif
            *aNameSpaceID = attr->mName.NamespaceID();
            NS_ADDREF(*aName = attr->mName.LocalName());
            NS_IF_ADDREF(*aPrefix = attr->mName.GetPrefix());

            return NS_OK;
        }
        // else, we are out of attrs to return, fall-through
    }

#ifdef DEBUG_ATTRIBUTE_STATS
    fprintf(stderr, " not found\n");
#endif

    *aNameSpaceID = kNameSpaceID_None;
    *aName = nsnull;
    *aPrefix = nsnull;

    return NS_ERROR_ILLEGAL_VALUE;
}

Here is the call graph for this function:

already_AddRefed< nsIURI > nsGenericElement::GetBaseURI ( ) const [virtual, inherited]

Get the base URI for any relative URIs within this piece of content.

Generally, this is the document's base URI, but certain content carries a local base for backward compatibility, and XML supports setting a per-node base URI.

Returns:
the base URI

Implements nsIContent.

Reimplemented in nsGenericHTMLElement.

Definition at line 2477 of file nsGenericElement.cpp.

{
  nsIDocument* doc = GetOwnerDoc();
  if (!doc) {
    // We won't be able to do security checks, etc.  So don't go any
    // further.  That said, this really shouldn't happen...
    NS_ERROR("Element without owner document");
    return nsnull;
  }

  // Our base URL depends on whether we have an xml:base attribute, as
  // well as on whether any of our ancestors do.
  nsCOMPtr<nsIURI> parentBase;

  nsIContent *parent = GetParent();
  if (parent) {
    parentBase = parent->GetBaseURI();
  } else {
    // No parent, so just use the document (we must be the root or not in the
    // tree).
    parentBase = doc->GetBaseURI();
  }
  
  // Now check for an xml:base attr 
  nsAutoString value;
  nsresult rv = GetAttr(kNameSpaceID_XML, nsHTMLAtoms::base, value);
  if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
    // No xml:base, so we just use the parent's base URL
    nsIURI *base = parentBase;
    NS_IF_ADDREF(base);

    return base;
  }

  nsCOMPtr<nsIURI> ourBase;
  rv = NS_NewURI(getter_AddRefs(ourBase), value,
                 doc->GetDocumentCharacterSet().get(), parentBase);
  if (NS_SUCCEEDED(rv)) {
    // do a security check, almost the same as nsDocument::SetBaseURL()
    rv = nsContentUtils::GetSecurityManager()->
      CheckLoadURIWithPrincipal(doc->GetPrincipal(), ourBase,
                                nsIScriptSecurityManager::STANDARD);
  }

  nsIURI *base;
  if (NS_FAILED(rv)) {
    base = parentBase;
  } else {
    base = ourBase;
  }

  NS_IF_ADDREF(base);

  return base;    
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets content node with the binding responsible for our construction (and existence).

Used by anonymous content (XBL-generated). null for all explicit content.

Returns:
the binding parent

Reimplemented from nsGenericElement.

Definition at line 2847 of file nsXULElement.cpp.

{
    return mBindingParent;
}

Here is the caller graph for this function:

nsIContent * nsXULElement::GetChildAt ( PRUint32  aIndex) const [virtual]

Get a child by index.

Parameters:
aIndexthe index of the child to get, or null if index out of bounds
Returns:
the child

Reimplemented from nsGenericElement.

Definition at line 1068 of file nsXULElement.cpp.

Here is the call graph for this function:

Get the number of children.

Returns:
the number of children

Reimplemented from nsGenericElement.

Definition at line 1058 of file nsXULElement.cpp.

{
    if (NS_FAILED(EnsureContentsGenerated())) {
        return 0;
    }

    return PeekChildCount();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericElement::GetChildNodes ( nsIDOMNodeList **  aChildNodes) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1395 of file nsGenericElement.cpp.

{
  nsDOMSlots *slots = GetDOMSlots();

  if (!slots) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (!slots->mChildNodes) {
    slots->mChildNodes = new nsChildContentList(this);
    if (!slots->mChildNodes) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
  }

  NS_ADDREF(*aChildNodes = slots->mChildNodes);

  return NS_OK;
}

Here is the call graph for this function:

Returns an atom holding the name of the "class" attribute on this content node (if applicable).

Returns null for non-element content nodes.

Reimplemented from nsGenericElement.

Definition at line 2569 of file nsXULElement.cpp.

{
    return nsXULAtoms::clazz;
}

Reimplemented from nsGenericElement.

Definition at line 2462 of file nsXULElement.cpp.

{
    return FindLocalOrProtoAttr(kNameSpaceID_None, nsXULAtoms::clazz);
}

Here is the call graph for this function:

nsresult nsXULElement::GetCompiledEventHandler ( nsIAtom aName,
void **  aHandler 
) [virtual]

Retrieve an already-compiled event handler that can be bound to a target object using a script context.

Parameters:
aNamethe name of the event handler to retrieve
aHandlerthe compiled event handler

Implements nsIScriptEventHandlerOwner.

Definition at line 679 of file nsXULElement.cpp.

{
    XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheTests);
    *aHandler = nsnull;

    nsXULPrototypeAttribute *attr =
        FindPrototypeAttribute(kNameSpaceID_None, aName);
    if (attr) {
        XUL_PROTOTYPE_ATTRIBUTE_METER(gNumCacheHits);
        *aHandler = attr->mEventHandler;
    }

    return NS_OK;
}

Here is the call graph for this function:

void nsGenericElement::GetContentsAsText ( nsAString &  aText) [protected, inherited]

GetContentsAsText will take all the textnodes that are children of |this| and concatenate the text in them into aText.

It completely ignores any non-text-node children of |this|; in particular it does not descend into any children of |this| that happen to be container elements.

Parameters:
aTextthe resulting text [OUT]

Definition at line 4328 of file nsGenericElement.cpp.

{
  aText.Truncate();
  PRInt32 children = GetChildCount();

  nsCOMPtr<nsITextContent> tc;

  PRInt32 i;
  for (i = 0; i < children; ++i) {
    nsIContent *child = GetChildAt(i);

    if (child->IsContentOfType(eTEXT)) {
      tc = do_QueryInterface(child);

      tc->AppendTextTo(aText);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDocument* nsIContent::GetCurrentDoc ( ) const [inline, inherited]

Get the document that this content is currently in, if any.

This will be null if the content has no ancestor that is a document.

Returns:
the current document

Reimplemented in nsGenericDOMDataNode.

Definition at line 145 of file nsIContent.h.

  {
    // XXX This should become:
    // return IsInDoc() ? GetOwnerDoc() : nsnull;
    return GetDocument();
  }

Here is the call graph for this function:

nsIDocument* nsGenericElement::GetDocument ( ) const [inline, virtual, inherited]

DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.

Get the document for this content.

Returns:
the document

Implements nsIContent.

Definition at line 448 of file nsGenericElement.h.

  {
    return IsInDoc() ? GetOwnerDoc() : nsnull;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsIDOMNSFeatureFactory > nsGenericElement::GetDOMFeatureFactory ( const nsAString &  aFeature,
const nsAString &  aVersion 
) [static, inherited]

Definition at line 1330 of file nsGenericElement.cpp.

{
  nsIDOMNSFeatureFactory *factory = nsnull;
  nsCOMPtr<nsICategoryManager> categoryManager =
    do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
  if (categoryManager) {
    nsCAutoString featureCategory(NS_DOMNS_FEATURE_PREFIX);
    AppendUTF16toUTF8(aFeature, featureCategory);
    nsXPIDLCString contractID;
    nsresult rv = categoryManager->GetCategoryEntry(featureCategory.get(),
                                                    NS_ConvertUTF16toUTF8(aVersion).get(),
                                                    getter_Copies(contractID));
    if (NS_SUCCEEDED(rv)) {
      CallGetService(contractID.get(), &factory);  // addrefs
    }
  }
  return factory;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsDOMSlots* nsGenericElement::GetDOMSlots ( ) [inline, protected, inherited]

Definition at line 760 of file nsGenericElement.h.

  {
    if (!HasDOMSlots()) {
      nsDOMSlots *slots = new nsDOMSlots(mFlagsOrSlots);

      if (!slots) {
        return nsnull;
      }

      mFlagsOrSlots = NS_REINTERPRET_CAST(PtrBits, slots);
    }

    return NS_REINTERPRET_CAST(nsDOMSlots *, mFlagsOrSlots);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMNodeList nsIDOMXULElement::getElementsByAttribute ( in DOMString  name,
in DOMString  value 
) [inherited]
nsIDOMNodeList nsIDOMElement::getElementsByTagName ( in DOMString  name) [inherited]
nsresult nsGenericElement::GetElementsByTagName ( const nsAString &  aTagname,
nsIDOMNodeList **  aReturn 
) [inherited]

Reimplemented in nsGenericHTMLElement.

Definition at line 1592 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
  NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);

  nsContentList *list = NS_GetContentList(GetCurrentDoc(), nameAtom,
                                          kNameSpaceID_Unknown, this).get();
  NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);

  // transfer ref to aReturn
  *aReturn = list;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMNodeList nsIDOMElement::getElementsByTagNameNS ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]
nsresult nsGenericElement::GetElementsByTagNameNS ( const nsAString &  aNamespaceURI,
const nsAString &  aLocalName,
nsIDOMNodeList **  aReturn 
) [inherited]

Reimplemented in nsGenericHTMLElement.

Definition at line 1714 of file nsGenericElement.cpp.

{
  PRInt32 nameSpaceId = kNameSpaceID_Unknown;

  nsContentList *list = nsnull;

  nsIDocument* document = GetCurrentDoc();
  if (!aNamespaceURI.EqualsLiteral("*")) {
    nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI,
                                                          &nameSpaceId);

    if (nameSpaceId == kNameSpaceID_Unknown) {
      // Unknown namespace means no matches, we create an empty list...
      list = NS_GetContentList(document, nsnull,
                               kNameSpaceID_None, nsnull).get();
      NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
    }
  }

  if (!list) {
    nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
    NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);

    list = NS_GetContentList(document, nameAtom, nameSpaceId, this).get();
    NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
  }

  // transfer ref to aReturn
  *aReturn = list;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

already_AddRefed< nsINodeInfo > nsGenericElement::GetExistingAttrNameFromQName ( const nsAString &  aStr) const [virtual, inherited]

Normalizes an attribute name and returns it as a nodeinfo if an attribute with that name exists.

This method is intended for character case conversion if the content object is case insensitive (e.g. HTML). Returns the nodeinfo of the attribute with the specified name if one exists or null otherwise.

Parameters:
aStrthe unparsed attribute string
Returns:
the node info. May be nsnull.

Implements nsIContent.

Reimplemented in nsXTFElementWrapper.

Definition at line 2457 of file nsGenericElement.cpp.

{
  const nsAttrName* name = InternalGetExistingAttrNameFromQName(aStr);
  if (!name) {
    return nsnull;
  }

  nsINodeInfo* nodeInfo;
  if (name->IsAtom()) {
    mNodeInfo->NodeInfoManager()->GetNodeInfo(name->Atom(), nsnull,
                                              kNameSpaceID_None, &nodeInfo);
  }
  else {
    NS_ADDREF(nodeInfo = name->NodeInfo());
  }

  return nodeInfo;
}

Here is the call graph for this function:

nsDOMSlots* nsGenericElement::GetExistingDOMSlots ( ) const [inline, protected, inherited]

Definition at line 775 of file nsGenericElement.h.

  {
    if (!HasDOMSlots()) {
      return nsnull;
    }

    return NS_REINTERPRET_CAST(nsDOMSlots *, mFlagsOrSlots);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericElement::GetFirstChild ( nsIDOMNode **  aFirstChild) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1424 of file nsGenericElement.cpp.

{
  nsIContent *child = mAttrsAndChildren.GetSafeChildAt(0);
  if (child) {
    return CallQueryInterface(child, aNode);
  }

  *aNode = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

PtrBits nsGenericElement::GetFlags ( ) const [inline, protected, inherited]

Definition at line 784 of file nsGenericElement.h.

  {
    if (HasDOMSlots()) {
      return NS_REINTERPRET_CAST(nsDOMSlots *, mFlagsOrSlots)->mFlags;
    }

    return mFlagsOrSlots;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIAtom * nsXULElement::GetID ( ) const [virtual]

XXX GetID must be defined here because nsXUL element does not inherit from nsGenericElement.

Reimplemented from nsGenericElement.

Definition at line 2445 of file nsXULElement.cpp.

{
    const nsAttrValue* attrVal = FindLocalOrProtoAttr(kNameSpaceID_None, nsXULAtoms::id);

    NS_ASSERTION(!attrVal ||
                 attrVal->Type() == nsAttrValue::eAtom ||
                 (attrVal->Type() == nsAttrValue::eString &&
                  attrVal->GetStringValue().IsEmpty()),
                 "unexpected attribute type");

    if (attrVal && attrVal->Type() == nsAttrValue::eAtom) {
        return attrVal->GetAtomValue();
    }
    return nsnull;
}

Here is the call graph for this function:

Returns an atom holding the name of the attribute of type ID on this content node (if applicable).

Returns null for non-element content nodes.

Reimplemented from nsGenericElement.

Definition at line 2563 of file nsXULElement.cpp.

{
    return nsXULAtoms::id;
}

Reimplemented from nsGenericElement.

Definition at line 2490 of file nsXULElement.cpp.

{
    // Fetch the cached style rule from the attributes.
    const nsAttrValue* attrVal = FindLocalOrProtoAttr(kNameSpaceID_None, nsXULAtoms::style);

    if (attrVal && attrVal->Type() == nsAttrValue::eCSSStyleRule) {
        return attrVal->GetCSSStyleRuleValue();
    }

    return nsnull;
}

Here is the call graph for this function:

nsresult nsGenericElement::GetLastChild ( nsIDOMNode **  aLastChild) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1437 of file nsGenericElement.cpp.

{
  PRUint32 count = mAttrsAndChildren.ChildCount();
  
  if (count > 0) {
    return CallQueryInterface(mAttrsAndChildren.ChildAt(count - 1), aNode);
  }

  *aNode = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 546 of file nsXULElement.h.

    { return GetFlags() & (aFlag << XUL_ELEMENT_LAZY_STATE_OFFSET); }

Here is the call graph for this function:

Here is the caller graph for this function:

Get the event listener manager, the guy you talk to to register for events on this element.

Parameters:
aResultthe event listener manager [OUT]

Reimplemented from nsGenericElement.

Definition at line 622 of file nsXULElement.cpp.

{
    if (!mListenerManager) {
        nsresult rv =
            NS_NewEventListenerManager(getter_AddRefs(mListenerManager));
        if (NS_FAILED(rv))
            return rv;

        mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIContent*, this));
    }

    *aResult = mListenerManager;
    NS_ADDREF(*aResult);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsGenericElement::GetLocalName ( nsAString &  aLocalName) [inherited]

Reimplemented in nsDocumentFragment, and nsGenericHTMLElement.

Definition at line 1066 of file nsGenericElement.cpp.

{
  mNodeInfo->GetLocalName(aLocalName);
  return NS_OK;
}
PRInt32 nsGenericElement::GetNameSpaceID ( ) const [virtual, inherited]

Get the namespace that this element's tag is defined in.

Returns:
the namespace

Implements nsIContent.

Definition at line 2057 of file nsGenericElement.cpp.

{
  return mNodeInfo->NamespaceID();
}
NS_IMETHODIMP nsGenericElement::GetNamespaceURI ( nsAString &  aNamespaceURI) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1199 of file nsGenericElement.cpp.

{
  return mNodeInfo->GetNamespaceURI(aNamespaceURI);
}
NS_IMETHODIMP nsGenericElement::GetNextSibling ( nsIDOMNode **  aNextSibling) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1152 of file nsGenericElement.cpp.

{
  *aNextSibling = nsnull;

  nsIContent *sibling = nsnull;
  nsresult rv = NS_OK;

  nsIContent *parent = GetParent();
  if (parent) {
    PRInt32 pos = parent->IndexOf(this);
    if (pos > -1 ) {
      sibling = parent->GetChildAt(pos + 1);
    }
  } else {
    nsIDocument* document = GetCurrentDoc();
    if (document) {
      // Nodes that are just below the document (their parent is the
      // document) need to go to the document to find their next sibling.
      PRInt32 pos = document->IndexOf(this);
      if (pos > -1 ) {
        sibling = document->GetChildAt(pos + 1);
      }
    }
  }

  if (sibling) {
    rv = CallQueryInterface(sibling, aNextSibling);
    NS_ASSERTION(*aNextSibling, "Must be a DOM Node");
  }

  return rv;
}

Here is the call graph for this function:

nsINodeInfo * nsGenericElement::GetNodeInfo ( ) const [virtual, inherited]

Get the NodeInfo for this element.

Returns:
the nodes node info

Implements nsIContent.

Definition at line 2069 of file nsGenericElement.cpp.

{
  return mNodeInfo;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsGenericElement::GetNodeName ( nsAString &  aNodeName) [inherited]

Reimplemented in nsGenericHTMLElement, and nsDocumentFragment.

Definition at line 1059 of file nsGenericElement.cpp.

{
  mNodeInfo->GetQualifiedName(aNodeName);
  return NS_OK;
}

Reimplemented in nsDocumentFragment.

Definition at line 1089 of file nsGenericElement.cpp.

{
  *aNodeType = (PRUint16)nsIDOMNode::ELEMENT_NODE;
  return NS_OK;
}
NS_IMETHODIMP nsGenericElement::GetNodeValue ( nsAString &  aNodeValue) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1073 of file nsGenericElement.cpp.

{
  SetDOMStringToNull(aNodeValue);

  return NS_OK;
}

Here is the call graph for this function:

nsIDocument* nsGenericElement::GetOwnerDoc ( ) const [inline, virtual, inherited]

Get the ownerDocument for this content.

Returns:
the ownerDocument

Implements nsIContent.

Definition at line 461 of file nsGenericElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsDocumentFragment.

Definition at line 1186 of file nsGenericElement.cpp.

{
  nsIDocument *doc = GetOwnerDoc();
  if (doc) {
    return CallQueryInterface(doc, aOwnerDocument);
  }

  *aOwnerDocument = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent* nsIContent::GetParent ( ) const [inline, inherited]

Get the parent content for this content.

Returns:
the parent, or null if no parent

Definition at line 163 of file nsIContent.h.

NS_IMETHODIMP nsGenericElement::GetParentNode ( nsIDOMNode **  aParentNode) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1096 of file nsGenericElement.cpp.

{
  nsIContent *parent = GetParent();
  if (parent) {
    return CallQueryInterface(parent, aParentNode);
  }

  nsIDocument* doc = GetCurrentDoc();
  if (doc) {
    // If we don't have a parent, but we're in the document, we must
    // be the root node of the document. The DOM says that the root
    // is the document.

    return CallQueryInterface(doc, aParentNode);
  }

  *aParentNode = nsnull;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2698 of file nsXULElement.cpp.

{
    for (nsIContent* current = GetParent(); current;
         current = current->GetParent()) {
        if (current->GetNodeInfo()->Equals(nsXULAtoms::listbox,
                                           kNameSpaceID_XUL)) {
            CallQueryInterface(current, aTreeElement);
            // XXX returning NS_OK because that's what the code used to do;
            // is that the right thing, though?

            return NS_OK;
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsGenericElement::GetPrefix ( nsAString &  aPrefix) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1205 of file nsGenericElement.cpp.

{
  mNodeInfo->GetPrefix(aPrefix);
  return NS_OK;
}
NS_IMETHODIMP nsGenericElement::GetPreviousSibling ( nsIDOMNode **  aPreviousSibling) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1118 of file nsGenericElement.cpp.

{
  *aPrevSibling = nsnull;

  nsIContent *sibling = nsnull;
  nsresult rv = NS_OK;

  nsIContent *parent = GetParent();
  if (parent) {
    PRInt32 pos = parent->IndexOf(this);
    if (pos > 0 ) {
      sibling = parent->GetChildAt(pos - 1);
    }
  } else {
    nsIDocument* document = GetCurrentDoc();
    if (document) {
      // Nodes that are just below the document (their parent is the
      // document) need to go to the document to find their next sibling.
      PRInt32 pos = document->IndexOf(this);
      if (pos > 0 ) {
        sibling = document->GetChildAt(pos - 1);
      }
    }
  }

  if (sibling) {
    rv = CallQueryInterface(sibling, aPrevSibling);
    NS_ASSERTION(*aPrevSibling, "Must be a DOM Node");
  }

  return rv;
}

Here is the call graph for this function:

void * nsGenericElement::GetProperty ( nsIAtom aPropertyName,
nsresult aStatus = nsnull 
) const [virtual, inherited]

Reimplemented from nsIContent.

Definition at line 4348 of file nsGenericElement.cpp.

{
  nsIDocument *doc = GetOwnerDoc();
  if (!doc)
    return nsnull;

  return doc->PropertyTable()->GetProperty(this, aPropertyName, aStatus);
}

Here is the call graph for this function:

Get the list of ranges that have either endpoint in this content item.

Returns:
the list of ranges owned partially by this content. The nsVoidArray is owned by the content object and its lifetime is controlled completely by the content object.

Reimplemented from nsGenericElement.

Definition at line 2333 of file nsXULElement.cpp.

{
    // XUL content does not yet support DOM ranges
    return nsnull;
}

During the Mark phase of the GC, we need to mark all of the preserved wrappers that are reachable via DOM APIs.

Since reachability for DOM nodes is symmetric, if one DOM node is reachable from another via DOM APIs, then they are in the same strongly connected component. (Strongly connected components are never reachable from each other via DOM APIs.) We can refer to each strongly connected component by walking up to the top of the parent chain. This function finds that root node for any DOM node.

Implements nsIDOMGCParticipant.

Definition at line 1029 of file nsGenericElement.cpp.

{
  // This is an optimized way of walking nsIDOMNode::GetParentNode to
  // the top of the tree.
  nsCOMPtr<nsIDOMGCParticipant> result = do_QueryInterface(GetCurrentDoc());
  if (!result) {
    nsIContent *top = this;
    while (top->GetParent())
      top = top->GetParent();
    result = do_QueryInterface(top);
  }

  return result;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGenericElement::GetTagName ( nsAString &  aTagName) [inherited]

Reimplemented in nsGenericHTMLElement.

Definition at line 1451 of file nsGenericElement.cpp.

{
  mNodeInfo->GetQualifiedName(aTagName);
  return NS_OK;
}
static nsIXBLService* nsXULElement::GetXBLService ( ) [inline, static]

Definition at line 444 of file nsXULElement.h.

                                          {
        if (!gXBLService)
            CallGetService("@mozilla.org/xbl;1", &gXBLService);
        return gXBLService;
    }

Here is the call graph for this function:

void nsIChromeEventHandler::handleChromeEvent ( in nsPresContext  aPresContext,
in nsEventPtr  aEvent,
out nsIDOMEvent  aDOMEvent,
in unsigned long  aFlags,
inout nsEventStatus  aStatus 
) [inherited]

Handle a chrome DOM event.

nsresult nsXULElement::HandleDOMEvent ( nsPresContext aPresContext,
nsEvent aEvent,
nsIDOMEvent **  aDOMEvent,
PRUint32  aFlags,
nsEventStatus aEventStatus 
) [virtual]

Handle a DOM event for this piece of content.

This method is responsible for handling and controlling all three stages of events, capture, local and bubble. It also does strange things to anonymous content which whiz right by this author's head.

Here are some beginning explanations:

  • if in INIT or CAPTURE mode, it must pass the event to its parent in CAPTURE mode (this happens before the event is fired, therefore the firing of events will occur from the root up to the target).
  • The event is fired to listeners.
  • If in INIT or BUBBLE mode, it passes the event to its parent in BUBBLE mode. This means that the events will be fired up the chain starting from the target to the ancestor.

NOTE: if you are extending nsGenericElement and have to do a default action, call super::HandleDOMEvent() first and check for aEventStatus != nsEventStatus_eIgnore and make sure you are not in CAPTURE mode before proceeding.

XXX Go comment that method, Will Robinson.

Parameters:
aPresContextthe current presentation context
aEventthe event that is being propagated
aDOMEventa special event that may contain a modified target. Pass in null here or aDOMEvent if you are in HandleDOMEvent already; don't worry your pretty little head about it.
aFlagsflags that describe what mode we are in. Generally NS_EVENT_FLAG_CAPTURE, NS_EVENT_FLAG_BUBBLE and NS_EVENT_FLAG_INIT are the ones that matter.
aEventStatusthe status returned from the function. Generally nsEventStatus_eIgnore

Reimplemented from nsGenericElement.

Definition at line 1957 of file nsXULElement.cpp.

{
    // Make sure to tell the event that dispatch has started.
    NS_MARK_EVENT_DISPATCH_STARTED(aEvent);

    nsresult ret = NS_OK;

    PRBool retarget = PR_FALSE;
    PRBool externalDOMEvent = PR_FALSE;
    nsCOMPtr<nsIDOMEventTarget> oldTarget;

    nsIDOMEvent* domEvent = nsnull;
    if (NS_EVENT_FLAG_INIT & aFlags) {
        nsIAtom* tag = Tag();
        if (aEvent->message == NS_XUL_COMMAND && tag != nsXULAtoms::command) {
            // See if we have a command elt.  If so, we execute on the command instead
            // of on our content element.
            nsAutoString command;
            GetAttr(kNameSpaceID_None, nsXULAtoms::command, command);
            if (!command.IsEmpty()) {
                // XXX sXBL/XBL2 issue! Owner or current document?
                nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(GetCurrentDoc()));
                NS_ENSURE_STATE(domDoc);
                nsCOMPtr<nsIDOMElement> commandElt;
                domDoc->GetElementById(command, getter_AddRefs(commandElt));
                nsCOMPtr<nsIContent> commandContent(do_QueryInterface(commandElt));
                if (commandContent) {
                    // Create a new command event to the element pointed to
                    // by the command attribute.  The new event's sourceEvent
                    // will be the original event that we're handling.
                    aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;

                    nsXULCommandEvent event(NS_IS_TRUSTED_EVENT(aEvent),
                                            NS_XUL_COMMAND, nsnull);
                    if (aEvent->eventStructType == NS_XUL_COMMAND_EVENT) {
                        nsXULCommandEvent *orig =
                            NS_STATIC_CAST(nsXULCommandEvent*, aEvent);

                        event.isShift = orig->isShift;
                        event.isControl = orig->isControl;
                        event.isAlt = orig->isAlt;
                        event.isMeta = orig->isMeta;
                    } else {
                        NS_WARNING("Incorrect eventStructType for command event");
                    }

                    // Make sure we have a DOMEvent.
                    if (aDOMEvent) {
                        if (*aDOMEvent) {
                            externalDOMEvent = PR_TRUE;
                        }
                    } else {
                        aDOMEvent = &domEvent;
                    }

                    if (!*aDOMEvent) {
                        nsCOMPtr<nsIEventListenerManager> lm;
                        ret = GetListenerManager(getter_AddRefs(lm));
                        NS_ENSURE_SUCCESS(ret, ret);

                        ret = lm->CreateEvent(aPresContext, aEvent,
                                              EmptyString(), aDOMEvent);
                        NS_ENSURE_SUCCESS(ret, ret);

                        // We need to explicitly set the target here, because
                        // the DOM implementation will try to compute the
                        // target from the frame. If we don't have a frame
                        // (e.g., we're a key), then that breaks.
                        nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
                            do_QueryInterface(*aDOMEvent);
                        NS_ENSURE_TRUE(privateEvent, NS_ERROR_FAILURE);

                        nsCOMPtr<nsIDOMEventTarget> target =
                            do_QueryInterface(NS_STATIC_CAST(nsIContent*,
                                                             this));
                        privateEvent->SetTarget(target);
                    }
                    event.sourceEvent = *aDOMEvent;

                    ret = commandContent->HandleDOMEvent(aPresContext,
                                                         &event, nsnull,
                                                         NS_EVENT_FLAG_INIT,
                                                         aEventStatus);

                    // We're leaving the DOM event loop so if we created a
                    // DOM event, release here.  If externalDOMEvent is
                    // set, the event was passed in, and we don't own it.
                    if (*aDOMEvent && !externalDOMEvent) {
                        nsrefcnt rc;
                        NS_RELEASE2(*aDOMEvent, rc);
                        // Note: we expect one outstanding reference to
                        // *aDOMEvent, because we set it in event.sourceEvent.
                        if (rc > 1) {
                            // Okay, so someone in the DOM loop (a listener,
                            // JS object) still has a ref to the DOM Event,
                            // but the internal data hasn't been malloc'd.
                            // Force a copy of the data here so the DOM Event
                            // is still valid.
                            nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
                                do_QueryInterface(*aDOMEvent);
                            if (privateEvent) {
                                privateEvent->DuplicatePrivateData();
                            }
                        }
                    }
                    return ret;
                }
                else {
                    NS_WARNING("A XUL element is attached to a command that doesn't exist!\n");
                    return NS_ERROR_FAILURE;
                }
            }
        }
        if (aDOMEvent) {
            if (*aDOMEvent)
                externalDOMEvent = PR_TRUE;
        }
        else
            aDOMEvent = &domEvent;

        aEvent->flags |= aFlags;
        aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
        aFlags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;

        if (!externalDOMEvent) {
            // In order for the event to have a proper target for events that don't go through
            // the presshell (onselect, oncommand, oncreate, ondestroy) we need to set our target
            // ourselves. Also, key sets and menus don't have frames and therefore need their
            // targets explicitly specified.
            //
            // We need this for drag&drop as well since the mouse may have moved into a different
            // frame between the initial mouseDown and the generation of the drag gesture.
            // Obviously, the target should be the content/frame where the mouse was depressed,
            // not one computed by the current mouse location.
            if (aEvent->message == NS_XUL_COMMAND || aEvent->message == NS_XUL_POPUP_SHOWING ||
                aEvent->message == NS_XUL_POPUP_SHOWN || aEvent->message == NS_XUL_POPUP_HIDING ||
                aEvent->message == NS_XUL_POPUP_HIDDEN || aEvent->message == NS_FORM_SELECTED ||
                aEvent->message == NS_XUL_BROADCAST || aEvent->message == NS_XUL_COMMAND_UPDATE ||
                aEvent->message == NS_XUL_CLICK || aEvent->message == NS_DRAGDROP_GESTURE ||
                tag == nsXULAtoms::menu || tag == nsXULAtoms::menuitem ||
                tag == nsXULAtoms::menulist || tag == nsXULAtoms::menubar ||
                tag == nsXULAtoms::menupopup || tag == nsXULAtoms::key ||
                tag == nsXULAtoms::keyset) {

                nsCOMPtr<nsIEventListenerManager> listenerManager;
                if (NS_FAILED(ret = GetListenerManager(getter_AddRefs(listenerManager)))) {
                    NS_ERROR("Unable to instantiate a listener manager on this event.");
                    return ret;
                }
                nsAutoString empty;
                if (NS_FAILED(ret = listenerManager->CreateEvent(aPresContext, aEvent, empty, aDOMEvent))) {
                    NS_ERROR("This event will fail without the ability to create the event early.");
                    return ret;
                }

                // We need to explicitly set the target here, because the
                // DOM implementation will try to compute the target from
                // the frame. If we don't have a frame (e.g., we're a
                // menu), then that breaks.
                nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
                if (privateEvent) {
                    nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
                    privateEvent->SetTarget(target);
                }
                else
                    return NS_ERROR_FAILURE;

                // if we are a XUL click, we have the private event set.
                // now switch to a left mouse click for the duration of the event
                if (aEvent->message == NS_XUL_CLICK)
                    aEvent->message = NS_MOUSE_LEFT_CLICK;
            }
        }
    }
    else if (aEvent->message == NS_IMAGE_LOAD)
        return NS_OK; // Don't let these events bubble or be captured.  Just allow them
                    // on the target image.

    // Find out whether we're anonymous.
    // XXX Workaround bug 280541 without regressing bug 251197
    if (nsGenericElement::IsNativeAnonymous()) {
        retarget = PR_TRUE;
    } else {
        nsIContent* parent = GetParent();
        if (parent) {
            if (*aDOMEvent) {
                (*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget));
                nsCOMPtr<nsIContent> content(do_QueryInterface(oldTarget));
                if (content && content->GetBindingParent() == parent)
                    retarget = PR_TRUE;
            } else if (GetBindingParent() == parent) {
                retarget = PR_TRUE;
            }
        }
    }

    // determine the parent:
    nsCOMPtr<nsIContent> parent;
    // XXX sXBL/XBL2 issue! Owner or current document?
    nsIDocument* doc = GetCurrentDoc();
    if (doc) {
        // check for an anonymous parent
        doc->BindingManager()->GetInsertionParent(this,
                                                  getter_AddRefs(parent));
    }

    if (!parent) {
        // if we didn't find an anonymous parent, use the explicit one,
        // whether it's null or not...
        parent = GetParent();
    }

    if (retarget || (parent != GetParent())) {
        if (!*aDOMEvent) {
            // We haven't made a DOMEvent yet.  Force making one now.
            nsCOMPtr<nsIEventListenerManager> listenerManager;
            if (NS_FAILED(ret = GetListenerManager(getter_AddRefs(listenerManager)))) {
                return ret;
            }
            nsAutoString empty;
            if (NS_FAILED(ret = listenerManager->CreateEvent(aPresContext, aEvent, empty, aDOMEvent)))
                return ret;

            if (!*aDOMEvent) {
                return NS_ERROR_FAILURE;
            }
        }

        nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
            do_QueryInterface(*aDOMEvent);
        if (!privateEvent) {
            return NS_ERROR_FAILURE;
        }

        (*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget));

        PRBool hasOriginal;
        privateEvent->HasOriginalTarget(&hasOriginal);

        if (!hasOriginal)
            privateEvent->SetOriginalTarget(oldTarget);

        if (retarget) {
            nsCOMPtr<nsIDOMEventTarget> target =
                do_QueryInterface(GetParent());
            privateEvent->SetTarget(target);
      }
    }

    //Capturing stage evaluation
    if (NS_EVENT_FLAG_CAPTURE & aFlags &&
        !(aEvent->eventStructType == NS_MUTATION_EVENT &&
          IsAnonymousForEvents())) {
        //Initiate capturing phase.  Special case first call to document
        if (parent) {
            parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags & NS_EVENT_CAPTURE_MASK, aEventStatus);
        }
        else if (doc) {
            ret = doc->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
                                      aFlags & NS_EVENT_CAPTURE_MASK,
                                      aEventStatus);
        }
    }


    if (retarget) {
        // The event originated beneath us, and we performed a retargeting.
        // We need to restore the original target of the event.
        nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
        if (privateEvent)
            privateEvent->SetTarget(oldTarget);
    }

    //Local handling stage
    if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
        aEvent->flags |= aFlags;
        nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
        mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, target, aFlags, aEventStatus);
        aEvent->flags &= ~aFlags;
    }

    if (retarget) {
        // The event originated beneath us, and we need to perform a
        // retargeting.
        nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
        if (privateEvent) {
            nsCOMPtr<nsIDOMEventTarget> parentTarget =
                do_QueryInterface(GetParent());
            privateEvent->SetTarget(parentTarget);
        }
    }

    //Bubbling stage
    if (NS_EVENT_FLAG_BUBBLE & aFlags &&
        !(aEvent->eventStructType == NS_MUTATION_EVENT &&
          IsAnonymousForEvents())) {
        if (parent != nsnull) {
            // We have a parent. Let them field the event.
            ret = parent->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
                                         aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
      }
        else if (IsInDoc()) {
        // We must be the document root. The event should bubble to the
        // document.
        ret = GetCurrentDoc()->HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
                                            aFlags & NS_EVENT_BUBBLE_MASK, aEventStatus);
        }
    }

    if (retarget) {
        // The event originated beneath us, and we performed a retargeting.
        // We need to restore the original target of the event.
        nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
        if (privateEvent)
            privateEvent->SetTarget(oldTarget);
    }

    if (NS_EVENT_FLAG_INIT & aFlags) {
        // We're leaving the DOM event loop so if we created a DOM event,
        // release here.  If externalDOMEvent is set the event was passed in
        // and we don't own it
        if (*aDOMEvent && !externalDOMEvent) {
            nsrefcnt rc;
            NS_RELEASE2(*aDOMEvent, rc);
            if (0 != rc) {
                // Okay, so someone in the DOM loop (a listener, JS object)
                // still has a ref to the DOM Event but the internal data
                // hasn't been malloc'd.  Force a copy of the data here so the
                // DOM Event is still valid.
                nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
                    do_QueryInterface(*aDOMEvent);
                if (privateEvent) {
                    privateEvent->DuplicatePrivateData();
                }
            }
            aDOMEvent = nsnull;
        }

        // Now that we're done with this event, remove the flag that says
        // we're in the process of dispatching this event.
        NS_MARK_EVENT_DISPATCH_DONE(aEvent);
    }

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsXULElement::HasAttr ( PRInt32  aNameSpaceID,
nsIAtom aName 
) const [virtual]

Determine if an attribute has been set (empty string or otherwise).

Parameters:
aNameSpaceIdthe namespace id of the attribute
aAttrthe attribute name
Returns:
whether an attribute exists

Reimplemented from nsGenericElement.

Definition at line 1573 of file nsXULElement.cpp.

{
    NS_ASSERTION(nsnull != aName, "must have attribute name");
    NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
                 "must have a real namespace ID!");

    return mAttrsAndChildren.GetAttr(aName, aNameSpaceID) ||
           FindPrototypeAttribute(aNameSpaceID, aName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIDOMElement::hasAttribute ( in DOMString  name) [inherited]
nsresult nsGenericElement::HasAttribute ( const nsAString &  aName,
PRBool aReturn 
) [inherited]

Reimplemented in nsXTFElementWrapper.

Definition at line 1749 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);

  const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
  *aReturn = (name != nsnull);

  return NS_OK;
}

Here is the call graph for this function:

boolean nsIDOMElement::hasAttributeNS ( in DOMString  namespaceURI,
in DOMString  localName 
) [inherited]
nsresult nsGenericElement::HasAttributeNS ( const nsAString &  aNamespaceURI,
const nsAString &  aLocalName,
PRBool aReturn 
) [inherited]

Definition at line 1760 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);

  PRInt32 nsid;
  nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, &nsid);

  if (nsid == kNameSpaceID_Unknown) {
    // Unknown namespace means no attr...

    *aReturn = PR_FALSE;

    return NS_OK;
  }

  nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
  *aReturn = HasAttr(nsid, name);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGenericElement::HasAttributes ( PRBool aHasAttributes) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1359 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);

  *aReturn = GetAttrCount() > 0;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericElement::HasChildNodes ( PRBool aHasChildNodes) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1416 of file nsGenericElement.cpp.

{
  *aReturn = mAttrsAndChildren.ChildCount() > 0;

  return NS_OK;
}

Here is the call graph for this function:

PRBool nsGenericElement::HasDOMSlots ( ) const [inline, protected, inherited]

Definition at line 755 of file nsGenericElement.h.

Here is the caller graph for this function:

PRBool nsGenericElement::HasEventListenerManager ( ) const [inline, protected, inherited]

Definition at line 834 of file nsGenericElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsGenericElement::HasMutationListeners ( nsIContent aContent,
PRUint32  aType 
) [static, inherited]

Quick helper to determine whether there are any mutation listeners of a given type that apply to this content (are at or above it).

Parameters:
aContentthe content to look for listeners for
aTypethe type of listener (NS_EVENT_BITS_MUTATION_*)
Returns:
whether there are mutation listeners of the specified type for this content or not

Definition at line 3900 of file nsGenericElement.cpp.

{
  nsIDocument* doc = aContent->GetDocument();
  if (!doc)
    return PR_FALSE;

  nsIScriptGlobalObject *global = doc->GetScriptGlobalObject();
  if (!global)
    return PR_FALSE;

  nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(global));
  if (!window)
    return PR_FALSE;

  if (!window->HasMutationListeners(aType))
    return PR_FALSE;

  // We know a mutation listener is registered, but it might not
  // be in our chain.  Check quickly to see.

  for (nsIContent* curr = aContent; curr; curr = curr->GetParent())
    if (NodeHasMutationListeners(curr))
      return PR_TRUE;

  return NodeHasMutationListeners(doc) || NodeHasMutationListeners(window);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsGenericElement::HasProperties ( ) const [inline, protected, inherited]

Definition at line 842 of file nsGenericElement.h.

  {
    PtrBits flags = GetFlags();

    return (flags & GENERIC_ELEMENT_HAS_PROPERTIES) != 0;
  }

Here is the call graph for this function:

PRBool nsGenericElement::HasRangeList ( ) const [inline, protected, inherited]

Definition at line 827 of file nsGenericElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULElement::HideWindowChrome ( PRBool  aShouldHide) [protected]

Definition at line 2994 of file nsXULElement.cpp.

{
    nsIDocument* doc = GetCurrentDoc();
    if (!doc)
      return NS_ERROR_UNEXPECTED;

    // only top level chrome documents can hide the window chrome
    if (doc->GetParentDocument())
      return NS_OK;

    nsIPresShell *shell = doc->GetShellAt(0);

    if (shell) {
        nsIContent* content = NS_STATIC_CAST(nsIContent*, this);
        nsIFrame* frame = nsnull;
        shell->GetPrimaryFrameFor(content, &frame);

        nsPresContext *presContext = shell->GetPresContext();

        if (frame && presContext && presContext->IsChrome()) {
            nsIView* view = frame->GetClosestView();

            if (view) {
                // XXXldb Um, not all views have widgets...
                view->GetWidget()->HideWindowChrome(aShouldHide);
            }
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsXULElement::IndexOf ( nsIContent aPossibleChild) const [virtual]

Get the index of a child within this content.

Parameters:
aPossibleChildthe child to get the index
Returns:
the index of the child, or -1 if not a child

Reimplemented from nsGenericElement.

Definition at line 1078 of file nsXULElement.cpp.

{
    if (NS_FAILED(EnsureContentsGenerated())) {
        return -1;
    }

    return mAttrsAndChildren.IndexOfChild(aPossibleChild);
}

Here is the call graph for this function:

nsresult nsGenericElement::InitHashes ( ) [static, inherited]
nsIDOMNode nsIDOMNode::insertBefore ( in nsIDOMNode  newChild,
in nsIDOMNode  refChild 
) raises (DOMException) [inherited]
NS_IMETHODIMP nsGenericElement::InsertBefore ( nsIDOMNode aNewChild,
nsIDOMNode aRefChild,
nsIDOMNode **  aReturn 
) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 3069 of file nsGenericElement.cpp.

{
  return doReplaceOrInsertBefore(PR_FALSE, aNewChild, aRefChild, this,
                                 GetCurrentDoc(), mAttrsAndChildren, aReturn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXULElement::InsertChildAt ( nsIContent aKid,
PRUint32  aIndex,
PRBool  aNotify 
) [virtual]

Insert a content node at a particular index.

Parameters:
aKidthe content to insert
aIndexthe index it is being inserted at (the index it will have after it is inserted)
aNotifywhether to notify the document and appropriate mutation event listeners that the insert has occurred

Reimplemented from nsGenericElement.

Definition at line 1088 of file nsXULElement.cpp.

{
    nsresult rv = EnsureContentsGenerated();
    NS_ENSURE_SUCCESS(rv, rv);

    NS_PRECONDITION(nsnull != aKid, "null ptr");

    // Make sure that we're not trying to insert the same child
    // twice. If we do, the DOM APIs (e.g., GetNextSibling()), will
    // freak out.
    NS_ASSERTION(mAttrsAndChildren.IndexOfChild(aKid) < 0,
                 "element is already a child");

    PRBool isAppend = aIndex == mAttrsAndChildren.ChildCount();
    
    nsIDocument* doc = GetCurrentDoc();
    mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);

    rv = mAttrsAndChildren.InsertChildAt(aKid, aIndex);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = aKid->BindToTree(doc, this, nsnull, PR_TRUE);
    if (NS_FAILED(rv)) {
        mAttrsAndChildren.RemoveChildAt(aIndex);
        aKid->UnbindFromTree();
        return rv;
    }

    // XXXbz this screws up ranges, no?  Need to figure out why this is
    // commented and uncomment....
    //nsRange::OwnerChildInserted(this, aIndex);

    // The kid may have removed us from the document, so recheck that we're
    // still in the document before proceeding.  Also, the kid may have just
    // removed itself, in which case we don't really want to fire
    // ContentAppended or a mutation event.
    // XXXbz What if the kid just moved us in the document?  Scripts suck.  We
    // really need to stop running them while we're in the middle of modifying
    // the DOM....
    if (doc && doc == GetCurrentDoc() && aKid->GetParent() == this) {
        if (aNotify) {
            if (isAppend) {
                doc->ContentAppended(this, aIndex);
            } else {
                doc->ContentInserted(this, aKid, aIndex);
            }
        }

        if (HasMutationListeners(this,
                                 NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
            nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
            mutation.mRelatedNode =
                do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this));

            nsEventStatus status = nsEventStatus_eIgnore;
            aKid->HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT,
                                 &status);
        }

    }

    return NS_OK;
}

Here is the call graph for this function:

const nsAttrName * nsXULElement::InternalGetExistingAttrNameFromQName ( const nsAString &  aStr) const [protected, virtual]

Internal hook for converting an attribute name-string to an atomized name.

Reimplemented from nsGenericElement.

Definition at line 1526 of file nsXULElement.cpp.

{
    NS_ConvertUTF16toUTF8 name(aStr);
    const nsAttrName* attrName =
        mAttrsAndChildren.GetExistingAttrNameFromQName(name);
    if (attrName) {
        return attrName;
    }

    if (mPrototype) {
        PRUint32 i;
        for (i = 0; i < mPrototype->mNumAttributes; ++i) {
            attrName = &mPrototype->mAttributes[i].mName;
            if (attrName->QualifiedNameEquals(name)) {
                return attrName;
            }
        }
    }

    return nsnull;
}

Here is the call graph for this function:

nsresult nsGenericElement::InternalGetFeature ( nsISupports *  aObject,
const nsAString &  aFeature,
const nsAString &  aVersion,
nsISupports **  aReturn 
) [static, inherited]

Definition at line 1313 of file nsGenericElement.cpp.

{
  *aReturn = nsnull;
  nsCOMPtr<nsIDOMNSFeatureFactory> factory =
    GetDOMFeatureFactory(aFeature, aVersion);

  if (factory) {
    factory->GetFeature(aObject, aFeature, aVersion, aReturn);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericElement::InternalIsSupported ( nsISupports *  aObject,
const nsAString &  aFeature,
const nsAString &  aVersion,
PRBool aReturn 
) [static, inherited]

Check whether a spec feature/version is supported.

Parameters:
aObjectthe object, which should support the feature, for example nsIDOMNode or nsIDOMDOMImplementation
aFeaturethe feature ("Views", "Core", "HTML", "Range" ...)
aVersionthe version ("1.0", "2.0", ...)
aReturnwhether the feature is supported or not [OUT]

Definition at line 1237 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);
  *aReturn = PR_FALSE;

  // Convert the incoming UTF16 strings to raw char*'s to save us some
  // code when doing all those string compares.
  NS_ConvertUTF16toUTF8 feature(aFeature);
  NS_ConvertUTF16toUTF8 version(aVersion);

  const char *f = feature.get();
  const char *v = version.get();

  if (PL_strcasecmp(f, "XML") == 0 ||
      PL_strcasecmp(f, "HTML") == 0) {
    if (aVersion.IsEmpty() ||
        PL_strcmp(v, "1.0") == 0 ||
        PL_strcmp(v, "2.0") == 0) {
      *aReturn = PR_TRUE;
    }
  } else if (PL_strcasecmp(f, "Views") == 0 ||
             PL_strcasecmp(f, "StyleSheets") == 0 ||
             PL_strcasecmp(f, "Core") == 0 ||
             PL_strcasecmp(f, "CSS") == 0 ||
             PL_strcasecmp(f, "CSS2") == 0 ||
             PL_strcasecmp(f, "Events") == 0 ||
             PL_strcasecmp(f, "UIEvents") == 0 ||
             PL_strcasecmp(f, "MouseEvents") == 0 ||
             // Non-standard!
             PL_strcasecmp(f, "MouseScrollEvents") == 0 ||
             PL_strcasecmp(f, "HTMLEvents") == 0 ||
             PL_strcasecmp(f, "Range") == 0 ||
             PL_strcasecmp(f, "XHTML") == 0) {
    if (aVersion.IsEmpty() ||
        PL_strcmp(v, "2.0") == 0) {
      *aReturn = PR_TRUE;
    }
  } else if ((!gCheckedForXPathDOM || gHaveXPathDOM) &&
             PL_strcasecmp(f, "XPath") == 0 &&
             (aVersion.IsEmpty() ||
              PL_strcmp(v, "3.0") == 0)) {
    if (!gCheckedForXPathDOM) {
      nsCOMPtr<nsIDOMXPathEvaluator> evaluator =
        do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID);
      gHaveXPathDOM = (evaluator != nsnull);
      gCheckedForXPathDOM = PR_TRUE;
    }

    *aReturn = gHaveXPathDOM;
  }
#ifdef MOZ_SVG
  else if (PL_strcasecmp(f, "SVGEvents") == 0 ||
           PL_strcasecmp(f, "SVGZoomEvents") == 0 ||
           NS_SVG_TestFeature(aFeature)) {
    if (aVersion.IsEmpty() ||
        PL_strcmp(v, "1.0") == 0 ||
        PL_strcmp(v, "1.1") == 0) {
      *aReturn = PR_TRUE;
    }
  }
#endif /* MOZ_SVG */
  else {
    nsCOMPtr<nsIDOMNSFeatureFactory> factory =
      GetDOMFeatureFactory(aFeature, aVersion);

    if (factory) {
      factory->HasFeature(aObject, aFeature, aVersion, aReturn);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual PRInt32 nsIContent::IntrinsicState ( ) const [inline, virtual, inherited]

Method to get the intrinsic content state of this content node.

This is the state that is independent of the node's presentation. To get the full content state, use nsIEventStateManager. Also see nsIEventStateManager for the possible bits that could be set here.

Reimplemented in nsGenericHTMLFormElement, nsHTMLInputElement, nsHTMLOptionElement, nsXTFElementWrapper, and nsHTMLOptGroupElement.

Definition at line 667 of file nsIContent.h.

  {
    return 0;
  }

Here is the caller graph for this function:

PRBool nsGenericElement::IsAnonymousForEvents ( ) const [inline, protected, inherited]

Returns PR_TRUE if this content is anonymous for event handling.

Definition at line 863 of file nsGenericElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

nsGenericElement::IsAttributeMapped ( const nsIAtom aAttribute) const [inherited]

Definition at line 2415 of file nsGenericElement.cpp.

{
  return PR_FALSE;
}

Here is the caller graph for this function:

PRBool nsXULElement::IsContentOfType ( PRUint32  aFlags) const [virtual]

API for doing a quick check if a content object is of a given type, such as HTML, XUL, Text, ...

Use this when you can instead of checking the tag.

Parameters:
aFlagswhat types you want to test for (see above, eTEXT, eELEMENT, eHTML, eHTML_FORM_CONTROL, eXUL)
Returns:
whether the content matches ALL flags passed in

Reimplemented from nsGenericElement.

Definition at line 2853 of file nsXULElement.cpp.

{
    return !(aFlags & ~(eELEMENT | eXUL));
}
virtual PRBool nsIContent::IsDoneAddingChildren ( ) [inline, virtual, inherited]

For HTML textarea, select, applet, and object elements, returns PR_TRUE if all children have been added OR if the element was not created by the parser.

Returns PR_TRUE for all other elements.

Reimplemented in nsHTMLSelectElement, nsHTMLTextAreaElement, nsHTMLObjectElement, and nsHTMLAppletElement.

Definition at line 654 of file nsIContent.h.

  {
    return PR_TRUE;
  }

Here is the caller graph for this function:

PRBool nsXULElement::IsFocusable ( PRInt32 aTabIndex = nsnull) [virtual]

Check if this content is focusable and in the current tab order.

Note: most callers should use nsIFrame::IsFocusable() instead as it checks visibility and other layout factors as well. Tabbable is indicated by a nonnegative tabindex & is a subset of focusable. For example, only the selected radio button in a group is in the tab order, unless the radio group has no selection in which case all of the visible, non-disabled radio buttons in the group are in the tab order. On the other hand, all of the visible, non-disabled radio buttons are always focusable via clicking or script. Also, depending on either the accessibility.tabfocus pref or a system setting (nowadays: Full keyboard access, mac only) some widgets may be focusable but removed from the tab order.

Parameters:
[inout,optional]aTabIndex the computed tab index In: default tabindex for element (-1 nonfocusable, == 0 focusable) Out: computed tabindex
[optional]aTabIndex the computed tab index < 0 if not tabbable == 0 if in normal tab order > 0 can be tabbed to in the order specified by this value
Returns:
whether the content is focusable via mouse, kbd or script.

Reimplemented from nsIContent.

Definition at line 639 of file nsXULElement.cpp.

{
  // Use incoming tabindex as default value
  PRInt32 tabIndex = aTabIndex? *aTabIndex : -1;
  PRBool disabled = tabIndex < 0;
  nsCOMPtr<nsIDOMXULControlElement> xulControl = 
    do_QueryInterface(NS_STATIC_CAST(nsIContent*, this));
  if (xulControl) {
    xulControl->GetDisabled(&disabled);
    if (disabled) {
      tabIndex = -1;  // Can't tab to disabled elements
    }
    else if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex)) {
      // If attribute not set, will use default value passed in
      xulControl->GetTabIndex(&tabIndex);
    }
    if (tabIndex != -1 && sTabFocusModelAppliesToXUL &&
        !(sTabFocusModel & eTabFocus_formElementsMask)) {
      // By default, the tab focus model doesn't apply to xul element on any system but OS X.
      // on OS X we're following it for UI elements (XUL) as sTabFocusModel is based on
      // "Full Keyboard Access" system setting (see mac/nsILookAndFeel).
      // both textboxes and list elements (i.e. trees and list) should always be focusable
      // (textboxes are handled as html:input)
      if (!mNodeInfo->Equals(nsXULAtoms::tree) && !mNodeInfo->Equals(nsXULAtoms::listbox))
        tabIndex = -1; 
    }
  }

  if (aTabIndex) {
    *aTabIndex = tabIndex;
  }

  return tabIndex >= 0 || (!disabled && HasAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex));
}

Here is the call graph for this function:

PRBool nsGenericElement::IsInDoc ( ) const [inline, virtual, inherited]

Returns true if the content has an ancestor that is a document.

Returns:
whether this content is in a document tree

Implements nsIContent.

Definition at line 457 of file nsGenericElement.h.

Here is the caller graph for this function:

Get whether this content is C++-generated anonymous content.

See also:
nsIAnonymousContentCreator
Returns:
whether this content is anonymous

Reimplemented from nsGenericElement.

Definition at line 1050 of file nsXULElement.cpp.

{
    // XXX Workaround for bug 280541, wallpaper for bug 326644
    return Tag() == nsXULAtoms::popupgroup &&
           nsGenericElement::IsNativeAnonymous();
}

Here is the call graph for this function:

boolean nsIDOMNode::isSupported ( in DOMString  feature,
in DOMString  version 
) [inherited]
NS_IMETHODIMP nsGenericElement::IsSupported ( const nsAString &  aFeature,
const nsAString &  aVersion,
PRBool aReturn 
) [inherited]

Reimplemented in nsDocumentFragment, and nsSVGElement.

Definition at line 1351 of file nsGenericElement.cpp.

{
  return InternalIsSupported(this, aFeature, aVersion, aReturn);
}

Here is the call graph for this function:

nsresult nsGenericElement::JoinTextNodes ( nsIContent aFirst,
nsIContent aSecond 
) [inherited]

Take two text nodes and append the second to the first.

Parameters:
aFirstthe node which will contain first + second [INOUT]
aSecondthe node which will be appended

Definition at line 1784 of file nsGenericElement.cpp.

{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIDOMText> firstText(do_QueryInterface(aFirst, &rv));

  if (NS_SUCCEEDED(rv)) {
    nsCOMPtr<nsIDOMText> secondText(do_QueryInterface(aSecond, &rv));

    if (NS_SUCCEEDED(rv)) {
      nsAutoString str;

      rv = secondText->GetData(str);
      if (NS_SUCCEEDED(rv)) {
        rv = firstText->AppendData(str);
      }
    }
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericElement::LeaveLink ( nsPresContext aPresContext) [inherited]

Do whatever needs to be done when the mouse leaves a link.

Definition at line 3733 of file nsGenericElement.cpp.

{
  nsILinkHandler *handler = aPresContext->GetLinkHandler();
  if (!handler) {
    return NS_OK;
  }

  return handler->OnLeaveLink();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Abandon our prototype linkage, and copy all attributes locally.

Definition at line 2956 of file nsXULElement.cpp.

{
    if (!mPrototype)
        return NS_OK;           // already heavyweight

    nsRefPtr<nsXULPrototypeElement> proto;
    proto.swap(mPrototype);

    PRBool hadAttributes = mAttrsAndChildren.AttrCount() > 0;

    PRUint32 i;
    nsresult rv;
    for (i = 0; i < proto->mNumAttributes; ++i) {
        nsXULPrototypeAttribute* protoattr = &proto->mAttributes[i];

        // We might have a local value for this attribute, in which case
        // we don't want to copy the prototype's value.
        if (hadAttributes &&
            mAttrsAndChildren.GetAttr(protoattr->mName.LocalName(),
                                      protoattr->mName.NamespaceID())) {
            continue;
        }

        // XXX we might wanna have a SetAndTakeAttr that takes an nsAttrName
        nsAttrValue attrValue(protoattr->mValue);
        if (protoattr->mName.IsAtom()) {
            rv = mAttrsAndChildren.SetAndTakeAttr(protoattr->mName.Atom(), attrValue);
        }
        else {
            rv = mAttrsAndChildren.SetAndTakeAttr(protoattr->mName.NodeInfo(),
                                                  attrValue);
        }
        NS_ENSURE_SUCCESS(rv, rv);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXULElement::MaybeAddPopupListener ( nsIAtom aLocalName) [protected]

Definition at line 805 of file nsXULElement.cpp.

{
    // If appropriate, add a popup listener. Called when we change the
    // element's document, create a new element, change an attribute's
    // value, etc.
    if (aLocalName == nsXULAtoms::menu ||
        aLocalName == nsXULAtoms::contextmenu ||
        // XXXdwh popup and context are deprecated
        aLocalName == nsXULAtoms::popup ||
        aLocalName == nsXULAtoms::context) {
        AddPopupListener(aLocalName);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Give this element a chance to fire links that should be fired automatically when loaded.

If the element was an autoloading link and it was succesfully handled, we will throw special nsresult values.

Parameters:
aShellthe current doc shell (to possibly load the link on)
Exceptions:
NS_OKif nothing happened
NS_XML_AUTOLINK_EMBEDif the caller is loading the link embedded
NS_XML_AUTOLINK_NEWif the caller is loading the link in a new window
NS_XML_AUTOLINK_REPLACEif it is loading a link that will replace the current window (and thus the caller must stop parsing)
NS_XML_AUTOLINK_UNDEFINEDif it is loading in any other way--in which case, the caller should stop parsing as well.

Reimplemented from nsGenericElement.

Definition at line 572 of file nsXULElement.cpp.

{
  return NS_OK;
}
PRBool nsGenericElement::MayHaveFrame ( ) const [virtual, inherited]

Returns PR_TRUE if there is a chance that the content node has a frame, PR_FALSE otherwise.

Reimplemented from nsIContent.

Definition at line 2774 of file nsGenericElement.cpp.

Here is the call graph for this function:

void nsIDOMNode::normalize ( ) [inherited]

Reimplemented in nsDocumentFragment.

Definition at line 1807 of file nsGenericElement.cpp.

{
  nsresult result = NS_OK;
  PRUint32 index, count = GetChildCount();

  for (index = 0; (index < count) && (NS_OK == result); index++) {
    nsIContent *child = GetChildAt(index);

    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(child);
    if (node) {
      PRUint16 nodeType;
      node->GetNodeType(&nodeType);

      switch (nodeType) {
        case nsIDOMNode::TEXT_NODE:

          if (index+1 < count) {
            // Get the sibling. If it's also a text node, then
            // remove it from the tree and join the two text
            // nodes.
            nsIContent *sibling = GetChildAt(index + 1);

            nsCOMPtr<nsIDOMNode> siblingNode = do_QueryInterface(sibling);

            if (siblingNode) {
              PRUint16 siblingNodeType;
              siblingNode->GetNodeType(&siblingNodeType);

              if (siblingNodeType == nsIDOMNode::TEXT_NODE) {
                result = RemoveChildAt(index+1, PR_TRUE);
                if (NS_FAILED(result)) {
                  return result;
                }

                result = JoinTextNodes(child, sibling);
                if (NS_FAILED(result)) {
                  return result;
                }
                count--;
                index--;
              }
            }
          }
          break;

        case nsIDOMNode::ELEMENT_NODE:
          nsCOMPtr<nsIDOMElement> element = do_QueryInterface(child);

          if (element) {
            result = element->Normalize();
          }
          break;
      }
    }
  }

  return result;
}

Here is the call graph for this function:

Reimplemented from nsGenericElement.

nsXULElement::NS_IMETHOD_ ( PRBool  ) const [virtual]

Is the attribute named stored in the mapped attributes?

This really belongs on nsIHTMLContent instead.

Implements nsIStyledContent.

Definition at line 540 of file nsXULElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

NS_DECL_ISUPPORTS nsresult nsGenericElement::PostQueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
) [inherited]

Called during QueryInterface to give the binding manager a chance to get an interface for this element.

nsresult nsXULElement::RangeAdd ( nsIDOMRange aRange) [virtual]

Inform content of range ownership changes.

This allows content to do the right thing to ranges in the face of changes to the content model. RangeRemove -- informs content that it no longer owns a range endpoint GetRangeList -- returns the list of ranges that have one or both endpoints within this content item Inform content that it owns one or both range endpoints

Parameters:
aRangethe range the content owns

Reimplemented from nsGenericElement.

Definition at line 2318 of file nsXULElement.cpp.

{
    // rdf content does not yet support DOM ranges
    return NS_OK;
}
void nsXULElement::RangeRemove ( nsIDOMRange aRange) [virtual]

Inform content that it no longer owns either range endpoint.

Parameters:
aRangethe range the content no longer owns

Reimplemented from nsGenericElement.

Definition at line 2326 of file nsXULElement.cpp.

{
    // rdf content does not yet support DOM ranges
}
static void nsXULElement::ReleaseGlobals ( ) [inline, static]

Definition at line 449 of file nsXULElement.h.

Here is the caller graph for this function:

void nsIDOMElement::removeAttribute ( in DOMString  name) raises (DOMException) [inherited]
nsresult nsGenericElement::RemoveAttribute ( const nsAString &  aName) [inherited]

Reimplemented in nsXTFElementWrapper.

Definition at line 1502 of file nsGenericElement.cpp.

{
  const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);

  if (!name) {
    return NS_OK;
  }

  // Hold a strong reference here so that the atom or nodeinfo doesn't go
  // away during UnsetAttr. If it did UnsetAttr would be left with a
  // dangling pointer as argument without knowing it.
  nsAttrName tmp(*name);

  return UnsetAttr(name->NamespaceID(), name->LocalName(), PR_TRUE);
}

Here is the call graph for this function:

nsIDOMAttr nsIDOMElement::removeAttributeNode ( in nsIDOMAttr  oldAttr) raises (DOMException) [inherited]
nsresult nsGenericElement::RemoveAttributeNode ( nsIDOMAttr aOldAttr,
nsIDOMAttr **  aReturn 
) [inherited]

Definition at line 1564 of file nsGenericElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aReturn);
  NS_ENSURE_ARG_POINTER(aAttribute);

  *aReturn = nsnull;

  nsCOMPtr<nsIDOMNamedNodeMap> map;
  nsresult rv = GetAttributes(getter_AddRefs(map));
  NS_ENSURE_SUCCESS(rv, rv);

  nsAutoString name;

  rv = aAttribute->GetName(name);
  if (NS_SUCCEEDED(rv)) {
    nsCOMPtr<nsIDOMNode> node;
    rv = map->RemoveNamedItem(name, getter_AddRefs(node));

    if (NS_SUCCEEDED(rv) && node) {
      rv = CallQueryInterface(node, aReturn);
    }
  }

  return rv;
}

Here is the call graph for this function:

void nsIDOMElement::removeAttributeNS ( in DOMString  namespaceURI,
in DOMString  localName 
) raises (DOMException) [inherited]
nsresult nsGenericElement::RemoveAttributeNS ( const nsAString &  aNamespaceURI,
const nsAString &  aLocalName 
) [inherited]

Definition at line 1646 of file nsGenericElement.cpp.

{
  nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
  PRInt32 nsid;

  nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, &nsid);

  if (nsid == kNameSpaceID_Unknown) {
    // Unknown namespace means no attr...

    return NS_OK;
  }

  nsAutoString tmp;
  UnsetAttr(nsid, name, PR_TRUE);

  return NS_OK;
}

Here is the call graph for this function: