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
nsHTMLFormElement Class Reference
Inheritance diagram for nsHTMLFormElement:
Inheritance graph
[legend]
Collaboration diagram for nsHTMLFormElement:
Collaboration graph
[legend]

List of all members.

Public Types

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

 nsHTMLFormElement (nsINodeInfo *aNodeInfo)
virtual ~nsHTMLFormElement ()
nsresult Init ()
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMHTMLFORMELEMENT
NS_DECL_NSIDOMNSHTMLFORMELEMENT
NS_DECL_NSIWEBPROGRESSLISTENER
NS_IMETHOD 
AddElement (nsIFormControl *aElement)
 Add an element to end of this form's list of elements.
NS_IMETHOD AddElementToTable (nsIFormControl *aChild, const nsAString &aName)
 Add an element to the lookup table mainted by the form.
NS_IMETHOD GetElementAt (PRInt32 aIndex, nsIFormControl **aElement) const
 Get the element at a specified index position in form.elements.
NS_IMETHOD GetElementCount (PRUint32 *aCount) const
 Get the number of elements in form.elements.
NS_IMETHOD RemoveElement (nsIFormControl *aElement)
 Remove an element from this form's list of elements.
NS_IMETHOD RemoveElementFromTable (nsIFormControl *aElement, const nsAString &aName)
 Remove an element from the lookup table mainted by the form.
NS_IMETHOD ResolveName (const nsAString &aName, nsISupports **aReturn)
 Resolve a name in the scope of the form object, this means find form controls in this form with the correct value in the name attribute.
NS_IMETHOD IndexOfControl (nsIFormControl *aControl, PRInt32 *aIndex)
 Get the index of the given control within form.elements.
NS_IMETHOD GetControlEnumerator (nsISimpleEnumerator **aEnumerator)
 Get an enumeration that goes through all controls, including images and that ilk.
NS_IMETHOD OnSubmitClickBegin ()
 Flag the form to know that a button or image triggered scripted form submission.
NS_IMETHOD OnSubmitClickEnd ()
NS_IMETHOD FlushPendingSubmission ()
 Flush a possible pending submission.
NS_IMETHOD ForgetPendingSubmission ()
 Forget a possible pending submission.
NS_IMETHOD GetActionURL (nsIURI **aActionURL)
 Get the full URL to submit to.
NS_IMETHOD SetCurrentRadioButton (const nsAString &aName, nsIDOMHTMLInputElement *aRadio)
 Set the current radio button in a group.
NS_IMETHOD GetCurrentRadioButton (const nsAString &aName, nsIDOMHTMLInputElement **aRadio)
 Get the current radio button in a group.
NS_IMETHOD GetPositionInGroup (nsIDOMHTMLInputElement *aRadio, PRInt32 *aPositionIndex, PRInt32 *aItemsInGroup)
 Get the radio group position and the number of radio buttons in the group.
NS_IMETHOD GetNextRadioButton (const nsAString &aName, const PRBool aPrevious, nsIDOMHTMLInputElement *aFocusedRadio, nsIDOMHTMLInputElement **aRadioOut)
 Get the next/prev radio button in a group.
NS_IMETHOD WalkRadioGroup (const nsAString &aName, nsIRadioVisitor *aVisitor)
 Walk through the radio group, visiting each note with avisitor->Visit()
NS_IMETHOD AddToRadioGroup (const nsAString &aName, nsIFormControl *aRadio)
 Add radio button to radio group.
NS_IMETHOD RemoveFromRadioGroup (const nsAString &aName, nsIFormControl *aRadio)
 Remove radio button from radio group.
virtual PRBool ParseAttribute (nsIAtom *aAttribute, const nsAString &aValue, nsAttrValue &aResult)
 Convert an attribute string value to attribute type based on the type of attribute.
virtual nsresult HandleDOMEvent (nsPresContext *aPresContext, nsEvent *aEvent, nsIDOMEvent **aDOMEvent, PRUint32 aFlags, nsEventStatus *aEventStatus)
 Handle a DOM event for this piece of content.
virtual 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.
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.
void ForgetCurrentSubmission ()
 Forget all information about the current submission (and the fact that we are currently submitting at all).
nsresult DOMQueryInterface (nsIDOMHTMLElement *aElement, REFNSIID aIID, void **aInstancePtr)
 Handle QI for the standard DOM interfaces (DOMNode, DOMElement, DOMHTMLElement) and handles tearoffs for other standard interfaces.
nsresult CopyInnerTo (nsGenericElement *aDest, PRBool aDeep)
 Copy attributes and children from another content object.
NS_METHOD GetNodeName (nsAString &aNodeName)
NS_METHOD GetLocalName (nsAString &aLocalName)
NS_METHOD SetAttribute (const nsAString &aName, const nsAString &aValue)
NS_METHOD GetTagName (nsAString &aTagName)
NS_METHOD GetElementsByTagName (const nsAString &aTagname, nsIDOMNodeList **aReturn)
NS_METHOD GetElementsByTagNameNS (const nsAString &aNamespaceURI, const nsAString &aLocalName, nsIDOMNodeList **aReturn)
nsresult GetId (nsAString &aId)
nsresult SetId (const nsAString &aId)
nsresult GetTitle (nsAString &aTitle)
nsresult SetTitle (const nsAString &aTitle)
nsresult GetLang (nsAString &aLang)
nsresult SetLang (const nsAString &aLang)
nsresult GetDir (nsAString &aDir)
nsresult SetDir (const nsAString &aDir)
nsresult GetClassName (nsAString &aClassName)
nsresult SetClassName (const nsAString &aClassName)
nsresult GetStyle (nsIDOMCSSStyleDeclaration **aStyle)
nsresult GetOffsetTop (PRInt32 *aOffsetTop)
nsresult GetOffsetLeft (PRInt32 *aOffsetLeft)
nsresult GetOffsetWidth (PRInt32 *aOffsetWidth)
nsresult GetOffsetHeight (PRInt32 *aOffsetHeight)
nsresult GetOffsetParent (nsIDOMElement **aOffsetParent)
virtual nsresult GetInnerHTML (nsAString &aInnerHTML)
virtual nsresult SetInnerHTML (const nsAString &aInnerHTML)
nsresult GetScrollTop (PRInt32 *aScrollTop)
nsresult SetScrollTop (PRInt32 aScrollTop)
nsresult GetScrollLeft (PRInt32 *aScrollLeft)
nsresult SetScrollLeft (PRInt32 aScrollLeft)
nsresult GetScrollHeight (PRInt32 *aScrollHeight)
nsresult GetScrollWidth (PRInt32 *aScrollWidth)
nsresult GetClientHeight (PRInt32 *aClientHeight)
nsresult GetClientWidth (PRInt32 *aClientWidth)
nsresult ScrollIntoView (PRBool aTop)
NS_IMETHOD Focus ()
NS_IMETHOD Blur ()
NS_IMETHOD GetTabIndex (PRInt32 *aTabIndex)
NS_IMETHOD SetTabIndex (PRInt32 aTabIndex)
NS_IMETHOD GetSpellcheck (PRBool *aSpellcheck)
NS_IMETHOD SetSpellcheck (PRBool aSpellcheck)
void GetOffsetRect (nsRect &aRect, nsIContent **aOffsetParent)
 Get the frame's offset information for offsetTop/Left/Width/Height.
void GetScrollInfo (nsIScrollableView **aScrollableView, float *aP2T, float *aT2P, nsIFrame **aFrame=nsnull)
virtual nsresult GetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, nsAString &aResult) const
 Get the current value of the attribute.
virtual nsresult UnsetAttr (PRInt32 aNameSpaceID, nsIAtom *aName, PRBool aNotify)
 Remove an attribute so that it is no longer explicitly specified.
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 void RemoveFocus (nsPresContext *aPresContext)
 Remove the focus on this content.
virtual PRBool IsFocusable (PRInt32 *aTabIndex=nsnull)
 Check if this content is focusable and in the current tab order.
nsresult HandleDOMEventForAnchors (nsPresContext *aPresContext, nsEvent *aEvent, nsIDOMEvent **aDOMEvent, PRUint32 aFlags, nsEventStatus *aEventStatus)
 Standard anchor HandleDOMEvent, used by A, AREA and LINK (parameters are the same as HandleDOMEvent)
nsresult GetHrefURIForAnchors (nsIURI **aURI)
void Compact ()
const nsAttrValueGetParsedAttr (nsIAtom *aAttr) const
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction () const
virtual const nsAttrValueGetClasses () const
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).
 NS_IMETHOD_ (PRBool) HasClass(nsIAtom *aClass
 NS_IMETHOD_ (PRBool) IsAttributeMapped(const nsIAtom *aAttribute) const
 Is the attribute named stored in the mapped attributes?
NS_IMETHOD WalkContentStyleRules (nsRuleWalker *aRuleWalker)
virtual nsICSSStyleRuleGetInlineStyleRule ()
NS_IMETHOD SetInlineStyleRule (nsICSSStyleRule *aStyleRule, PRBool aNotify)
already_AddRefed< nsIURIGetBaseURI () const
 Get the base URI for any relative URIs within this piece of content.
void GetBaseTarget (nsAString &aBaseTarget) const
 Get the base target for any links within this piece of content.
nsIFormControlFrameGetFormControlFrame (PRBool aFlushContent)
 Get the primary form control frame for this content (see GetFormControlFrameFor)
nsIFrameGetPrimaryFrame (PRBool aFlushContent)
 Get the primary frame for this content (see GetPrimaryFrameFor)
PRBool ParseDivAlignValue (const nsAString &aString, nsAttrValue &aResult) const
 Parse a div align string to value (left/right/center/middle/justify)
PRBool ParseTableHAlignValue (const nsAString &aString, nsAttrValue &aResult) const
 Convert a table halign string to value (left/right/center/char/justify)
PRBool ParseTableCellHAlignValue (const nsAString &aString, nsAttrValue &aResult) const
 Convert a table cell halign string to value.
nsresult ReparseStyleAttribute (void)
 Create the style struct from the style attr.
 NS_HIDDEN_ (nsPresContext *) GetPresContext()
 Get the presentation context for this content node.
already_AddRefed
< nsIDOMHTMLFormElement
FindForm (nsIForm *aCurrentForm=nsnull)
 Find an ancestor of this content node which is a form (could be null)
nsresult SetAttrAndNotify (PRInt32 aNamespaceID, nsIAtom *aAttribute, nsIAtom *aPrefix, const nsAString &aOldValue, nsAttrValue &aParsedValue, PRBool aModification, PRBool aFireMutation, PRBool aNotify)
 Set attribute and (if needed) notify documentobservers and fire off mutation events.
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 PRBool IsNativeAnonymous () const
 Get whether this content is C++-generated anonymous 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 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 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 PRBool HasAttr (PRInt32 aNameSpaceID, nsIAtom *aName) const
 Determine if an attribute has been set (empty string or otherwise).
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 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 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 void SetFocus (nsPresContext *aContext)
 Set the focus on this content.
virtual nsIContentGetBindingParent () const
 Gets content node with the binding responsible for our construction (and existence).
virtual nsresult GetListenerManager (nsIEventListenerManager **aResult)
 Get the event listener manager, the guy you talk to to register for events on this element.
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.
virtual nsIAtomGetID () const
 IsAttributeMapped (const nsIAtom *aAttribute) const
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 MaybeTriggerAutoLink (nsIDocShell *aShell)
 Give this element a chance to fire links that should be fired automatically when loaded.
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 GetAttribute (const nsAString &aName, nsAString &aReturn)
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 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 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 submit ()
void reset ()
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 onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus)
 Notification indicating the state has changed for one of the requests associated with aWebProgress.
void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress)
 Notification that the progress has changed for one of the requests associated with aWebProgress.
void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI aLocation)
 Called when the location of the window being watched changes.
void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage)
 Notification that the status of a request has changed.
void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aState)
 Notification called for security progress.

Static Public Member Functions

static nsresult CompareNodes (nsIDOMNode *a, nsIDOMNode *b, PRInt32 *retval)
 Compare two nodes in the same tree (Negative result means a < b, 0 ==, positive >).
static nsGenericHTMLElementFromContent (nsIContent *aContent)
 Typesafe, non-refcounting cast from nsIContent.
static void Shutdown ()
 Call on shutdown to release globals.
static const nsSize GetClientAreaSize (nsIFrame *aFrame)
 Get an element's client info if the element doesn't have a scrollable view.
static nsresult DispatchClickEvent (nsPresContext *aPresContext, nsInputEvent *aSourceEvent, nsIContent *aTarget, PRBool aFullDispatch, nsEventStatus *aStatus)
 Method to create and dispatch a left-click event loosely based on aSourceEvent.
static nsresult DispatchEvent (nsPresContext *aPresContext, nsEvent *aEvent, nsIContent *aTarget, PRBool aFullDispatch, nsEventStatus *aStatus)
 Method to dispatch aEvent to aTarget without crashing and all.
static PRBool ParseAlignValue (const nsAString &aString, nsAttrValue &aResult)
 Parse an alignment attribute (top/middle/bottom/baseline)
static PRBool ParseTableVAlignValue (const nsAString &aString, nsAttrValue &aResult)
 Convert a table valign string to value (left/right/center/char/justify/ abscenter/absmiddle/middle)
static PRBool ParseImageAttribute (nsIAtom *aAttribute, const nsAString &aString, nsAttrValue &aResult)
 Convert an image attribute to value (width, height, hspace, vspace, border)
static PRBool ParseFrameborderValue (const nsAString &aString, nsAttrValue &aResult)
 Convert a frameborder string to value (yes/no/1/0)
static PRBool ParseScrollingValue (const nsAString &aString, nsAttrValue &aResult)
 Convert a scrolling string to value (yes/no/on/off/scroll/noscroll/auto)
static void ParseStyleAttribute (nsIContent *aContent, PRBool aCaseSensitive, const nsAString &aValue, nsAttrValue &aResult)
 Parse a style attr value into a CSS rulestruct (or, if there is no document, leave it as a string) and return as nsAttrValue.
static void MapCommonAttributesInto (const nsMappedAttributes *aAttributes, nsRuleData *aRuleData)
 A style attribute mapping function for the most common attributes, to be called by subclasses' attribute mapping functions.
static void MapImageAlignAttributeInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the align attribute into a style struct.
static void MapDivAlignAttributeInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the align attribute into a style struct for things like

,.

static void MapImageBorderAttributeInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the image border attribute into a style struct.
static void MapImageMarginAttributeInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the image margin attribute into a style struct.
static void MapImageSizeAttributesInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the image position attribute into a style struct.
static void MapBackgroundAttributesInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the background attributes (currently background and bgcolor) into a style struct.
static void MapScrollingAttributeInto (const nsMappedAttributes *aAttributes, nsRuleData *aData)
 Helper to map the scrolling attribute on FRAME and IFRAME into a style struct.
static nsIFrameGetPrimaryFrameFor (nsIContent *aContent, nsIDocument *aDocument, PRBool aFlushContent)
 Get the primary frame for a piece of content.
static nsIFormControlFrameGetFormControlFrameFor (nsIContent *aContent, nsIDocument *aDocument, PRBool aFlushContent)
 Get the primary form control frame for a piece of content.
static nsresult GetPrimaryPresState (nsGenericHTMLElement *aContent, nsPresState **aPresState)
 Get the presentation state for a piece of content, or create it if it does not exist.
static nsresult GetLayoutHistoryAndKey (nsGenericHTMLElement *aContent, nsILayoutHistoryState **aState, nsACString &aKey)
 Get the layout history object and generate the key for a particular piece of content.
static PRBool RestoreFormControlState (nsGenericHTMLElement *aContent, nsIFormControl *aControl)
 Restore the state for a form control.
static PRBool InNavQuirksMode (nsIDocument *aDoc)
 See if the document being tested has nav-quirks mode enabled.
static nsresult SetProtocolInHrefString (const nsAString &aHref, const nsAString &aProtocol, nsAString &aResult)
static nsresult SetHostInHrefString (const nsAString &aHref, const nsAString &aHost, nsAString &aResult)
static nsresult SetHostnameInHrefString (const nsAString &aHref, const nsAString &aHostname, nsAString &aResult)
static nsresult SetPathnameInHrefString (const nsAString &aHref, const nsAString &aHostname, nsAString &aResult)
static nsresult SetSearchInHrefString (const nsAString &aHref, const nsAString &aSearch, nsAString &aResult)
static nsresult SetHashInHrefString (const nsAString &aHref, const nsAString &aHash, nsAString &aResult)
static nsresult SetPortInHrefString (const nsAString &aHref, const nsAString &aPort, nsAString &aResult)
static nsresult GetProtocolFromHrefString (const nsAString &aHref, nsAString &aProtocol, nsIDocument *aDocument)
static nsresult GetHostFromHrefString (const nsAString &aHref, nsAString &aHost)
static nsresult GetHostnameFromHrefString (const nsAString &aHref, nsAString &aHostname)
static nsresult GetPathnameFromHrefString (const nsAString &aHref, nsAString &aPathname)
static nsresult GetSearchFromHrefString (const nsAString &aHref, nsAString &aSearch)
static nsresult GetPortFromHrefString (const nsAString &aHref, nsAString &aPort)
static nsresult GetHashFromHrefString (const nsAString &aHref, nsAString &aHash)
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
readonly attribute
nsIDOMHTMLCollection 
elements
readonly attribute long length
attribute DOMString name
attribute DOMString acceptCharset
attribute DOMString action
attribute DOMString enctype
attribute DOMString method
attribute DOMString target
attribute DOMString id
attribute DOMString title
attribute DOMString lang
attribute DOMString dir
attribute DOMString className
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
attribute DOMString encoding
const unsigned long STATE_START = 0x00000001
 State Transition Flags.
const unsigned long STATE_REDIRECTING = 0x00000002
const unsigned long STATE_TRANSFERRING = 0x00000004
const unsigned long STATE_NEGOTIATING = 0x00000008
const unsigned long STATE_STOP = 0x00000010
const unsigned long STATE_IS_REQUEST = 0x00010000
 State Type Flags.
const unsigned long STATE_IS_DOCUMENT = 0x00020000
const unsigned long STATE_IS_NETWORK = 0x00040000
const unsigned long STATE_IS_WINDOW = 0x00080000
const unsigned long STATE_RESTORING = 0x01000000
 State Modifier Flags.
const unsigned long STATE_IS_INSECURE = 0x00000004
 State Security Flags.
const unsigned long STATE_IS_BROKEN = 0x00000001
const unsigned long STATE_IS_SECURE = 0x00000002
const unsigned long STATE_SECURE_HIGH = 0x00040000
 Security Strength Flags.
const unsigned long STATE_SECURE_MED = 0x00010000
const unsigned long STATE_SECURE_LOW = 0x00020000

Static Public Attributes

static const MappedAttributeEntry sCommonAttributeMap []
static const MappedAttributeEntry sImageMarginSizeAttributeMap []
static const MappedAttributeEntry sImageBorderAttributeMap []
static const MappedAttributeEntry sImageAlignAttributeMap []
static const MappedAttributeEntry sDivAlignAttributeMap []
static const MappedAttributeEntry sBackgroundAttributeMap []
static const MappedAttributeEntry sScrollingAttributeMap []
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

nsresult DoSubmitOrReset (nsPresContext *aPresContext, nsEvent *aEvent, PRInt32 aMessage)
nsresult DoReset ()
nsresult DoSubmit (nsPresContext *aPresContext, nsEvent *aEvent)
 Attempt to submit (submission might be deferred) (called by DoSubmitOrReset)
nsresult BuildSubmission (nsPresContext *aPresContext, nsCOMPtr< nsIFormSubmission > &aFormSubmission, nsEvent *aEvent)
 Prepare the submission object (called by DoSubmit)
nsresult SubmitSubmission (nsPresContext *aPresContext, nsIFormSubmission *aFormSubmission)
 Perform the submission (called by DoSubmit and FlushPendingSubmission)
nsresult WalkFormElements (nsIFormSubmission *aFormSubmission, nsIContent *aSubmitElement)
 Walk over the form elements and call SubmitNamesValues() on them to get their data pumped into the FormSubmitter.
nsresult NotifySubmitObservers (nsIURI *aActionURL, PRBool *aCancelSubmit, PRBool aEarlyNotify)
 Notify any submit observers of the submit.
 NS_HIDDEN_ (nsresult) GetAttrHelper(nsIAtom *aAttr
 Helper method for NS_IMPL_STRING_ATTR macro.
 NS_HIDDEN_ (nsresult) SetAttrHelper(nsIAtom *aAttr
 Helper method for NS_IMPL_STRING_ATTR macro.
 NS_HIDDEN_ (nsresult) GetStringAttrWithDefault(nsIAtom *aAttr
 Helper method for NS_IMPL_STRING_ATTR_DEFAULT_VALUE macro.
 NS_HIDDEN_ (nsresult) GetBoolAttr(nsIAtom *aAttr
 Helper method for NS_IMPL_BOOL_ATTR macro.
 NS_HIDDEN_ (nsresult) SetBoolAttr(nsIAtom *aAttr
 Helper method for NS_IMPL_BOOL_ATTR macro.
 NS_HIDDEN_ (nsresult) GetIntAttr(nsIAtom *aAttr
 Helper method for NS_IMPL_INT_ATTR macro.
 NS_HIDDEN_ (nsresult) SetIntAttr(nsIAtom *aAttr
 Helper method for NS_IMPL_INT_ATTR macro.
 NS_HIDDEN_ (nsresult) GetURIAttr(nsIAtom *aAttr
 Helper method for NS_IMPL_URI_ATTR macro.
 NS_HIDDEN_ (nsresult) GetEditor(nsIEditor **aEditor)
 Locate an nsIEditor rooted at this content node, if there is one.
 NS_HIDDEN_ (nsresult) GetEditorInternal(nsIEditor **aEditor)
void SetElementFocus (PRBool aDoFocus)
 Focus or blur the element.
void RegUnRegAccessKey (PRBool aDoReg)
 Register or unregister an access key to this element based on the accesskey attribute.
PRBool IsEventName (nsIAtom *aName)
 Determine whether an attribute is an event (onclick, etc.)
virtual const nsAttrNameInternalGetExistingAttrNameFromQName (const nsAString &aStr) const
 Internal hook for converting an attribute name-string to an atomized name.
nsresult ReplaceContentsWithText (const nsAString &aText, PRBool aNotify)
 ReplaceContentsWithText will take the aText string and make sure that the only child of |this| is a textnode which corresponds to that string.
void RecreateFrames ()
 Helper method to recreate all frames for this content, if there are any.
virtual already_AddRefed
< nsIEditor
GetAssociatedEditor ()
 Locates the nsIEditor associated with this node.
PRBool IsCurrentBodyElement ()
 Returns true if this is the current document's body element.
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 void SyncEditorsOnSubtree (nsIContent *content)
 Ensures all editors associated with a subtree are synced, for purposes of spellchecking.

Protected Attributes

nsFormControlListmControls
 The list of controls (form.elements as well as stuff not in elements)
nsInterfaceHashtable
< nsStringHashKey,
nsIDOMHTMLInputElement
mSelectedRadioButtons
 The currently selected radio button of each group.
PRPackedBool mGeneratingSubmit
 Whether we are currently processing a submit event or not.
PRPackedBool mGeneratingReset
 Whether we are currently processing a reset event or not.
PRPackedBool mIsSubmitting
 Whether we are submitting currently.
PRPackedBool mDeferSubmission
 Whether the submission is to be deferred in case a script triggers it.
PRPackedBool mNotifiedObservers
 Whether we notified NS_FORMSUBMIT_SUBJECT listeners already.
PRPackedBool mNotifiedObserversResult
 If we notified the listeners early, what was the result?
PopupControlState mSubmitPopupState
 Keep track of what the popup state was when the submit was initiated.
PRBool mSubmitInitiatedFromUserInput
 Keep track of whether a submission was user-initiated or not.
nsCOMPtr< nsIFormSubmissionmPendingSubmission
 The pending submission object.
nsCOMPtr< nsIRequestmSubmittingRequest
 The request currently being submitted.
nsCOMPtr< nsIWebProgressmWebProgress
 The web progress object we are currently listening to.
PRBool *aValue const
nsAString & aValue
const nsAString & aValue
PRBool aValue
PRInt32 PRInt32aValue
PRInt32 aValue
const char * aDefault
PRInt32 aDefault
const char nsAString & aResult
nsAString & aResult
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 PRBool gFirstFormSubmitted = PR_FALSE
 Detection of first form to notify observers.
static PRBool gPasswordManagerInitialized = PR_FALSE
 Detection of first password input to initialize the password manager.

Friends

class nsFormControlEnumerator

Detailed Description

Definition at line 94 of file nsHTMLFormElement.cpp.


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
  };

Constructor & Destructor Documentation

Definition at line 451 of file nsHTMLFormElement.cpp.

Here is the call graph for this function:


Member Function Documentation

Add an element to end of this form's list of elements.

Parameters:
aElementthe element to add
Returns:
NS_OK if the element was successfully added

Implements nsIForm.

Definition at line 1177 of file nsHTMLFormElement.cpp.

{
  NS_ENSURE_TRUE(mControls, NS_ERROR_UNEXPECTED);

  if (ShouldBeInElements(aChild)) {
    PRUint32 count;
    GetElementCount(&count);

    nsCOMPtr<nsIFormControl> element;

    // Optimize most common case where we insert at the end.
    PRInt32 position = -1;
    if (count > 0) {
      GetElementAt(count - 1, getter_AddRefs(element));
      position = CompareFormControlPosition(aChild, element);
    }

    // If this item comes after the last element, or the elements array is
    // empty, we append to the end. Otherwise, we do a binary search to
    // determine where the element should go.    
    if (position >= 0 || count == 0) {
      // WEAK - don't addref
      mControls->mElements.AppendElement(aChild);
    }
    else {
      PRInt32 low = 0, mid, high;
      high = count - 1;
      
      while (low <= high) {
        mid = (low + high) / 2;
        
        GetElementAt(mid, getter_AddRefs(element));
        position = CompareFormControlPosition(aChild, element);
        if (position >= 0)
          low = mid + 1;
        else
          high = mid - 1;
      }
      
      // WEAK - don't addref
      mControls->mElements.InsertElementAt(aChild, low);
    }
  } else {
    // WEAK - don't addref
    mControls->mNotInElements.AppendElement(aChild);
  }

  //
  // Notify the radio button it's been added to a group
  //
  PRInt32 type = aChild->GetType();
  if (type == NS_FORM_INPUT_RADIO) {
    nsCOMPtr<nsIRadioControlElement> radio = do_QueryInterface(aChild);
    nsresult rv = radio->AddedToRadioGroup();
    NS_ENSURE_SUCCESS(rv, rv);
  }

  //
  // If it is a password control, and the password manager has not yet been
  // initialized, initialize the password manager
  //
  if (!gPasswordManagerInitialized && type == NS_FORM_INPUT_PASSWORD) {
    // Initialize the password manager category
    gPasswordManagerInitialized = PR_TRUE;
    NS_CreateServicesFromCategory(NS_PASSWORDMANAGER_CATEGORY,
                                  nsnull,
                                  NS_PASSWORDMANAGER_CATEGORY);
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsHTMLFormElement::AddElementToTable ( nsIFormControl aElement,
const nsAString &  aName 
) [virtual]

Add an element to the lookup table mainted by the form.

We can't fold this method into AddElement() because when AddElement() is called, the form control has no attributes. The name or id attributes of the form control are used as a key into the table.

Implements nsIForm.

Definition at line 1250 of file nsHTMLFormElement.cpp.

Here is the call 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:

NS_IMETHODIMP nsHTMLFormElement::AddToRadioGroup ( const nsAString &  aName,
nsIFormControl aRadio 
) [virtual]

Add radio button to radio group.

Note that forms do not do anything for this method since they already store radio groups on their own.

Parameters:
aNameradio group's name
aRadioradio button's pointer

Implements nsIRadioGroupContainer.

Definition at line 1755 of file nsHTMLFormElement.cpp.

{
  return NS_OK;
}
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 nsGenericElement::AppendChildTo ( nsIContent aKid,
PRBool  aNotify 
) [virtual, inherited]

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

Implements nsIContent.

Reimplemented in nsXULElement, nsHTMLScriptElement, nsHTMLSelectElement, nsHTMLTextAreaElement, nsSVGScriptElement, nsXTFElementWrapper, nsHTMLOptGroupElement, nsHTMLStyleElement, and nsSVGStyleElement.

Definition at line 2866 of file nsGenericElement.cpp.

{
  NS_PRECONDITION(aKid && this != aKid, "null ptr");
  nsIDocument *document = GetCurrentDoc();
  mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
  
  nsresult rv = mAttrsAndChildren.AppendChild(aKid);
  NS_ENSURE_SUCCESS(rv, rv);
  
  rv = aKid->BindToTree(document, 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 (aNotify && document && document == GetCurrentDoc() &&
      aKid->GetParent() == this) {
    document->ContentAppended(this, GetChildCount() - 1);
    
    if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
      nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
      mutation.mRelatedNode = do_QueryInterface(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:

Here is the caller 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 nsHTMLFormElement::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 nsGenericHTMLElement.

Definition at line 648 of file nsHTMLFormElement.cpp.

{
  nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
                                                 aBindingParent,
                                                 aCompileEventHandlers);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
  if (htmlDoc) {
    htmlDoc->AddedForm();
  }

  return rv;
}

Here is the call graph for this function:

Reimplemented in nsHTMLButtonElement.

Definition at line 3734 of file nsGenericHTMLElement.cpp.

{
  if (ShouldFocus(this)) {
    SetElementFocus(PR_FALSE);
  }

  return NS_OK;
}
nsresult nsHTMLFormElement::BuildSubmission ( nsPresContext aPresContext,
nsCOMPtr< nsIFormSubmission > &  aFormSubmission,
nsEvent aEvent 
) [protected]

Prepare the submission object (called by DoSubmit)

Parameters:
aPresContextthe presentation context
aFormSubmissionthe submission object
aEventthe DOM event that was passed to us for the submit

Definition at line 865 of file nsHTMLFormElement.cpp.

{
  NS_ASSERTION(!mPendingSubmission, "tried to build two submissions!");

  // Get the originating frame (failure is non-fatal)
  nsIContent *originatingElement = nsnull;
  if (aEvent) {
    if (NS_FORM_EVENT == aEvent->eventStructType) {
      originatingElement = ((nsFormEvent *)aEvent)->originator;
    }
  }

  nsresult rv;

  //
  // Get the submission object
  //
  rv = GetSubmissionFromForm(this, aPresContext, getter_AddRefs(aFormSubmission));
  NS_ENSURE_SUBMIT_SUCCESS(rv);

  //
  // Dump the data into the submission object
  //
  rv = WalkFormElements(aFormSubmission, originatingElement);
  NS_ENSURE_SUBMIT_SUCCESS(rv);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIDOMNode nsIDOMNode::cloneNode ( in boolean  deep) [inherited]
void nsGenericHTMLElement::Compact ( ) [inline, inherited]

Definition at line 245 of file nsGenericHTMLElement.h.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLFormElement::CompareNodes ( nsIDOMNode a,
nsIDOMNode b,
PRInt32 retval 
) [static]

Compare two nodes in the same tree (Negative result means a < b, 0 ==, positive >).

This function may fail if the nodes are not in a tree or are in different trees.

Parameters:
athe first node
bthe second node
retvalwhether a < b (negative), a == b (0), or a > b (positive)

Definition at line 1060 of file nsHTMLFormElement.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIDOMNode> parentANode;
  PRInt32 indexA;
  rv = a->GetParentNode(getter_AddRefs(parentANode));
  NS_ENSURE_SUCCESS(rv, rv);
  if (!parentANode) {
    return NS_ERROR_UNEXPECTED;
  }

  {
    // To get the index, we must turn them both into contents
    // and do IndexOf().  Ick.
    nsCOMPtr<nsIContent> parentA(do_QueryInterface(parentANode));
    nsCOMPtr<nsIContent> contentA(do_QueryInterface(a));
    if (!parentA || !contentA) {
      return NS_ERROR_UNEXPECTED;
    }
    indexA = parentA->IndexOf(contentA);
  }

  nsCOMPtr<nsIDOMNode> parentBNode;
  PRInt32 indexB;
  rv = b->GetParentNode(getter_AddRefs(parentBNode));
  NS_ENSURE_SUCCESS(rv, rv);
  if (!parentBNode) {
    return NS_ERROR_UNEXPECTED;
  }

  {
    // To get the index, we must turn them both into contents
    // and do IndexOf().  Ick.
    nsCOMPtr<nsIContent> parentB(do_QueryInterface(parentBNode));
    nsCOMPtr<nsIContent> bContent(do_QueryInterface(b));
    if (!parentB || !bContent) {
      return NS_ERROR_UNEXPECTED;
    }
    indexB = parentB->IndexOf(bContent);
  }

  *retval = nsRange::ComparePoints(parentANode, indexA, parentBNode, indexB);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsGenericElement::ContentID ( ) const [virtual, inherited]

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!!!

Implements nsIContent.

Reimplemented in nsXULElement.

Definition at line 2318 of file nsGenericElement.cpp.

{
  nsDOMSlots *slots = GetExistingDOMSlots();

  if (slots) {
    return slots->mContentID;
  }

  PtrBits flags = GetFlags();

  return flags >> GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET;
}

Here is the call graph for this function:

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

Copy attributes and children from another content object.

Parameters:
aSrcContentthe object to copy from
aDeepwhether to copy children

Reimplemented from nsGenericElement.

Definition at line 284 of file nsGenericHTMLElement.cpp.

{
  nsresult rv = NS_OK;
  PRInt32 i, count = GetAttrCount();
  nsCOMPtr<nsIAtom> name, prefix;
  PRInt32 namespace_id;
  nsAutoString value;

  for (i = 0; i < count; ++i) {
    rv = GetAttrNameAt(i, &namespace_id, getter_AddRefs(name),
                       getter_AddRefs(prefix));
    NS_ENSURE_SUCCESS(rv, rv);

    if (name == nsHTMLAtoms::style && namespace_id == kNameSpaceID_None) {
      // We can't just set this as a string, because that will fail
      // to reparse the string into style data until the node is
      // inserted into the document.  Clone the HTMLValue instead.
      const nsAttrValue* styleVal =
        mAttrsAndChildren.GetAttr(nsHTMLAtoms::style);
      if (styleVal && styleVal->Type() == nsAttrValue::eCSSStyleRule) {
        nsCOMPtr<nsICSSRule> ruleClone;
        rv = styleVal->GetCSSStyleRuleValue()->
          Clone(*getter_AddRefs(ruleClone));
        NS_ENSURE_SUCCESS(rv, rv);

        nsCOMPtr<nsICSSStyleRule> styleRule = do_QueryInterface(ruleClone);
        NS_ENSURE_TRUE(styleRule, NS_ERROR_UNEXPECTED);

        rv = aDst->SetInlineStyleRule(styleRule, PR_FALSE);
        NS_ENSURE_SUCCESS(rv, rv);

        continue;
      }
    }

    rv = GetAttr(namespace_id, name, value);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = aDst->SetAttr(namespace_id, name, prefix, value, PR_FALSE);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  nsIDocument *doc = nsContentUtils::GetDocument(mNodeInfo);

  PRInt32 id;
  if (doc) {
    id = doc->GetAndIncrementContentID();
  } else {
    id = PR_INT32_MAX;
  }

  aDst->SetContentID(id);

  if (aDeep) {
    PRInt32 i;
    PRInt32 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(aDeep, getter_AddRefs(newNode));
      NS_ENSURE_SUCCESS(rv, rv);

      nsCOMPtr<nsIContent> newContent(do_QueryInterface(newNode));
      NS_ASSERTION(newContent, "clone doesn't implement nsIContent");
      rv = aDst->AppendChildTo(newContent, PR_FALSE);
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }

  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:

nsresult nsGenericHTMLElement::DispatchClickEvent ( nsPresContext aPresContext,
nsInputEvent aSourceEvent,
nsIContent aTarget,
PRBool  aFullDispatch,
nsEventStatus aStatus 
) [static, inherited]

Method to create and dispatch a left-click event loosely based on aSourceEvent.

If aFullDispatch is true, the event will be dispatched in all event groups and so forth; if it's false it will be dispatched only as a DOM event.

Definition at line 1544 of file nsGenericHTMLElement.cpp.

{
  NS_PRECONDITION(aTarget, "Must have target");
  NS_PRECONDITION(aSourceEvent, "Must have source event");
  NS_PRECONDITION(aStatus, "Null out param?");

  nsMouseEvent event(NS_IS_TRUSTED_EVENT(aSourceEvent), NS_MOUSE_LEFT_CLICK,
                     aSourceEvent->widget, nsMouseEvent::eReal);
  event.point = aSourceEvent->point;
  event.refPoint = aSourceEvent->refPoint;
  PRUint32 clickCount = 1;
  if (aSourceEvent->eventStructType == NS_MOUSE_EVENT) {
    clickCount = NS_STATIC_CAST(nsMouseEvent*, aSourceEvent)->clickCount;
  }
  event.clickCount = clickCount;
  event.isShift = aSourceEvent->isShift;
  event.isControl = aSourceEvent->isControl;
  event.isAlt = aSourceEvent->isAlt;
  event.isMeta = aSourceEvent->isMeta;

  return DispatchEvent(aPresContext, &event, aTarget, aFullDispatch, aStatus);
}

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::DispatchEvent ( nsPresContext aPresContext,
nsEvent aEvent,
nsIContent aTarget,
PRBool  aFullDispatch,
nsEventStatus aStatus 
) [static, inherited]

Method to dispatch aEvent to aTarget without crashing and all.

Definition at line 1515 of file nsGenericHTMLElement.cpp.

{
  NS_PRECONDITION(aTarget, "Must have target");
  NS_PRECONDITION(aEvent, "Must have source event");
  NS_PRECONDITION(aStatus, "Null out param?");

  if (!aPresContext) {
    return NS_OK;
  }

  nsCOMPtr<nsIPresShell> shell = aPresContext->GetPresShell();
  if (!shell) {
    return NS_OK;
  }

  if (aFullDispatch) {
    return shell->HandleEventWithTarget(aEvent, nsnull, aTarget,
                                        NS_EVENT_FLAG_INIT, aStatus);
  }

  return shell->HandleDOMEventWithTarget(aTarget, aEvent, aStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::DOMQueryInterface ( nsIDOMHTMLElement aElement,
REFNSIID  aIID,
void **  aInstancePtr 
) [inherited]

Handle QI for the standard DOM interfaces (DOMNode, DOMElement, DOMHTMLElement) and handles tearoffs for other standard interfaces.

Parameters:
aElementthe element as nsIDOMHTMLElement*
aIIDthe IID to QI to
aInstancePtrthe QI'd method [OUT]
See also:
nsGenericHTMLElementTearoff

Definition at line 243 of file nsGenericHTMLElement.cpp.

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 792 of file nsHTMLFormElement.cpp.

{
  // JBK walk the elements[] array instead of form frame controls - bug 34297
  PRUint32 numElements;
  GetElementCount(&numElements);
  for (PRUint32 elementX = 0; (elementX < numElements); elementX++) {
    nsCOMPtr<nsIFormControl> controlNode;
    GetElementAt(elementX, getter_AddRefs(controlNode));
    if (controlNode) {
      controlNode->Reset();
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLFormElement::DoSubmit ( nsPresContext aPresContext,
nsEvent aEvent 
) [protected]

Attempt to submit (submission might be deferred) (called by DoSubmitOrReset)

Parameters:
aPresContextthe presentation context
aEventthe DOM event that was passed to us for the submit

Definition at line 815 of file nsHTMLFormElement.cpp.

{
  NS_ASSERTION(!mIsSubmitting, "Either two people are trying to submit or the "
               "previous submit was not properly cancelled by the DocShell");
  if (mIsSubmitting) {
    // XXX Should this return an error?
    return NS_OK;
  }

  // Mark us as submitting so that we don't try to submit again
  mIsSubmitting = PR_TRUE;
  NS_ASSERTION(!mWebProgress && !mSubmittingRequest, "Web progress / submitting request should not exist here!");

  nsCOMPtr<nsIFormSubmission> submission;
   
  //
  // prepare the submission object
  //
  BuildSubmission(aPresContext, submission, aEvent); 

  // XXXbz if the script global is that for an sXBL/XBL2 doc, it won't
  // be a window...
  nsCOMPtr<nsPIDOMWindow> window =
    do_QueryInterface(GetOwnerDoc()->GetScriptGlobalObject());

  if (window) {
    mSubmitPopupState = window->GetPopupControlState();
  } else {
    mSubmitPopupState = openAbused;
  }

  mSubmitInitiatedFromUserInput = nsEventStateManager::IsHandlingUserInput();

  if(mDeferSubmission) { 
    // we are in an event handler, JS submitted so we have to
    // defer this submission. let's remember it and return
    // without submitting
    mPendingSubmission = submission;
    // ensure reentrancy
    mIsSubmitting = PR_FALSE;
    return NS_OK; 
  } 
  
  // 
  // perform the submission
  //
  return SubmitSubmission(aPresContext, submission); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsHTMLFormElement::DoSubmitOrReset ( nsPresContext aPresContext,
nsEvent aEvent,
PRInt32  aMessage 
) [protected]

Definition at line 766 of file nsHTMLFormElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aPresContext);

  // Make sure the presentation is up-to-date
  nsIDocument* doc = GetCurrentDoc();
  if (doc) {
    doc->FlushPendingNotifications(Flush_ContentAndNotify);
  }

  // JBK Don't get form frames anymore - bug 34297

  // Submit or Reset the form
  nsresult rv = NS_OK;
  if (NS_FORM_RESET == aMessage) {
    rv = DoReset();
  }
  else if (NS_FORM_SUBMIT == aMessage) {
    rv = DoSubmit(aPresContext, aEvent);
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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;
}

Find an ancestor of this content node which is a form (could be null)

Parameters:
aCurrentFormthe current form for this node. If this is non-null, and no ancestor form is found, and the current form is in a connected subtree with the node, the current form will be returned. This is needed to handle cases when HTML elements have a current form that they're not descendants of.

Definition at line 1449 of file nsGenericHTMLElement.cpp.

{
  nsIContent* content = this;
  while (content) {
    // If the current ancestor is a form, return it as our form
    if (content->IsContentOfType(nsIContent::eHTML) &&
        content->GetNodeInfo()->Equals(nsHTMLAtoms::form)) {
      nsIDOMHTMLFormElement* form;
      CallQueryInterface(content, &form);

      return form;
    }

    nsIContent *prevContent = content;
    content = prevContent->GetParent();

    if (!content && aCurrentForm) {
      // We got to the root of the subtree we're in, and we're being removed
      // from the DOM (the only time we get into this method with a non-null
      // aCurrentForm).  Check whether aCurrentForm is in the same subtree.  If
      // it is, we want to return aCurrentForm, since this case means that
      // we're one of those inputs-in-a-table that have a hacked mForm pointer
      // and a subtree containing both us and the form got removed from the
      // DOM.
      nsCOMPtr<nsIContent> formCOMPtr = do_QueryInterface(aCurrentForm);
      NS_ASSERTION(formCOMPtr, "aCurrentForm isn't an nsIContent?");
      // Use an nsIContent temporary to reduce addref/releasing as we go up the
      // tree
      nsIContent* iter = formCOMPtr;
      do {
        iter = iter->GetParent();
        if (iter == prevContent) {
          nsIDOMHTMLFormElement* form;
          CallQueryInterface(aCurrentForm, &form);
          return form;
        }
      } while (iter);
    }
    
    if (content) {
      PRInt32 i = content->IndexOf(prevContent);

      if (i < 0) {
        // This means 'prevContent' is anonymous content, form controls in
        // anonymous content can't refer to the real form, if they do
        // they end up in form.elements n' such, and that's wrong...

        return nsnull;
      }
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Flush a possible pending submission.

If there was a scripted submission triggered by a button or image, the submission was defered. This method forces the pending submission to be submitted. (happens when the handler returns false or there is an action/target change in the script)

Implements nsIForm.

Definition at line 1334 of file nsHTMLFormElement.cpp.

{
  nsCOMPtr<nsIFormSubmission> kunkFuDeathGrip(mPendingSubmission);

  if (!mPendingSubmission) {
    return NS_OK;
  }

  //
  // perform the submission with the stored pending submission
  //
  nsCOMPtr<nsPresContext> presContext = GetPresContext();
  SubmitSubmission(presContext, mPendingSubmission);

  // now delete the pending submission object
  mPendingSubmission = nsnull;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsHTMLButtonElement, and nsHTMLLabelElement.

Definition at line 3744 of file nsGenericHTMLElement.cpp.

{
  // Generic HTML elements are focusable only if tabindex explicitly set.
  // SetFocus() will check to see if we're focusable and then
  // call into esm to do the work of focusing.
  if (ShouldFocus(this)) {
    SetElementFocus(PR_TRUE);
  }

  return NS_OK;
}

Forget all information about the current submission (and the fact that we are currently submitting at all).

Definition at line 1460 of file nsHTMLFormElement.cpp.

Here is the caller graph for this function:

Forget a possible pending submission.

Same as above but this time we get rid of the pending submission cause the handler returned true so we will rebuild the submission with the name/value of the triggering element

Implements nsIForm.

Definition at line 1354 of file nsHTMLFormElement.cpp.

{
  // just delete the pending submission
  mPendingSubmission = nsnull;
  return NS_OK;
}

Here is the caller graph for this function:

static nsGenericHTMLElement* nsGenericHTMLElement::FromContent ( nsIContent aContent) [inline, static, inherited]

Typesafe, non-refcounting cast from nsIContent.

Cheaper than QI.

Definition at line 86 of file nsGenericHTMLElement.h.

  {
    if (aContent->IsContentOfType(eHTML))
      return NS_STATIC_CAST(nsGenericHTMLElement*, aContent);
    return nsnull;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Get the full URL to submit to.

Do not submit if the returned URL is null.

Parameters:
aActionURLthe full, unadulterated URL you'll be submitting to [OUT]

Implements nsIForm.

Definition at line 1362 of file nsHTMLFormElement.cpp.

{
  nsresult rv = NS_OK;

  *aActionURL = nsnull;

  //
  // Grab the URL string
  //
  nsAutoString action;
  GetAction(action);

  //
  // Form the full action URL
  //

  // Get the document to form the URL.
  // We'll also need it later to get the DOM window when notifying form submit
  // observers (bug 33203)
  if (!IsInDoc()) {
    return NS_OK; // No doc means don't submit, see Bug 28988
  }

  // Get base URL
  nsIDocument *document = GetOwnerDoc();
  nsIURI *docURI = document->GetDocumentURI();
  NS_ENSURE_TRUE(docURI, NS_ERROR_UNEXPECTED);

  // If an action is not specified and we are inside
  // a HTML document then reload the URL. This makes us
  // compatible with 4.x browsers.
  // If we are in some other type of document such as XML or
  // XUL, do nothing. This prevents undesirable reloading of
  // a document inside XUL.

  nsCOMPtr<nsIURI> actionURL;
  if (action.IsEmpty()) {
    nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
    if (!htmlDoc) {
      // Must be a XML, XUL or other non-HTML document type
      // so do nothing.
      return NS_OK;
    }

    rv = docURI->Clone(getter_AddRefs(actionURL));
    NS_ENSURE_SUCCESS(rv, rv);
  } else {
    nsCOMPtr<nsIURI> baseURL = GetBaseURI();
    NS_ASSERTION(baseURL, "No Base URL found in Form Submit!\n");
    if (!baseURL) {
      return NS_OK; // No base URL -> exit early, see Bug 30721
    }
    rv = NS_NewURI(getter_AddRefs(actionURL), action, nsnull, baseURL);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  //
  // Verify the URL should be reached
  //
  // Get security manager, check to see if access to action URI is allowed.
  //
  nsIScriptSecurityManager *securityManager =
      nsContentUtils::GetSecurityManager();
  rv = securityManager->
    CheckLoadURIWithPrincipal(document->GetPrincipal(), actionURL,
                              nsIScriptSecurityManager::STANDARD);
  NS_ENSURE_SUCCESS(rv, rv);

  //
  // Assign to the output
  //
  *aActionURL = actionURL;
  NS_ADDREF(*aActionURL);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Locates the nsIEditor associated with this node.

In general this is equivalent to GetEditorInternal(), but for designmode or contenteditable, this may need to get an editor that's not actually on this element's associated TextControlFrame. This is used by the spellchecking routines to get the editor affected by changing the spellcheck attribute on this node.

Reimplemented in nsHTMLBodyElement.

Definition at line 4267 of file nsGenericHTMLElement.cpp.

{
  // If contenteditable is ever implemented, it might need to do something different here?

  nsIEditor* editor = nsnull;
  GetEditorInternal(&editor);
  return editor;
}

Here is the caller graph for this function:

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

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 2003 of file nsGenericHTMLElement.cpp.

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

  aResult.Truncate();

  const nsAttrValue* attrValue =
    mAttrsAndChildren.GetAttr(aAttribute, aNameSpaceID);
  if (!attrValue) {
    return NS_CONTENT_ATTR_NOT_THERE;
  }

  attrValue->ToString(aResult);

  return NS_CONTENT_ATTR_HAS_VALUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsGenericElement::GetAttrCount ( ) const [virtual, inherited]

Get the number of all specified attributes.

Returns:
the number of attributes

Implements nsIContent.

Reimplemented in nsXULElement, and nsXTFElementWrapper.

Definition at line 4193 of file nsGenericElement.cpp.

Here is the call graph for this function:

Here is the caller 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 nsGenericElement::GetAttributeChangeHint ( const nsIAtom aAttribute,
PRInt32  aModType 
) const [virtual, inherited]

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.

Implements nsIStyledContent.

Reimplemented in nsXULElement, nsHTMLSelectElement, nsHTMLInputElement, nsHTMLTextAreaElement, nsHTMLImageElement, nsHTMLOptionElement, nsHTMLCanvasElement, nsHTMLLegendElement, and nsHTMLFrameSetElement.

Definition at line 2421 of file nsGenericElement.cpp.

{
  return nsChangeHint(0);
}
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 nsGenericElement::GetAttrNameAt ( PRUint32  aIndex,
PRInt32 aNameSpaceID,
nsIAtom **  aName,
nsIAtom **  aPrefix 
) const [virtual, inherited]

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]

Implements nsIContent.

Reimplemented in nsXULElement, nsDocumentFragment, and nsXTFElementWrapper.

Definition at line 4173 of file nsGenericElement.cpp.

{
  const nsAttrName* name = mAttrsAndChildren.GetSafeAttrNameAt(aIndex);
  if (name) {
    *aNameSpaceID = name->NamespaceID();
    NS_ADDREF(*aName = name->LocalName());
    NS_IF_ADDREF(*aPrefix = name->GetPrefix());

    return NS_OK;
  }

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

  return NS_ERROR_ILLEGAL_VALUE;
}

Here is the call graph for this function:

void nsGenericHTMLElement::GetBaseTarget ( nsAString &  aBaseTarget) const [inherited]

Get the base target for any links within this piece of content.

Generally, this is the document's base target, but certain content carries a local base for backward compatibility.

Parameters:
aBaseTargetthe base target [OUT]

Definition at line 2176 of file nsGenericHTMLElement.cpp.

{
  const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsHTMLAtoms::_baseTarget);
  if (val) {
    val->ToString(aBaseTarget);
    return;
  }

  nsIDocument* ownerDoc = GetOwnerDoc();
  if (ownerDoc) {
    ownerDoc->GetBaseTarget(aBaseTarget);
  } else {
    aBaseTarget.Truncate();
  }
}

Here is the call graph for this function:

already_AddRefed< nsIURI > nsGenericHTMLElement::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

Reimplemented from nsGenericElement.

Definition at line 2138 of file nsGenericHTMLElement.cpp.

{
  nsIDocument* doc = GetOwnerDoc();

  const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsHTMLAtoms::_baseHref);
  if (val) {
    // We have a _baseHref attribute; that will determine our base URI
    nsAutoString str;
    val->ToString(str);

    nsIURI* docBaseURL = nsnull;
    if (doc) {
      docBaseURL = doc->GetBaseURI();
    }

    nsIURI* uri = nsnull;
    NS_NewURI(&uri, str, nsnull, docBaseURL);

    return uri;
  }

  // If we are a plain old HTML element (not XHTML), don't bother asking the
  // base class -- our base URI is determined solely by the document base.
  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
    if (doc) {
      nsIURI *uri = doc->GetBaseURI();
      NS_IF_ADDREF(uri);

      return uri;
    }

    return nsnull;
  }

  return nsGenericElement::GetBaseURI();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent * nsGenericElement::GetBindingParent ( ) const [virtual, inherited]

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

Implements nsIContent.

Reimplemented in nsXULElement.

Definition at line 2700 of file nsGenericElement.cpp.

{
  nsDOMSlots *slots = GetExistingDOMSlots();

  if (slots) {
    return slots->mBindingParent;
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent * nsGenericElement::GetChildAt ( PRUint32  aIndex) const [virtual, inherited]

Get a child by index.

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

Implements nsIContent.

Reimplemented in nsXULElement.

Definition at line 4314 of file nsGenericElement.cpp.

{
  return mAttrsAndChildren.GetSafeChildAt(aIndex);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsGenericElement::GetChildCount ( ) const [virtual, inherited]

Get the number of children.

Returns:
the number of children

Implements nsIContent.

Reimplemented in nsXULElement.

Definition at line 4308 of file nsGenericElement.cpp.

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:

nsIAtom * nsGenericHTMLElement::GetClassAttributeName ( ) const [virtual, inherited]

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 2035 of file nsGenericHTMLElement.cpp.

{
  return nsHTMLAtoms::kClass;
}
const nsAttrValue * nsGenericHTMLElement::GetClasses ( ) const [virtual, inherited]

Reimplemented from nsGenericElement.

Definition at line 2023 of file nsGenericHTMLElement.cpp.

{
  return mAttrsAndChildren.GetAttr(nsHTMLAtoms::kClass);
}
nsresult nsGenericHTMLElement::GetClassName ( nsAString &  aClassName) [inherited]

Definition at line 521 of file nsGenericHTMLElement.cpp.

{
  GetAttr(kNameSpaceID_None, nsHTMLAtoms::kClass, aClassName);
  return NS_OK;
}
const nsSize nsGenericHTMLElement::GetClientAreaSize ( nsIFrame aFrame) [static, inherited]

Get an element's client info if the element doesn't have a scrollable view.

Parameters:
aFramethe frame for which to get the client area size
Returns:
the size of the frame's client area

Definition at line 1221 of file nsGenericHTMLElement.cpp.

{
  nsRect rect = aFrame->GetRect();

  const nsStyleBorder* border = aFrame->GetStyleBorder();

  nsMargin border_size;
  border->CalcBorderFor(aFrame, border_size);

  rect.Deflate(border_size);

  return nsSize(rect.width, rect.height);
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetClientHeight ( PRInt32 aClientHeight) [inherited]

Definition at line 1236 of file nsGenericHTMLElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aClientHeight);
  *aClientHeight = 0;

  nsIScrollableView *scrollView = nsnull;
  float p2t, t2p;
  nsIFrame *frame = nsnull;

  GetScrollInfo(&scrollView, &p2t, &t2p, &frame);

  if (scrollView) {
    nsRect r = scrollView->View()->GetBounds();

    *aClientHeight = NSTwipsToIntPixels(r.height, t2p);
  } else if (frame &&
             (frame->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_INLINE ||
              (frame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT))) {
    // Special case code to make clientHeight work even when there isn't
    // a scroll view, see bug 180552 and bug 227567.

    *aClientHeight = NSTwipsToIntPixels(GetClientAreaSize(frame).height, t2p);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetClientWidth ( PRInt32 aClientWidth) [inherited]

Definition at line 1264 of file nsGenericHTMLElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aClientWidth);
  *aClientWidth = 0;

  nsIScrollableView *scrollView = nsnull;
  float p2t, t2p;
  nsIFrame *frame = nsnull;

  GetScrollInfo(&scrollView, &p2t, &t2p, &frame);

  if (scrollView) {
    nsRect r = scrollView->View()->GetBounds();

    *aClientWidth = NSTwipsToIntPixels(r.width, t2p);
  } else if (frame &&
             (frame->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_INLINE ||
              (frame->GetStateBits() & NS_FRAME_REPLACED_ELEMENT))) {
    // Special case code to make clientWidth work even when there isn't
    // a scroll view, see bug 180552 and bug 227567.

    *aClientWidth = NSTwipsToIntPixels(GetClientAreaSize(frame).width, t2p);
  }

  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:

Get an enumeration that goes through all controls, including images and that ilk.

Parameters:
aEnumthe enumeration [OUT]

Implements nsIForm.

Definition at line 1531 of file nsHTMLFormElement.cpp.

{
  *aEnum = new nsFormControlEnumerator(this);
  NS_ENSURE_TRUE(*aEnum, NS_ERROR_OUT_OF_MEMORY);
  NS_ADDREF(*aEnum);
  return NS_OK;
}

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:

NS_IMETHODIMP nsHTMLFormElement::GetCurrentRadioButton ( const nsAString &  aName,
nsIDOMHTMLInputElement **  aRadio 
) [virtual]

Get the current radio button in a group.

Parameters:
aNamethe group name
aRadiothe currently selected radio button [OUT]

Implements nsIRadioGroupContainer.

Definition at line 1558 of file nsHTMLFormElement.cpp.

{
  mSelectedRadioButtons.Get(aName, aRadio);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetDir ( nsAString &  aDir) [inherited]

Definition at line 499 of file nsGenericHTMLElement.cpp.

{
  const nsAttrValue* attr = mAttrsAndChildren.GetAttr(nsHTMLAtoms::dir);

  if (attr && attr->Type() == nsAttrValue::eEnum) {
    attr->ToString(aDir);
  }
  else {
    aDir.Truncate();
  }

  return NS_OK;
}

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:

NS_IMETHODIMP nsHTMLFormElement::GetElementAt ( PRInt32  aIndex,
nsIFormControl **  aElement 
) const [virtual]

Get the element at a specified index position in form.elements.

Parameters:
aIndexthe index
aElementthe element at that index
Returns:
NS_OK if there was an element at that position, -1 otherwise

Implements nsIForm.

Definition at line 1144 of file nsHTMLFormElement.cpp.

{
  *aFormControl = NS_STATIC_CAST(nsIFormControl *,
                                 mControls->mElements.SafeElementAt(aIndex));
  NS_IF_ADDREF(*aFormControl);

  return NS_OK;
}

Here is the caller graph for this function:

Get the number of elements in form.elements.

Parameters:
aCountthe number of elements
Returns:
NS_OK if there was an element at that position, -1 otherwise

Implements nsIForm.

Definition at line 1137 of file nsHTMLFormElement.cpp.

{
  mControls->GetLength(aCount); 
  return NS_OK;
}

Here is the caller graph for this function:

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

Reimplemented from nsGenericElement.

Definition at line 420 of file nsGenericHTMLElement.cpp.

{
  nsAutoString tagName(aTagname);

  // Only lowercase the name if this element has no namespace (i.e.
  // it's a HTML element, not an XHTML element).
  if (mNodeInfo && mNodeInfo->NamespaceEquals(kNameSpaceID_None))
    ToLowerCase(tagName);

  return nsGenericElement::GetElementsByTagName(tagName, aReturn);
}

Here is the call graph for this function:

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

Reimplemented from nsGenericElement.

Definition at line 434 of file nsGenericHTMLElement.cpp.

{
  nsAutoString localName(aLocalName);

  // Only lowercase the name if this element has no namespace (i.e.
  // it's a HTML element, not an XHTML element).
  if (mNodeInfo && mNodeInfo->NamespaceEquals(kNameSpaceID_None))
    ToLowerCase(localName);

  return nsGenericElement::GetElementsByTagNameNS(aNamespaceURI, localName,
                                                  aReturn);
}

Here is the call 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:

nsIFormControlFrame* nsGenericHTMLElement::GetFormControlFrame ( PRBool  aFlushContent) [inline, inherited]

Get the primary form control frame for this content (see GetFormControlFrameFor)

Parameters:
aFlushContentwhether to flush the content sink
Returns:
the primary form control frame (or null)

Definition at line 300 of file nsGenericHTMLElement.h.

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

    return GetFormControlFrameFor(this, doc, aFlushContent);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFormControlFrame * nsGenericHTMLElement::GetFormControlFrameFor ( nsIContent aContent,
nsIDocument aDocument,
PRBool  aFlushContent 
) [static, inherited]

Get the primary form control frame for a piece of content.

Same as GetPrimaryFrameFor, except it QI's to nsIFormControlFrame.

Parameters:
aContentthe content to get the primary frame for
aDocumentthe document for this content
aFlushContentwhether to flush the content sink, which creates frames for content that do not already have it. EXPENSIVE.
Returns:
the primary frame as nsIFormControlFrame

Definition at line 2371 of file nsGenericHTMLElement.cpp.

{
  nsIFrame* frame = GetPrimaryFrameFor(aContent, aDocument, aFlushContent);
  if (frame) {
    nsIFormControlFrame* form_frame = nsnull;
    CallQueryInterface(frame, &form_frame);
    if (form_frame) {
      return form_frame;
    }

    // If we have generated content, the primary frame will be a
    // wrapper frame..  out real frame will be in its child list.
    for (frame = frame->GetFirstChild(nsnull);
         frame;
         frame = frame->GetNextSibling()) {
      CallQueryInterface(frame, &form_frame);
      if (form_frame) {
        return form_frame;
      }
    }
        
    NS_ERROR("Form control has a frame, but it's not a form frame");
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetHashFromHrefString ( const nsAString &  aHref,
nsAString &  aHash 
) [static, inherited]

Definition at line 4193 of file nsGenericHTMLElement.cpp.

{
  aHash.Truncate();
  nsCOMPtr<nsIURI> uri;

  nsresult rv = NS_NewURI(getter_AddRefs(uri), aHref);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIURL> url(do_QueryInterface(uri));

  if (!url) {
    // If this is not a URL, we can't get the hash part from the URI

    return NS_OK;
  }

  nsCAutoString ref;
  rv = url->GetRef(ref);
  if (NS_FAILED(rv))
    return rv;
  NS_UnescapeURL(ref); // XXX may result in random non-ASCII bytes!

  if (!ref.IsEmpty()) {
    aHash.Assign(PRUnichar('#'));
    AppendASCIItoUTF16(ref, aHash);
  }
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetHostFromHrefString ( const nsAString &  aHref,
nsAString &  aHost 
) [static, inherited]

Definition at line 4053 of file nsGenericHTMLElement.cpp.

{
  aHost.Truncate();
  nsCOMPtr<nsIURI> uri;
  nsresult rv = NS_NewURI(getter_AddRefs(uri), aHref);
  if (NS_FAILED(rv))
    return rv;

  nsCAutoString hostport;
  rv = uri->GetHostPort(hostport);

  // Failure to get the hostport from the URI isn't necessarily an
  // error. Some URI's just don't have a hostport.

  if (NS_SUCCEEDED(rv)) {
    CopyUTF8toUTF16(hostport, aHost);
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetHostnameFromHrefString ( const nsAString &  aHref,
nsAString &  aHostname 
) [static, inherited]

Definition at line 4077 of file nsGenericHTMLElement.cpp.

{
  aHostname.Truncate();
  nsCOMPtr<nsIURI> url;
  nsresult rv = NS_NewURI(getter_AddRefs(url), aHref);
  if (NS_FAILED(rv))
    return rv;

  nsCAutoString host;
  rv = url->GetHost(host);

  if (NS_SUCCEEDED(rv)) {
    // Failure to get the host from the URI isn't necessarily an
    // error. Some URI's just don't have a host.

    CopyUTF8toUTF16(host, aHostname);
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 1756 of file nsGenericHTMLElement.cpp.

{
  // This is used by the three nsILink implementations and
  // nsHTMLStyleElement.

  // Get href= attribute (relative URI).

  // We use the nsAttrValue's copy of the URI string to avoid copying.
  const nsAttrValue* attr = mAttrsAndChildren.GetAttr(nsHTMLAtoms::href);
  if (attr) {
    // Get base URI.
    nsCOMPtr<nsIURI> baseURI = GetBaseURI();

    // Get absolute URI.
    nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI,
                                                            attr->GetStringValue(),
                                                            GetOwnerDoc(),
                                                            baseURI);
    if (NS_FAILED(rv)) {
      *aURI = nsnull;
    }
  }
  else {
    // Absolute URI is null to say we have no HREF.
    *aURI = nsnull;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetId ( nsAString &  aId) [inherited]

Definition at line 451 of file nsGenericHTMLElement.cpp.

nsIAtom * nsGenericElement::GetID ( ) const [virtual, inherited]

Implements nsIStyledContent.

Reimplemented in nsXULElement.

Definition at line 2355 of file nsGenericElement.cpp.

{
  nsIAtom* IDName = GetIDAttributeName();
  if (IDName) {
    const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName);
    if (attrVal){
      if (attrVal->Type() == nsAttrValue::eAtom) {
        return attrVal->GetAtomValue();
      }
      if(attrVal->IsEmptyString()){
        return nsnull;
      }
      // Check if the ID has been stored as a string.
      // This would occur if the ID attribute name changed after 
      // the ID was parsed. 
      if (attrVal->Type() == nsAttrValue::eString) {
        nsAutoString idVal(attrVal->GetStringValue());

        // Create an atom from the value and set it into the attribute list. 
        NS_CONST_CAST(nsAttrValue*, attrVal)->ParseAtom(idVal);
        return attrVal->GetAtomValue();
      }
    }
  }
  return nsnull;
}

Here is the call graph for this function:

nsIAtom * nsGenericHTMLElement::GetIDAttributeName ( ) const [virtual, inherited]

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 2029 of file nsGenericHTMLElement.cpp.

{
  return nsHTMLAtoms::id;
}

Reimplemented from nsGenericElement.

Definition at line 2086 of file nsGenericHTMLElement.cpp.

{ 
  const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(nsHTMLAtoms::style);
  
  if (attrVal) {
    if (attrVal->Type() != nsAttrValue::eCSSStyleRule) {
      ReparseStyleAttribute();
      attrVal = mAttrsAndChildren.GetAttr(nsHTMLAtoms::style);
      // hopefully attrVal->Type() is now nsAttrValue::eCSSStyleRule
    }

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

  return nsnull;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetInnerHTML ( nsAString &  aInnerHTML) [virtual, inherited]

Reimplemented in nsHTMLScriptElement, nsHTMLStyleElement, and nsHTMLSpanElement.

Definition at line 872 of file nsGenericHTMLElement.cpp.

{
  aInnerHTML.Truncate();

  nsCOMPtr<nsIDocument> doc = GetOwnerDoc();
  if (!doc) {
    return NS_OK; // We rely on the document for doing HTML conversion
  }

  nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *,
                                                                 this)));
  nsresult rv = NS_OK;

  nsAutoString contentType;
  if (!doc->IsCaseSensitive()) {
    // All case-insensitive documents are HTML as far as we're concerned
    contentType.AssignLiteral("text/html");
  } else {
    doc->GetContentType(contentType);
  }
  
  nsCOMPtr<nsIDocumentEncoder> docEncoder;
  docEncoder =
    do_CreateInstance(PromiseFlatCString(
        nsDependentCString(NS_DOC_ENCODER_CONTRACTID_BASE) +
        NS_ConvertUTF16toUTF8(contentType)
      ).get());
  if (!docEncoder && doc->IsCaseSensitive()) {
    // This could be some type for which we create a synthetic document.  Try
    // again as XML
    contentType.AssignLiteral("application/xml");
    docEncoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "application/xml");
  }

  NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);

  docEncoder->Init(doc, contentType,
                   nsIDocumentEncoder::OutputEncodeBasicEntities |
                   // Output DOM-standard newlines
                   nsIDocumentEncoder::OutputLFLineBreak |
                   // Don't do linebreaking that's not present in the source
                   nsIDocumentEncoder::OutputRaw);

  nsCOMPtr<nsIDOMRange> range(new nsRange);
  NS_ENSURE_TRUE(range, NS_ERROR_OUT_OF_MEMORY);

  rv = range->SelectNodeContents(thisNode);
  NS_ENSURE_SUCCESS(rv, rv);

  docEncoder->SetRange(range);

  docEncoder->EncodeToString(aInnerHTML);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetLang ( nsAString &  aLang) [inherited]

Definition at line 479 of file nsGenericHTMLElement.cpp.

{
  GetAttr(kNameSpaceID_None, nsHTMLAtoms::lang, aLang);
  return NS_OK;
}
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:

nsresult nsGenericHTMLElement::GetLayoutHistoryAndKey ( nsGenericHTMLElement aContent,
nsILayoutHistoryState **  aState,
nsACString &  aKey 
) [static, inherited]

Get the layout history object and generate the key for a particular piece of content.

Parameters:
aContentthe content to generate the key for
aStatethe history state object (out param)
aKeythe key (out param)

Definition at line 2429 of file nsGenericHTMLElement.cpp.

{
  //
  // Get the pres shell
  //
  nsCOMPtr<nsIDocument> doc = aContent->GetDocument();
  if (!doc) {
    return NS_OK;
  }

  //
  // Get the history (don't bother with the key if the history is not there)
  //
  *aHistory = doc->GetLayoutHistoryState().get();
  if (!*aHistory) {
    return NS_OK;
  }

  //
  // Get the state key
  //
  nsresult rv = nsContentUtils::GenerateStateKey(aContent, doc,
                                                 nsIStatefulFrame::eNoID,
                                                 aKey);
  if (NS_FAILED(rv)) {
    NS_RELEASE(*aHistory);
    return rv;
  }

  // If the state key is blank, this is anonymous content or for
  // whatever reason we are not supposed to save/restore state.
  if (aKey.IsEmpty()) {
    NS_RELEASE(*aHistory);
    return NS_OK;
  }

  // Add something unique to content so layout doesn't muck us up
  aKey += "-C";

  return rv;
}

Here is the call 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]

Implements nsIContent.

Reimplemented in nsXULElement.

Definition at line 2719 of file nsGenericElement.cpp.

{
  *aResult = nsnull;

  if (!sEventListenerManagersHash.ops) {
    // We're already shut down, don't bother creating a event listener
    // manager.

    return NS_ERROR_NOT_AVAILABLE;
  }

  EventListenerManagerMapEntry *entry =
    NS_STATIC_CAST(EventListenerManagerMapEntry *,
                   PL_DHashTableOperate(&sEventListenerManagersHash, this,
                                        PL_DHASH_ADD));

  if (!entry) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (!entry->mListenerManager) {
    nsresult rv =
      NS_NewEventListenerManager(getter_AddRefs(entry->mListenerManager));

    if (NS_FAILED(rv)) {
      PL_DHashTableRawRemove(&sEventListenerManagersHash, entry);

      return rv;
    }

    entry->mListenerManager->SetListenerTarget(NS_STATIC_CAST(nsIXMLContent *,
                                                              this));

    SetFlags(GENERIC_ELEMENT_HAS_LISTENERMANAGER);
  }

  *aResult = entry->mListenerManager;
  NS_ADDREF(*aResult);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetLocalName ( nsAString &  aLocalName) [inherited]

Reimplemented from nsGenericElement.

Definition at line 405 of file nsGenericHTMLElement.cpp.

{
  mNodeInfo->GetLocalName(aLocalName);

  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
    // No namespace, this means we're dealing with a good ol' HTML
    // element, so uppercase the local name.

    ToUpperCase(aLocalName);
  }

  return NS_OK;
}

Here is the call graph for this function:

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 nsHTMLFormElement::GetNextRadioButton ( const nsAString &  aName,
const PRBool  aPrevious,
nsIDOMHTMLInputElement aFocusedRadio,
nsIDOMHTMLInputElement **  aRadio 
) [virtual]

Get the next/prev radio button in a group.

Parameters:
aNamethe group name
aPrevious,truegets previous radio button, false gets next
aFocusedRadiothe currently focused radio button
aRadiothe currently selected radio button [OUT]

Implements nsIRadioGroupContainer.

Definition at line 1606 of file nsHTMLFormElement.cpp.

{
  // Return the radio button relative to the focused radio button.
  // If no radio is focused, get the radio relative to the selected one.
  *aRadioOut = nsnull;

  nsCOMPtr<nsIDOMHTMLInputElement> currentRadio;
  if (aFocusedRadio) {
    currentRadio = aFocusedRadio;
  }
  else {
    mSelectedRadioButtons.Get(aName, getter_AddRefs(currentRadio));
  }

  nsCOMPtr<nsISupports> itemWithName;
  ResolveName(aName, getter_AddRefs(itemWithName));
  nsCOMPtr<nsIDOMNodeList> radioNodeList(do_QueryInterface(itemWithName));

  // XXX If ResolveName could return an nsContentList instead then we 
  //     could get an nsContentList instead of using this hacky upcast

  nsBaseContentList *radioGroup =
    NS_STATIC_CAST(nsBaseContentList *, (nsIDOMNodeList *)radioNodeList);
  if (!radioGroup) {
    return NS_ERROR_FAILURE;
  }

  nsCOMPtr<nsIContent> currentRadioNode(do_QueryInterface(currentRadio));
  NS_ASSERTION(currentRadioNode, "No nsIContent for current radio button");
  PRInt32 index = radioGroup->IndexOf(currentRadioNode, PR_TRUE);
  if (index < 0) {
    return NS_ERROR_FAILURE;
  }

  PRUint32 numRadios;
  radioGroup->GetLength(&numRadios);
  PRBool disabled = PR_TRUE;
  nsCOMPtr<nsIDOMHTMLInputElement> radio;
  nsCOMPtr<nsIDOMNode> radioDOMNode;
  nsCOMPtr<nsIFormControl> formControl;

  do {
    if (aPrevious) {
      if (--index < 0) {
        index = numRadios -1;
      }
    }
    else if (++index >= numRadios) {
      index = 0;
    }
    radioGroup->Item(index, getter_AddRefs(radioDOMNode));
    radio = do_QueryInterface(radioDOMNode);
    if (!radio)
      continue;

    formControl = do_QueryInterface(radio);
    if (!formControl || formControl->GetType() != NS_FORM_INPUT_RADIO)
      continue;

    radio->GetDisabled(&disabled);
  } while (disabled && radio != currentRadio);

  NS_IF_ADDREF(*aRadioOut = radio);
  return NS_OK;
}

Here is the call graph for this function:

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:

nsresult nsGenericHTMLElement::GetNodeName ( nsAString &  aNodeName) [inherited]

Reimplemented from nsGenericElement.

Definition at line 394 of file nsGenericHTMLElement.cpp.

{
  mNodeInfo->GetQualifiedName(aNodeName);

  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None))
    ToUpperCase(aNodeName);

  return NS_OK;
}

Here is the call graph for this function:

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:

nsresult nsGenericHTMLElement::GetOffsetHeight ( PRInt32 aOffsetHeight) [inherited]

Definition at line 844 of file nsGenericHTMLElement.cpp.

{
  nsRect rcFrame;
  nsCOMPtr<nsIContent> parent;
  GetOffsetRect(rcFrame, getter_AddRefs(parent));

  *aOffsetHeight = rcFrame.height;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetOffsetLeft ( PRInt32 aOffsetLeft) [inherited]

Definition at line 820 of file nsGenericHTMLElement.cpp.

{
  nsRect rcFrame;
  nsCOMPtr<nsIContent> parent;
  GetOffsetRect(rcFrame, getter_AddRefs(parent));

  *aOffsetLeft = rcFrame.x;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 856 of file nsGenericHTMLElement.cpp.

{
  nsRect rcFrame;
  nsCOMPtr<nsIContent> parent;
  GetOffsetRect(rcFrame, getter_AddRefs(parent));

  if (parent) {
    CallQueryInterface(parent, aOffsetParent);
  } else {
    *aOffsetParent = nsnull;
  }

  return NS_OK;
}

Here is the call graph for this function:

void nsGenericHTMLElement::GetOffsetRect ( nsRect aRect,
nsIContent **  aOffsetParent 
) [inherited]

Get the frame's offset information for offsetTop/Left/Width/Height.

Parameters:
aRectthe offset information [OUT]
aOffsetParentthe parent the offset is relative to (offsetParent) [OUT]

Definition at line 606 of file nsGenericHTMLElement.cpp.

{
  *aOffsetParent = nsnull;

  aRect.x = aRect.y = 0;
  aRect.Empty();

  nsIDocument *document = GetCurrentDoc();
  if (!document) {
    return;
  }

  // Flush all pending notifications so that our frames are up to date.  Make
  // sure to do this first thing, since it may end up destroying our document's
  // presshell.
  document->FlushPendingNotifications(Flush_Layout);

  // Get Presentation shell 0
  nsIPresShell *presShell = document->GetShellAt(0);

  if (!presShell) {
    return;
  }

  // Get the Presentation Context from the Shell
  nsPresContext *context = presShell->GetPresContext();
  if (!context) {
    return;
  }

  // Get the Frame for our content
  nsIFrame* frame = nsnull;
  presShell->GetPrimaryFrameFor(this, &frame);

  if (!frame) {
    return;
  }

  // Get the union of all rectangles in this and continuation frames
  nsRect rcFrame;
  nsIFrame* next = frame;

  do {
    rcFrame.UnionRect(rcFrame, next->GetRect());
    next = next->GetNextInFlow();
  } while (next);

  if (rcFrame.IsEmpty()) {
    // It could happen that all the rects are empty (eg zero-width or
    // zero-height).  In that case, use the first rect for the frame.
    rcFrame = frame->GetRect();
  }

  nsIContent *docElement = document->GetRootContent();

  // Find the frame parent whose content's tagName either matches
  // the tagName passed in or is the document element.
  nsIFrame* parent = nsnull;
  PRBool done = PR_FALSE;

  nsIContent* content = frame->GetContent();

  if (content) {
    if (IsBody(content) || content == docElement) {
      done = PR_TRUE;

      parent = frame;
    }
  }

  nsPoint origin(0, 0);

  if (!done) {
    PRBool is_absolutely_positioned = PR_FALSE;
    PRBool is_positioned = PR_FALSE;

    origin = frame->GetPosition();

    const nsStyleDisplay* display = frame->GetStyleDisplay();

    if (display->IsPositioned()) {
      if (display->IsAbsolutelyPositioned()) {
        // If the primary frame or a parent is absolutely positioned
        // (fixed or absolute) we stop walking up the frame parent
        // chain

        is_absolutely_positioned = PR_TRUE;
      }

      // We need to know if the primary frame is positioned later on.
      is_positioned = PR_TRUE;
    }

    parent = frame->GetParent();

    while (parent) {
      display = parent->GetStyleDisplay();

      if (display->IsPositioned()) {
        // Stop at the first *parent* that is positioned (fixed,
        // absolute, or relatiive)

        *aOffsetParent = parent->GetContent();
        NS_IF_ADDREF(*aOffsetParent);

        break;
      }

      // Add the parent's origin to our own to get to the
      // right coordinate system

      if (!is_absolutely_positioned) {
        origin += parent->GetPosition();
      }

      content = parent->GetContent();

      if (content) {
        // If we've hit the document element, break here
        if (content == docElement) {
          break;
        }

        // If the tag of this frame is a offset parent tag and this
        // element is *not* positioned, break here. Also break if we
        // hit the body element.
        if ((!is_positioned && IsOffsetParent(content)) || IsBody(content)) {
          *aOffsetParent = content;
          NS_ADDREF(*aOffsetParent);

          break;
        }
      }

      parent = parent->GetParent();
    }

    if (is_absolutely_positioned && !*aOffsetParent) {
      // If this element is absolutely positioned, but we don't have
      // an offset parent it means this element is an absolutely
      // positioned child that's not nested inside another positioned
      // element, in this case the element's frame's parent is the
      // frame for the HTML element so we fail to find the body in the
      // parent chain. We want the offset parent in this case to be
      // the body, so we just get the body element from the document.

      nsCOMPtr<nsIDOMHTMLDocument> html_doc(do_QueryInterface(document));

      if (html_doc) {
        nsCOMPtr<nsIDOMHTMLElement> html_element;

        html_doc->GetBody(getter_AddRefs(html_element));

        if (html_element) {
          CallQueryInterface(html_element, aOffsetParent);
        }
      }
    }
  }

  // For the origin, add in the border for the frame

#if 0
  // We used to do this to include the border of the frame in the
  // calculations, but I think that's wrong. My tests show that we
  // work more like IE if we don't do this, so lets try this and see
  // if people agree.
  const nsStyleBorder* border = frame->GetStyleBorder();
  origin.x += border->GetBorderWidth(NS_SIDE_LEFT);
  origin.y += border->GetBorderWidth(NS_SIDE_TOP);
#endif

  // And subtract out the border for the parent
  if (parent) {
    PRBool includeBorder = PR_TRUE;  // set to false if border-box sizing is used
    const nsStylePosition* position = parent->GetStylePosition();
    if (position->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
      includeBorder = PR_FALSE;
    }
    
    if (includeBorder) {
      const nsStyleBorder* border = parent->GetStyleBorder();
      origin.x -= border->GetBorderWidth(NS_SIDE_LEFT);
      origin.y -= border->GetBorderWidth(NS_SIDE_TOP);
    }
  }

  // XXX We should really consider subtracting out padding for
  // content-box sizing, but we should see what IE does....
  
  // Get the scale from that Presentation Context
  float scale;
  scale = context->TwipsToPixels();

  // Convert to pixels using that scale
  aRect.x = NSTwipsToIntPixels(origin.x, scale);
  aRect.y = NSTwipsToIntPixels(origin.y, scale);
  aRect.width = NSTwipsToIntPixels(rcFrame.width, scale);
  aRect.height = NSTwipsToIntPixels(rcFrame.height, scale);
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetOffsetTop ( PRInt32 aOffsetTop) [inherited]

Definition at line 808 of file nsGenericHTMLElement.cpp.

{
  nsRect rcFrame;
  nsCOMPtr<nsIContent> parent;
  GetOffsetRect(rcFrame, getter_AddRefs(parent));

  *aOffsetTop = rcFrame.y;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetOffsetWidth ( PRInt32 aOffsetWidth) [inherited]

Definition at line 832 of file nsGenericHTMLElement.cpp.

{
  nsRect rcFrame;
  nsCOMPtr<nsIContent> parent;
  GetOffsetRect(rcFrame, getter_AddRefs(parent));

  *aOffsetWidth = rcFrame.width;

  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:

const nsAttrValue* nsGenericHTMLElement::GetParsedAttr ( nsIAtom aAttr) const [inline, inherited]

Definition at line 246 of file nsGenericHTMLElement.h.

  {
    return mAttrsAndChildren.GetAttr(aAttr);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetPathnameFromHrefString ( const nsAString &  aHref,
nsAString &  aPathname 
) [static, inherited]

Definition at line 4101 of file nsGenericHTMLElement.cpp.

{
  aPathname.Truncate();
  nsCOMPtr<nsIURI> uri;

  nsresult rv = NS_NewURI(getter_AddRefs(uri), aHref);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsIURL> url(do_QueryInterface(uri));

  if (!url) {
    // If this is not a URL, we can't get the pathname from the URI

    return NS_OK;
  }

  nsCAutoString file;
  rv = url->GetFilePath(file);
  if (NS_FAILED(rv))
    return rv;

  CopyUTF8toUTF16(file, aPathname);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsGenericHTMLElement::GetPortFromHrefString ( const nsAString &  aHref,
nsAString &  aPort 
) [static, inherited]

Definition at line 4163 of file nsGenericHTMLElement.cpp.

{
  aPort.Truncate();
  nsCOMPtr<nsIURI> uri;
  nsresult rv = NS_NewURI(getter_AddRefs(uri), aHref);
  if (NS_FAILED(rv))
    return rv;

  PRInt32 port;
  rv = uri->GetPort(&port);

  if (NS_SUCCEEDED(rv)) {
    // Failure to get the port from the URI isn't necessarily an
    // error. Some URI's just don't have a port.

    if (port == -1) {
      return NS_OK;
    }

    nsAutoString portStr;
    portStr.AppendInt(port, 10);
    aPort.Assign(portStr);
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsHTMLFormElement::GetPositionInGroup ( nsIDOMHTMLInputElement aRadio,
PRInt32 aPositionIndex,
PRInt32 aItemsInGroup 
) [virtual]

Get the radio group position and the number of radio buttons in the group.

that the radio button is in. If the radio button not grouped with any other radio buttons this method will treat it as being in a group of one.

Parameters:
aRadioradio button's pointer
aPositionIndexout indicates 0-indexed position in the radio group, or just 0 if a group cannot be found
aItemsInGroupthe number of radio buttons in the group

Implements nsIRadioGroupContainer.

Definition at line 1567 of file nsHTMLFormElement.cpp.

{
  *aPositionIndex = 0;
  *aItemsInGroup = 1;

  nsAutoString name;
  aRadio->GetName(name);
  if (name.IsEmpty()) {
    return NS_OK;
  }

  nsCOMPtr<nsISupports> itemWithName;
  nsresult rv = ResolveName(name, getter_AddRefs(itemWithName));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIDOMNodeList> radioNodeList(do_QueryInterface(itemWithName));

  // XXX If ResolveName could return an nsContentList instead then we 
  //     could get an nsContentList instead of using this hacky upcast
  nsBaseContentList *radioGroup =
    NS_STATIC_CAST(nsBaseContentList *, (nsIDOMNodeList *)radioNodeList);
  NS_ASSERTION(radioGroup, "No such radio group in this container");
  if (!radioGroup) {
    return NS_OK;
  }

  nsCOMPtr<nsIContent> currentRadioNode(do_QueryInterface(aRadio));
  NS_ASSERTION(currentRadioNode, "No nsIContent for current radio button");
  *aPositionIndex = radioGroup->IndexOf(currentRadioNode, PR_TRUE);
  NS_ASSERTION(*aPositionIndex >= 0, "Radio button not found in its own group");
  PRUint32 itemsInGroup;
  radioGroup->GetLength(&itemsInGroup);
  *aItemsInGroup = itemsInGroup;

  return NS_OK;
}

Here is the call 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:

nsIFrame* nsGenericHTMLElement::GetPrimaryFrame ( PRBool  aFlushContent) [inline, inherited]

Get the primary frame for this content (see GetPrimaryFrameFor)

Parameters:
aFlushContentwhether to flush the content sink
Returns:
the primary frame

Definition at line 316 of file nsGenericHTMLElement.h.

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

    return GetPrimaryFrameFor(this, doc, aFlushContent);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFrame * nsGenericHTMLElement::GetPrimaryFrameFor ( nsIContent aContent,
nsIDocument aDocument,
PRBool  aFlushContent 
) [static, inherited]

Get the primary frame for a piece of content.

Parameters:
aContentthe content to get the primary frame for
aDocumentthe document for this content
aFlushContentwhether to flush the content sink, which creates frames for content that do not already have it. EXPENSIVE.
Returns:
the primary frame

Definition at line 2347 of file nsGenericHTMLElement.cpp.

{
  if (aFlushContent) {
    // Cause a flush of content, so we get up-to-date frame
    // information
    aDocument->FlushPendingNotifications(Flush_Frames);
  }

  // Get presentation shell 0
  nsIPresShell *presShell = aDocument->GetShellAt(0);

  nsIFrame *frame = nsnull;

  if (presShell) {
    presShell->GetPrimaryFrameFor(aContent, &frame);
  }

  return frame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsGenericHTMLElement::GetPrimaryPresState ( nsGenericHTMLElement aContent,
nsPresState **  aPresState 
) [static, inherited]

Get the presentation state for a piece of content, or create it if it does not exist.

Generally used by SaveState().

Parameters:
aContentthe content to get presentation state for.
aPresStatethe presentation state (out param)

Definition at line 2401 of file nsGenericHTMLElement.cpp.

{
  NS_ENSURE_ARG_POINTER(aPresState);
  *aPresState = nsnull;

  nsresult result = NS_OK;

  nsCOMPtr<nsILayoutHistoryState> history;
  nsCAutoString key;
  GetLayoutHistoryAndKey(aContent, getter_AddRefs(history), key);

  if (history) {
    // Get the pres state for this key, if it doesn't exist, create one
    result = history->GetState(key, aPresState);
    if (!*aPresState) {
      result = NS_NewPresState(aPresState);
      if (NS_SUCCEEDED(result)) {
        result = history->AddState(key, *aPresState);
      }
    }
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: