LCOV - code coverage report
Current view: directory - content/html/content/src - nsGenericHTMLElement.h (source / functions) Found Hit Coverage
Test: app.info Lines: 60 21 35.0 %
Date: 2012-06-02 Functions: 21 7 33.3 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Communicator client code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : #ifndef nsGenericHTMLElement_h___
      39                 : #define nsGenericHTMLElement_h___
      40                 : 
      41                 : #include "nsMappedAttributeElement.h"
      42                 : #include "nsIDOMHTMLElement.h"
      43                 : #include "nsINameSpaceManager.h"  // for kNameSpaceID_None
      44                 : #include "nsIFormControl.h"
      45                 : #include "nsFrameLoader.h"
      46                 : #include "nsGkAtoms.h"
      47                 : #include "nsContentCreatorFunctions.h"
      48                 : 
      49                 : class nsIDOMAttr;
      50                 : class nsIDOMEventListener;
      51                 : class nsIDOMNodeList;
      52                 : class nsIFrame;
      53                 : class nsIStyleRule;
      54                 : class nsChildContentList;
      55                 : class nsDOMCSSDeclaration;
      56                 : class nsIDOMCSSStyleDeclaration;
      57                 : class nsIURI;
      58                 : class nsIFormControlFrame;
      59                 : class nsIForm;
      60                 : class nsPresState;
      61                 : class nsILayoutHistoryState;
      62                 : class nsIEditor;
      63                 : struct nsRect;
      64                 : struct nsSize;
      65                 : class nsHTMLFormElement;
      66                 : class nsIDOMDOMStringMap;
      67                 : class nsIDOMHTMLMenuElement;
      68                 : 
      69                 : typedef nsMappedAttributeElement nsGenericHTMLElementBase;
      70                 : 
      71                 : /**
      72                 :  * A common superclass for HTML elements
      73                 :  */
      74                 : class nsGenericHTMLElement : public nsGenericHTMLElementBase
      75            1582 : {
      76                 : public:
      77             791 :   nsGenericHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
      78             791 :     : nsGenericHTMLElementBase(aNodeInfo)
      79                 :   {
      80             791 :     NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML,
      81                 :                  "Unexpected namespace");
      82             791 :   }
      83                 : 
      84                 :   /** Typesafe, non-refcounting cast from nsIContent.  Cheaper than QI. **/
      85               0 :   static nsGenericHTMLElement* FromContent(nsIContent *aContent)
      86                 :   {
      87               0 :     if (aContent->IsHTML())
      88               0 :       return static_cast<nsGenericHTMLElement*>(aContent);
      89               0 :     return nsnull;
      90                 :   }
      91                 : 
      92                 :   /**
      93                 :    * Handle QI for the standard DOM interfaces (DOMNode, DOMElement,
      94                 :    * DOMHTMLElement) and handles tearoffs for other standard interfaces.
      95                 :    * @param aElement the element as nsIDOMHTMLElement*
      96                 :    * @param aIID the IID to QI to
      97                 :    * @param aInstancePtr the QI'd method [OUT]
      98                 :    * @see nsGenericHTMLElementTearoff
      99                 :    */
     100                 :   nsresult DOMQueryInterface(nsIDOMHTMLElement *aElement, REFNSIID aIID,
     101                 :                              void **aInstancePtr);
     102                 : 
     103                 :   // From nsGenericElement
     104                 :   nsresult CopyInnerTo(nsGenericElement* aDest) const;
     105                 : 
     106                 :   // Implementation for nsIDOMElement
     107                 :   NS_METHOD SetAttribute(const nsAString& aName,
     108                 :                          const nsAString& aValue);
     109                 : 
     110                 :   // nsIDOMHTMLElement methods. Note that these are non-virtual
     111                 :   // methods, implementations are expected to forward calls to these
     112                 :   // methods.
     113                 :   nsresult GetId(nsAString& aId);
     114                 :   nsresult SetId(const nsAString& aId);
     115                 :   nsresult GetTitle(nsAString& aTitle);
     116                 :   nsresult SetTitle(const nsAString& aTitle);
     117                 :   nsresult GetLang(nsAString& aLang);
     118                 :   nsresult SetLang(const nsAString& aLang);
     119                 :   NS_IMETHOD GetDir(nsAString& aDir);
     120                 :   NS_IMETHOD SetDir(const nsAString& aDir);
     121                 :   nsresult GetClassName(nsAString& aClassName);
     122                 :   nsresult SetClassName(const nsAString& aClassName);
     123                 :   nsresult GetOffsetTop(PRInt32* aOffsetTop);
     124                 :   nsresult GetOffsetLeft(PRInt32* aOffsetLeft);
     125                 :   nsresult GetOffsetWidth(PRInt32* aOffsetWidth);
     126                 :   nsresult GetOffsetHeight(PRInt32* aOffsetHeight);
     127                 :   nsresult GetOffsetParent(nsIDOMElement** aOffsetParent);
     128                 :   NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
     129                 :   NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML);
     130                 :   NS_IMETHOD GetOuterHTML(nsAString& aOuterHTML);
     131                 :   NS_IMETHOD SetOuterHTML(const nsAString& aOuterHTML);
     132                 :   NS_IMETHOD InsertAdjacentHTML(const nsAString& aPosition,
     133                 :                                 const nsAString& aText);
     134                 :   nsresult ScrollIntoView(bool aTop, PRUint8 optional_argc);
     135                 :   nsresult MozRequestFullScreen();
     136                 :   // Declare Focus(), Blur(), GetTabIndex(), SetTabIndex(), GetHidden(),
     137                 :   // SetHidden(), GetSpellcheck(), SetSpellcheck(), and GetDraggable() such that
     138                 :   // classes that inherit interfaces with those methods properly override them.
     139                 :   NS_IMETHOD Focus();
     140                 :   NS_IMETHOD Blur();
     141                 :   NS_IMETHOD Click();
     142                 :   NS_IMETHOD GetTabIndex(PRInt32 *aTabIndex);
     143                 :   NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
     144                 :   NS_IMETHOD GetHidden(bool* aHidden);
     145                 :   NS_IMETHOD SetHidden(bool aHidden);
     146                 :   NS_IMETHOD GetSpellcheck(bool* aSpellcheck);
     147                 :   NS_IMETHOD SetSpellcheck(bool aSpellcheck);
     148                 :   NS_IMETHOD GetDraggable(bool* aDraggable);
     149                 :   NS_IMETHOD SetDraggable(bool aDraggable);
     150                 :   NS_IMETHOD GetAccessKey(nsAString &aAccessKey);
     151                 :   NS_IMETHOD SetAccessKey(const nsAString& aAccessKey);
     152                 :   NS_IMETHOD GetAccessKeyLabel(nsAString& aLabel);
     153                 :   nsresult GetContentEditable(nsAString& aContentEditable);
     154                 :   nsresult GetIsContentEditable(bool* aContentEditable);
     155                 :   nsresult SetContentEditable(const nsAString &aContentEditable);
     156                 :   nsresult GetDataset(nsIDOMDOMStringMap** aDataset);
     157                 :   // Callback for destructor of of dataset to ensure to null out weak pointer.
     158                 :   nsresult ClearDataset();
     159                 :   nsresult GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu);
     160                 : 
     161                 : protected:
     162                 :   nsresult GetMarkup(bool aIncludeSelf, nsAString& aMarkup);
     163                 : 
     164                 : public:
     165                 :   // Implementation for nsIContent
     166                 :   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
     167                 :                               nsIContent* aBindingParent,
     168                 :                               bool aCompileEventHandlers);
     169                 :   virtual void UnbindFromTree(bool aDeep = true,
     170                 :                               bool aNullParent = true);
     171               0 :   nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
     172                 :                    const nsAString& aValue, bool aNotify)
     173                 :   {
     174               0 :     return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
     175                 :   }
     176                 :   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
     177                 :                            nsIAtom* aPrefix, const nsAString& aValue,
     178                 :                            bool aNotify);
     179                 :   virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
     180                 :                              bool aNotify);
     181               0 :   virtual bool IsFocusable(PRInt32 *aTabIndex = nsnull, bool aWithMouse = false)
     182                 :   {
     183               0 :     bool isFocusable = false;
     184               0 :     IsHTMLFocusable(aWithMouse, &isFocusable, aTabIndex);
     185               0 :     return isFocusable;
     186                 :   }
     187                 :   /**
     188                 :    * Returns true if a subclass is not allowed to override the value returned
     189                 :    * in aIsFocusable.
     190                 :    */
     191                 :   virtual bool IsHTMLFocusable(bool aWithMouse,
     192                 :                                  bool *aIsFocusable,
     193                 :                                  PRInt32 *aTabIndex);
     194                 :   virtual void PerformAccesskey(bool aKeyCausesActivation,
     195                 :                                 bool aIsTrustedEvent);
     196                 : 
     197                 :   /**
     198                 :    * Check if an event for an anchor can be handled
     199                 :    * @return true if the event can be handled, false otherwise
     200                 :    */
     201                 :   bool CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor);
     202                 :   nsresult PreHandleEventForAnchors(nsEventChainPreVisitor& aVisitor);
     203                 :   nsresult PostHandleEventForAnchors(nsEventChainPostVisitor& aVisitor);
     204                 :   bool IsHTMLLink(nsIURI** aURI) const;
     205                 : 
     206                 :   // HTML element methods
     207               0 :   void Compact() { mAttrsAndChildren.Compact(); }
     208                 : 
     209                 :   virtual void UpdateEditableState(bool aNotify);
     210                 : 
     211                 :   // Helper for setting our editable flag and notifying
     212               1 :   void DoSetEditableFlag(bool aEditable, bool aNotify) {
     213               1 :     SetEditableFlag(aEditable);
     214               1 :     UpdateState(aNotify);
     215               1 :   }
     216                 : 
     217                 :   virtual bool ParseAttribute(PRInt32 aNamespaceID,
     218                 :                                 nsIAtom* aAttribute,
     219                 :                                 const nsAString& aValue,
     220                 :                                 nsAttrValue& aResult);
     221                 : 
     222                 :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
     223                 :   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
     224                 : 
     225                 :   /**
     226                 :    * Get the base target for any links within this piece
     227                 :    * of content. Generally, this is the document's base target,
     228                 :    * but certain content carries a local base for backward
     229                 :    * compatibility.
     230                 :    *
     231                 :    * @param aBaseTarget the base target [OUT]
     232                 :    */
     233                 :   void GetBaseTarget(nsAString& aBaseTarget) const;
     234                 : 
     235                 :   /**
     236                 :    * Get the primary form control frame for this element.  Same as
     237                 :    * GetPrimaryFrame(), except it QI's to nsIFormControlFrame.
     238                 :    *
     239                 :    * @param aFlush whether to flush out frames so that they're up to date.
     240                 :    * @return the primary frame as nsIFormControlFrame
     241                 :    */
     242                 :   nsIFormControlFrame* GetFormControlFrame(bool aFlushFrames);
     243                 : 
     244                 :   //----------------------------------------
     245                 : 
     246                 :   /**
     247                 :    * Parse an alignment attribute (top/middle/bottom/baseline)
     248                 :    *
     249                 :    * @param aString the string to parse
     250                 :    * @param aResult the resulting HTMLValue
     251                 :    * @return whether the value was parsed
     252                 :    */
     253                 :   static bool ParseAlignValue(const nsAString& aString,
     254                 :                                 nsAttrValue& aResult);
     255                 : 
     256                 :   /**
     257                 :    * Parse a div align string to value (left/right/center/middle/justify)
     258                 :    *
     259                 :    * @param aString the string to parse
     260                 :    * @param aResult the resulting HTMLValue
     261                 :    * @return whether the value was parsed
     262                 :    */
     263                 :   static bool ParseDivAlignValue(const nsAString& aString,
     264                 :                                    nsAttrValue& aResult);
     265                 : 
     266                 :   /**
     267                 :    * Convert a table halign string to value (left/right/center/char/justify)
     268                 :    *
     269                 :    * @param aString the string to parse
     270                 :    * @param aResult the resulting HTMLValue
     271                 :    * @return whether the value was parsed
     272                 :    */
     273                 :   static bool ParseTableHAlignValue(const nsAString& aString,
     274                 :                                       nsAttrValue& aResult);
     275                 : 
     276                 :   /**
     277                 :    * Convert a table cell halign string to value
     278                 :    *
     279                 :    * @param aString the string to parse
     280                 :    * @param aResult the resulting HTMLValue
     281                 :    * @return whether the value was parsed
     282                 :    */
     283                 :   static bool ParseTableCellHAlignValue(const nsAString& aString,
     284                 :                                           nsAttrValue& aResult);
     285                 : 
     286                 :   /**
     287                 :    * Convert a table valign string to value (left/right/center/char/justify/
     288                 :    * abscenter/absmiddle/middle)
     289                 :    *
     290                 :    * @param aString the string to parse
     291                 :    * @param aResult the resulting HTMLValue
     292                 :    * @return whether the value was parsed
     293                 :    */
     294                 :   static bool ParseTableVAlignValue(const nsAString& aString,
     295                 :                                       nsAttrValue& aResult);
     296                 : 
     297                 :   /**
     298                 :    * Convert an image attribute to value (width, height, hspace, vspace, border)
     299                 :    *
     300                 :    * @param aAttribute the attribute to parse
     301                 :    * @param aString the string to parse
     302                 :    * @param aResult the resulting HTMLValue
     303                 :    * @return whether the value was parsed
     304                 :    */
     305                 :   static bool ParseImageAttribute(nsIAtom* aAttribute,
     306                 :                                     const nsAString& aString,
     307                 :                                     nsAttrValue& aResult);
     308                 :   /**
     309                 :    * Convert a frameborder string to value (yes/no/1/0)
     310                 :    *
     311                 :    * @param aString the string to parse
     312                 :    * @param aResult the resulting HTMLValue
     313                 :    * @return whether the value was parsed
     314                 :    */
     315                 :   static bool ParseFrameborderValue(const nsAString& aString,
     316                 :                                       nsAttrValue& aResult);
     317                 : 
     318                 :   /**
     319                 :    * Convert a scrolling string to value (yes/no/on/off/scroll/noscroll/auto)
     320                 :    *
     321                 :    * @param aString the string to parse
     322                 :    * @param aResult the resulting HTMLValue
     323                 :    * @return whether the value was parsed
     324                 :    */
     325                 :   static bool ParseScrollingValue(const nsAString& aString,
     326                 :                                     nsAttrValue& aResult);
     327                 : 
     328                 :   /*
     329                 :    * Attribute Mapping Helpers
     330                 :    */
     331                 : 
     332                 :   /**
     333                 :    * A style attribute mapping function for the most common attributes, to be
     334                 :    * called by subclasses' attribute mapping functions.  Currently handles
     335                 :    * dir and lang, could handle others.
     336                 :    *
     337                 :    * @param aAttributes the list of attributes to map
     338                 :    * @param aData the returned rule data [INOUT]
     339                 :    * @see GetAttributeMappingFunction
     340                 :    */
     341                 :   static void MapCommonAttributesInto(const nsMappedAttributes* aAttributes, 
     342                 :                                       nsRuleData* aRuleData);
     343                 : 
     344                 :   /**
     345                 :    * This method is used by embed elements because they should ignore the hidden
     346                 :    * attribute for the moment.
     347                 :    * TODO: This should be removed when bug 614825 will be fixed.
     348                 :    */
     349                 :   static void MapCommonAttributesExceptHiddenInto(const nsMappedAttributes* aAttributes,
     350                 :                                                   nsRuleData* aRuleData);
     351                 : 
     352                 :   static const MappedAttributeEntry sCommonAttributeMap[];
     353                 :   static const MappedAttributeEntry sImageMarginSizeAttributeMap[];
     354                 :   static const MappedAttributeEntry sImageBorderAttributeMap[];
     355                 :   static const MappedAttributeEntry sImageAlignAttributeMap[];
     356                 :   static const MappedAttributeEntry sDivAlignAttributeMap[];
     357                 :   static const MappedAttributeEntry sBackgroundAttributeMap[];
     358                 :   static const MappedAttributeEntry sBackgroundColorAttributeMap[];
     359                 :   static const MappedAttributeEntry sScrollingAttributeMap[];
     360                 :   
     361                 :   /**
     362                 :    * Helper to map the align attribute into a style struct.
     363                 :    *
     364                 :    * @param aAttributes the list of attributes to map
     365                 :    * @param aData the returned rule data [INOUT]
     366                 :    * @see GetAttributeMappingFunction
     367                 :    */
     368                 :   static void MapImageAlignAttributeInto(const nsMappedAttributes* aAttributes,
     369                 :                                          nsRuleData* aData);
     370                 : 
     371                 :   /**
     372                 :    * Helper to map the align attribute into a style struct for things
     373                 :    * like <div>, <h1>, etc.
     374                 :    *
     375                 :    * @param aAttributes the list of attributes to map
     376                 :    * @param aData the returned rule data [INOUT]
     377                 :    * @see GetAttributeMappingFunction
     378                 :    */
     379                 :   static void MapDivAlignAttributeInto(const nsMappedAttributes* aAttributes,
     380                 :                                        nsRuleData* aData);
     381                 : 
     382                 :   /**
     383                 :    * Helper to map the image border attribute into a style struct.
     384                 :    *
     385                 :    * @param aAttributes the list of attributes to map
     386                 :    * @param aData the returned rule data [INOUT]
     387                 :    * @see GetAttributeMappingFunction
     388                 :    */
     389                 :   static void MapImageBorderAttributeInto(const nsMappedAttributes* aAttributes,
     390                 :                                           nsRuleData* aData);
     391                 :   /**
     392                 :    * Helper to map the image margin attribute into a style struct.
     393                 :    *
     394                 :    * @param aAttributes the list of attributes to map
     395                 :    * @param aData the returned rule data [INOUT]
     396                 :    * @see GetAttributeMappingFunction
     397                 :    */
     398                 :   static void MapImageMarginAttributeInto(const nsMappedAttributes* aAttributes,
     399                 :                                           nsRuleData* aData);
     400                 :   /**
     401                 :    * Helper to map the image position attribute into a style struct.
     402                 :    *
     403                 :    * @param aAttributes the list of attributes to map
     404                 :    * @param aData the returned rule data [INOUT]
     405                 :    * @see GetAttributeMappingFunction
     406                 :    */
     407                 :   static void MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes,
     408                 :                                          nsRuleData* aData);
     409                 :   /**
     410                 :    * Helper to map the background attribute
     411                 :    * into a style struct.
     412                 :    *
     413                 :    * @param aAttributes the list of attributes to map
     414                 :    * @param aData the returned rule data [INOUT]
     415                 :    * @see GetAttributeMappingFunction
     416                 :    */
     417                 :   static void MapBackgroundInto(const nsMappedAttributes* aAttributes,
     418                 :                                 nsRuleData* aData);
     419                 :   /**
     420                 :    * Helper to map the bgcolor attribute
     421                 :    * into a style struct.
     422                 :    *
     423                 :    * @param aAttributes the list of attributes to map
     424                 :    * @param aData the returned rule data [INOUT]
     425                 :    * @see GetAttributeMappingFunction
     426                 :    */
     427                 :   static void MapBGColorInto(const nsMappedAttributes* aAttributes,
     428                 :                              nsRuleData* aData);
     429                 :   /**
     430                 :    * Helper to map the background attributes (currently background and bgcolor)
     431                 :    * into a style struct.
     432                 :    *
     433                 :    * @param aAttributes the list of attributes to map
     434                 :    * @param aData the returned rule data [INOUT]
     435                 :    * @see GetAttributeMappingFunction
     436                 :    */
     437                 :   static void MapBackgroundAttributesInto(const nsMappedAttributes* aAttributes,
     438                 :                                           nsRuleData* aData);
     439                 :   /**
     440                 :    * Helper to map the scrolling attribute on FRAME and IFRAME
     441                 :    * into a style struct.
     442                 :    *
     443                 :    * @param aAttributes the list of attributes to map
     444                 :    * @param aData the returned rule data [INOUT]
     445                 :    * @see GetAttributeMappingFunction
     446                 :    */
     447                 :   static void MapScrollingAttributeInto(const nsMappedAttributes* aAttributes,
     448                 :                                         nsRuleData* aData);
     449                 :   /**
     450                 :    * Get the presentation state for a piece of content, or create it if it does
     451                 :    * not exist.  Generally used by SaveState().
     452                 :    *
     453                 :    * @param aContent the content to get presentation state for.
     454                 :    * @param aPresState the presentation state (out param)
     455                 :    */
     456                 :   static nsresult GetPrimaryPresState(nsGenericHTMLElement* aContent,
     457                 :                                       nsPresState** aPresState);
     458                 :   /**
     459                 :    * Get the layout history object *and* generate the key for a particular
     460                 :    * piece of content.
     461                 :    *
     462                 :    * @param aContent the content to generate the key for
     463                 :    * @param aRead if true, won't return a layout history state (and won't
     464                 :    *              generate a key) if the layout history state is empty.
     465                 :    * @param aState the history state object (out param)
     466                 :    * @param aKey the key (out param)
     467                 :    */
     468                 :   static already_AddRefed<nsILayoutHistoryState>
     469                 :   GetLayoutHistoryAndKey(nsGenericHTMLElement* aContent,
     470                 :                          bool aRead,
     471                 :                          nsACString& aKey);
     472                 :   /**
     473                 :    * Restore the state for a form control.  Ends up calling
     474                 :    * nsIFormControl::RestoreState().
     475                 :    *
     476                 :    * @param aContent an nsGenericHTMLElement* pointing to the form control
     477                 :    * @param aControl an nsIFormControl* pointing to the form control
     478                 :    * @return false if RestoreState() was not called, the return
     479                 :    *         value of RestoreState() otherwise.
     480                 :    */
     481                 :   static bool RestoreFormControlState(nsGenericHTMLElement* aContent,
     482                 :                                         nsIFormControl* aControl);
     483                 : 
     484                 :   /**
     485                 :    * Get the presentation context for this content node.
     486                 :    * @return the presentation context
     487                 :    */
     488                 :   NS_HIDDEN_(nsPresContext*) GetPresContext();
     489                 : 
     490                 :   // Form Helper Routines
     491                 :   /**
     492                 :    * Find an ancestor of this content node which is a form (could be null)
     493                 :    * @param aCurrentForm the current form for this node.  If this is
     494                 :    *        non-null, and no ancestor form is found, and the current form is in
     495                 :    *        a connected subtree with the node, the current form will be
     496                 :    *        returned.  This is needed to handle cases when HTML elements have a
     497                 :    *        current form that they're not descendants of.
     498                 :    * @note This method should not be called if the element has a form attribute.
     499                 :    */
     500                 :   nsHTMLFormElement* FindAncestorForm(nsHTMLFormElement* aCurrentForm = nsnull);
     501                 : 
     502                 :   virtual void RecompileScriptEventListeners();
     503                 : 
     504                 :   /**
     505                 :    * See if the document being tested has nav-quirks mode enabled.
     506                 :    * @param doc the document
     507                 :    */
     508                 :   static bool InNavQuirksMode(nsIDocument* aDoc);
     509                 : 
     510                 :   /**
     511                 :    * Locate an nsIEditor rooted at this content node, if there is one.
     512                 :    */
     513                 :   NS_HIDDEN_(nsresult) GetEditor(nsIEditor** aEditor);
     514                 :   NS_HIDDEN_(nsresult) GetEditorInternal(nsIEditor** aEditor);
     515                 : 
     516                 :   /**
     517                 :    * Helper method for NS_IMPL_URI_ATTR macro.
     518                 :    * Gets the absolute URI value of an attribute, by resolving any relative
     519                 :    * URIs in the attribute against the baseuri of the element. If the attribute
     520                 :    * isn't a relative URI the value of the attribute is returned as is. Only
     521                 :    * works for attributes in null namespace.
     522                 :    *
     523                 :    * @param aAttr      name of attribute.
     524                 :    * @param aBaseAttr  name of base attribute.
     525                 :    * @param aResult    result value [out]
     526                 :    */
     527                 :   NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult);
     528                 : 
     529                 :   /**
     530                 :    * Returns the current disabled state of the element.
     531                 :    */
     532               0 :   virtual bool IsDisabled() const {
     533               0 :     return false;
     534                 :   }
     535                 : 
     536               0 :   bool IsHidden() const
     537                 :   {
     538               0 :     return HasAttr(kNameSpaceID_None, nsGkAtoms::hidden);
     539                 :   }
     540                 : 
     541                 : protected:
     542                 :   /**
     543                 :    * Add/remove this element to the documents name cache
     544                 :    */
     545               0 :   void AddToNameTable(nsIAtom* aName) {
     546               0 :     NS_ASSERTION(HasName(), "Node doesn't have name?");
     547               0 :     nsIDocument* doc = GetCurrentDoc();
     548               0 :     if (doc && !IsInAnonymousSubtree()) {
     549               0 :       doc->AddToNameTable(this, aName);
     550                 :     }
     551               0 :   }
     552            1249 :   void RemoveFromNameTable() {
     553            1249 :     if (HasName()) {
     554               0 :       nsIDocument* doc = GetCurrentDoc();
     555               0 :       if (doc) {
     556                 :         doc->RemoveFromNameTable(this, GetParsedAttr(nsGkAtoms::name)->
     557               0 :                                          GetAtomValue());
     558                 :       }
     559                 :     }
     560            1249 :   }
     561                 : 
     562                 :   /**
     563                 :    * Register or unregister an access key to this element based on the
     564                 :    * accesskey attribute.
     565                 :    */
     566             789 :   void RegAccessKey()
     567                 :   {
     568             789 :     if (HasFlag(NODE_HAS_ACCESSKEY)) {
     569               0 :       RegUnRegAccessKey(true);
     570                 :     }
     571             789 :   }
     572                 : 
     573             789 :   void UnregAccessKey()
     574                 :   {
     575             789 :     if (HasFlag(NODE_HAS_ACCESSKEY)) {
     576               0 :       RegUnRegAccessKey(false);
     577                 :     }
     578             789 :   }
     579                 : 
     580                 : private:
     581                 :   /**
     582                 :    * Fire mutation events for changes caused by parsing directly into a
     583                 :    * context node.
     584                 :    *
     585                 :    * @param aDoc the document of the node
     586                 :    * @param aDest the destination node that got stuff appended to it
     587                 :    * @param aOldChildCount the number of children the node had before parsing
     588                 :    */
     589                 :   void FireMutationEventsForDirectParsing(nsIDocument* aDoc,
     590                 :                                           nsIContent* aDest,
     591                 :                                           PRInt32 aOldChildCount);
     592                 : 
     593                 :   void RegUnRegAccessKey(bool aDoReg);
     594                 : 
     595                 : protected:
     596                 :   /**
     597                 :    * Determine whether an attribute is an event (onclick, etc.)
     598                 :    * @param aName the attribute
     599                 :    * @return whether the name is an event handler name
     600                 :    */
     601                 :   bool IsEventName(nsIAtom* aName);
     602                 : 
     603                 :   virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
     604                 :                                 const nsAttrValue* aValue, bool aNotify);
     605                 : 
     606                 :   virtual nsEventListenerManager*
     607                 :     GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer);
     608                 : 
     609                 :   virtual const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
     610                 : 
     611                 :   /**
     612                 :    * Helper method for NS_IMPL_STRING_ATTR macro.
     613                 :    * Gets the value of an attribute, returns empty string if
     614                 :    * attribute isn't set. Only works for attributes in null namespace.
     615                 :    *
     616                 :    * @param aAttr    name of attribute.
     617                 :    * @param aDefault default-value to return if attribute isn't set.
     618                 :    * @param aResult  result value [out]
     619                 :    * @result always NS_OK
     620                 :    */
     621                 :   NS_HIDDEN_(nsresult) GetAttrHelper(nsIAtom* aAttr, nsAString& aValue);
     622                 : 
     623                 :   /**
     624                 :    * Helper method for NS_IMPL_STRING_ATTR macro.
     625                 :    * Sets the value of an attribute, returns specified default value if the
     626                 :    * attribute isn't set. Only works for attributes in null namespace.
     627                 :    *
     628                 :    * @param aAttr    name of attribute.
     629                 :    * @param aDefault default-value to return if attribute isn't set.
     630                 :    * @param aResult  result value [out]
     631                 :    */
     632                 :   NS_HIDDEN_(nsresult) SetAttrHelper(nsIAtom* aAttr, const nsAString& aValue);
     633                 : 
     634                 :   /**
     635                 :    * Helper method for NS_IMPL_BOOL_ATTR macro.
     636                 :    * Gets value of boolean attribute. Only works for attributes in null
     637                 :    * namespace.
     638                 :    *
     639                 :    * @param aAttr    name of attribute.
     640                 :    * @param aValue   Boolean value of attribute.
     641                 :    */
     642                 :   NS_HIDDEN_(nsresult) GetBoolAttr(nsIAtom* aAttr, bool* aValue) const;
     643                 : 
     644                 :   /**
     645                 :    * Helper method for NS_IMPL_BOOL_ATTR macro.
     646                 :    * Sets value of boolean attribute by removing attribute or setting it to
     647                 :    * the empty string. Only works for attributes in null namespace.
     648                 :    *
     649                 :    * @param aAttr    name of attribute.
     650                 :    * @param aValue   Boolean value of attribute.
     651                 :    */
     652                 :   NS_HIDDEN_(nsresult) SetBoolAttr(nsIAtom* aAttr, bool aValue);
     653                 : 
     654                 :   /**
     655                 :    * Helper method for NS_IMPL_INT_ATTR macro.
     656                 :    * Gets the integer-value of an attribute, returns specified default value
     657                 :    * if the attribute isn't set or isn't set to an integer. Only works for
     658                 :    * attributes in null namespace.
     659                 :    *
     660                 :    * @param aAttr    name of attribute.
     661                 :    * @param aDefault default-value to return if attribute isn't set.
     662                 :    * @param aResult  result value [out]
     663                 :    */
     664                 :   NS_HIDDEN_(nsresult) GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aValue);
     665                 : 
     666                 :   /**
     667                 :    * Helper method for NS_IMPL_INT_ATTR macro.
     668                 :    * Sets value of attribute to specified integer. Only works for attributes
     669                 :    * in null namespace.
     670                 :    *
     671                 :    * @param aAttr    name of attribute.
     672                 :    * @param aValue   Integer value of attribute.
     673                 :    */
     674                 :   NS_HIDDEN_(nsresult) SetIntAttr(nsIAtom* aAttr, PRInt32 aValue);
     675                 : 
     676                 :   /**
     677                 :    * Helper method for NS_IMPL_UINT_ATTR macro.
     678                 :    * Gets the unsigned integer-value of an attribute, returns specified default
     679                 :    * value if the attribute isn't set or isn't set to an integer. Only works for
     680                 :    * attributes in null namespace.
     681                 :    *
     682                 :    * @param aAttr    name of attribute.
     683                 :    * @param aDefault default-value to return if attribute isn't set.
     684                 :    * @param aResult  result value [out]
     685                 :    */
     686                 :   NS_HIDDEN_(nsresult) GetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aDefault,
     687                 :                                           PRUint32* aValue);
     688                 : 
     689                 :   /**
     690                 :    * Helper method for NS_IMPL_UINT_ATTR macro.
     691                 :    * Sets value of attribute to specified unsigned integer. Only works for
     692                 :    * attributes in null namespace.
     693                 :    *
     694                 :    * @param aAttr    name of attribute.
     695                 :    * @param aValue   Integer value of attribute.
     696                 :    */
     697                 :   NS_HIDDEN_(nsresult) SetUnsignedIntAttr(nsIAtom* aAttr, PRUint32 aValue);
     698                 : 
     699                 :   /**
     700                 :    * Helper method for NS_IMPL_DOUBLE_ATTR macro.
     701                 :    * Gets the double-value of an attribute, returns specified default value
     702                 :    * if the attribute isn't set or isn't set to a double. Only works for
     703                 :    * attributes in null namespace.
     704                 :    *
     705                 :    * @param aAttr    name of attribute.
     706                 :    * @param aDefault default-value to return if attribute isn't set.
     707                 :    * @param aResult  result value [out]
     708                 :    */
     709                 :   NS_HIDDEN_(nsresult) GetDoubleAttr(nsIAtom* aAttr, double aDefault, double* aValue);
     710                 : 
     711                 :   /**
     712                 :    * Helper method for NS_IMPL_DOUBLE_ATTR macro.
     713                 :    * Sets value of attribute to specified double. Only works for attributes
     714                 :    * in null namespace.
     715                 :    *
     716                 :    * @param aAttr    name of attribute.
     717                 :    * @param aValue   Double value of attribute.
     718                 :    */
     719                 :   NS_HIDDEN_(nsresult) SetDoubleAttr(nsIAtom* aAttr, double aValue);
     720                 : 
     721                 :   /**
     722                 :    * Helper for GetURIAttr and GetHrefURIForAnchors which returns an
     723                 :    * nsIURI in the out param.
     724                 :    *
     725                 :    * @return true if we had the attr, false otherwise.
     726                 :    */
     727                 :   NS_HIDDEN_(bool) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsIURI** aURI) const;
     728                 : 
     729                 :   /**
     730                 :    * This method works like GetURIAttr, except that it supports multiple
     731                 :    * URIs separated by whitespace (one or more U+0020 SPACE characters).
     732                 :    *
     733                 :    * Gets the absolute URI values of an attribute, by resolving any relative
     734                 :    * URIs in the attribute against the baseuri of the element. If a substring
     735                 :    * isn't a relative URI, the substring is returned as is. Only works for
     736                 :    * attributes in null namespace.
     737                 :    *
     738                 :    * @param aAttr    name of attribute.
     739                 :    * @param aResult  result value [out]
     740                 :    */
     741                 :   NS_HIDDEN_(nsresult) GetURIListAttr(nsIAtom* aAttr, nsAString& aResult);
     742                 : 
     743                 :   /**
     744                 :    * Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_VALUE.
     745                 :    * Gets the enum value string of an attribute and using a default value if
     746                 :    * the attribute is missing or the string is an invalid enum value.
     747                 :    *
     748                 :    * @param aType     the name of the attribute.
     749                 :    * @param aDefault  the default value if the attribute is missing or invalid.
     750                 :    * @param aResult   string corresponding to the value [out].
     751                 :    */
     752                 :   NS_HIDDEN_(nsresult) GetEnumAttr(nsIAtom* aAttr,
     753                 :                                    const char* aDefault,
     754                 :                                    nsAString& aResult);
     755                 : 
     756                 :   /**
     757                 :    * Locates the nsIEditor associated with this node.  In general this is
     758                 :    * equivalent to GetEditorInternal(), but for designmode or contenteditable,
     759                 :    * this may need to get an editor that's not actually on this element's
     760                 :    * associated TextControlFrame.  This is used by the spellchecking routines
     761                 :    * to get the editor affected by changing the spellcheck attribute on this
     762                 :    * node.
     763                 :    */
     764                 :   virtual already_AddRefed<nsIEditor> GetAssociatedEditor();
     765                 : 
     766                 :   /**
     767                 :    * Get the frame's offset information for offsetTop/Left/Width/Height.
     768                 :    * @note This method flushes pending notifications (Flush_Layout).
     769                 :    * @param aRect the offset information [OUT]
     770                 :    * @param aOffsetParent the parent the offset is relative to (offsetParent)
     771                 :    *        [OUT]
     772                 :    */
     773                 :   virtual void GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent);
     774                 : 
     775                 :   /**
     776                 :    * Returns true if this is the current document's body element
     777                 :    */
     778                 :   bool IsCurrentBodyElement();
     779                 : 
     780                 :   /**
     781                 :    * Ensures all editors associated with a subtree are synced, for purposes of
     782                 :    * spellchecking.
     783                 :    */
     784                 :   static void SyncEditorsOnSubtree(nsIContent* content);
     785                 : 
     786                 :   enum ContentEditableTristate {
     787                 :     eInherit = -1,
     788                 :     eFalse = 0,
     789                 :     eTrue = 1
     790                 :   };
     791                 : 
     792                 :   /**
     793                 :    * Returns eTrue if the element has a contentEditable attribute and its value
     794                 :    * is "true" or an empty string. Returns eFalse if the element has a
     795                 :    * contentEditable attribute and its value is "false". Otherwise returns
     796                 :    * eInherit.
     797                 :    */
     798            2040 :   NS_HIDDEN_(ContentEditableTristate) GetContentEditableValue() const
     799                 :   {
     800                 :     static const nsIContent::AttrValuesArray values[] =
     801                 :       { &nsGkAtoms::_false, &nsGkAtoms::_true, &nsGkAtoms::_empty, nsnull };
     802                 : 
     803            2040 :     if (!MayHaveContentEditableAttr())
     804            2040 :       return eInherit;
     805                 : 
     806                 :     PRInt32 value = FindAttrValueIn(kNameSpaceID_None,
     807                 :                                     nsGkAtoms::contenteditable, values,
     808               0 :                                     eIgnoreCase);
     809                 : 
     810               0 :     return value > 0 ? eTrue : (value == 0 ? eFalse : eInherit);
     811                 :   }
     812                 : 
     813                 :   // Used by A, AREA, LINK, and STYLE.
     814                 :   already_AddRefed<nsIURI> GetHrefURIForAnchors() const;
     815                 : 
     816                 :   /**
     817                 :    * Returns whether this element is an editable root. There are two types of
     818                 :    * editable roots:
     819                 :    *   1) the documentElement if the whole document is editable (for example for
     820                 :    *      desginMode=on)
     821                 :    *   2) an element that is marked editable with contentEditable=true and that
     822                 :    *      doesn't have a parent or whose parent is not editable.
     823                 :    * Note that this doesn't return input and textarea elements that haven't been
     824                 :    * made editable through contentEditable or designMode.
     825                 :    */
     826                 :   bool IsEditableRoot() const;
     827                 : 
     828                 : private:
     829                 :   void ChangeEditableState(PRInt32 aChange);
     830                 : };
     831                 : 
     832                 : 
     833                 : //----------------------------------------------------------------------
     834                 : 
     835                 : class nsHTMLFieldSetElement;
     836                 : 
     837                 : /**
     838                 :  * A helper class for form elements that can contain children
     839                 :  */
     840                 : class nsGenericHTMLFormElement : public nsGenericHTMLElement,
     841                 :                                  public nsIFormControl
     842                 : {
     843                 : public:
     844                 :   nsGenericHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo);
     845                 :   virtual ~nsGenericHTMLFormElement();
     846                 : 
     847                 :   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
     848                 : 
     849                 :   virtual bool IsNodeOfType(PRUint32 aFlags) const;
     850                 :   virtual void SaveSubtreeState();
     851                 : 
     852                 :   // nsIFormControl
     853                 :   virtual mozilla::dom::Element* GetFormElement();
     854                 :   virtual void SetForm(nsIDOMHTMLFormElement* aForm);
     855                 :   virtual void ClearForm(bool aRemoveFromForm);
     856                 : 
     857                 :   nsresult GetForm(nsIDOMHTMLFormElement** aForm);
     858                 : 
     859               0 :   NS_IMETHOD SaveState()
     860                 :   {
     861               0 :     return NS_OK;
     862                 :   }
     863                 : 
     864               0 :   virtual bool RestoreState(nsPresState* aState)
     865                 :   {
     866               0 :     return false;
     867                 :   }
     868               0 :   virtual bool AllowDrop()
     869                 :   {
     870               0 :     return true;
     871                 :   }
     872                 : 
     873                 :   // nsIContent
     874                 :   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
     875                 :                               nsIContent* aBindingParent,
     876                 :                               bool aCompileEventHandlers);
     877                 :   virtual void UnbindFromTree(bool aDeep = true,
     878                 :                               bool aNullParent = true);
     879                 :   virtual IMEState GetDesiredIMEState();
     880                 :   virtual nsEventStates IntrinsicState() const;
     881                 : 
     882                 :   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
     883                 : 
     884                 :   virtual bool IsDisabled() const;
     885                 : 
     886                 :   /**
     887                 :    * This callback is called by a fieldest on all its elements whenever its
     888                 :    * disabled attribute is changed so the element knows its disabled state
     889                 :    * might have changed.
     890                 :    *
     891                 :    * @note Classes redefining this method should not do any content
     892                 :    * state updates themselves but should just make sure to call into
     893                 :    * nsGenericHTMLFormElement::FieldSetDisabledChanged.
     894                 :    */
     895                 :   virtual void FieldSetDisabledChanged(bool aNotify);
     896                 : 
     897               0 :   void FieldSetFirstLegendChanged(bool aNotify) {
     898               0 :     UpdateFieldSet(aNotify);
     899               0 :   }
     900                 : 
     901                 :   /**
     902                 :    * This callback is called by a fieldset on all it's elements when it's being
     903                 :    * destroyed. When called, the elements should check that aFieldset is there
     904                 :    * first parent fieldset and null mFieldset in that case only.
     905                 :    *
     906                 :    * @param aFieldSet The fieldset being removed.
     907                 :    */
     908                 :   void ForgetFieldSet(nsIContent* aFieldset);
     909                 : 
     910                 :   /**
     911                 :    * Returns if the control can be disabled.
     912                 :    */
     913                 :   bool CanBeDisabled() const;
     914                 : 
     915                 :   virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
     916                 :                                  PRInt32* aTabIndex);
     917                 : 
     918                 : protected:
     919                 :   virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
     920                 :                                  const nsAttrValueOrString* aValue,
     921                 :                                  bool aNotify);
     922                 : 
     923                 :   virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
     924                 :                                 const nsAttrValue* aValue, bool aNotify);
     925                 : 
     926                 :   void UpdateEditableFormControlState(bool aNotify);
     927                 : 
     928                 :   /**
     929                 :    * This method will update the form owner, using @form or looking to a parent.
     930                 :    *
     931                 :    * @param aBindToTree Whether the element is being attached to the tree.
     932                 :    * @param aFormIdElement The element associated with the id in @form. If
     933                 :    * aBindToTree is false, aFormIdElement *must* contain the element associated
     934                 :    * with the id in @form. Otherwise, it *must* be null.
     935                 :    *
     936                 :    * @note Callers of UpdateFormOwner have to be sure the element is in a
     937                 :    * document (GetCurrentDoc() != nsnull).
     938                 :    */
     939                 :   void UpdateFormOwner(bool aBindToTree, Element* aFormIdElement);
     940                 : 
     941                 :   /**
     942                 :    * This method will update mFieldset and set it to the first fieldset parent.
     943                 :    */
     944                 :   void UpdateFieldSet(bool aNotify);
     945                 : 
     946                 :   /**
     947                 :    * Add a form id observer which will observe when the element with the id in
     948                 :    * @form will change.
     949                 :    *
     950                 :    * @return The element associated with the current id in @form (may be null).
     951                 :    */
     952                 :   Element* AddFormIdObserver();
     953                 : 
     954                 :   /**
     955                 :    * Remove the form id observer.
     956                 :    */
     957                 :   void RemoveFormIdObserver();
     958                 : 
     959                 :   /**
     960                 :    * This method is a a callback for IDTargetObserver (from nsIDocument).
     961                 :    * It will be called each time the element associated with the id in @form
     962                 :    * changes.
     963                 :    */
     964                 :   static bool FormIdUpdated(Element* aOldElement, Element* aNewElement,
     965                 :                               void* aData);
     966                 : 
     967                 :   // Returns true if the event should not be handled from PreHandleEvent
     968                 :   virtual bool IsElementDisabledForEvents(PRUint32 aMessage, nsIFrame* aFrame);
     969                 : 
     970                 :   // The focusability state of this form control.  eUnfocusable means that it
     971                 :   // shouldn't be focused at all, eInactiveWindow means it's in an inactive
     972                 :   // window, eActiveWindow means it's in an active window.
     973                 :   enum FocusTristate {
     974                 :     eUnfocusable,
     975                 :     eInactiveWindow,
     976                 :     eActiveWindow
     977                 :   };
     978                 : 
     979                 :   // Get our focus state.  If this returns eInactiveWindow, it will set this
     980                 :   // element as the focused element for that window.
     981                 :   FocusTristate FocusState();
     982                 : 
     983                 :   /** The form that contains this control */
     984                 :   nsHTMLFormElement* mForm;
     985                 : 
     986                 :   /* This is a pointer to our closest fieldset parent if any */
     987                 :   nsHTMLFieldSetElement* mFieldSet;
     988                 : };
     989                 : 
     990                 : // If this flag is set on an nsGenericHTMLFormElement, that means that we have
     991                 : // added ourselves to our mForm.  It's possible to have a non-null mForm, but
     992                 : // not have this flag set.  That happens when the form is set via the content
     993                 : // sink.
     994                 : #define ADDED_TO_FORM (1 << ELEMENT_TYPE_SPECIFIC_BITS_OFFSET)
     995                 : 
     996                 : // If this flag is set on an nsGenericHTMLFormElement, that means that its form
     997                 : // is in the process of being unbound from the tree, and this form element
     998                 : // hasn't re-found its form in nsGenericHTMLFormElement::UnbindFromTree yet.
     999                 : #define MAYBE_ORPHAN_FORM_ELEMENT (1 << (ELEMENT_TYPE_SPECIFIC_BITS_OFFSET+1))
    1000                 : 
    1001                 : // NOTE: I don't think it's possible to have the above two flags set at the
    1002                 : // same time, so if it becomes an issue we can probably merge them into the
    1003                 : // same bit.  --bz
    1004                 : 
    1005                 : // Make sure we have enough space for those bits
    1006                 : PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 1 < 32);
    1007                 : 
    1008                 : //----------------------------------------------------------------------
    1009                 : 
    1010                 : /**
    1011                 :  * A macro to implement the getter and setter for a given string
    1012                 :  * valued content property. The method uses the generic GetAttr and
    1013                 :  * SetAttr methods.
    1014                 :  */
    1015                 : #define NS_IMPL_STRING_ATTR(_class, _method, _atom)                  \
    1016                 :   NS_IMETHODIMP                                                      \
    1017                 :   _class::Get##_method(nsAString& aValue)                            \
    1018                 :   {                                                                  \
    1019                 :     return GetAttrHelper(nsGkAtoms::_atom, aValue);                  \
    1020                 :   }                                                                  \
    1021                 :   NS_IMETHODIMP                                                      \
    1022                 :   _class::Set##_method(const nsAString& aValue)                      \
    1023                 :   {                                                                  \
    1024                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);                  \
    1025                 :   }
    1026                 : 
    1027                 : /**
    1028                 :  * This macro is similar to NS_IMPL_STRING_ATTR except that the getter method
    1029                 :  * falls back to an alternative method if the content attribute isn't set.
    1030                 :  */
    1031                 : #define NS_IMPL_STRING_ATTR_WITH_FALLBACK(_class, _method, _atom, _fallback) \
    1032                 :   NS_IMETHODIMP                                                              \
    1033                 :   _class::Get##_method(nsAString& aValue)                                    \
    1034                 :   {                                                                          \
    1035                 :     if (!GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue)) {             \
    1036                 :       _fallback(aValue);                                                     \
    1037                 :     }                                                                        \
    1038                 :     return NS_OK;                                                            \
    1039                 :   }                                                                          \
    1040                 :   NS_IMETHODIMP                                                              \
    1041                 :   _class::Set##_method(const nsAString& aValue)                              \
    1042                 :   {                                                                          \
    1043                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);                          \
    1044                 :   }
    1045                 : 
    1046                 : /**
    1047                 :  * A macro to implement the getter and setter for a given boolean
    1048                 :  * valued content property. The method uses the generic GetAttr and
    1049                 :  * SetAttr methods.
    1050                 :  */
    1051                 : #define NS_IMPL_BOOL_ATTR(_class, _method, _atom)                     \
    1052                 :   NS_IMETHODIMP                                                       \
    1053                 :   _class::Get##_method(bool* aValue)                                \
    1054                 :   {                                                                   \
    1055                 :     return GetBoolAttr(nsGkAtoms::_atom, aValue);                   \
    1056                 :   }                                                                   \
    1057                 :   NS_IMETHODIMP                                                       \
    1058                 :   _class::Set##_method(bool aValue)                                 \
    1059                 :   {                                                                   \
    1060                 :     return SetBoolAttr(nsGkAtoms::_atom, aValue);                   \
    1061                 :   }
    1062                 : 
    1063                 : /**
    1064                 :  * A macro to implement the getter and setter for a given integer
    1065                 :  * valued content property. The method uses the generic GetAttr and
    1066                 :  * SetAttr methods.
    1067                 :  */
    1068                 : #define NS_IMPL_INT_ATTR(_class, _method, _atom)                    \
    1069                 :   NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0)
    1070                 : 
    1071                 : #define NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default)  \
    1072                 :   NS_IMETHODIMP                                                           \
    1073                 :   _class::Get##_method(PRInt32* aValue)                                   \
    1074                 :   {                                                                       \
    1075                 :     return GetIntAttr(nsGkAtoms::_atom, _default, aValue);              \
    1076                 :   }                                                                       \
    1077                 :   NS_IMETHODIMP                                                           \
    1078                 :   _class::Set##_method(PRInt32 aValue)                                    \
    1079                 :   {                                                                       \
    1080                 :     return SetIntAttr(nsGkAtoms::_atom, aValue);                        \
    1081                 :   }
    1082                 : 
    1083                 : /**
    1084                 :  * A macro to implement the getter and setter for a given unsigned integer
    1085                 :  * valued content property. The method uses GetUnsignedIntAttr and
    1086                 :  * SetUnsignedIntAttr methods.
    1087                 :  */
    1088                 : #define NS_IMPL_UINT_ATTR(_class, _method, _atom)                         \
    1089                 :   NS_IMPL_UINT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0)
    1090                 : 
    1091                 : #define NS_IMPL_UINT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
    1092                 :   NS_IMETHODIMP                                                           \
    1093                 :   _class::Get##_method(PRUint32* aValue)                                  \
    1094                 :   {                                                                       \
    1095                 :     return GetUnsignedIntAttr(nsGkAtoms::_atom, _default, aValue);        \
    1096                 :   }                                                                       \
    1097                 :   NS_IMETHODIMP                                                           \
    1098                 :   _class::Set##_method(PRUint32 aValue)                                   \
    1099                 :   {                                                                       \
    1100                 :     return SetUnsignedIntAttr(nsGkAtoms::_atom, aValue);                  \
    1101                 :   }
    1102                 : 
    1103                 : /**
    1104                 :  * A macro to implement the getter and setter for a given unsigned integer
    1105                 :  * valued content property. The method uses GetUnsignedIntAttr and
    1106                 :  * SetUnsignedIntAttr methods. This macro is similar to NS_IMPL_UINT_ATTR except
    1107                 :  * that it throws an exception if the set value is null.
    1108                 :  */
    1109                 : #define NS_IMPL_UINT_ATTR_NON_ZERO(_class, _method, _atom)                \
    1110                 :   NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(_class, _method, _atom, 1)
    1111                 : 
    1112                 : #define NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(_class, _method, _atom, _default) \
    1113                 :   NS_IMETHODIMP                                                           \
    1114                 :   _class::Get##_method(PRUint32* aValue)                                  \
    1115                 :   {                                                                       \
    1116                 :     return GetUnsignedIntAttr(nsGkAtoms::_atom, _default, aValue);        \
    1117                 :   }                                                                       \
    1118                 :   NS_IMETHODIMP                                                           \
    1119                 :   _class::Set##_method(PRUint32 aValue)                                   \
    1120                 :   {                                                                       \
    1121                 :     if (aValue == 0) {                                                    \
    1122                 :       return NS_ERROR_DOM_INDEX_SIZE_ERR;                                 \
    1123                 :     }                                                                     \
    1124                 :     return SetUnsignedIntAttr(nsGkAtoms::_atom, aValue);                  \
    1125                 :   }
    1126                 : 
    1127                 : /**
    1128                 :  * A macro to implement the getter and setter for a given double-precision
    1129                 :  * floating point valued content property. The method uses GetDoubleAttr and
    1130                 :  * SetDoubleAttr methods.
    1131                 :  */
    1132                 : #define NS_IMPL_DOUBLE_ATTR(_class, _method, _atom)                    \
    1133                 :   NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0.0)
    1134                 : 
    1135                 : #define NS_IMPL_DOUBLE_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
    1136                 :   NS_IMETHODIMP                                                             \
    1137                 :   _class::Get##_method(double* aValue)                                      \
    1138                 :   {                                                                         \
    1139                 :     return GetDoubleAttr(nsGkAtoms::_atom, _default, aValue);               \
    1140                 :   }                                                                         \
    1141                 :   NS_IMETHODIMP                                                             \
    1142                 :   _class::Set##_method(double aValue)                                       \
    1143                 :   {                                                                         \
    1144                 :     return SetDoubleAttr(nsGkAtoms::_atom, aValue);                         \
    1145                 :   }
    1146                 : 
    1147                 : /**
    1148                 :  * A macro to implement the getter and setter for a given content
    1149                 :  * property that needs to return a URI in string form.  The method
    1150                 :  * uses the generic GetAttr and SetAttr methods.  This macro is much
    1151                 :  * like the NS_IMPL_STRING_ATTR macro, except we make sure the URI is
    1152                 :  * absolute.
    1153                 :  */
    1154                 : #define NS_IMPL_URI_ATTR(_class, _method, _atom)                    \
    1155                 :   NS_IMETHODIMP                                                     \
    1156                 :   _class::Get##_method(nsAString& aValue)                           \
    1157                 :   {                                                                 \
    1158                 :     return GetURIAttr(nsGkAtoms::_atom, nsnull, aValue);          \
    1159                 :   }                                                                 \
    1160                 :   NS_IMETHODIMP                                                     \
    1161                 :   _class::Set##_method(const nsAString& aValue)                     \
    1162                 :   {                                                                 \
    1163                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);               \
    1164                 :   }
    1165                 : 
    1166                 : #define NS_IMPL_URI_ATTR_WITH_BASE(_class, _method, _atom, _base_atom)       \
    1167                 :   NS_IMETHODIMP                                                              \
    1168                 :   _class::Get##_method(nsAString& aValue)                                    \
    1169                 :   {                                                                          \
    1170                 :     return GetURIAttr(nsGkAtoms::_atom, nsGkAtoms::_base_atom, aValue);  \
    1171                 :   }                                                                          \
    1172                 :   NS_IMETHODIMP                                                              \
    1173                 :   _class::Set##_method(const nsAString& aValue)                              \
    1174                 :   {                                                                          \
    1175                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);                        \
    1176                 :   }
    1177                 : 
    1178                 : /**
    1179                 :  * A macro to implement getter and setter for action and form action content
    1180                 :  * attributes. It's very similar to NS_IMPL_URI_ATTR excepted that if the
    1181                 :  * content attribute is the empty string, the empty string is returned.
    1182                 :  */
    1183                 : #define NS_IMPL_ACTION_ATTR(_class, _method, _atom)                 \
    1184                 :   NS_IMETHODIMP                                                     \
    1185                 :   _class::Get##_method(nsAString& aValue)                           \
    1186                 :   {                                                                 \
    1187                 :     GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue);           \
    1188                 :     if (aValue.IsEmpty()) {                                         \
    1189                 :       return NS_OK;                                                 \
    1190                 :     }                                                               \
    1191                 :     return GetURIAttr(nsGkAtoms::_atom, nsnull, aValue);            \
    1192                 :   }                                                                 \
    1193                 :   NS_IMETHODIMP                                                     \
    1194                 :   _class::Set##_method(const nsAString& aValue)                     \
    1195                 :   {                                                                 \
    1196                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);                 \
    1197                 :   }
    1198                 : 
    1199                 : /**
    1200                 :  * A macro to implement the getter and setter for a given content
    1201                 :  * property that needs to set a non-negative integer. The method
    1202                 :  * uses the generic GetAttr and SetAttr methods. This macro is much
    1203                 :  * like the NS_IMPL_INT_ATTR macro except we throw an exception if
    1204                 :  * the set value is negative.
    1205                 :  */
    1206                 : #define NS_IMPL_NON_NEGATIVE_INT_ATTR(_class, _method, _atom)             \
    1207                 :   NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
    1208                 : 
    1209                 : #define NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default)  \
    1210                 :   NS_IMETHODIMP                                                           \
    1211                 :   _class::Get##_method(PRInt32* aValue)                                   \
    1212                 :   {                                                                       \
    1213                 :     return GetIntAttr(nsGkAtoms::_atom, _default, aValue);                \
    1214                 :   }                                                                       \
    1215                 :   NS_IMETHODIMP                                                           \
    1216                 :   _class::Set##_method(PRInt32 aValue)                                    \
    1217                 :   {                                                                       \
    1218                 :     if (aValue < 0) {                                                     \
    1219                 :       return NS_ERROR_DOM_INDEX_SIZE_ERR;                                 \
    1220                 :     }                                                                     \
    1221                 :     return SetIntAttr(nsGkAtoms::_atom, aValue);                          \
    1222                 :   }
    1223                 : 
    1224                 : /**
    1225                 :  * A macro to implement the getter and setter for a given content
    1226                 :  * property that needs to set an enumerated string. The method
    1227                 :  * uses a specific GetEnumAttr and the generic SetAttrHelper methods.
    1228                 :  */
    1229                 : #define NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
    1230                 :   NS_IMETHODIMP                                                           \
    1231                 :   _class::Get##_method(nsAString& aValue)                                 \
    1232                 :   {                                                                       \
    1233                 :     return GetEnumAttr(nsGkAtoms::_atom, _default, aValue);               \
    1234                 :   }                                                                       \
    1235                 :   NS_IMETHODIMP                                                           \
    1236                 :   _class::Set##_method(const nsAString& aValue)                           \
    1237                 :   {                                                                       \
    1238                 :     return SetAttrHelper(nsGkAtoms::_atom, aValue);                       \
    1239                 :   }
    1240                 : 
    1241                 : /**
    1242                 :  * A macro to implement the getter and setter for a given content
    1243                 :  * property that needs to set a positive integer. The method uses
    1244                 :  * the generic GetAttr and SetAttr methods. This macro is much like
    1245                 :  * the NS_IMPL_NON_NEGATIVE_INT_ATTR macro except the exception is
    1246                 :  * thrown also when the value is equal to 0.
    1247                 :  */
    1248                 : #define NS_IMPL_POSITIVE_INT_ATTR(_class, _method, _atom)                 \
    1249                 :   NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 1)
    1250                 : 
    1251                 : #define NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default)  \
    1252                 :   NS_IMETHODIMP                                                           \
    1253                 :   _class::Get##_method(PRInt32* aValue)                                   \
    1254                 :   {                                                                       \
    1255                 :     return GetIntAttr(nsGkAtoms::_atom, _default, aValue);                \
    1256                 :   }                                                                       \
    1257                 :   NS_IMETHODIMP                                                           \
    1258                 :   _class::Set##_method(PRInt32 aValue)                                    \
    1259                 :   {                                                                       \
    1260                 :     if (aValue <= 0) {                                                    \
    1261                 :       return NS_ERROR_DOM_INDEX_SIZE_ERR;                                 \
    1262                 :     }                                                                     \
    1263                 :     return SetIntAttr(nsGkAtoms::_atom, aValue);                          \
    1264                 :   }
    1265                 : 
    1266                 : /**
    1267                 :  * QueryInterface() implementation helper macros
    1268                 :  */
    1269                 : 
    1270                 : #define NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(_class, _base)        \
    1271                 :   NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
    1272                 :     NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, _base)             \
    1273                 :     NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMElement, _base)          \
    1274                 :     NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMHTMLElement, _base)
    1275                 : 
    1276                 : #define NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                         \
    1277                 :   NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(_class, nsIDOMHTMLElement)
    1278                 : 
    1279                 : #define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base, \
    1280                 :                                                                _base_if)      \
    1281                 :   rv = _base::QueryInterface(aIID, aInstancePtr);                             \
    1282                 :   if (NS_SUCCEEDED(rv))                                                       \
    1283                 :     return rv;                                                                \
    1284                 :                                                                               \
    1285                 :   rv = DOMQueryInterface(static_cast<_base_if *>(this), aIID, aInstancePtr);  \
    1286                 :   if (NS_SUCCEEDED(rv))                                                       \
    1287                 :     return rv;                                                                \
    1288                 :                                                                               \
    1289                 :   NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
    1290                 : 
    1291                 : #define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(_class, _base)           \
    1292                 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base,       \
    1293                 :                                                          nsIDOMHTMLElement)
    1294                 : 
    1295                 : #define NS_HTML_CONTENT_INTERFACE_MAP_END                                     \
    1296                 :   NS_ELEMENT_INTERFACE_MAP_END
    1297                 : 
    1298                 : #define NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(_class)                \
    1299                 :     NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class)                              \
    1300                 :   NS_HTML_CONTENT_INTERFACE_MAP_END
    1301                 : 
    1302                 : #define NS_INTERFACE_MAP_ENTRY_IF_TAG(_interface, _tag)                       \
    1303                 :   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface,                              \
    1304                 :                                      mNodeInfo->Equals(nsGkAtoms::_tag))
    1305                 : 
    1306                 : 
    1307                 : #define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_GETTER(_getter) \
    1308                 :   if (aIID.Equals(NS_GET_IID(nsIClassInfo)) ||               \
    1309                 :       aIID.Equals(NS_GET_IID(nsXPCClassInfo))) {             \
    1310                 :     foundInterface = _getter ();                             \
    1311                 :     if (!foundInterface) {                                   \
    1312                 :       *aInstancePtr = nsnull;                                \
    1313                 :       return NS_ERROR_OUT_OF_MEMORY;                         \
    1314                 :     }                                                        \
    1315                 :   } else
    1316                 : 
    1317                 : #define NS_HTML_CONTENT_INTERFACE_TABLE0(_class)                              \
    1318                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1319                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1320                 : 
    1321                 : #define NS_HTML_CONTENT_INTERFACE_TABLE1(_class, _i1)                         \
    1322                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1323                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1324                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1325                 : 
    1326                 : #define NS_HTML_CONTENT_INTERFACE_TABLE2(_class, _i1, _i2)                    \
    1327                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1328                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1329                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1330                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1331                 : 
    1332                 : #define NS_HTML_CONTENT_INTERFACE_TABLE3(_class, _i1, _i2, _i3)          \
    1333                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1334                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1335                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1336                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1337                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1338                 : 
    1339                 : #define NS_HTML_CONTENT_INTERFACE_TABLE4(_class, _i1, _i2, _i3, _i4)          \
    1340                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1341                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1342                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1343                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1344                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1345                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1346                 : 
    1347                 : #define NS_HTML_CONTENT_INTERFACE_TABLE5(_class, _i1, _i2, _i3, _i4, _i5)     \
    1348                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1349                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1350                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1351                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1352                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1353                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1354                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1355                 : 
    1356                 : #define NS_HTML_CONTENT_INTERFACE_TABLE6(_class, _i1, _i2, _i3, _i4, _i5,     \
    1357                 :                                          _i6)                                 \
    1358                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1359                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1360                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1361                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1362                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1363                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1364                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
    1365                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1366                 : 
    1367                 : #define NS_HTML_CONTENT_INTERFACE_TABLE7(_class, _i1, _i2, _i3, _i4, _i5,     \
    1368                 :                                          _i6, _i7)                            \
    1369                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1370                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1371                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1372                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1373                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1374                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1375                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
    1376                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
    1377                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1378                 : 
    1379                 : #define NS_HTML_CONTENT_INTERFACE_TABLE8(_class, _i1, _i2, _i3, _i4, _i5,     \
    1380                 :                                          _i6, _i7, _i8)                       \
    1381                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1382                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1383                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1384                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1385                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1386                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1387                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
    1388                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
    1389                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
    1390                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1391                 : 
    1392                 : #define NS_HTML_CONTENT_INTERFACE_TABLE9(_class, _i1, _i2, _i3, _i4, _i5,     \
    1393                 :                                          _i6, _i7, _i8, _i9)                  \
    1394                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1395                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1396                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1397                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1398                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1399                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1400                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
    1401                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
    1402                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
    1403                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i9)                                     \
    1404                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1405                 : 
    1406                 : #define NS_HTML_CONTENT_INTERFACE_TABLE10(_class, _i1, _i2, _i3, _i4, _i5,    \
    1407                 :                                           _i6, _i7, _i8, _i9, _i10)           \
    1408                 :   NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
    1409                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
    1410                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
    1411                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
    1412                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
    1413                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
    1414                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
    1415                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
    1416                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
    1417                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i9)                                     \
    1418                 :     NS_INTERFACE_TABLE_ENTRY(_class, _i10)                                    \
    1419                 :   NS_OFFSET_AND_INTERFACE_TABLE_END
    1420                 : 
    1421                 : /* Use this macro to declare functions that forward the behavior of this
    1422                 :  * interface to another object. 
    1423                 :  * This macro doesn't forward
    1424                 :  * - Click
    1425                 :  * - GetTabIndex
    1426                 :  * - SetTabIndex
    1427                 :  * - Focus
    1428                 :  * - GetDraggable
    1429                 :  * - GetInnerHTML
    1430                 :  * - SetInnerHTML
    1431                 :  * because sometimes elements want to override them.
    1432                 :  */
    1433                 : #define NS_FORWARD_NSIDOMHTMLELEMENT_BASIC(_to) \
    1434                 :   NS_SCRIPTABLE NS_IMETHOD GetId(nsAString& aId) { \
    1435                 :     return _to GetId(aId); \
    1436                 :   } \
    1437                 :   NS_SCRIPTABLE NS_IMETHOD SetId(const nsAString& aId) { \
    1438                 :     return _to SetId(aId); \
    1439                 :   } \
    1440                 :   NS_SCRIPTABLE NS_IMETHOD GetTitle(nsAString& aTitle) { \
    1441                 :     return _to GetTitle(aTitle); \
    1442                 :   } \
    1443                 :   NS_SCRIPTABLE NS_IMETHOD SetTitle(const nsAString& aTitle) { \
    1444                 :     return _to SetTitle(aTitle); \
    1445                 :   } \
    1446                 :   NS_SCRIPTABLE NS_IMETHOD GetLang(nsAString& aLang) { \
    1447                 :     return _to GetLang(aLang); \
    1448                 :   } \
    1449                 :   NS_SCRIPTABLE NS_IMETHOD SetLang(const nsAString& aLang) { \
    1450                 :     return _to SetLang(aLang); \
    1451                 :   } \
    1452                 :   NS_SCRIPTABLE NS_IMETHOD GetDir(nsAString& aDir) { \
    1453                 :     return _to GetDir(aDir); \
    1454                 :   } \
    1455                 :   NS_SCRIPTABLE NS_IMETHOD SetDir(const nsAString& aDir) { \
    1456                 :     return _to SetDir(aDir); \
    1457                 :   } \
    1458                 :   NS_SCRIPTABLE NS_IMETHOD GetClassName(nsAString& aClassName) { \
    1459                 :     return _to GetClassName(aClassName); \
    1460                 :   } \
    1461                 :   NS_SCRIPTABLE NS_IMETHOD SetClassName(const nsAString& aClassName) { \
    1462                 :     return _to SetClassName(aClassName); \
    1463                 :   } \
    1464                 :   NS_SCRIPTABLE NS_IMETHOD GetDataset(nsIDOMDOMStringMap** aDataset) { \
    1465                 :     return _to GetDataset(aDataset); \
    1466                 :   } \
    1467                 :   NS_SCRIPTABLE NS_IMETHOD GetHidden(bool* aHidden) { \
    1468                 :     return _to GetHidden(aHidden); \
    1469                 :   } \
    1470                 :   NS_SCRIPTABLE NS_IMETHOD SetHidden(bool aHidden) { \
    1471                 :     return _to SetHidden(aHidden); \
    1472                 :   } \
    1473                 :   NS_SCRIPTABLE NS_IMETHOD Blur() { \
    1474                 :     return _to Blur(); \
    1475                 :   } \
    1476                 :   NS_SCRIPTABLE NS_IMETHOD GetAccessKey(nsAString& aAccessKey) { \
    1477                 :     return _to GetAccessKey(aAccessKey); \
    1478                 :   } \
    1479                 :   NS_SCRIPTABLE NS_IMETHOD SetAccessKey(const nsAString& aAccessKey) { \
    1480                 :     return _to SetAccessKey(aAccessKey); \
    1481                 :   } \
    1482                 :   NS_SCRIPTABLE NS_IMETHOD GetAccessKeyLabel(nsAString& aAccessKeyLabel) { \
    1483                 :     return _to GetAccessKeyLabel(aAccessKeyLabel); \
    1484                 :   } \
    1485                 :   NS_SCRIPTABLE NS_IMETHOD SetDraggable(bool aDraggable) { \
    1486                 :     return _to SetDraggable(aDraggable); \
    1487                 :   } \
    1488                 :   NS_SCRIPTABLE NS_IMETHOD GetContentEditable(nsAString& aContentEditable) { \
    1489                 :     return _to GetContentEditable(aContentEditable); \
    1490                 :   } \
    1491                 :   NS_SCRIPTABLE NS_IMETHOD SetContentEditable(const nsAString& aContentEditable) { \
    1492                 :     return _to SetContentEditable(aContentEditable); \
    1493                 :   } \
    1494                 :   NS_SCRIPTABLE NS_IMETHOD GetIsContentEditable(bool* aIsContentEditable) { \
    1495                 :     return _to GetIsContentEditable(aIsContentEditable); \
    1496                 :   } \
    1497                 :   NS_SCRIPTABLE NS_IMETHOD GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu) { \
    1498                 :     return _to GetContextMenu(aContextMenu); \
    1499                 :   } \
    1500                 :   NS_SCRIPTABLE NS_IMETHOD GetSpellcheck(bool* aSpellcheck) { \
    1501                 :     return _to GetSpellcheck(aSpellcheck); \
    1502                 :   } \
    1503                 :   NS_SCRIPTABLE NS_IMETHOD SetSpellcheck(bool aSpellcheck) { \
    1504                 :     return _to SetSpellcheck(aSpellcheck); \
    1505                 :   } \
    1506                 :   NS_SCRIPTABLE NS_IMETHOD GetOuterHTML(nsAString& aOuterHTML) { \
    1507                 :     return _to GetOuterHTML(aOuterHTML); \
    1508                 :   } \
    1509                 :   NS_SCRIPTABLE NS_IMETHOD SetOuterHTML(const nsAString& aOuterHTML) { \
    1510                 :     return _to SetOuterHTML(aOuterHTML); \
    1511                 :   } \
    1512                 :   NS_SCRIPTABLE NS_IMETHOD InsertAdjacentHTML(const nsAString& position, const nsAString& text) { \
    1513                 :     return _to InsertAdjacentHTML(position, text); \
    1514                 :   } \
    1515                 :   NS_SCRIPTABLE NS_IMETHOD ScrollIntoView(bool top, PRUint8 _argc) { \
    1516                 :     return _to ScrollIntoView(top, _argc); \
    1517                 :   } \
    1518                 :   NS_SCRIPTABLE NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) { \
    1519                 :     return _to GetOffsetParent(aOffsetParent); \
    1520                 :   } \
    1521                 :   NS_SCRIPTABLE NS_IMETHOD GetOffsetTop(PRInt32* aOffsetTop) { \
    1522                 :     return _to GetOffsetTop(aOffsetTop); \
    1523                 :   } \
    1524                 :   NS_SCRIPTABLE NS_IMETHOD GetOffsetLeft(PRInt32* aOffsetLeft) { \
    1525                 :     return _to GetOffsetLeft(aOffsetLeft); \
    1526                 :   } \
    1527                 :   NS_SCRIPTABLE NS_IMETHOD GetOffsetWidth(PRInt32* aOffsetWidth) { \
    1528                 :     return _to GetOffsetWidth(aOffsetWidth); \
    1529                 :   } \
    1530                 :   NS_SCRIPTABLE NS_IMETHOD GetOffsetHeight(PRInt32* aOffsetHeight) { \
    1531                 :     return _to GetOffsetHeight(aOffsetHeight); \
    1532                 :   } \
    1533                 :   NS_SCRIPTABLE NS_IMETHOD MozRequestFullScreen() { \
    1534                 :     return _to MozRequestFullScreen(); \
    1535                 :   }
    1536                 : 
    1537                 : /**
    1538                 :  * A macro to declare the NS_NewHTMLXXXElement() functions.
    1539                 :  */
    1540                 : #define NS_DECLARE_NS_NEW_HTML_ELEMENT(_elementName)                       \
    1541                 : nsGenericHTMLElement*                                                      \
    1542                 : NS_NewHTML##_elementName##Element(already_AddRefed<nsINodeInfo> aNodeInfo, \
    1543                 :                                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
    1544                 : 
    1545                 : #define NS_DECLARE_NS_NEW_HTML_ELEMENT_AS_SHARED(_elementName)             \
    1546                 : inline nsGenericHTMLElement*                                               \
    1547                 : NS_NewHTML##_elementName##Element(already_AddRefed<nsINodeInfo> aNodeInfo, \
    1548                 :                                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER) \
    1549                 : {                                                                          \
    1550                 :   return NS_NewHTMLSharedElement(aNodeInfo, aFromParser);                  \
    1551                 : }
    1552                 : 
    1553                 : /**
    1554                 :  * A macro to implement the NS_NewHTMLXXXElement() functions.
    1555                 :  */
    1556                 : #define NS_IMPL_NS_NEW_HTML_ELEMENT(_elementName)                            \
    1557                 : nsGenericHTMLElement*                                                        \
    1558                 : NS_NewHTML##_elementName##Element(already_AddRefed<nsINodeInfo> aNodeInfo,   \
    1559                 :                                   mozilla::dom::FromParser aFromParser)      \
    1560                 : {                                                                            \
    1561                 :   return new nsHTML##_elementName##Element(aNodeInfo);                       \
    1562                 : }
    1563                 : 
    1564                 : #define NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(_elementName)               \
    1565                 : nsGenericHTMLElement*                                                        \
    1566                 : NS_NewHTML##_elementName##Element(already_AddRefed<nsINodeInfo> aNodeInfo,   \
    1567                 :                                   mozilla::dom::FromParser aFromParser)      \
    1568                 : {                                                                            \
    1569                 :   return new nsHTML##_elementName##Element(aNodeInfo, aFromParser);          \
    1570                 : }
    1571                 : 
    1572                 : // Here, we expand 'NS_DECLARE_NS_NEW_HTML_ELEMENT()' by hand.
    1573                 : // (Calling the macro directly (with no args) produces compiler warnings.)
    1574                 : nsGenericHTMLElement*
    1575                 : NS_NewHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo,
    1576                 :                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
    1577                 : 
    1578                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Shared)
    1579                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(SharedList)
    1580                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(SharedObject)
    1581                 : 
    1582                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Anchor)
    1583                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Area)
    1584                 : #if defined(MOZ_MEDIA)
    1585                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Audio)
    1586                 : #endif
    1587                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(BR)
    1588                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Body)
    1589                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Button)
    1590                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Canvas)
    1591                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Mod)
    1592                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(DataList)
    1593                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Div)
    1594                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(FieldSet)
    1595                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Font)
    1596                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Form)
    1597                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Frame)
    1598                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(FrameSet)
    1599                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(HR)
    1600               0 : NS_DECLARE_NS_NEW_HTML_ELEMENT_AS_SHARED(Head)
    1601                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Heading)
    1602               0 : NS_DECLARE_NS_NEW_HTML_ELEMENT_AS_SHARED(Html)
    1603                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(IFrame)
    1604                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Image)
    1605                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Input)
    1606                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(LI)
    1607                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Label)
    1608                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Legend)
    1609                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Link)
    1610                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Map)
    1611                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Menu)
    1612                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(MenuItem)
    1613                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Meta)
    1614                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Object)
    1615                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(OptGroup)
    1616                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Option)
    1617                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Output)
    1618                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Paragraph)
    1619                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Pre)
    1620                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Progress)
    1621                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Script)
    1622                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Select)
    1623                 : #if defined(MOZ_MEDIA)
    1624                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Source)
    1625                 : #endif
    1626                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Span)
    1627                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Style)
    1628                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TableCaption)
    1629                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TableCell)
    1630                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TableCol)
    1631                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Table)
    1632                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TableRow)
    1633                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TableSection)
    1634                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Tbody)
    1635                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(TextArea)
    1636                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Tfoot)
    1637                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Thead)
    1638                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Title)
    1639                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Unknown)
    1640                 : #if defined(MOZ_MEDIA)
    1641                 : NS_DECLARE_NS_NEW_HTML_ELEMENT(Video)
    1642                 : #endif
    1643                 : 
    1644                 : #endif /* nsGenericHTMLElement_h___ */

Generated by: LCOV version 1.7