NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_SELECT; }
NS_IMETHOD_(PRInt32) GetType() const { return NS_FORM_SELECT; }
NS_IMPL_ISUPPORTS0(nsSelectState)/** * Implementation of &lt;select&gt; */class nsHTMLSelectElement : public nsGenericHTMLFormElement,                            public nsIDOMHTMLSelectElement,                            public nsIDOMNSHTMLSelectElement,                            public nsIDOMNSXBLFormControl,                            public nsISelectElement{public:  nsHTMLSelectElement(nsINodeInfo *aNodeInfo, PRBool aFromParser = PR_FALSE);  virtual ~nsHTMLSelectElement();  // nsISupports  NS_DECL_ISUPPORTS_INHERITED  // nsIDOMNode  NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLFormElement::)  // nsIDOMElement  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::)  // nsIDOMHTMLElement  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)  // nsIDOMHTMLSelectElement  NS_DECL_NSIDOMHTMLSELECTELEMENT  // nsIDOMNSHTMLSelectElement  NS_DECL_NSIDOMNSHTMLSELECTELEMENT  // nsIDOMNSXBLFormControl  NS_DECL_NSIDOMNSXBLFORMCONTROL  // nsIContent  virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,                                 PRBool aNotify);  virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);  virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);  virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,                                  nsEvent* aEvent, nsIDOMEvent** aDOMEvent,                                  PRUint32 aFlags,                                  nsEventStatus* aEventStatus);  virtual void SetFocus(nsPresContext* aPresContext);  virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);  // Overriden nsIFormControl methods  NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_SELECT; }  NS_IMETHOD Reset();  NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission,                               nsIContent* aSubmitElement);  NS_IMETHOD SaveState();  virtual PRBool RestoreState(nsPresState* aState);  // nsISelectElement  NS_DECL_NSISELECTELEMENT  virtual void DoneAddingChildren();  virtual PRBool IsDoneAddingChildren();  virtual PRBool ParseAttribute(nsIAtom* aAttribute,                                const nsAString& aValue,                                nsAttrValue& aResult);  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;  virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,                                              PRInt32 aModType) const;  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;protected:  // Helper Methods  /**   * Check whether the option specified by the index is selected   * @param aIndex the index   * @return whether the option at the index is selected   */  PRBool IsOptionSelectedByIndex(PRInt32 aIndex);  /**   * Starting with (and including) aStartIndex, find the first selected index   * and set mSelectedIndex to it.   * @param aStartIndex the index to start with   */  void FindSelectedIndex(PRInt32 aStartIndex);  /**   * Select some option if possible (generally the first non-disabled option).   * @return true if something was selected, false otherwise   */  PRBool SelectSomething();  /**   * Call SelectSomething(), but only if nothing is selected   * @see SelectSomething()   * @return true if something was selected, false otherwise   */  PRBool CheckSelectSomething();  /**   * Called to trigger notifications of frames and fixing selected index   *   * @param aSelectFrame the frame for this content (could be null)   * @param aPresContext the current pres context   * @param aIndex the index that was selected or deselected   * @param aSelected whether the index was selected or deselected   * @param aNotify whether to notify the style system and such   */  void OnOptionSelected(nsISelectControlFrame* aSelectFrame,                        nsPresContext* aPresContext,                        PRInt32 aIndex,                        PRBool aSelected,                        PRBool aNotify);  /**   * Restore state to a particular state string (representing the options)   * @param aNewSelected the state string to restore to   */  void RestoreStateTo(nsSelectState* aNewSelected);#ifdef DEBUG_john  // Don't remove these, por favor.  They're very useful in debugging  nsresult PrintOptions(nsIContent* aOptions, PRInt32 tabs);#endif  // Adding options  /**   * Insert option(s) into the options[] array and perform notifications   * @param aOptions the option or optgroup being added   * @param aListIndex the index to start adding options into the list at   * @param aDepth the depth of aOptions (1=direct child of select ...)   */  nsresult InsertOptionsIntoList(nsIContent* aOptions,                                 PRInt32 aListIndex,                                 PRInt32 aDepth);  /**   * Remove option(s) from the options[] array   * @param aOptions the option or optgroup being added   * @param aListIndex the index to start removing options from the list at   * @param aDepth the depth of aOptions (1=direct child of select ...)   */  nsresult RemoveOptionsFromList(nsIContent* aOptions,                                 PRInt32 aListIndex,                                 PRInt32 aDepth);  /**   * Insert option(s) into the options[] array (called by InsertOptionsIntoList)   * @param aOptions the option or optgroup being added   * @param aInsertIndex the index to start adding options into the list at   * @param aDepth the depth of aOptions (1=direct child of select ...)   */  nsresult InsertOptionsIntoListRecurse(nsIContent* aOptions,                                        PRInt32* aInsertIndex,                                        PRInt32 aDepth);  /**   * Remove option(s) from the options[] array (called by RemoveOptionsFromList)   * @param aOptions the option or optgroup being added   * @param aListIndex the index to start removing options from the list at   * @param aNumRemoved the number removed so far [OUT]   * @param aDepth the depth of aOptions (1=direct child of select ...)   */  nsresult RemoveOptionsFromListRecurse(nsIContent* aOptions,                                        PRInt32 aRemoveIndex,                                        PRInt32* aNumRemoved,                                        PRInt32 aDepth);  /**   * Find out how deep this content is from the select (1=direct child)   * @param aContent the content to check   * @return the depth   */  PRInt32 GetContentDepth(nsIContent* aContent);  /**   * Get the index of the first option at, under or following the content in   * the select, or length of options[] if none are found   * @param aOptions the content   * @return the index of the first option   */  PRInt32 GetOptionIndexAt(nsIContent* aOptions);  /**   * Get the next option following the content in question (not at or under)   * (this could include siblings of the current content or siblings of the   * parent or children of siblings of the parent).   * @param aOptions the content   * @return the index of the next option after the content   */  PRInt32 GetOptionIndexAfter(nsIContent* aOptions);  /**   * Get the first option index at or under the content in question.   * @param aOptions the content   * @return the index of the first option at or under the content   */  PRInt32 GetFirstOptionIndex(nsIContent* aOptions);  /**   * Get the first option index under the content in question, within the   * range specified.   * @param aOptions the content   * @param aStartIndex the first child to look at   * @param aEndIndex the child *after* the last child to look at   * @return the index of the first option at or under the content   */  PRInt32 GetFirstChildOptionIndex(nsIContent* aOptions,                                   PRInt32 aStartIndex,                                   PRInt32 aEndIndex);  /**   * Get the frame as an nsISelectControlFrame (MAY RETURN NULL)   * @return the select frame, or null   */  nsISelectControlFrame *GetSelectFrame();  /**   * Helper method for dispatching custom DOM events to our anonymous subcontent   * (for XBL form controls)   * @param aName the name of the event to dispatch   */  void DispatchDOMEvent(const nsAString& aName);  /**   * Is this a combobox?   */  PRBool IsCombobox() {    PRBool isMultiple = PR_TRUE;    PRInt32 size = 1;    GetSize(&size);    GetMultiple(&isMultiple);    return !isMultiple && size <= 1;  }  /** The options[] array */  nsHTMLOptionCollection* mOptions;  /** false if the parser is in the middle of adding children. */  PRBool    mIsDoneAddingChildren;  /** The number of non-options as children of the select */  PRUint32  mNonOptionChildren;  /** The number of optgroups anywhere under the select */  PRUint32  mOptGroupCount;  /**   * The current selected index for selectedIndex (will be the first selected   * index if multiple are selected)   */  PRInt32   mSelectedIndex;  /**   * The temporary restore state in case we try to restore before parser is   * done adding options   */  nsSelectState* mRestoreState;};