LCOV - code coverage report
Current view: directory - dom/base - nsDOMClassInfo.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 3832 1505 39.3 %
Date: 2012-06-02 Functions: 249 67 26.9 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set ts=2 sw=2 et tw=78: */
       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.org 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) 2000
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Johnny Stenback <jst@netscape.com> (original author)
      25                 :  *   Ms2ger <ms2ger@gmail.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #include "mozilla/Util.h"
      42                 : #include "SmsFilter.h" // On top because it includes basictypes.h.
      43                 : 
      44                 : #ifdef XP_WIN
      45                 : #undef GetClassName
      46                 : #endif
      47                 : 
      48                 : // JavaScript includes
      49                 : #include "jsapi.h"
      50                 : #include "jsfriendapi.h"
      51                 : #include "jsprvtd.h"    // we are using private JS typedefs...
      52                 : #include "jsdbgapi.h"
      53                 : #include "WrapperFactory.h"
      54                 : #include "AccessCheck.h"
      55                 : 
      56                 : #include "xpcprivate.h"
      57                 : #include "XPCWrapper.h"
      58                 : 
      59                 : #include "nscore.h"
      60                 : #include "nsDOMClassInfo.h"
      61                 : #include "nsCRT.h"
      62                 : #include "nsCRTGlue.h"
      63                 : #include "nsIServiceManager.h"
      64                 : #include "nsICategoryManager.h"
      65                 : #include "nsIComponentRegistrar.h"
      66                 : #include "nsXPCOM.h"
      67                 : #include "nsISupportsPrimitives.h"
      68                 : #include "nsIXPConnect.h"
      69                 : #include "nsIJSContextStack.h"
      70                 : #include "nsIXPCSecurityManager.h"
      71                 : #include "nsIStringBundle.h"
      72                 : #include "nsIConsoleService.h"
      73                 : #include "nsIScriptError.h"
      74                 : #include "nsXPIDLString.h"
      75                 : #include "nsReadableUtils.h"
      76                 : #include "nsUnicharUtils.h"
      77                 : #include "xptcall.h"
      78                 : #include "prprf.h"
      79                 : #include "nsTArray.h"
      80                 : #include "nsCSSValue.h"
      81                 : #include "nsIRunnable.h"
      82                 : #include "nsThreadUtils.h"
      83                 : #include "nsDOMEventTargetHelper.h"
      84                 : #include "xpcprivate.h"
      85                 : #include "XrayWrapper.h"
      86                 : 
      87                 : // General helper includes
      88                 : #include "nsGlobalWindow.h"
      89                 : #include "nsHistory.h"
      90                 : #include "nsIContent.h"
      91                 : #include "nsIAttribute.h"
      92                 : #include "nsIDocument.h"
      93                 : #include "nsIDOMDocument.h"
      94                 : #include "nsIDOMXMLDocument.h"
      95                 : #include "nsIDOMEvent.h"
      96                 : #include "nsIDOMNSEvent.h"
      97                 : #include "nsIDOMKeyEvent.h"
      98                 : #include "nsIDOMEventListener.h"
      99                 : #include "nsIDOMPopStateEvent.h"
     100                 : #include "nsIDOMHashChangeEvent.h"
     101                 : #include "nsContentUtils.h"
     102                 : #include "nsDOMWindowUtils.h"
     103                 : #include "nsIDOMGlobalPropertyInitializer.h"
     104                 : #include "mozilla/Preferences.h"
     105                 : #include "nsLocation.h"
     106                 : 
     107                 : // Window scriptable helper includes
     108                 : #include "nsIDocShell.h"
     109                 : #include "nsIDocShellTreeItem.h"
     110                 : #include "nsIDocShellTreeNode.h"
     111                 : #include "nsIScriptExternalNameSet.h"
     112                 : #include "nsJSUtils.h"
     113                 : #include "nsIInterfaceRequestor.h"
     114                 : #include "nsIInterfaceRequestorUtils.h"
     115                 : #include "nsScriptNameSpaceManager.h"
     116                 : #include "nsIScriptObjectOwner.h"
     117                 : #include "nsIJSNativeInitializer.h"
     118                 : #include "nsJSEnvironment.h"
     119                 : 
     120                 : // DOM base includes
     121                 : #include "nsIDOMPluginArray.h"
     122                 : #include "nsIDOMPlugin.h"
     123                 : #include "nsIDOMMimeTypeArray.h"
     124                 : #include "nsIDOMMimeType.h"
     125                 : #include "nsIDOMLocation.h"
     126                 : #include "nsIDOMWindow.h"
     127                 : #include "nsPIDOMWindow.h"
     128                 : #include "nsIDOMJSWindow.h"
     129                 : #include "nsIDOMWindowCollection.h"
     130                 : #include "nsIDOMHistory.h"
     131                 : #include "nsIDOMMediaList.h"
     132                 : #include "nsIDOMChromeWindow.h"
     133                 : #include "nsIDOMConstructor.h"
     134                 : #include "nsIDOMPerformanceTiming.h"
     135                 : #include "nsIDOMPerformanceNavigation.h"
     136                 : #include "nsIDOMPerformance.h"
     137                 : #include "nsClientRect.h"
     138                 : 
     139                 : // DOM core includes
     140                 : #include "nsDOMError.h"
     141                 : #include "nsIDOMDOMException.h"
     142                 : #include "nsIDOMNode.h"
     143                 : #include "nsIDOMNamedNodeMap.h"
     144                 : #include "nsIDOMDOMStringList.h"
     145                 : #include "nsIDOMDOMTokenList.h"
     146                 : #include "nsIDOMDOMSettableTokenList.h"
     147                 : #include "nsIDOMNSElement.h"
     148                 : 
     149                 : #include "nsDOMStringMap.h"
     150                 : 
     151                 : // HTMLFormElement helper includes
     152                 : #include "nsIForm.h"
     153                 : #include "nsIFormControl.h"
     154                 : #include "nsIDOMHTMLFormElement.h"
     155                 : #include "nsHTMLDocument.h"
     156                 : 
     157                 : // Constraint Validation API helper includes
     158                 : #include "nsIDOMValidityState.h"
     159                 : 
     160                 : // HTMLSelectElement helper includes
     161                 : #include "nsIDOMHTMLSelectElement.h"
     162                 : 
     163                 : // HTMLEmbed/ObjectElement helper includes
     164                 : #include "nsNPAPIPluginInstance.h"
     165                 : #include "nsIObjectFrame.h"
     166                 : #include "nsIObjectLoadingContent.h"
     167                 : #include "nsIPluginHost.h"
     168                 : 
     169                 : #include "nsIDOMHTMLOptionElement.h"
     170                 : #include "nsGenericElement.h"
     171                 : 
     172                 : // Event related includes
     173                 : #include "nsEventListenerManager.h"
     174                 : #include "nsIDOMEventTarget.h"
     175                 : 
     176                 : // CSS related includes
     177                 : #include "nsIDOMStyleSheet.h"
     178                 : #include "nsIDOMStyleSheetList.h"
     179                 : #include "nsIDOMCSSStyleDeclaration.h"
     180                 : #include "nsIDOMCSSRule.h"
     181                 : #include "nsICSSRuleList.h"
     182                 : #include "nsIDOMRect.h"
     183                 : #include "nsIDOMRGBColor.h"
     184                 : #include "nsIDOMNSRGBAColor.h"
     185                 : #include "nsDOMCSSAttrDeclaration.h"
     186                 : 
     187                 : // XBL related includes.
     188                 : #include "nsIXBLService.h"
     189                 : #include "nsXBLBinding.h"
     190                 : #include "nsBindingManager.h"
     191                 : #include "nsIFrame.h"
     192                 : #include "nsIPresShell.h"
     193                 : #include "nsIDOMElement.h"
     194                 : #include "nsIDOMCSSStyleDeclaration.h"
     195                 : #include "nsStyleContext.h"
     196                 : #include "nsAutoPtr.h"
     197                 : #include "nsMemory.h"
     198                 : 
     199                 : // Tranformiix
     200                 : #include "nsIDOMXPathEvaluator.h"
     201                 : #include "nsIXSLTProcessor.h"
     202                 : #include "nsIXSLTProcessorPrivate.h"
     203                 : 
     204                 : #include "nsIDOMLSProgressEvent.h"
     205                 : #include "nsIDOMParser.h"
     206                 : #include "nsIDOMSerializer.h"
     207                 : #include "nsXMLHttpRequest.h"
     208                 : #include "nsWebSocket.h"
     209                 : #include "nsIDOMCloseEvent.h"
     210                 : #include "nsEventSource.h"
     211                 : 
     212                 : // includes needed for the prototype chain interfaces
     213                 : #include "nsIDOMNavigator.h"
     214                 : #include "nsIDOMBarProp.h"
     215                 : #include "nsIDOMScreen.h"
     216                 : #include "nsIDOMDocumentType.h"
     217                 : #include "nsIDOMDOMImplementation.h"
     218                 : #include "nsIDOMDocumentFragment.h"
     219                 : #include "nsDOMAttribute.h"
     220                 : #include "nsIDOMText.h"
     221                 : #include "nsIDOMComment.h"
     222                 : #include "nsIDOMCDATASection.h"
     223                 : #include "nsIDOMProcessingInstruction.h"
     224                 : #include "nsIDOMDataContainerEvent.h"
     225                 : #include "nsIDOMKeyEvent.h"
     226                 : #include "nsIDOMCompositionEvent.h"
     227                 : #include "nsIDOMMouseEvent.h"
     228                 : #include "nsIDOMMouseScrollEvent.h"
     229                 : #include "nsIDOMDragEvent.h"
     230                 : #include "nsIDOMCommandEvent.h"
     231                 : #include "nsIDOMPopupBlockedEvent.h"
     232                 : #include "nsIDOMBeforeUnloadEvent.h"
     233                 : #include "nsIDOMMutationEvent.h"
     234                 : #include "nsIDOMSmartCardEvent.h"
     235                 : #include "nsIDOMXULCommandEvent.h"
     236                 : #include "nsIDOMPageTransitionEvent.h"
     237                 : #include "nsIDOMMessageEvent.h"
     238                 : #include "nsPaintRequest.h"
     239                 : #include "nsIDOMNotifyPaintEvent.h"
     240                 : #include "nsIDOMNotifyAudioAvailableEvent.h"
     241                 : #include "nsIDOMScrollAreaEvent.h"
     242                 : #include "nsIDOMTransitionEvent.h"
     243                 : #include "nsIDOMAnimationEvent.h"
     244                 : #include "nsIDOMDocumentXBL.h"
     245                 : #include "nsIDOMElementCSSInlineStyle.h"
     246                 : #include "nsIDOMLinkStyle.h"
     247                 : #include "nsIDOMHTMLDocument.h"
     248                 : #include "nsIDOMHTMLElement.h"
     249                 : #include "nsIDOMHTMLAnchorElement.h"
     250                 : #include "nsIDOMHTMLAppletElement.h"
     251                 : #include "nsIDOMHTMLAreaElement.h"
     252                 : #include "nsIDOMHTMLBRElement.h"
     253                 : #include "nsIDOMHTMLBaseElement.h"
     254                 : #include "nsIDOMHTMLBodyElement.h"
     255                 : #include "nsIDOMHTMLButtonElement.h"
     256                 : #include "nsIDOMHTMLCanvasElement.h"
     257                 : #include "nsIDOMHTMLDataListElement.h"
     258                 : #include "nsIDOMHTMLDListElement.h"
     259                 : #include "nsIDOMHTMLDirectoryElement.h"
     260                 : #include "nsIDOMHTMLDivElement.h"
     261                 : #include "nsIDOMHTMLEmbedElement.h"
     262                 : #include "nsIDOMHTMLFieldSetElement.h"
     263                 : #include "nsIDOMHTMLFontElement.h"
     264                 : #include "nsIDOMHTMLFrameElement.h"
     265                 : #include "nsIDOMHTMLFrameSetElement.h"
     266                 : #include "nsIDOMHTMLFrameElement.h"
     267                 : #include "nsIDOMHTMLHRElement.h"
     268                 : #include "nsIDOMHTMLHeadElement.h"
     269                 : #include "nsIDOMHTMLHeadingElement.h"
     270                 : #include "nsIDOMHTMLHtmlElement.h"
     271                 : #include "nsIDOMHTMLIFrameElement.h"
     272                 : #include "nsIDOMHTMLImageElement.h"
     273                 : #include "nsIDOMHTMLInputElement.h"
     274                 : #include "nsIDOMHTMLLIElement.h"
     275                 : #include "nsIDOMHTMLLabelElement.h"
     276                 : #include "nsIDOMHTMLLegendElement.h"
     277                 : #include "nsIDOMHTMLLinkElement.h"
     278                 : #include "nsIDOMHTMLMapElement.h"
     279                 : #include "nsIDOMHTMLMenuElement.h"
     280                 : #include "nsIDOMHTMLMenuItemElement.h"
     281                 : #include "nsIDOMHTMLMetaElement.h"
     282                 : #include "nsIDOMHTMLModElement.h"
     283                 : #include "nsIDOMHTMLOListElement.h"
     284                 : #include "nsIDOMHTMLObjectElement.h"
     285                 : #include "nsIDOMHTMLOptGroupElement.h"
     286                 : #include "nsIDOMHTMLOutputElement.h"
     287                 : #include "nsIDOMHTMLParagraphElement.h"
     288                 : #include "nsIDOMHTMLParamElement.h"
     289                 : #include "nsIDOMHTMLPreElement.h"
     290                 : #include "nsIDOMHTMLProgressElement.h"
     291                 : #include "nsIDOMHTMLQuoteElement.h"
     292                 : #include "nsIDOMHTMLScriptElement.h"
     293                 : #include "nsIDOMHTMLStyleElement.h"
     294                 : #include "nsIDOMHTMLTableCaptionElem.h"
     295                 : #include "nsIDOMHTMLTableCellElement.h"
     296                 : #include "nsIDOMHTMLTableColElement.h"
     297                 : #include "nsIDOMHTMLTableElement.h"
     298                 : #include "nsIDOMHTMLTableRowElement.h"
     299                 : #include "nsIDOMHTMLTableSectionElem.h"
     300                 : #include "nsIDOMHTMLTextAreaElement.h"
     301                 : #include "nsIDOMHTMLTitleElement.h"
     302                 : #include "nsIDOMHTMLUListElement.h"
     303                 : #include "nsIDOMHTMLUnknownElement.h"
     304                 : #include "nsIDOMMediaError.h"
     305                 : #include "nsIDOMTimeRanges.h"
     306                 : #include "nsIDOMHTMLSourceElement.h"
     307                 : #include "nsIDOMHTMLVideoElement.h"
     308                 : #include "nsIDOMHTMLAudioElement.h"
     309                 : #include "nsIDOMProgressEvent.h"
     310                 : #include "nsIDOMCSS2Properties.h"
     311                 : #include "nsIDOMCSSCharsetRule.h"
     312                 : #include "nsIDOMCSSImportRule.h"
     313                 : #include "nsIDOMCSSMediaRule.h"
     314                 : #include "nsIDOMCSSFontFaceRule.h"
     315                 : #include "nsIDOMCSSMozDocumentRule.h"
     316                 : #include "nsIDOMMozCSSKeyframeRule.h"
     317                 : #include "nsIDOMMozCSSKeyframesRule.h"
     318                 : #include "nsIDOMCSSPrimitiveValue.h"
     319                 : #include "nsIDOMCSSStyleRule.h"
     320                 : #include "nsIDOMCSSStyleSheet.h"
     321                 : #include "nsDOMCSSValueList.h"
     322                 : #include "nsIDOMDeviceOrientationEvent.h"
     323                 : #include "nsIDOMDeviceMotionEvent.h"
     324                 : #include "nsIDOMRange.h"
     325                 : #include "nsIDOMNodeIterator.h"
     326                 : #include "nsIDOMTreeWalker.h"
     327                 : #include "nsIDOMXULDocument.h"
     328                 : #include "nsIDOMXULElement.h"
     329                 : #include "nsIDOMXULCommandDispatcher.h"
     330                 : #include "nsIDOMCrypto.h"
     331                 : #include "nsIDOMCRMFObject.h"
     332                 : #include "nsIControllers.h"
     333                 : #include "nsISelection.h"
     334                 : #include "nsIBoxObject.h"
     335                 : #ifdef MOZ_XUL
     336                 : #include "nsITreeSelection.h"
     337                 : #include "nsITreeContentView.h"
     338                 : #include "nsITreeView.h"
     339                 : #include "nsIXULTemplateBuilder.h"
     340                 : #include "nsTreeColumns.h"
     341                 : #endif
     342                 : #include "nsIDOMXPathException.h"
     343                 : #include "nsIDOMXPathExpression.h"
     344                 : #include "nsIDOMNSXPathExpression.h"
     345                 : #include "nsIDOMXPathNSResolver.h"
     346                 : #include "nsIDOMXPathResult.h"
     347                 : #include "nsIDOMMozBrowserFrame.h"
     348                 : 
     349                 : #include "nsIDOMGetSVGDocument.h"
     350                 : #include "nsIDOMSVGAElement.h"
     351                 : #include "nsIDOMSVGAltGlyphElement.h"
     352                 : #include "nsIDOMSVGAngle.h"
     353                 : #include "nsIDOMSVGAnimatedAngle.h"
     354                 : #include "nsIDOMSVGAnimatedBoolean.h"
     355                 : #include "nsIDOMSVGAnimatedEnum.h"
     356                 : #include "nsIDOMSVGAnimatedInteger.h"
     357                 : #include "nsIDOMSVGAnimatedLength.h"
     358                 : #include "nsIDOMSVGAnimatedLengthList.h"
     359                 : #include "nsIDOMSVGAnimatedNumber.h"
     360                 : #include "nsIDOMSVGAnimatedNumberList.h"
     361                 : #include "nsIDOMSVGAnimatedPathData.h"
     362                 : #include "nsIDOMSVGAnimatedPoints.h"
     363                 : #include "nsIDOMSVGAnimatedRect.h"
     364                 : #include "nsIDOMSVGAnimatedString.h"
     365                 : #include "nsIDOMSVGAnimPresAspRatio.h"
     366                 : #include "nsIDOMSVGAnimateElement.h"
     367                 : #include "nsIDOMSVGAnimateTransformElement.h"
     368                 : #include "nsIDOMSVGAnimateMotionElement.h"
     369                 : #include "nsIDOMSVGMpathElement.h"
     370                 : #include "nsIDOMSVGSetElement.h"
     371                 : #include "nsIDOMSVGAnimationElement.h"
     372                 : #include "nsIDOMElementTimeControl.h"
     373                 : #include "nsIDOMTimeEvent.h"
     374                 : #include "nsIDOMSVGAnimTransformList.h"
     375                 : #include "nsIDOMSVGCircleElement.h"
     376                 : #include "nsIDOMSVGClipPathElement.h"
     377                 : #include "nsIDOMSVGDefsElement.h"
     378                 : #include "nsIDOMSVGDescElement.h"
     379                 : #include "nsIDOMSVGDocument.h"
     380                 : #include "nsIDOMSVGElement.h"
     381                 : #include "nsIDOMSVGEllipseElement.h"
     382                 : #include "nsIDOMSVGEvent.h"
     383                 : #include "nsIDOMSVGException.h"
     384                 : #include "nsIDOMSVGFilterElement.h"
     385                 : #include "nsIDOMSVGFilters.h"
     386                 : #include "nsIDOMSVGFitToViewBox.h"
     387                 : #include "nsIDOMSVGForeignObjectElem.h"
     388                 : #include "nsIDOMSVGGElement.h"
     389                 : #include "nsIDOMSVGGradientElement.h"
     390                 : #include "nsIDOMSVGImageElement.h"
     391                 : #include "nsIDOMSVGLength.h"
     392                 : #include "nsIDOMSVGLengthList.h"
     393                 : #include "nsIDOMSVGLineElement.h"
     394                 : #include "nsIDOMSVGLocatable.h"
     395                 : #include "nsIDOMSVGMarkerElement.h"
     396                 : #include "nsIDOMSVGMaskElement.h"
     397                 : #include "nsIDOMSVGMatrix.h"
     398                 : #include "nsIDOMSVGMetadataElement.h"
     399                 : #include "nsIDOMSVGNumber.h"
     400                 : #include "nsIDOMSVGNumberList.h"
     401                 : #include "nsIDOMSVGPathElement.h"
     402                 : #include "nsIDOMSVGPathSeg.h"
     403                 : #include "nsIDOMSVGPathSegList.h"
     404                 : #include "nsIDOMSVGPatternElement.h"
     405                 : #include "nsIDOMSVGPoint.h"
     406                 : #include "nsIDOMSVGPointList.h"
     407                 : #include "nsIDOMSVGPolygonElement.h"
     408                 : #include "nsIDOMSVGPolylineElement.h"
     409                 : #include "nsIDOMSVGPresAspectRatio.h"
     410                 : #include "nsIDOMSVGRect.h"
     411                 : #include "nsIDOMSVGRectElement.h"
     412                 : #include "nsIDOMSVGScriptElement.h"
     413                 : #include "nsIDOMSVGStopElement.h"
     414                 : #include "nsIDOMSVGStylable.h"
     415                 : #include "nsIDOMSVGStyleElement.h"
     416                 : #include "nsIDOMSVGSVGElement.h"
     417                 : #include "nsIDOMSVGSwitchElement.h"
     418                 : #include "nsIDOMSVGSymbolElement.h"
     419                 : #include "nsIDOMSVGTests.h"
     420                 : #include "nsIDOMSVGTextElement.h"
     421                 : #include "nsIDOMSVGTextPathElement.h"
     422                 : #include "nsIDOMSVGTitleElement.h"
     423                 : #include "nsIDOMSVGTransform.h"
     424                 : #include "nsIDOMSVGTransformable.h"
     425                 : #include "nsIDOMSVGTransformList.h"
     426                 : #include "nsIDOMSVGTSpanElement.h"
     427                 : #include "nsIDOMSVGUnitTypes.h"
     428                 : #include "nsIDOMSVGURIReference.h"
     429                 : #include "nsIDOMSVGUseElement.h"
     430                 : #include "nsIDOMSVGZoomAndPan.h"
     431                 : #include "nsIDOMSVGZoomEvent.h"
     432                 : 
     433                 : #include "nsIDOMCanvasRenderingContext2D.h"
     434                 : #include "nsIDOMWebGLRenderingContext.h"
     435                 : 
     436                 : #include "nsIImageDocument.h"
     437                 : 
     438                 : // Storage includes
     439                 : #include "nsDOMStorage.h"
     440                 : 
     441                 : // Drag and drop
     442                 : #include "nsIDOMDataTransfer.h"
     443                 : 
     444                 : // Geolocation
     445                 : #include "nsIDOMGeoGeolocation.h"
     446                 : #include "nsIDOMGeoPosition.h"
     447                 : #include "nsIDOMGeoPositionCoords.h"
     448                 : #include "nsIDOMGeoPositionError.h"
     449                 : 
     450                 : // Workers
     451                 : #include "mozilla/dom/workers/Workers.h"
     452                 : 
     453                 : #include "nsDOMFile.h"
     454                 : #include "nsDOMFileReader.h"
     455                 : #include "nsIDOMFileException.h"
     456                 : #include "nsIDOMFormData.h"
     457                 : 
     458                 : #include "nsIDOMDOMStringMap.h"
     459                 : 
     460                 : #include "nsIDOMDesktopNotification.h"
     461                 : #include "nsIDOMNavigatorDesktopNotification.h"
     462                 : #include "nsIDOMNavigatorGeolocation.h"
     463                 : #include "Navigator.h"
     464                 : 
     465                 : #include "nsPluginArray.h"
     466                 : #include "nsMimeTypeArray.h"
     467                 : 
     468                 : // Simple gestures include
     469                 : #include "nsIDOMSimpleGestureEvent.h"
     470                 : #include "nsIDOMMozTouchEvent.h"
     471                 : 
     472                 : #include "nsIEventListenerService.h"
     473                 : #include "nsIFrameMessageManager.h"
     474                 : #include "mozilla/dom/Element.h"
     475                 : #include "nsHTMLSelectElement.h"
     476                 : #include "nsHTMLLegendElement.h"
     477                 : 
     478                 : #include "DOMSVGLengthList.h"
     479                 : #include "DOMSVGNumberList.h"
     480                 : #include "DOMSVGPathSegList.h"
     481                 : #include "DOMSVGPointList.h"
     482                 : #include "DOMSVGStringList.h"
     483                 : #include "DOMSVGTransformList.h"
     484                 : 
     485                 : #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
     486                 : #include "mozilla/dom/indexedDB/IDBFactory.h"
     487                 : #include "mozilla/dom/indexedDB/IDBRequest.h"
     488                 : #include "mozilla/dom/indexedDB/IDBDatabase.h"
     489                 : #include "mozilla/dom/indexedDB/IDBEvents.h"
     490                 : #include "mozilla/dom/indexedDB/IDBObjectStore.h"
     491                 : #include "mozilla/dom/indexedDB/IDBTransaction.h"
     492                 : #include "mozilla/dom/indexedDB/IDBCursor.h"
     493                 : #include "mozilla/dom/indexedDB/IDBKeyRange.h"
     494                 : #include "mozilla/dom/indexedDB/IDBIndex.h"
     495                 : #include "nsIIDBDatabaseException.h"
     496                 : 
     497                 : using mozilla::dom::indexedDB::IDBWrapperCache;
     498                 : 
     499                 : #include "nsIDOMMediaQueryList.h"
     500                 : 
     501                 : #include "nsDOMTouchEvent.h"
     502                 : #include "nsIDOMCustomEvent.h"
     503                 : 
     504                 : #include "nsWrapperCacheInlines.h"
     505                 : #include "dombindings.h"
     506                 : 
     507                 : #include "nsIDOMBatteryManager.h"
     508                 : #include "BatteryManager.h"
     509                 : #include "nsIDOMPowerManager.h"
     510                 : #include "nsIDOMWakeLock.h"
     511                 : #include "nsIDOMSmsManager.h"
     512                 : #include "nsIDOMSmsMessage.h"
     513                 : #include "nsIDOMSmsEvent.h"
     514                 : #include "nsIDOMSmsRequest.h"
     515                 : #include "nsIDOMSmsFilter.h"
     516                 : #include "nsIDOMSmsCursor.h"
     517                 : #include "nsIPrivateDOMEvent.h"
     518                 : #include "nsIDOMConnection.h"
     519                 : #include "mozilla/dom/network/Utils.h"
     520                 : 
     521                 : #ifdef MOZ_B2G_RIL
     522                 : #include "Telephony.h"
     523                 : #include "TelephonyCall.h"
     524                 : #include "CallEvent.h"
     525                 : #endif
     526                 : 
     527                 : #ifdef MOZ_B2G_BT
     528                 : #include "BluetoothAdapter.h"
     529                 : #endif
     530                 : 
     531                 : #include "DOMError.h"
     532                 : #include "DOMRequest.h"
     533                 : 
     534                 : using namespace mozilla;
     535                 : using namespace mozilla::dom;
     536                 : 
     537                 : static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
     538                 : 
     539                 : static const char kDOMStringBundleURL[] =
     540                 :   "chrome://global/locale/dom/dom.properties";
     541                 : 
     542                 : // NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
     543                 : //       are defined in nsIDOMClassInfo.h.
     544                 : 
     545                 : #define WINDOW_SCRIPTABLE_FLAGS                                               \
     546                 :  (nsIXPCScriptable::WANT_GETPROPERTY |                                        \
     547                 :   nsIXPCScriptable::WANT_PRECREATE |                                          \
     548                 :   nsIXPCScriptable::WANT_FINALIZE |                                           \
     549                 :   nsIXPCScriptable::WANT_ENUMERATE |                                          \
     550                 :   nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE |                               \
     551                 :   nsIXPCScriptable::USE_STUB_EQUALITY_HOOK |                                  \
     552                 :   nsIXPCScriptable::IS_GLOBAL_OBJECT |                                        \
     553                 :   nsIXPCScriptable::WANT_OUTER_OBJECT)
     554                 : 
     555                 : #define NODE_SCRIPTABLE_FLAGS                                                 \
     556                 :  ((DOM_DEFAULT_SCRIPTABLE_FLAGS |                                             \
     557                 :    nsIXPCScriptable::USE_STUB_EQUALITY_HOOK |                                 \
     558                 :    nsIXPCScriptable::WANT_ADDPROPERTY) &                                      \
     559                 :   ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
     560                 : 
     561                 : // We need to let JavaScript QI elements to interfaces that are not in
     562                 : // the classinfo since XBL can be used to dynamically implement new
     563                 : // unknown interfaces on elements, accessibility relies on this being
     564                 : // possible.
     565                 : 
     566                 : #define ELEMENT_SCRIPTABLE_FLAGS                                              \
     567                 :   ((NODE_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY) |   \
     568                 :    nsIXPCScriptable::WANT_POSTCREATE |                                        \
     569                 :    nsIXPCScriptable::WANT_ENUMERATE)
     570                 : 
     571                 : #define EXTERNAL_OBJ_SCRIPTABLE_FLAGS                                         \
     572                 :   ((ELEMENT_SCRIPTABLE_FLAGS &                                                \
     573                 :     ~nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY) |                          \
     574                 :    nsIXPCScriptable::WANT_POSTCREATE |                                        \
     575                 :    nsIXPCScriptable::WANT_GETPROPERTY |                                       \
     576                 :    nsIXPCScriptable::WANT_SETPROPERTY |                                       \
     577                 :    nsIXPCScriptable::WANT_CALL)
     578                 : 
     579                 : #define DOCUMENT_SCRIPTABLE_FLAGS                                             \
     580                 :   (NODE_SCRIPTABLE_FLAGS |                                                    \
     581                 :    nsIXPCScriptable::WANT_POSTCREATE |                                        \
     582                 :    nsIXPCScriptable::WANT_ENUMERATE)
     583                 : 
     584                 : #define ARRAY_SCRIPTABLE_FLAGS                                                \
     585                 :   (DOM_DEFAULT_SCRIPTABLE_FLAGS       |                                       \
     586                 :    nsIXPCScriptable::WANT_GETPROPERTY |                                       \
     587                 :    nsIXPCScriptable::WANT_ENUMERATE)
     588                 : 
     589                 : #define DOMSTRINGMAP_SCRIPTABLE_FLAGS                                         \
     590                 :   (DOM_DEFAULT_SCRIPTABLE_FLAGS       |                                       \
     591                 :    nsIXPCScriptable::WANT_ENUMERATE   |                                       \
     592                 :    nsIXPCScriptable::WANT_PRECREATE   |                                       \
     593                 :    nsIXPCScriptable::WANT_DELPROPERTY |                                       \
     594                 :    nsIXPCScriptable::WANT_SETPROPERTY |                                       \
     595                 :    nsIXPCScriptable::WANT_GETPROPERTY)
     596                 : 
     597                 : #define EVENTTARGET_SCRIPTABLE_FLAGS                                          \
     598                 :   (DOM_DEFAULT_SCRIPTABLE_FLAGS       |                                       \
     599                 :    nsIXPCScriptable::WANT_ADDPROPERTY)
     600                 : 
     601                 : #define IDBEVENTTARGET_SCRIPTABLE_FLAGS                                       \
     602                 :   (EVENTTARGET_SCRIPTABLE_FLAGS)
     603                 : 
     604                 : #define DOMCLASSINFO_STANDARD_FLAGS                                           \
     605                 :   (nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::DOM_OBJECT)
     606                 : 
     607                 : 
     608                 : #ifdef NS_DEBUG
     609                 : #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class)                                \
     610                 :     eDOMClassInfo_##_class##_id,
     611                 : #else
     612                 : #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class)                                \
     613                 :   // nothing
     614                 : #endif
     615                 : 
     616                 : DOMCI_DATA(Crypto, void)
     617                 : DOMCI_DATA(CRMFObject, void)
     618                 : DOMCI_DATA(SmartCardEvent, void)
     619                 : DOMCI_DATA(ContentFrameMessageManager, void)
     620                 : 
     621                 : DOMCI_DATA(DOMPrototype, void)
     622                 : DOMCI_DATA(DOMConstructor, void)
     623                 : 
     624                 : #define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper,            \
     625                 :                                            _flags)                            \
     626                 :   { #_name,                                                                   \
     627                 :     nsnull,                                                                   \
     628                 :     { _helper::doCreate },                                                    \
     629                 :     nsnull,                                                                   \
     630                 :     nsnull,                                                                   \
     631                 :     nsnull,                                                                   \
     632                 :     _flags,                                                                   \
     633                 :     true,                                                                  \
     634                 :     0,                                                                        \
     635                 :     false,                                                                 \
     636                 :     false,                                                                 \
     637                 :     NULL,                                                                     \
     638                 :     NS_DEFINE_CLASSINFO_DATA_DEBUG(_class)                                    \
     639                 :   },
     640                 : 
     641                 : #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _name,         \
     642                 :                                                        _helper, _flags)       \
     643                 :   { #_name,                                                                   \
     644                 :     nsnull,                                                                   \
     645                 :     { _helper::doCreate },                                                    \
     646                 :     nsnull,                                                                   \
     647                 :     nsnull,                                                                   \
     648                 :     nsnull,                                                                   \
     649                 :     _flags,                                                                   \
     650                 :     true,                                                                  \
     651                 :     0,                                                                        \
     652                 :     true,                                                                  \
     653                 :     false,                                                                 \
     654                 :     NULL,                                                                     \
     655                 :     NS_DEFINE_CLASSINFO_DATA_DEBUG(_class)                                    \
     656                 :   },
     657                 : 
     658                 : #define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags)                     \
     659                 :   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
     660                 : 
     661                 : #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags)          \
     662                 :   NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
     663                 :                                                  _flags)
     664                 : 
     665                 : namespace {
     666                 : 
     667                 : class IDBEventTargetSH : public nsEventTargetSH
     668                 : {
     669                 : protected:
     670             174 :   IDBEventTargetSH(nsDOMClassInfoData* aData) : nsEventTargetSH(aData)
     671             174 :   { }
     672                 : 
     673             348 :   virtual ~IDBEventTargetSH()
     674             696 :   { }
     675                 : 
     676                 : public:
     677                 :   NS_IMETHOD PreCreate(nsISupports *aNativeObj, JSContext *aCx,
     678                 :                        JSObject *aGlobalObj, JSObject **aParentObj);
     679                 : 
     680             174 :   static nsIClassInfo *doCreate(nsDOMClassInfoData *aData)
     681                 :   {
     682             174 :     return new IDBEventTargetSH(aData);
     683                 :   }
     684                 : };
     685                 : 
     686                 : } // anonymous namespace
     687                 : 
     688                 : // This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
     689                 : // classes their correct behavior when used through XPConnect. The
     690                 : // arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
     691                 : //
     692                 : // 1. Class name as it should appear in JavaScript, this name is also
     693                 : //    used to find the id of the class in nsDOMClassInfo
     694                 : //    (i.e. e<classname>_id)
     695                 : // 2. Scriptable helper class
     696                 : // 3. nsIClassInfo/nsIXPCScriptable flags (i.e. for GetScriptableFlags)
     697                 : 
     698                 : static nsDOMClassInfoData sClassInfoData[] = {
     699                 :   // Base classes
     700                 : 
     701                 :   // The Window class lets you QI into interfaces that are not in the
     702                 :   // flattened set (i.e. nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY
     703                 :   // is not set), because of this make sure all scriptable interfaces
     704                 :   // that are implemented by nsGlobalWindow can securely be exposed
     705                 :   // to JS.
     706                 : 
     707                 : 
     708                 :   NS_DEFINE_CLASSINFO_DATA(Window, nsWindowSH,
     709                 :                            DEFAULT_SCRIPTABLE_FLAGS |
     710                 :                            WINDOW_SCRIPTABLE_FLAGS)
     711                 : 
     712                 :   NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
     713                 :                            (DOM_DEFAULT_SCRIPTABLE_FLAGS &
     714                 :                             ~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
     715                 : 
     716                 :   NS_DEFINE_CLASSINFO_DATA(Navigator, nsNavigatorSH,
     717                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS |
     718                 :                            nsIXPCScriptable::WANT_PRECREATE |
     719                 :                            nsIXPCScriptable::WANT_NEWRESOLVE)
     720                 :   NS_DEFINE_CLASSINFO_DATA(Plugin, nsPluginSH,
     721                 :                            ARRAY_SCRIPTABLE_FLAGS)
     722                 :   NS_DEFINE_CLASSINFO_DATA(PluginArray, nsPluginArraySH,
     723                 :                            ARRAY_SCRIPTABLE_FLAGS)
     724                 :   NS_DEFINE_CLASSINFO_DATA(MimeType, nsDOMGenericSH,
     725                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     726                 :   NS_DEFINE_CLASSINFO_DATA(MimeTypeArray, nsMimeTypeArraySH,
     727                 :                            ARRAY_SCRIPTABLE_FLAGS)
     728                 :   NS_DEFINE_CLASSINFO_DATA(BarProp, nsDOMGenericSH,
     729                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     730                 :   NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
     731                 :                            ARRAY_SCRIPTABLE_FLAGS |
     732                 :                            nsIXPCScriptable::WANT_PRECREATE)
     733                 :   NS_DEFINE_CLASSINFO_DATA(PerformanceTiming, nsDOMGenericSH,
     734                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     735                 :   NS_DEFINE_CLASSINFO_DATA(PerformanceNavigation, nsDOMGenericSH,
     736                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     737                 :   NS_DEFINE_CLASSINFO_DATA(Performance, nsDOMGenericSH,
     738                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     739                 :   NS_DEFINE_CLASSINFO_DATA(Screen, nsDOMGenericSH,
     740                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     741                 :   NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
     742                 :                            DOM_BASE_SCRIPTABLE_FLAGS |
     743                 :                            nsIXPCScriptable::WANT_PRECREATE |
     744                 :                            nsIXPCScriptable::WANT_NEWRESOLVE |
     745                 :                            nsIXPCScriptable::WANT_HASINSTANCE |
     746                 :                            nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
     747                 :   NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMConstructorSH,
     748                 :                            DOM_BASE_SCRIPTABLE_FLAGS |
     749                 :                            nsIXPCScriptable::WANT_PRECREATE |
     750                 :                            nsIXPCScriptable::WANT_NEWRESOLVE |
     751                 :                            nsIXPCScriptable::WANT_HASINSTANCE |
     752                 :                            nsIXPCScriptable::WANT_CALL |
     753                 :                            nsIXPCScriptable::WANT_CONSTRUCT |
     754                 :                            nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
     755                 : 
     756                 :   // Core classes
     757                 :   NS_DEFINE_CLASSINFO_DATA(XMLDocument, nsDocumentSH,
     758                 :                            DOCUMENT_SCRIPTABLE_FLAGS)
     759                 :   NS_DEFINE_CLASSINFO_DATA(DocumentType, nsNodeSH,
     760                 :                            NODE_SCRIPTABLE_FLAGS)
     761                 :   NS_DEFINE_CLASSINFO_DATA(DOMImplementation, nsDOMGenericSH,
     762                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     763                 :   NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
     764                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     765                 :   NS_DEFINE_CLASSINFO_DATA(DOMTokenList, nsDOMTokenListSH,
     766                 :                            ARRAY_SCRIPTABLE_FLAGS)
     767                 :   NS_DEFINE_CLASSINFO_DATA(DOMSettableTokenList, nsDOMTokenListSH,
     768                 :                            ARRAY_SCRIPTABLE_FLAGS)
     769                 :   NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
     770                 :   NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
     771                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     772                 :   NS_DEFINE_CLASSINFO_DATA(Attr, nsAttributeSH,
     773                 :                            NODE_SCRIPTABLE_FLAGS)
     774                 :   NS_DEFINE_CLASSINFO_DATA(Text, nsNodeSH,
     775                 :                            NODE_SCRIPTABLE_FLAGS)
     776                 :   NS_DEFINE_CLASSINFO_DATA(Comment, nsNodeSH,
     777                 :                            NODE_SCRIPTABLE_FLAGS)
     778                 :   NS_DEFINE_CLASSINFO_DATA(CDATASection, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
     779                 :   NS_DEFINE_CLASSINFO_DATA(ProcessingInstruction, nsNodeSH,
     780                 :                            NODE_SCRIPTABLE_FLAGS)
     781                 :   NS_DEFINE_CLASSINFO_DATA(NodeList, nsDOMGenericSH,
     782                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     783                 :   NS_DEFINE_CLASSINFO_DATA(NamedNodeMap, nsNamedNodeMapSH,
     784                 :                            ARRAY_SCRIPTABLE_FLAGS)
     785                 : 
     786                 :   // Misc Core related classes
     787                 : 
     788                 :   // Event
     789                 :   NS_DEFINE_CLASSINFO_DATA(Event, nsDOMGenericSH,
     790                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     791                 :   NS_DEFINE_CLASSINFO_DATA(MutationEvent, nsDOMGenericSH,
     792                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     793                 :   NS_DEFINE_CLASSINFO_DATA(UIEvent, nsDOMGenericSH,
     794                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     795                 :   NS_DEFINE_CLASSINFO_DATA(MouseEvent, nsDOMGenericSH,
     796                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     797                 :   NS_DEFINE_CLASSINFO_DATA(MouseScrollEvent, nsDOMGenericSH,
     798                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     799                 :   NS_DEFINE_CLASSINFO_DATA(DragEvent, nsDOMGenericSH,
     800                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     801                 :   NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
     802                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     803                 :   NS_DEFINE_CLASSINFO_DATA(CompositionEvent, nsDOMGenericSH,
     804                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     805                 :   NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
     806                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     807                 :   // Device Orientation
     808                 :   NS_DEFINE_CLASSINFO_DATA(DeviceOrientationEvent, nsDOMGenericSH,
     809                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     810                 :   NS_DEFINE_CLASSINFO_DATA(DeviceMotionEvent, nsDOMGenericSH,
     811                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     812                 :   NS_DEFINE_CLASSINFO_DATA(DeviceAcceleration, nsDOMGenericSH,
     813                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     814                 :   NS_DEFINE_CLASSINFO_DATA(DeviceRotationRate, nsDOMGenericSH,
     815                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     816                 : 
     817                 :   // Misc HTML classes
     818                 :   NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH,
     819                 :                            DOCUMENT_SCRIPTABLE_FLAGS |
     820                 :                            nsIXPCScriptable::WANT_GETPROPERTY)
     821                 :   NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection, nsDOMGenericSH,
     822                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     823                 :   NS_DEFINE_CLASSINFO_DATA(HTMLCollection, nsDOMGenericSH,
     824                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     825                 : 
     826                 :   // HTML element classes
     827                 :   NS_DEFINE_CLASSINFO_DATA(HTMLElement, nsElementSH,
     828                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     829                 :   NS_DEFINE_CLASSINFO_DATA(HTMLAnchorElement, nsElementSH,
     830                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     831                 :   NS_DEFINE_CLASSINFO_DATA(HTMLAppletElement, nsHTMLPluginObjElementSH,
     832                 :                            EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
     833                 :   NS_DEFINE_CLASSINFO_DATA(HTMLAreaElement, nsElementSH,
     834                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     835                 :   NS_DEFINE_CLASSINFO_DATA(HTMLBRElement, nsElementSH,
     836                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     837                 :   NS_DEFINE_CLASSINFO_DATA(HTMLBaseElement, nsElementSH,
     838                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     839                 :   NS_DEFINE_CLASSINFO_DATA(HTMLBodyElement, nsElementSH,
     840                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     841                 :   NS_DEFINE_CLASSINFO_DATA(HTMLButtonElement, nsElementSH,
     842                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     843                 :   NS_DEFINE_CLASSINFO_DATA(HTMLDataListElement, nsElementSH,
     844                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     845                 :   NS_DEFINE_CLASSINFO_DATA(HTMLDListElement, nsElementSH,
     846                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     847                 :   NS_DEFINE_CLASSINFO_DATA(HTMLDirectoryElement, nsElementSH,
     848                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     849                 :   NS_DEFINE_CLASSINFO_DATA(HTMLDivElement, nsElementSH,
     850                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     851                 :   NS_DEFINE_CLASSINFO_DATA(HTMLEmbedElement, nsHTMLPluginObjElementSH,
     852                 :                            EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
     853                 :   NS_DEFINE_CLASSINFO_DATA(HTMLFieldSetElement, nsElementSH,
     854                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     855                 :   NS_DEFINE_CLASSINFO_DATA(HTMLFontElement, nsElementSH,
     856                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     857                 :   NS_DEFINE_CLASSINFO_DATA(HTMLFormElement, nsHTMLFormElementSH,
     858                 :                            ELEMENT_SCRIPTABLE_FLAGS |
     859                 :                            nsIXPCScriptable::WANT_GETPROPERTY |
     860                 :                            nsIXPCScriptable::WANT_NEWENUMERATE)
     861                 :   NS_DEFINE_CLASSINFO_DATA(HTMLFrameElement, nsElementSH,
     862                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     863                 :   NS_DEFINE_CLASSINFO_DATA(HTMLFrameSetElement, nsElementSH,
     864                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     865                 :   NS_DEFINE_CLASSINFO_DATA(HTMLHRElement, nsElementSH,
     866                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     867                 :   NS_DEFINE_CLASSINFO_DATA(HTMLHeadElement, nsElementSH,
     868                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     869                 :   NS_DEFINE_CLASSINFO_DATA(HTMLHeadingElement, nsElementSH,
     870                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     871                 :   NS_DEFINE_CLASSINFO_DATA(HTMLHtmlElement, nsElementSH,
     872                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     873                 :   NS_DEFINE_CLASSINFO_DATA(HTMLIFrameElement, nsElementSH,
     874                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     875                 :   NS_DEFINE_CLASSINFO_DATA(HTMLImageElement, nsElementSH,
     876                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     877                 :   NS_DEFINE_CLASSINFO_DATA(HTMLInputElement, nsElementSH,
     878                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     879                 :   NS_DEFINE_CLASSINFO_DATA(HTMLLIElement, nsElementSH,
     880                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     881                 :   NS_DEFINE_CLASSINFO_DATA(HTMLLabelElement, nsElementSH,
     882                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     883                 :   NS_DEFINE_CLASSINFO_DATA(HTMLLegendElement, nsElementSH,
     884                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     885                 :   NS_DEFINE_CLASSINFO_DATA(HTMLLinkElement, nsElementSH,
     886                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     887                 :   NS_DEFINE_CLASSINFO_DATA(HTMLMapElement, nsElementSH,
     888                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     889                 :   NS_DEFINE_CLASSINFO_DATA(HTMLMenuElement, nsElementSH,
     890                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     891                 :   NS_DEFINE_CLASSINFO_DATA(HTMLMenuItemElement, nsElementSH,
     892                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     893                 :   NS_DEFINE_CLASSINFO_DATA(HTMLMetaElement, nsElementSH,
     894                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     895                 :   NS_DEFINE_CLASSINFO_DATA(HTMLModElement, nsElementSH,
     896                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     897                 :   NS_DEFINE_CLASSINFO_DATA(HTMLOListElement, nsElementSH,
     898                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     899                 :   NS_DEFINE_CLASSINFO_DATA(HTMLObjectElement, nsHTMLPluginObjElementSH,
     900                 :                            EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
     901                 :   NS_DEFINE_CLASSINFO_DATA(HTMLOptGroupElement, nsElementSH,
     902                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     903                 :   NS_DEFINE_CLASSINFO_DATA(HTMLOptionElement, nsElementSH,
     904                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     905                 :   NS_DEFINE_CLASSINFO_DATA(HTMLOutputElement, nsElementSH,
     906                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     907                 :   NS_DEFINE_CLASSINFO_DATA(HTMLParagraphElement, nsElementSH,
     908                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     909                 :   NS_DEFINE_CLASSINFO_DATA(HTMLParamElement, nsElementSH,
     910                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     911                 :   NS_DEFINE_CLASSINFO_DATA(HTMLPreElement, nsElementSH,
     912                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     913                 :   NS_DEFINE_CLASSINFO_DATA(HTMLProgressElement, nsElementSH,
     914                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     915                 :   NS_DEFINE_CLASSINFO_DATA(HTMLQuoteElement, nsElementSH,
     916                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     917                 :   NS_DEFINE_CLASSINFO_DATA(HTMLScriptElement, nsElementSH,
     918                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     919                 :   NS_DEFINE_CLASSINFO_DATA(HTMLSelectElement, nsHTMLSelectElementSH,
     920                 :                            ELEMENT_SCRIPTABLE_FLAGS |
     921                 :                            nsIXPCScriptable::WANT_SETPROPERTY |
     922                 :                            nsIXPCScriptable::WANT_GETPROPERTY)
     923                 :   NS_DEFINE_CLASSINFO_DATA(HTMLSpanElement, nsElementSH,
     924                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     925                 :   NS_DEFINE_CLASSINFO_DATA(HTMLStyleElement, nsElementSH,
     926                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     927                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableCaptionElement, nsElementSH,
     928                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     929                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableCellElement, nsElementSH,
     930                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     931                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableColElement, nsElementSH,
     932                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     933                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableElement, nsElementSH,
     934                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     935                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableRowElement, nsElementSH,
     936                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     937                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTableSectionElement, nsElementSH,
     938                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     939                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTextAreaElement, nsElementSH,
     940                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     941                 :   NS_DEFINE_CLASSINFO_DATA(HTMLTitleElement, nsElementSH,
     942                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     943                 :   NS_DEFINE_CLASSINFO_DATA(HTMLUListElement, nsElementSH,
     944                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     945                 :   NS_DEFINE_CLASSINFO_DATA(HTMLUnknownElement, nsElementSH,
     946                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     947                 : 
     948                 :   // Constraint Validation API classes
     949                 :   NS_DEFINE_CLASSINFO_DATA(ValidityState, nsDOMGenericSH,
     950                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     951                 : 
     952                 :   // CSS classes
     953                 :   NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
     954                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     955                 :   NS_DEFINE_CLASSINFO_DATA(CSSCharsetRule, nsDOMGenericSH,
     956                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     957                 :   NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
     958                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     959                 :   NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
     960                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     961                 :   NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
     962                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     963                 :   NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
     964                 :                            ARRAY_SCRIPTABLE_FLAGS)
     965                 :   NS_DEFINE_CLASSINFO_DATA(CSSGroupRuleRuleList, nsCSSRuleListSH,
     966                 :                            ARRAY_SCRIPTABLE_FLAGS)
     967                 :   NS_DEFINE_CLASSINFO_DATA(MediaList, nsMediaListSH,
     968                 :                            ARRAY_SCRIPTABLE_FLAGS)
     969                 :   NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
     970                 :                            ARRAY_SCRIPTABLE_FLAGS)
     971                 :   NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
     972                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     973                 :   NS_DEFINE_CLASSINFO_DATA(CSSStyleDeclaration, nsCSSStyleDeclSH,
     974                 :                            ARRAY_SCRIPTABLE_FLAGS)
     975                 :   NS_DEFINE_CLASSINFO_DATA(ROCSSPrimitiveValue, nsDOMGenericSH,
     976                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     977                 : 
     978                 :   // Range classes
     979                 :   NS_DEFINE_CLASSINFO_DATA(Range, nsDOMGenericSH,
     980                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     981                 :   NS_DEFINE_CLASSINFO_DATA(Selection, nsDOMGenericSH,
     982                 :                            DEFAULT_SCRIPTABLE_FLAGS)
     983                 : 
     984                 :   // XUL classes
     985                 : #ifdef MOZ_XUL
     986                 :   NS_DEFINE_CLASSINFO_DATA(XULDocument, nsDocumentSH,
     987                 :                            DOCUMENT_SCRIPTABLE_FLAGS)
     988                 :   NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH,
     989                 :                            ELEMENT_SCRIPTABLE_FLAGS)
     990                 :   NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
     991                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
     992                 : #endif
     993                 :   NS_DEFINE_CLASSINFO_DATA(XULControllers, nsNonDOMObjectSH,
     994                 :                            DEFAULT_SCRIPTABLE_FLAGS)
     995                 :   NS_DEFINE_CLASSINFO_DATA(BoxObject, nsDOMGenericSH,
     996                 :                            DEFAULT_SCRIPTABLE_FLAGS)
     997                 : #ifdef MOZ_XUL
     998                 :   NS_DEFINE_CLASSINFO_DATA(TreeSelection, nsDOMGenericSH,
     999                 :                            DEFAULT_SCRIPTABLE_FLAGS)
    1000                 :   NS_DEFINE_CLASSINFO_DATA(TreeContentView, nsDOMGenericSH,
    1001                 :                            DEFAULT_SCRIPTABLE_FLAGS)
    1002                 : #endif
    1003                 : 
    1004                 :   // Crypto classes
    1005                 :   NS_DEFINE_CLASSINFO_DATA(Crypto, nsDOMGenericSH,
    1006                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1007                 :   NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH,
    1008                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1009                 : 
    1010                 :   // DOM Traversal classes
    1011                 :   NS_DEFINE_CLASSINFO_DATA(TreeWalker, nsDOMGenericSH,
    1012                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1013                 : 
    1014                 :   // We are now trying to preserve binary compat in classinfo.  No
    1015                 :   // more putting things in those categories up there.  New entries
    1016                 :   // are to be added to the end of the list
    1017                 :   NS_DEFINE_CLASSINFO_DATA(CSSRect, nsDOMGenericSH,
    1018                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1019                 : 
    1020                 :   // DOM Chrome Window class.
    1021                 :   NS_DEFINE_CLASSINFO_DATA(ChromeWindow, nsWindowSH,
    1022                 :                            DEFAULT_SCRIPTABLE_FLAGS |
    1023                 :                            WINDOW_SCRIPTABLE_FLAGS)
    1024                 : 
    1025                 :   NS_DEFINE_CLASSINFO_DATA(CSSRGBColor, nsDOMGenericSH,
    1026                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1027                 : 
    1028                 :   NS_DEFINE_CLASSINFO_DATA(CSSValueList, nsCSSValueListSH,
    1029                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1030                 : 
    1031                 :   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(ContentList, HTMLCollection,
    1032                 :                                      nsDOMGenericSH,
    1033                 :                                      DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1034                 : 
    1035                 :   NS_DEFINE_CLASSINFO_DATA(XMLStylesheetProcessingInstruction, nsNodeSH,
    1036                 :                            NODE_SCRIPTABLE_FLAGS)
    1037                 : 
    1038                 :   NS_DEFINE_CLASSINFO_DATA(ImageDocument, nsHTMLDocumentSH,
    1039                 :                            DOCUMENT_SCRIPTABLE_FLAGS)
    1040                 : 
    1041                 : #ifdef MOZ_XUL
    1042                 :   NS_DEFINE_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
    1043                 :                            DEFAULT_SCRIPTABLE_FLAGS)
    1044                 : 
    1045                 :   NS_DEFINE_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
    1046                 :                            DEFAULT_SCRIPTABLE_FLAGS)
    1047                 : #endif
    1048                 : 
    1049                 :   NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
    1050                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1051                 : 
    1052                 : #ifdef MOZ_XUL
    1053                 :   NS_DEFINE_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
    1054                 :                            DEFAULT_SCRIPTABLE_FLAGS)
    1055                 : 
    1056                 :   NS_DEFINE_CLASSINFO_DATA(TreeColumns, nsTreeColumnsSH,
    1057                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1058                 : #endif
    1059                 : 
    1060                 :   NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
    1061                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1062                 : 
    1063                 :   NS_DEFINE_CLASSINFO_DATA(BeforeUnloadEvent, nsDOMGenericSH,
    1064                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1065                 : 
    1066                 :   // SVG document
    1067                 :   NS_DEFINE_CLASSINFO_DATA(SVGDocument, nsDocumentSH,
    1068                 :                            DOCUMENT_SCRIPTABLE_FLAGS)
    1069                 : 
    1070                 :   // SVG element classes
    1071                 :   NS_DEFINE_CLASSINFO_DATA(SVGAElement, nsElementSH,
    1072                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1073                 :   NS_DEFINE_CLASSINFO_DATA(SVGAltGlyphElement, nsElementSH,
    1074                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1075                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimateElement, nsElementSH,
    1076                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1077                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimateTransformElement, nsElementSH,
    1078                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1079                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimateMotionElement, nsElementSH,
    1080                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1081                 :   NS_DEFINE_CLASSINFO_DATA(SVGMpathElement, nsElementSH,
    1082                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1083                 :   NS_DEFINE_CLASSINFO_DATA(SVGSetElement, nsElementSH,
    1084                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1085                 :   NS_DEFINE_CLASSINFO_DATA(TimeEvent, nsDOMGenericSH,
    1086                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1087                 :   NS_DEFINE_CLASSINFO_DATA(SVGCircleElement, nsElementSH,
    1088                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1089                 :   NS_DEFINE_CLASSINFO_DATA(SVGClipPathElement, nsElementSH,
    1090                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1091                 :   NS_DEFINE_CLASSINFO_DATA(SVGDefsElement, nsElementSH,
    1092                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1093                 :   NS_DEFINE_CLASSINFO_DATA(SVGDescElement, nsElementSH,
    1094                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1095                 :   NS_DEFINE_CLASSINFO_DATA(SVGEllipseElement, nsElementSH,
    1096                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1097                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEBlendElement, nsElementSH,
    1098                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1099                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEColorMatrixElement, nsElementSH,
    1100                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1101                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEComponentTransferElement, nsElementSH,
    1102                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1103                 :   NS_DEFINE_CLASSINFO_DATA(SVGFECompositeElement, nsElementSH,
    1104                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1105                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH,
    1106                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1107                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH,
    1108                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1109                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH,
    1110                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1111                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEDistantLightElement, nsElementSH,
    1112                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1113                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEFloodElement, nsElementSH,
    1114                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1115                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEFuncAElement, nsElementSH,
    1116                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1117                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEFuncBElement, nsElementSH,
    1118                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1119                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEFuncGElement, nsElementSH,
    1120                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1121                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEFuncRElement, nsElementSH,
    1122                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1123                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEGaussianBlurElement, nsElementSH,
    1124                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1125                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEImageElement, nsElementSH,
    1126                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1127                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEMergeElement, nsElementSH,
    1128                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1129                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEMergeNodeElement, nsElementSH,
    1130                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1131                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH,
    1132                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1133                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEOffsetElement, nsElementSH,
    1134                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1135                 :   NS_DEFINE_CLASSINFO_DATA(SVGFEPointLightElement, nsElementSH,
    1136                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1137                 :   NS_DEFINE_CLASSINFO_DATA(SVGFESpecularLightingElement, nsElementSH,
    1138                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1139                 :   NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH,
    1140                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1141                 :   NS_DEFINE_CLASSINFO_DATA(SVGFETileElement, nsElementSH,
    1142                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1143                 :   NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH,
    1144                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1145                 :   NS_DEFINE_CLASSINFO_DATA(SVGFilterElement, nsElementSH,
    1146                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1147                 :   NS_DEFINE_CLASSINFO_DATA(SVGGElement, nsElementSH,
    1148                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1149                 :   NS_DEFINE_CLASSINFO_DATA(SVGImageElement, nsElementSH,
    1150                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1151                 :   NS_DEFINE_CLASSINFO_DATA(SVGLinearGradientElement, nsElementSH,
    1152                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1153                 :   NS_DEFINE_CLASSINFO_DATA(SVGLineElement, nsElementSH,
    1154                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1155                 :   NS_DEFINE_CLASSINFO_DATA(SVGMarkerElement, nsElementSH,
    1156                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1157                 :   NS_DEFINE_CLASSINFO_DATA(SVGMaskElement, nsElementSH,
    1158                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1159                 :   NS_DEFINE_CLASSINFO_DATA(SVGMetadataElement, nsElementSH,
    1160                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1161                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathElement, nsElementSH,
    1162                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1163                 :   NS_DEFINE_CLASSINFO_DATA(SVGPatternElement, nsElementSH,
    1164                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1165                 :   NS_DEFINE_CLASSINFO_DATA(SVGPolygonElement, nsElementSH,
    1166                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1167                 :   NS_DEFINE_CLASSINFO_DATA(SVGPolylineElement, nsElementSH,
    1168                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1169                 :   NS_DEFINE_CLASSINFO_DATA(SVGRadialGradientElement, nsElementSH,
    1170                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1171                 :   NS_DEFINE_CLASSINFO_DATA(SVGRectElement, nsElementSH,
    1172                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1173                 :   NS_DEFINE_CLASSINFO_DATA(SVGScriptElement, nsElementSH,
    1174                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1175                 :   NS_DEFINE_CLASSINFO_DATA(SVGStopElement, nsElementSH,
    1176                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1177                 :   NS_DEFINE_CLASSINFO_DATA(SVGStyleElement, nsElementSH,
    1178                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1179                 :   NS_DEFINE_CLASSINFO_DATA(SVGSVGElement, nsElementSH,
    1180                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1181                 :   NS_DEFINE_CLASSINFO_DATA(SVGSwitchElement, nsElementSH,
    1182                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1183                 :   NS_DEFINE_CLASSINFO_DATA(SVGSymbolElement, nsElementSH,
    1184                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1185                 :   NS_DEFINE_CLASSINFO_DATA(SVGTextElement, nsElementSH,
    1186                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1187                 :   NS_DEFINE_CLASSINFO_DATA(SVGTextPathElement, nsElementSH,
    1188                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1189                 :   NS_DEFINE_CLASSINFO_DATA(SVGTitleElement, nsElementSH,
    1190                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1191                 :   NS_DEFINE_CLASSINFO_DATA(SVGTSpanElement, nsElementSH,
    1192                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1193                 :   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(SVGUnknownElement, SVGElement, nsElementSH,
    1194                 :                                      ELEMENT_SCRIPTABLE_FLAGS)
    1195                 :   NS_DEFINE_CLASSINFO_DATA(SVGUseElement, nsElementSH,
    1196                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1197                 : 
    1198                 :   // other SVG classes
    1199                 :   NS_DEFINE_CLASSINFO_DATA(SVGAngle, nsDOMGenericSH,
    1200                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1201                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedAngle, nsDOMGenericSH,
    1202                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1203                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedBoolean, nsDOMGenericSH,
    1204                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1205                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedEnumeration, nsDOMGenericSH,
    1206                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1207                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH,
    1208                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1209                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLength, nsDOMGenericSH,
    1210                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1211                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLengthList, nsDOMGenericSH,
    1212                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1213                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH,
    1214                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)    
    1215                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumberList, nsDOMGenericSH,
    1216                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)    
    1217                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedPreserveAspectRatio, nsDOMGenericSH,
    1218                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1219                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedRect, nsDOMGenericSH,
    1220                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1221                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedString, nsDOMGenericSH,
    1222                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1223                 :   NS_DEFINE_CLASSINFO_DATA(SVGAnimatedTransformList, nsDOMGenericSH,
    1224                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1225                 :   NS_DEFINE_CLASSINFO_DATA(SVGEvent, nsDOMGenericSH,
    1226                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1227                 :   NS_DEFINE_CLASSINFO_DATA(SVGException, nsDOMGenericSH,
    1228                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1229                 :   NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
    1230                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1231                 :   NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsSVGLengthListSH,
    1232                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1233                 :   NS_DEFINE_CLASSINFO_DATA(SVGMatrix, nsDOMGenericSH,
    1234                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1235                 :   NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
    1236                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1237                 :   NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsSVGNumberListSH,
    1238                 :                            ARRAY_SCRIPTABLE_FLAGS)    
    1239                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcAbs, nsDOMGenericSH,
    1240                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1241                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcRel, nsDOMGenericSH,
    1242                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1243                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegClosePath, nsDOMGenericSH,
    1244                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1245                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicAbs, nsDOMGenericSH,
    1246                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1247                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicRel, nsDOMGenericSH,
    1248                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1249                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothAbs, nsDOMGenericSH,
    1250                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1251                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothRel, nsDOMGenericSH,
    1252                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1253                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticAbs, nsDOMGenericSH,
    1254                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1255                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticRel, nsDOMGenericSH,
    1256                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1257                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothAbs, nsDOMGenericSH,
    1258                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1259                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothRel, nsDOMGenericSH,
    1260                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1261                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoAbs, nsDOMGenericSH,
    1262                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1263                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalAbs, nsDOMGenericSH,
    1264                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1265                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalRel, nsDOMGenericSH,
    1266                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1267                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoRel, nsDOMGenericSH,
    1268                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1269                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalAbs, nsDOMGenericSH,
    1270                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1271                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalRel, nsDOMGenericSH,
    1272                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1273                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsSVGPathSegListSH,
    1274                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1275                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoAbs, nsDOMGenericSH,
    1276                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1277                 :   NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoRel, nsDOMGenericSH,
    1278                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1279                 :   NS_DEFINE_CLASSINFO_DATA(SVGPoint, nsDOMGenericSH,
    1280                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1281                 :   NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsSVGPointListSH,
    1282                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1283                 :   NS_DEFINE_CLASSINFO_DATA(SVGPreserveAspectRatio, nsDOMGenericSH,
    1284                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1285                 :   NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH,
    1286                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1287                 :   NS_DEFINE_CLASSINFO_DATA(SVGStringList, nsSVGStringListSH,
    1288                 :                            ARRAY_SCRIPTABLE_FLAGS)    
    1289                 :   NS_DEFINE_CLASSINFO_DATA(SVGTransform, nsDOMGenericSH,
    1290                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1291                 :   NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsSVGTransformListSH,
    1292                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1293                 :   NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
    1294                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1295                 : 
    1296                 :   NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsElementSH,
    1297                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1298                 :   NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContext2D, nsDOMGenericSH,
    1299                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1300                 :   NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
    1301                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1302                 :   NS_DEFINE_CLASSINFO_DATA(CanvasPattern, nsDOMGenericSH,
    1303                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1304                 :   NS_DEFINE_CLASSINFO_DATA(TextMetrics, nsDOMGenericSH,
    1305                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1306                 : 
    1307                 :   NS_DEFINE_CLASSINFO_DATA(SmartCardEvent, nsDOMGenericSH,
    1308                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1309                 :   NS_DEFINE_CLASSINFO_DATA(PageTransitionEvent, nsDOMGenericSH,
    1310                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1311                 :   NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH,
    1312                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1313                 : 
    1314                 :   NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
    1315                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1316                 : 
    1317                 :   NS_DEFINE_CLASSINFO_DATA(XPathEvaluator, nsDOMGenericSH,
    1318                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1319                 :   NS_DEFINE_CLASSINFO_DATA(XPathException, nsDOMGenericSH,
    1320                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1321                 :   NS_DEFINE_CLASSINFO_DATA(XPathExpression, nsDOMGenericSH,
    1322                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1323                 :   NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
    1324                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1325                 :   NS_DEFINE_CLASSINFO_DATA(XPathResult, nsDOMGenericSH,
    1326                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1327                 : 
    1328                 :   // WhatWG Storage
    1329                 : 
    1330                 :   // mrbkap says we don't need WANT_ADDPROPERTY on Storage objects
    1331                 :   // since a call to addProperty() is always followed by a call to
    1332                 :   // setProperty(), except in the case when a getter or setter is set
    1333                 :   // for a property. But we don't care about getters or setters here.
    1334                 :   NS_DEFINE_CLASSINFO_DATA(StorageObsolete, nsStorageSH,
    1335                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS |
    1336                 :                            nsIXPCScriptable::WANT_NEWRESOLVE |
    1337                 :                            nsIXPCScriptable::WANT_GETPROPERTY |
    1338                 :                            nsIXPCScriptable::WANT_SETPROPERTY |
    1339                 :                            nsIXPCScriptable::WANT_DELPROPERTY |
    1340                 :                            nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
    1341                 :                            nsIXPCScriptable::WANT_NEWENUMERATE)
    1342                 : 
    1343                 :   NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
    1344                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS |
    1345                 :                            nsIXPCScriptable::WANT_NEWRESOLVE |
    1346                 :                            nsIXPCScriptable::WANT_GETPROPERTY |
    1347                 :                            nsIXPCScriptable::WANT_SETPROPERTY |
    1348                 :                            nsIXPCScriptable::WANT_DELPROPERTY |
    1349                 :                            nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
    1350                 :                            nsIXPCScriptable::WANT_NEWENUMERATE)
    1351                 :   NS_DEFINE_CLASSINFO_DATA(StorageList, nsStorageListSH,
    1352                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1353                 :   NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
    1354                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1355                 :   NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
    1356                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1357                 :   NS_DEFINE_CLASSINFO_DATA(StorageEventObsolete, nsDOMGenericSH,
    1358                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1359                 : 
    1360                 :   NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
    1361                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1362                 :   NS_DEFINE_CLASSINFO_DATA(XMLSerializer, nsDOMGenericSH,
    1363                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1364                 : 
    1365                 :   NS_DEFINE_CLASSINFO_DATA(XMLHttpProgressEvent, nsDOMGenericSH,
    1366                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1367                 :   NS_DEFINE_CLASSINFO_DATA(XMLHttpRequest, nsEventTargetSH,
    1368                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1369                 : 
    1370                 :   NS_DEFINE_CLASSINFO_DATA(EventSource, nsEventTargetSH,
    1371                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1372                 : 
    1373                 :   NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
    1374                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1375                 :   NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsClientRectListSH,
    1376                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1377                 : 
    1378                 :   NS_DEFINE_CLASSINFO_DATA(SVGForeignObjectElement, nsElementSH,
    1379                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1380                 : 
    1381                 :   NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsDOMGenericSH,
    1382                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1383                 : 
    1384                 :   NS_DEFINE_CLASSINFO_DATA(CommandEvent, nsDOMGenericSH,
    1385                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1386                 :   NS_DEFINE_CLASSINFO_DATA(OfflineResourceList, nsOfflineResourceListSH,
    1387                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1388                 : 
    1389                 :   NS_DEFINE_CLASSINFO_DATA(FileList, nsFileListSH,
    1390                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1391                 :   NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
    1392                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1393                 :   NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
    1394                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1395                 :   NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
    1396                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1397                 :   NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
    1398                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1399                 :   NS_DEFINE_CLASSINFO_DATA(MozURLProperty, nsDOMGenericSH,
    1400                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1401                 :   NS_DEFINE_CLASSINFO_DATA(MozBlobBuilder, nsDOMGenericSH,
    1402                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1403                 : 
    1404                 :   NS_DEFINE_CLASSINFO_DATA(DOMStringMap, nsDOMStringMapSH,
    1405                 :                            DOMSTRINGMAP_SCRIPTABLE_FLAGS)
    1406                 : 
    1407                 :   NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
    1408                 :                            DEFAULT_SCRIPTABLE_FLAGS |
    1409                 :                            WINDOW_SCRIPTABLE_FLAGS)
    1410                 : 
    1411                 :   NS_DEFINE_CLASSINFO_DATA(DataContainerEvent, nsDOMGenericSH,
    1412                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1413                 : 
    1414                 :   NS_DEFINE_CLASSINFO_DATA(MessageEvent, nsDOMGenericSH,
    1415                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1416                 : 
    1417                 :   NS_DEFINE_CLASSINFO_DATA(GeoGeolocation, nsDOMGenericSH,
    1418                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1419                 :   
    1420                 :   NS_DEFINE_CLASSINFO_DATA(GeoPosition, nsDOMGenericSH,
    1421                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS) 
    1422                 :   
    1423                 :   NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsDOMGenericSH,
    1424                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1425                 : 
    1426                 :   NS_DEFINE_CLASSINFO_DATA(GeoPositionAddress, nsDOMGenericSH,
    1427                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1428                 : 
    1429                 :   NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
    1430                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1431                 : 
    1432                 :   NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
    1433                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1434                 : 
    1435                 :   NS_DEFINE_CLASSINFO_DATA(MozPowerManager, nsDOMGenericSH,
    1436                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1437                 : 
    1438                 :   NS_DEFINE_CLASSINFO_DATA(MozWakeLock, nsDOMGenericSH,
    1439                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1440                 : 
    1441                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsManager, nsDOMGenericSH,
    1442                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1443                 : 
    1444                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
    1445                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1446                 : 
    1447                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsEvent, nsDOMGenericSH,
    1448                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1449                 : 
    1450                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsRequest, nsDOMGenericSH,
    1451                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1452                 : 
    1453                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
    1454                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1455                 : 
    1456                 :   NS_DEFINE_CLASSINFO_DATA(MozSmsCursor, nsDOMGenericSH,
    1457                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1458                 : 
    1459                 :   NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
    1460                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1461                 : 
    1462                 :   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
    1463                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1464                 :   NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
    1465                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1466                 : 
    1467                 : #if defined(MOZ_MEDIA)
    1468                 :   NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
    1469                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1470                 :   NS_DEFINE_CLASSINFO_DATA(HTMLSourceElement, nsElementSH,
    1471                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1472                 :   NS_DEFINE_CLASSINFO_DATA(MediaError, nsDOMGenericSH,
    1473                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1474                 :   NS_DEFINE_CLASSINFO_DATA(HTMLAudioElement, nsElementSH,
    1475                 :                            ELEMENT_SCRIPTABLE_FLAGS)
    1476                 :   NS_DEFINE_CLASSINFO_DATA(TimeRanges, nsDOMGenericSH,
    1477                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1478                 : #endif
    1479                 : 
    1480                 :   NS_DEFINE_CLASSINFO_DATA(ProgressEvent, nsDOMGenericSH,
    1481                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1482                 : 
    1483                 :   NS_DEFINE_CLASSINFO_DATA(XMLHttpRequestUpload, nsEventTargetSH,
    1484                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1485                 : 
    1486                 :   // DOM Traversal NodeIterator class  
    1487                 :   NS_DEFINE_CLASSINFO_DATA(NodeIterator, nsDOMGenericSH,
    1488                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1489                 : 
    1490                 :   // data transfer for drag and drop
    1491                 :   NS_DEFINE_CLASSINFO_DATA(DataTransfer, nsDOMGenericSH,
    1492                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1493                 : 
    1494                 :   NS_DEFINE_CLASSINFO_DATA(NotifyPaintEvent, nsDOMGenericSH,
    1495                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1496                 : 
    1497                 :   NS_DEFINE_CLASSINFO_DATA(NotifyAudioAvailableEvent, nsDOMGenericSH,
    1498                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1499                 : 
    1500                 :   NS_DEFINE_CLASSINFO_DATA(SimpleGestureEvent, nsDOMGenericSH,
    1501                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1502                 : 
    1503                 :   NS_DEFINE_CLASSINFO_DATA(MozTouchEvent, nsDOMGenericSH,
    1504                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1505                 :   NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
    1506                 :                                      ELEMENT_SCRIPTABLE_FLAGS)
    1507                 : 
    1508                 :   NS_DEFINE_CLASSINFO_DATA(WebGLRenderingContext, nsWebGLViewportHandlerSH,
    1509                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1510                 :   NS_DEFINE_CLASSINFO_DATA(WebGLBuffer, nsDOMGenericSH,
    1511                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1512                 :   NS_DEFINE_CLASSINFO_DATA(WebGLTexture, nsDOMGenericSH,
    1513                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1514                 :   NS_DEFINE_CLASSINFO_DATA(WebGLProgram, nsDOMGenericSH,
    1515                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1516                 :   NS_DEFINE_CLASSINFO_DATA(WebGLShader, nsDOMGenericSH,
    1517                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1518                 :   NS_DEFINE_CLASSINFO_DATA(WebGLFramebuffer, nsDOMGenericSH,
    1519                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1520                 :   NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
    1521                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1522                 :   NS_DEFINE_CLASSINFO_DATA(WebGLUniformLocation, nsDOMGenericSH,
    1523                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1524                 :   NS_DEFINE_CLASSINFO_DATA(WebGLShaderPrecisionFormat, nsDOMGenericSH,
    1525                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1526                 :   NS_DEFINE_CLASSINFO_DATA(WebGLActiveInfo, nsDOMGenericSH,
    1527                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1528                 :   NS_DEFINE_CLASSINFO_DATA(WebGLExtension, nsDOMGenericSH,
    1529                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1530                 :   NS_DEFINE_CLASSINFO_DATA(WebGLExtensionStandardDerivatives, nsDOMGenericSH,
    1531                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1532                 :   NS_DEFINE_CLASSINFO_DATA(WebGLExtensionTextureFilterAnisotropic, nsDOMGenericSH,
    1533                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1534                 :   NS_DEFINE_CLASSINFO_DATA(WebGLExtensionLoseContext, nsDOMGenericSH,
    1535                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1536                 : 
    1537                 :   NS_DEFINE_CLASSINFO_DATA(PaintRequest, nsDOMGenericSH,
    1538                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1539                 :   NS_DEFINE_CLASSINFO_DATA(PaintRequestList, nsPaintRequestListSH,
    1540                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1541                 : 
    1542                 :   NS_DEFINE_CLASSINFO_DATA(ScrollAreaEvent, nsDOMGenericSH,
    1543                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1544                 :   NS_DEFINE_CLASSINFO_DATA(PopStateEvent, nsDOMGenericSH,
    1545                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1546                 :   NS_DEFINE_CLASSINFO_DATA(HashChangeEvent, nsDOMGenericSH,
    1547                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1548                 :   NS_DEFINE_CLASSINFO_DATA(EventListenerInfo, nsDOMGenericSH,
    1549                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1550                 :   NS_DEFINE_CLASSINFO_DATA(TransitionEvent, nsDOMGenericSH,
    1551                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1552                 :   NS_DEFINE_CLASSINFO_DATA(AnimationEvent, nsDOMGenericSH,
    1553                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1554                 :   NS_DEFINE_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
    1555                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::IS_GLOBAL_OBJECT)
    1556                 : 
    1557                 :   NS_DEFINE_CLASSINFO_DATA(FormData, nsDOMGenericSH,
    1558                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1559                 : 
    1560                 :   NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
    1561                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1562                 :   NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
    1563                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1564                 : 
    1565                 :   NS_DEFINE_CLASSINFO_DATA(WebSocket, nsEventTargetSH,
    1566                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1567                 : 
    1568                 :   NS_DEFINE_CLASSINFO_DATA(CloseEvent, nsDOMGenericSH,
    1569                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1570                 : 
    1571                 :   NS_DEFINE_CLASSINFO_DATA(IDBFactory, nsDOMGenericSH,
    1572                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1573                 :   NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
    1574                 :                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
    1575                 :   NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
    1576                 :                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
    1577                 :   NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
    1578                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1579                 :   NS_DEFINE_CLASSINFO_DATA(IDBTransaction, IDBEventTargetSH,
    1580                 :                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
    1581                 :   NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
    1582                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1583                 :   NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
    1584                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1585                 :   NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
    1586                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1587                 :   NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
    1588                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1589                 :   NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeEvent, nsDOMGenericSH,
    1590                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1591                 :   NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
    1592                 :                            IDBEVENTTARGET_SCRIPTABLE_FLAGS)
    1593                 :   NS_DEFINE_CLASSINFO_DATA(IDBDatabaseException, nsDOMGenericSH,
    1594                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1595                 : 
    1596                 :   NS_DEFINE_CLASSINFO_DATA(Touch, nsDOMGenericSH,
    1597                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1598                 :   NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMTouchListSH,
    1599                 :                            ARRAY_SCRIPTABLE_FLAGS)
    1600                 :   NS_DEFINE_CLASSINFO_DATA(TouchEvent, nsDOMGenericSH,
    1601                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1602                 : 
    1603                 :   NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframeRule, nsDOMGenericSH,
    1604                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1605                 :   NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframesRule, nsDOMGenericSH,
    1606                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1607                 : 
    1608                 :   NS_DEFINE_CLASSINFO_DATA(MediaQueryList, nsDOMGenericSH,
    1609                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1610                 :   NS_DEFINE_CLASSINFO_DATA(CustomEvent, nsDOMGenericSH,
    1611                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1612                 : 
    1613                 : #ifdef MOZ_B2G_RIL
    1614                 :   NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
    1615                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1616                 :   NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
    1617                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1618                 :   NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
    1619                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1620                 : #endif
    1621                 : 
    1622                 : #ifdef MOZ_B2G_BT
    1623                 :   NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
    1624                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1625                 : #endif
    1626                 : 
    1627                 :   NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH,
    1628                 :                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
    1629                 : 
    1630                 :   NS_DEFINE_CLASSINFO_DATA(DOMRequest, nsEventTargetSH,
    1631                 :                            EVENTTARGET_SCRIPTABLE_FLAGS)
    1632                 : };
    1633                 : 
    1634                 : // Objects that should be constructable through |new Name();|
    1635                 : struct nsContractIDMapData
    1636                 : {
    1637                 :   PRInt32 mDOMClassInfoID;
    1638                 :   const char *mContractID;
    1639                 : };
    1640                 : 
    1641                 : #define NS_DEFINE_CONSTRUCTOR_DATA(_class, _contract_id)                      \
    1642                 :   { eDOMClassInfo_##_class##_id, _contract_id },
    1643                 : 
    1644                 : static const nsContractIDMapData kConstructorMap[] =
    1645                 : {
    1646                 :   NS_DEFINE_CONSTRUCTOR_DATA(DOMParser, NS_DOMPARSER_CONTRACTID)
    1647                 :   NS_DEFINE_CONSTRUCTOR_DATA(FileReader, NS_FILEREADER_CONTRACTID)
    1648                 :   NS_DEFINE_CONSTRUCTOR_DATA(FormData, NS_FORMDATA_CONTRACTID)
    1649                 :   NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
    1650                 :   NS_DEFINE_CONSTRUCTOR_DATA(XMLHttpRequest, NS_XMLHTTPREQUEST_CONTRACTID)
    1651                 :   NS_DEFINE_CONSTRUCTOR_DATA(WebSocket, NS_WEBSOCKET_CONTRACTID)
    1652                 :   NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
    1653                 :   NS_DEFINE_CONSTRUCTOR_DATA(XSLTProcessor,
    1654                 :                              "@mozilla.org/document-transformer;1?type=xslt")
    1655                 :   NS_DEFINE_CONSTRUCTOR_DATA(EventSource, NS_EVENTSOURCE_CONTRACTID)
    1656                 : };
    1657                 : 
    1658                 : #define NS_DEFINE_EVENT_CTOR(_class)                        \
    1659                 :   nsresult                                                  \
    1660                 :   NS_DOM##_class##Ctor(nsISupports** aInstancePtrResult)    \
    1661                 :   {                                                         \
    1662                 :     nsIDOMEvent* e = nsnull;                                \
    1663                 :     nsresult rv = NS_NewDOM##_class(&e, nsnull, nsnull);    \
    1664                 :     *aInstancePtrResult = e;                                \
    1665                 :     return rv;                                              \
    1666                 :   }
    1667                 : 
    1668               0 : NS_DEFINE_EVENT_CTOR(Event)
    1669               0 : NS_DEFINE_EVENT_CTOR(CustomEvent)
    1670               0 : NS_DEFINE_EVENT_CTOR(PopStateEvent)
    1671               0 : NS_DEFINE_EVENT_CTOR(HashChangeEvent)
    1672               0 : NS_DEFINE_EVENT_CTOR(PageTransitionEvent)
    1673               0 : NS_DEFINE_EVENT_CTOR(CloseEvent)
    1674               0 : NS_DEFINE_EVENT_CTOR(UIEvent)
    1675               0 : NS_DEFINE_EVENT_CTOR(MouseEvent)
    1676                 : nsresult
    1677               0 : NS_DOMStorageEventCtor(nsISupports** aInstancePtrResult)
    1678                 : {
    1679               0 :   nsDOMStorageEvent* e = new nsDOMStorageEvent();
    1680               0 :   return CallQueryInterface(e, aInstancePtrResult);
    1681                 : }
    1682                 : 
    1683                 : struct nsConstructorFuncMapData
    1684                 : {
    1685                 :   PRInt32 mDOMClassInfoID;
    1686                 :   nsDOMConstructorFunc mConstructorFunc;
    1687                 : };
    1688                 : 
    1689                 : #define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func)                        \
    1690                 :   { eDOMClassInfo_##_class##_id, _func },
    1691                 : 
    1692                 : #define NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(_class)   \
    1693                 :   { eDOMClassInfo_##_class##_id, NS_DOM##_class##Ctor },
    1694                 : 
    1695                 : static const nsConstructorFuncMapData kConstructorFuncMap[] =
    1696                 : {
    1697                 :   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, nsDOMMultipartFile::NewBlob)
    1698                 :   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, nsDOMFileFile::NewFile)
    1699                 :   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozBlobBuilder, NS_NewBlobBuilder)
    1700                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
    1701                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
    1702                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PopStateEvent)
    1703                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(HashChangeEvent)
    1704                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PageTransitionEvent)
    1705                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CloseEvent)
    1706                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UIEvent)
    1707                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MouseEvent)
    1708                 :   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(StorageEvent)
    1709                 :   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter)
    1710                 : };
    1711                 : 
    1712                 : nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
    1713                 : nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
    1714                 : bool nsDOMClassInfo::sIsInitialized = false;
    1715                 : bool nsDOMClassInfo::sDisableDocumentAllSupport = false;
    1716                 : bool nsDOMClassInfo::sDisableGlobalScopePollutionSupport = false;
    1717                 : 
    1718                 : 
    1719            1464 : jsid nsDOMClassInfo::sParent_id          = JSID_VOID;
    1720            1464 : jsid nsDOMClassInfo::sScrollbars_id      = JSID_VOID;
    1721            1464 : jsid nsDOMClassInfo::sLocation_id        = JSID_VOID;
    1722            1464 : jsid nsDOMClassInfo::sConstructor_id     = JSID_VOID;
    1723            1464 : jsid nsDOMClassInfo::s_content_id        = JSID_VOID;
    1724            1464 : jsid nsDOMClassInfo::sContent_id         = JSID_VOID;
    1725            1464 : jsid nsDOMClassInfo::sMenubar_id         = JSID_VOID;
    1726            1464 : jsid nsDOMClassInfo::sToolbar_id         = JSID_VOID;
    1727            1464 : jsid nsDOMClassInfo::sLocationbar_id     = JSID_VOID;
    1728            1464 : jsid nsDOMClassInfo::sPersonalbar_id     = JSID_VOID;
    1729            1464 : jsid nsDOMClassInfo::sStatusbar_id       = JSID_VOID;
    1730            1464 : jsid nsDOMClassInfo::sDialogArguments_id = JSID_VOID;
    1731            1464 : jsid nsDOMClassInfo::sControllers_id     = JSID_VOID;
    1732            1464 : jsid nsDOMClassInfo::sLength_id          = JSID_VOID;
    1733            1464 : jsid nsDOMClassInfo::sInnerHeight_id     = JSID_VOID;
    1734            1464 : jsid nsDOMClassInfo::sInnerWidth_id      = JSID_VOID;
    1735            1464 : jsid nsDOMClassInfo::sOuterHeight_id     = JSID_VOID;
    1736            1464 : jsid nsDOMClassInfo::sOuterWidth_id      = JSID_VOID;
    1737            1464 : jsid nsDOMClassInfo::sScreenX_id         = JSID_VOID;
    1738            1464 : jsid nsDOMClassInfo::sScreenY_id         = JSID_VOID;
    1739            1464 : jsid nsDOMClassInfo::sStatus_id          = JSID_VOID;
    1740            1464 : jsid nsDOMClassInfo::sName_id            = JSID_VOID;
    1741            1464 : jsid nsDOMClassInfo::sScrollX_id         = JSID_VOID;
    1742            1464 : jsid nsDOMClassInfo::sScrollY_id         = JSID_VOID;
    1743            1464 : jsid nsDOMClassInfo::sScrollMaxX_id      = JSID_VOID;
    1744            1464 : jsid nsDOMClassInfo::sScrollMaxY_id      = JSID_VOID;
    1745            1464 : jsid nsDOMClassInfo::sItem_id            = JSID_VOID;
    1746            1464 : jsid nsDOMClassInfo::sNamedItem_id       = JSID_VOID;
    1747            1464 : jsid nsDOMClassInfo::sEnumerate_id       = JSID_VOID;
    1748            1464 : jsid nsDOMClassInfo::sNavigator_id       = JSID_VOID;
    1749            1464 : jsid nsDOMClassInfo::sDocument_id        = JSID_VOID;
    1750            1464 : jsid nsDOMClassInfo::sFrames_id          = JSID_VOID;
    1751            1464 : jsid nsDOMClassInfo::sSelf_id            = JSID_VOID;
    1752            1464 : jsid nsDOMClassInfo::sOpener_id          = JSID_VOID;
    1753            1464 : jsid nsDOMClassInfo::sAll_id             = JSID_VOID;
    1754            1464 : jsid nsDOMClassInfo::sTags_id            = JSID_VOID;
    1755            1464 : jsid nsDOMClassInfo::sAddEventListener_id= JSID_VOID;
    1756            1464 : jsid nsDOMClassInfo::sBaseURIObject_id   = JSID_VOID;
    1757            1464 : jsid nsDOMClassInfo::sNodePrincipal_id   = JSID_VOID;
    1758            1464 : jsid nsDOMClassInfo::sDocumentURIObject_id=JSID_VOID;
    1759            1464 : jsid nsDOMClassInfo::sJava_id            = JSID_VOID;
    1760            1464 : jsid nsDOMClassInfo::sPackages_id        = JSID_VOID;
    1761            1464 : jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
    1762            1464 : jsid nsDOMClassInfo::sURL_id             = JSID_VOID;
    1763            1464 : jsid nsDOMClassInfo::sKeyPath_id         = JSID_VOID;
    1764            1464 : jsid nsDOMClassInfo::sAutoIncrement_id   = JSID_VOID;
    1765            1464 : jsid nsDOMClassInfo::sUnique_id          = JSID_VOID;
    1766            1464 : jsid nsDOMClassInfo::sMultiEntry_id      = JSID_VOID;
    1767            1464 : jsid nsDOMClassInfo::sOnload_id          = JSID_VOID;
    1768            1464 : jsid nsDOMClassInfo::sOnerror_id         = JSID_VOID;
    1769                 : 
    1770                 : static const JSClass *sObjectClass = nsnull;
    1771                 : 
    1772                 : /**
    1773                 :  * Set our JSClass pointer for the Object class
    1774                 :  */
    1775                 : static void
    1776             306 : FindObjectClass(JSObject* aGlobalObject)
    1777                 : {
    1778             306 :   NS_ASSERTION(!sObjectClass,
    1779                 :                "Double set of sObjectClass");
    1780             306 :   JSObject *obj, *proto = aGlobalObject;
    1781             612 :   do {
    1782             612 :     obj = proto;
    1783             612 :     proto = js::GetObjectProto(obj);
    1784                 :   } while (proto);
    1785                 : 
    1786             306 :   sObjectClass = js::GetObjectJSClass(obj);
    1787             306 : }
    1788                 : 
    1789                 : static void
    1790               0 : PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
    1791                 : {
    1792                 :   nsCOMPtr<nsIStringBundleService> stringService =
    1793               0 :     mozilla::services::GetStringBundleService();
    1794               0 :   if (!stringService) {
    1795                 :     return;
    1796                 :   }
    1797                 : 
    1798               0 :   nsCOMPtr<nsIStringBundle> bundle;
    1799               0 :   stringService->CreateBundle(kDOMStringBundleURL, getter_AddRefs(bundle));
    1800               0 :   if (!bundle) {
    1801                 :     return;
    1802                 :   }
    1803                 : 
    1804               0 :   nsXPIDLString msg;
    1805               0 :   bundle->GetStringFromName(NS_ConvertASCIItoUTF16(stringBundleProperty).get(),
    1806               0 :                             getter_Copies(msg));
    1807                 : 
    1808               0 :   if (msg.IsEmpty()) {
    1809               0 :     NS_ERROR("Failed to get strings from dom.properties!");
    1810                 :     return;
    1811                 :   }
    1812                 : 
    1813                 :   nsCOMPtr<nsIConsoleService> consoleService
    1814               0 :     (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
    1815               0 :   if (!consoleService) {
    1816                 :     return;
    1817                 :   }
    1818                 : 
    1819                 :   nsCOMPtr<nsIScriptError> scriptError =
    1820               0 :     do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
    1821               0 :   if (!scriptError) {
    1822                 :     return;
    1823                 :   }
    1824                 : 
    1825               0 :   JSStackFrame *fp, *iterator = nsnull;
    1826               0 :   fp = ::JS_FrameIterator(cx, &iterator);
    1827               0 :   PRUint32 lineno = 0;
    1828               0 :   nsAutoString sourcefile;
    1829               0 :   if (fp) {
    1830               0 :     JSScript* script = ::JS_GetFrameScript(cx, fp);
    1831               0 :     if (script) {
    1832               0 :       const char* filename = ::JS_GetScriptFilename(cx, script);
    1833               0 :       if (filename) {
    1834               0 :         CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
    1835                 :       }
    1836               0 :       jsbytecode* pc = ::JS_GetFramePC(cx, fp);
    1837               0 :       if (pc) {
    1838               0 :         lineno = ::JS_PCToLineNumber(cx, script, pc);
    1839                 :       }
    1840                 :     }
    1841                 :   }
    1842                 : 
    1843               0 :   nsresult rv = scriptError->InitWithWindowID(msg.get(),
    1844                 :                                               sourcefile.get(),
    1845               0 :                                               EmptyString().get(),
    1846                 :                                               lineno,
    1847                 :                                               0, // column for error is not available
    1848                 :                                               nsIScriptError::warningFlag,
    1849                 :                                               "DOM:HTML",
    1850               0 :                                               nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
    1851                 : 
    1852               0 :   if (NS_SUCCEEDED(rv)) {
    1853               0 :     consoleService->LogMessage(scriptError);
    1854                 :   }
    1855                 : }
    1856                 : 
    1857                 : static inline JSString *
    1858              80 : IdToString(JSContext *cx, jsid id)
    1859                 : {
    1860              80 :   if (JSID_IS_STRING(id))
    1861              80 :     return JSID_TO_STRING(id);
    1862                 :   jsval idval;
    1863               0 :   if (!::JS_IdToValue(cx, id, &idval))
    1864               0 :     return nsnull;
    1865               0 :   return JS_ValueToString(cx, idval);
    1866                 : }
    1867                 : 
    1868                 : static inline nsresult
    1869           15161 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
    1870                 :            nsWrapperCache *cache, const nsIID* aIID, jsval *vp,
    1871                 :            nsIXPConnectJSObjectHolder** aHolder, bool aAllowWrapping)
    1872                 : {
    1873           15161 :   if (!native) {
    1874               0 :     NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!");
    1875                 : 
    1876               0 :     *vp = JSVAL_NULL;
    1877                 : 
    1878               0 :     return NS_OK;
    1879                 :   }
    1880                 : 
    1881           15161 :   JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
    1882           15161 :   if (wrapper) {
    1883           15156 :     return NS_OK;
    1884                 :   }
    1885                 : 
    1886               5 :   return nsDOMClassInfo::XPConnect()->WrapNativeToJSVal(cx, scope, native,
    1887                 :                                                         cache, aIID,
    1888                 :                                                         aAllowWrapping, vp,
    1889               5 :                                                         aHolder);
    1890                 : }
    1891                 : 
    1892                 : static inline nsresult
    1893               3 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
    1894                 :            const nsIID* aIID, bool aAllowWrapping, jsval *vp,
    1895                 :            // If non-null aHolder will keep the jsval alive
    1896                 :            // while there's a ref to it
    1897                 :            nsIXPConnectJSObjectHolder** aHolder = nsnull)
    1898                 : {
    1899                 :   return WrapNative(cx, scope, native, nsnull, aIID, vp, aHolder,
    1900               3 :                     aAllowWrapping);
    1901                 : }
    1902                 : 
    1903                 : // Same as the WrapNative above, but use these if aIID is nsISupports' IID.
    1904                 : static inline nsresult
    1905               0 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
    1906                 :            bool aAllowWrapping, jsval *vp,
    1907                 :            // If non-null aHolder will keep the jsval alive
    1908                 :            // while there's a ref to it
    1909                 :            nsIXPConnectJSObjectHolder** aHolder = nsnull)
    1910                 : {
    1911                 :   return WrapNative(cx, scope, native, nsnull, nsnull, vp, aHolder,
    1912               0 :                     aAllowWrapping);
    1913                 : }
    1914                 : 
    1915                 : static inline nsresult
    1916           15158 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
    1917                 :            nsWrapperCache *cache, bool aAllowWrapping, jsval *vp,
    1918                 :            // If non-null aHolder will keep the jsval alive
    1919                 :            // while there's a ref to it
    1920                 :            nsIXPConnectJSObjectHolder** aHolder = nsnull)
    1921                 : {
    1922                 :   return WrapNative(cx, scope, native, cache, nsnull, vp, aHolder,
    1923           15158 :                     aAllowWrapping);
    1924                 : }
    1925                 : 
    1926                 : // Used for cases where PreCreate needs to wrap the native parent, and the
    1927                 : // native parent is likely to have been wrapped already.  |native| must
    1928                 : // implement nsWrapperCache, and nativeWrapperCache must be |native|'s
    1929                 : // nsWrapperCache.
    1930                 : static inline nsresult
    1931           15158 : WrapNativeParent(JSContext *cx, JSObject *scope, nsISupports *native,
    1932                 :                                         nsWrapperCache *nativeWrapperCache,
    1933                 :                                         JSObject **parentObj)
    1934                 : {
    1935                 :   // In the common case, |native| is a wrapper cache with an existing wrapper
    1936                 : #ifdef DEBUG
    1937           15158 :   nsWrapperCache* cache = nsnull;
    1938           15158 :   CallQueryInterface(native, &cache);
    1939           15158 :   NS_PRECONDITION(nativeWrapperCache &&
    1940                 :                   cache == nativeWrapperCache, "What happened here?");
    1941                 : #endif
    1942                 :   
    1943           15158 :   JSObject* obj = nativeWrapperCache->GetWrapper();
    1944           15158 :   if (obj) {
    1945                 : #ifdef DEBUG
    1946                 :     jsval debugVal;
    1947                 :     nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false,
    1948           15156 :                              &debugVal);
    1949           15156 :     NS_ASSERTION(NS_SUCCEEDED(rv) && JSVAL_TO_OBJECT(debugVal) == obj,
    1950                 :                  "Unexpected object in nsWrapperCache");
    1951                 : #endif
    1952           15156 :     *parentObj = obj;
    1953           15156 :     return NS_OK;
    1954                 :   }
    1955                 : 
    1956                 :   jsval v;
    1957               2 :   nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false, &v);
    1958               2 :   NS_ENSURE_SUCCESS(rv, rv);
    1959               2 :   *parentObj = JSVAL_TO_OBJECT(v);
    1960               2 :   return NS_OK;
    1961                 : }
    1962                 : 
    1963                 : // static
    1964                 : 
    1965                 : nsISupports *
    1966               5 : nsDOMClassInfo::GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj)
    1967                 : {
    1968               5 :   return wrapper ? wrapper->Native() : static_cast<nsISupports*>(js::GetObjectPrivate(obj));
    1969                 : }
    1970                 : 
    1971                 : nsresult
    1972             306 : nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
    1973                 : {
    1974                 : #define SET_JSID_TO_STRING(_id, _cx, _str)                                    \
    1975                 :   if (JSString *str = ::JS_InternString(_cx, _str))                           \
    1976                 :       _id = INTERNED_STRING_TO_JSID(_cx, str);                                \
    1977                 :   else                                                                        \
    1978                 :       return NS_ERROR_OUT_OF_MEMORY;
    1979                 : 
    1980             612 :   JSAutoRequest ar(cx);
    1981                 : 
    1982             306 :   SET_JSID_TO_STRING(sParent_id,          cx, "parent");
    1983             612 :   SET_JSID_TO_STRING(sScrollbars_id,      cx, "scrollbars");
    1984             612 :   SET_JSID_TO_STRING(sLocation_id,        cx, "location");
    1985             612 :   SET_JSID_TO_STRING(sConstructor_id,     cx, "constructor");
    1986             612 :   SET_JSID_TO_STRING(s_content_id,        cx, "_content");
    1987             612 :   SET_JSID_TO_STRING(sContent_id,         cx, "content");
    1988             612 :   SET_JSID_TO_STRING(sMenubar_id,         cx, "menubar");
    1989             612 :   SET_JSID_TO_STRING(sToolbar_id,         cx, "toolbar");
    1990             612 :   SET_JSID_TO_STRING(sLocationbar_id,     cx, "locationbar");
    1991             612 :   SET_JSID_TO_STRING(sPersonalbar_id,     cx, "personalbar");
    1992             612 :   SET_JSID_TO_STRING(sStatusbar_id,       cx, "statusbar");
    1993             612 :   SET_JSID_TO_STRING(sDialogArguments_id, cx, "dialogArguments");
    1994             612 :   SET_JSID_TO_STRING(sControllers_id,     cx, "controllers");
    1995             612 :   SET_JSID_TO_STRING(sLength_id,          cx, "length");
    1996             612 :   SET_JSID_TO_STRING(sInnerHeight_id,     cx, "innerHeight");
    1997             612 :   SET_JSID_TO_STRING(sInnerWidth_id,      cx, "innerWidth");
    1998             612 :   SET_JSID_TO_STRING(sOuterHeight_id,     cx, "outerHeight");
    1999             612 :   SET_JSID_TO_STRING(sOuterWidth_id,      cx, "outerWidth");
    2000             612 :   SET_JSID_TO_STRING(sScreenX_id,         cx, "screenX");
    2001             612 :   SET_JSID_TO_STRING(sScreenY_id,         cx, "screenY");
    2002             612 :   SET_JSID_TO_STRING(sStatus_id,          cx, "status");
    2003             612 :   SET_JSID_TO_STRING(sName_id,            cx, "name");
    2004             612 :   SET_JSID_TO_STRING(sScrollX_id,         cx, "scrollX");
    2005             612 :   SET_JSID_TO_STRING(sScrollY_id,         cx, "scrollY");
    2006             612 :   SET_JSID_TO_STRING(sScrollMaxX_id,      cx, "scrollMaxX");
    2007             612 :   SET_JSID_TO_STRING(sScrollMaxY_id,      cx, "scrollMaxY");
    2008             612 :   SET_JSID_TO_STRING(sItem_id,            cx, "item");
    2009             612 :   SET_JSID_TO_STRING(sNamedItem_id,       cx, "namedItem");
    2010             612 :   SET_JSID_TO_STRING(sEnumerate_id,       cx, "enumerateProperties");
    2011             612 :   SET_JSID_TO_STRING(sNavigator_id,       cx, "navigator");
    2012             612 :   SET_JSID_TO_STRING(sDocument_id,        cx, "document");
    2013             612 :   SET_JSID_TO_STRING(sFrames_id,          cx, "frames");
    2014             612 :   SET_JSID_TO_STRING(sSelf_id,            cx, "self");
    2015             612 :   SET_JSID_TO_STRING(sOpener_id,          cx, "opener");
    2016             612 :   SET_JSID_TO_STRING(sAll_id,             cx, "all");
    2017             612 :   SET_JSID_TO_STRING(sTags_id,            cx, "tags");
    2018             612 :   SET_JSID_TO_STRING(sAddEventListener_id,cx, "addEventListener");
    2019             612 :   SET_JSID_TO_STRING(sBaseURIObject_id,   cx, "baseURIObject");
    2020             612 :   SET_JSID_TO_STRING(sNodePrincipal_id,   cx, "nodePrincipal");
    2021             612 :   SET_JSID_TO_STRING(sDocumentURIObject_id,cx,"documentURIObject");
    2022             612 :   SET_JSID_TO_STRING(sJava_id,            cx, "java");
    2023             612 :   SET_JSID_TO_STRING(sPackages_id,        cx, "Packages");
    2024             612 :   SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject");
    2025             612 :   SET_JSID_TO_STRING(sURL_id,             cx, "URL");
    2026             612 :   SET_JSID_TO_STRING(sKeyPath_id,         cx, "keyPath");
    2027             612 :   SET_JSID_TO_STRING(sAutoIncrement_id,   cx, "autoIncrement");
    2028             612 :   SET_JSID_TO_STRING(sUnique_id,          cx, "unique");
    2029             612 :   SET_JSID_TO_STRING(sMultiEntry_id,      cx, "multiEntry");
    2030             612 :   SET_JSID_TO_STRING(sOnload_id,          cx, "onload");
    2031             612 :   SET_JSID_TO_STRING(sOnerror_id,         cx, "onerror");
    2032                 : 
    2033             306 :   return NS_OK;
    2034                 : }
    2035                 : 
    2036                 : static nsresult
    2037               3 : CreateExceptionFromResult(JSContext *cx, nsresult aResult)
    2038                 : {
    2039                 :   nsCOMPtr<nsIExceptionService> xs =
    2040               6 :     do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
    2041               3 :   if (!xs) {
    2042               0 :     return NS_ERROR_FAILURE;
    2043                 :   }
    2044                 : 
    2045               6 :   nsCOMPtr<nsIExceptionManager> xm;
    2046               3 :   nsresult rv = xs->GetCurrentExceptionManager(getter_AddRefs(xm));
    2047               3 :   if (NS_FAILED(rv)) {
    2048               0 :     return NS_ERROR_FAILURE;
    2049                 :   }
    2050                 : 
    2051               6 :   nsCOMPtr<nsIException> exception;
    2052               3 :   rv = xm->GetExceptionFromProvider(aResult, 0, getter_AddRefs(exception));
    2053               3 :   if (NS_FAILED(rv) || !exception) {
    2054               0 :     return NS_ERROR_FAILURE;
    2055                 :   }
    2056                 : 
    2057                 :   jsval jv;
    2058               6 :   nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    2059                 :   rv = WrapNative(cx, ::JS_GetGlobalObject(cx), exception,
    2060                 :                   &NS_GET_IID(nsIException), false, &jv,
    2061               3 :                   getter_AddRefs(holder));
    2062               3 :   if (NS_FAILED(rv) || JSVAL_IS_NULL(jv)) {
    2063               0 :     return NS_ERROR_FAILURE;
    2064                 :   }
    2065                 : 
    2066               6 :   JSAutoEnterCompartment ac;
    2067                 : 
    2068               3 :   if (JSVAL_IS_OBJECT(jv)) {
    2069               3 :     if (!ac.enter(cx, JSVAL_TO_OBJECT(jv))) {
    2070               0 :       return NS_ERROR_UNEXPECTED;
    2071                 :     }
    2072                 :   }
    2073                 : 
    2074               3 :   JS_SetPendingException(cx, jv);
    2075               3 :   return NS_OK;
    2076                 : }
    2077                 : 
    2078                 : // static
    2079                 : nsresult
    2080               3 : nsDOMClassInfo::ThrowJSException(JSContext *cx, nsresult aResult)
    2081                 : {
    2082               6 :   JSAutoRequest ar(cx);
    2083                 : 
    2084               3 :   if (NS_SUCCEEDED(CreateExceptionFromResult(cx, aResult))) {
    2085               3 :     return NS_OK;
    2086                 :   }
    2087                 : 
    2088                 :   // XXX This probably wants to be localized, but that can fail in ways that
    2089                 :   // are hard to report correctly.
    2090                 :   JSString *str =
    2091               0 :     JS_NewStringCopyZ(cx, "An error occurred throwing an exception");
    2092               0 :   if (!str) {
    2093                 :     // JS_NewStringCopyZ reported the error for us.
    2094               0 :     return NS_OK; 
    2095                 :   }
    2096               0 :   JS_SetPendingException(cx, STRING_TO_JSVAL(str));
    2097               0 :   return NS_OK;
    2098                 : }
    2099                 : 
    2100                 : // static
    2101                 : bool
    2102             245 : nsDOMClassInfo::ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
    2103                 : {
    2104             245 :   return xpc::WrapperFactory::IsXrayWrapper(obj) &&
    2105             245 :          !xpc::WrapperFactory::IsPartiallyTransparent(obj);
    2106                 : }
    2107                 : 
    2108            1684 : nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
    2109                 : {
    2110            1684 : }
    2111                 : 
    2112            2306 : nsDOMClassInfo::~nsDOMClassInfo()
    2113                 : {
    2114            1679 :   if (IS_EXTERNAL(mData->mCachedClassInfo)) {
    2115                 :     // Some compilers don't like delete'ing a const nsDOMClassInfo*
    2116               0 :     nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
    2117                 :     delete static_cast<nsExternalDOMClassInfoData*>(data);
    2118                 :   }
    2119            4612 : }
    2120                 : 
    2121           89849 : NS_IMPL_ADDREF(nsDOMClassInfo)
    2122           89842 : NS_IMPL_RELEASE(nsDOMClassInfo)
    2123                 : 
    2124           55759 : NS_INTERFACE_MAP_BEGIN(nsDOMClassInfo)
    2125           55759 :   if (aIID.Equals(NS_GET_IID(nsXPCClassInfo)))
    2126                 :     foundInterface = static_cast<nsIClassInfo*>(
    2127           11682 :                                     static_cast<nsXPCClassInfo*>(this));
    2128                 :   else
    2129           44077 :   NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
    2130            2781 :   NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
    2131               0 :   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIClassInfo)
    2132               0 : NS_INTERFACE_MAP_END
    2133                 : 
    2134                 : 
    2135                 : static JSClass sDOMConstructorProtoClass = {
    2136                 :   "DOM Constructor.prototype", 0,
    2137                 :   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
    2138                 :   JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nsnull
    2139                 : };
    2140                 : 
    2141                 : 
    2142                 : static const char *
    2143          182718 : CutPrefix(const char *aName) {
    2144                 :   static const char prefix_nsIDOM[] = "nsIDOM";
    2145                 :   static const char prefix_nsI[]    = "nsI";
    2146                 : 
    2147          182718 :   if (strncmp(aName, prefix_nsIDOM, sizeof(prefix_nsIDOM) - 1) == 0) {
    2148          167077 :     return aName + sizeof(prefix_nsIDOM) - 1;
    2149                 :   }
    2150                 : 
    2151           15641 :   if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
    2152           15641 :     return aName + sizeof(prefix_nsI) - 1;
    2153                 :   }
    2154                 : 
    2155               0 :   return aName;
    2156                 : }
    2157                 : 
    2158                 : // static
    2159                 : nsresult
    2160          115362 : nsDOMClassInfo::RegisterClassName(PRInt32 aClassInfoID)
    2161                 : {
    2162                 :   nsScriptNameSpaceManager *nameSpaceManager =
    2163          115362 :     nsJSRuntime::GetNameSpaceManager();
    2164          115362 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    2165                 : 
    2166                 :   nameSpaceManager->RegisterClassName(sClassInfoData[aClassInfoID].mName,
    2167                 :                                       aClassInfoID,
    2168                 :                                       sClassInfoData[aClassInfoID].mChromeOnly,
    2169                 :                                       sClassInfoData[aClassInfoID].mDisabled,
    2170          115362 :                                       &sClassInfoData[aClassInfoID].mNameUTF16);
    2171                 : 
    2172          115362 :   return NS_OK;
    2173                 : }
    2174                 : 
    2175                 : // static
    2176                 : nsresult
    2177          115362 : nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID)
    2178                 : {
    2179                 :   nsScriptNameSpaceManager *nameSpaceManager =
    2180          115362 :     nsJSRuntime::GetNameSpaceManager();
    2181          115362 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    2182                 :   bool found_old;
    2183                 : 
    2184          115362 :   const nsIID *primary_iid = sClassInfoData[aClassInfoID].mProtoChainInterface;
    2185                 : 
    2186          115362 :   if (!primary_iid || primary_iid == &NS_GET_IID(nsISupports)) {
    2187               0 :     return NS_OK;
    2188                 :   }
    2189                 : 
    2190                 :   nsCOMPtr<nsIInterfaceInfoManager>
    2191          230724 :     iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
    2192          115362 :   NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
    2193                 : 
    2194          230724 :   nsCOMPtr<nsIInterfaceInfo> if_info;
    2195          115362 :   bool first = true;
    2196                 : 
    2197          115362 :   iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
    2198                 : 
    2199          351594 :   while (if_info) {
    2200          236232 :     const nsIID *iid = nsnull;
    2201                 : 
    2202          236232 :     if_info->GetIIDShared(&iid);
    2203          236232 :     NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
    2204                 : 
    2205          236232 :     if (iid->Equals(NS_GET_IID(nsISupports))) {
    2206           55998 :       break;
    2207                 :     }
    2208                 : 
    2209          180234 :     const char *name = nsnull;
    2210          180234 :     if_info->GetNameShared(&name);
    2211          180234 :     NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
    2212                 : 
    2213          180234 :     nameSpaceManager->RegisterClassProto(CutPrefix(name), iid, &found_old);
    2214                 : 
    2215          180234 :     if (first) {
    2216          115362 :       first = false;
    2217           64872 :     } else if (found_old) {
    2218           59364 :       break;
    2219                 :     }
    2220                 : 
    2221          241740 :     nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
    2222          120870 :     tmp->GetParent(getter_AddRefs(if_info));
    2223                 :   }
    2224                 : 
    2225          115362 :   return NS_OK;
    2226                 : }
    2227                 : 
    2228                 : // static
    2229                 : nsresult
    2230             306 : nsDOMClassInfo::RegisterExternalClasses()
    2231                 : {
    2232                 :   nsScriptNameSpaceManager *nameSpaceManager =
    2233             306 :     nsJSRuntime::GetNameSpaceManager();
    2234             306 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    2235                 : 
    2236             612 :   nsCOMPtr<nsIComponentRegistrar> registrar;
    2237             306 :   nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
    2238             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2239                 : 
    2240                 :   nsCOMPtr<nsICategoryManager> cm =
    2241             612 :     do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
    2242             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2243                 : 
    2244             612 :   nsCOMPtr<nsISimpleEnumerator> e;
    2245             306 :   rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
    2246             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2247                 : 
    2248             612 :   nsXPIDLCString contractId;
    2249             612 :   nsCAutoString categoryEntry;
    2250             612 :   nsCOMPtr<nsISupports> entry;
    2251                 : 
    2252             612 :   while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
    2253               0 :     nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
    2254                 : 
    2255               0 :     if (!category) {
    2256               0 :       NS_WARNING("Category entry not an nsISupportsCString!");
    2257               0 :       continue;
    2258                 :     }
    2259                 : 
    2260               0 :     rv = category->GetData(categoryEntry);
    2261                 : 
    2262               0 :     cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
    2263               0 :                          getter_Copies(contractId));
    2264               0 :     NS_ENSURE_SUCCESS(rv, rv);
    2265                 : 
    2266                 :     nsCID *cid;
    2267               0 :     rv = registrar->ContractIDToCID(contractId, &cid);
    2268               0 :     if (NS_FAILED(rv)) {
    2269               0 :       NS_WARNING("Bad contract id registered with the script namespace manager");
    2270               0 :       continue;
    2271                 :     }
    2272                 : 
    2273               0 :     rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
    2274               0 :     nsMemory::Free(cid);
    2275               0 :     NS_ENSURE_SUCCESS(rv, rv);
    2276                 :   }
    2277                 : 
    2278             306 :   return nameSpaceManager->RegisterExternalInterfaces(true);
    2279                 : }
    2280                 : 
    2281                 : #define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if, _disabled)    \
    2282                 :   {                                                                           \
    2283                 :     nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id];      \
    2284                 :     d.mProtoChainInterface = _ifptr;                                          \
    2285                 :     d.mHasClassInterface = _has_class_if;                                     \
    2286                 :     d.mInterfacesBitmap = kDOMClassInfo_##_class##_interfaces;                \
    2287                 :     d.mDisabled = _disabled;                                                  \
    2288                 :     static const nsIID *interface_list[] = {
    2289                 : 
    2290                 : #define DOM_CLASSINFO_MAP_BEGIN(_class, _interface)                           \
    2291                 :   _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, false)
    2292                 : 
    2293                 : #define DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(_class, _interface, _disable)   \
    2294                 :   _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, _disable)
    2295                 :   
    2296                 : #define DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(_class, _interface)               \
    2297                 :   _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), false, false)
    2298                 : 
    2299                 : #define DOM_CLASSINFO_MAP_ENTRY(_if)                                          \
    2300                 :       &NS_GET_IID(_if),
    2301                 : 
    2302                 : #define DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(_if, _cond)                       \
    2303                 :       (_cond) ? &NS_GET_IID(_if) : nsnull,
    2304                 : 
    2305                 : #define DOM_CLASSINFO_MAP_END                                                 \
    2306                 :       nsnull                                                                  \
    2307                 :     };                                                                        \
    2308                 :                                                                               \
    2309                 :     /* Compact the interface list */                                          \
    2310                 :     size_t count = ArrayLength(interface_list);                               \
    2311                 :     /* count is the number of array entries, which is one greater than the */ \
    2312                 :     /* number of interfaces due to the terminating null */                    \
    2313                 :     for (size_t i = 0; i < count - 1; ++i) {                                  \
    2314                 :       if (!interface_list[i]) {                                               \
    2315                 :         /* We are moving the element at index i+1 and successors, */          \
    2316                 :         /* so we must move only count - (i+1) elements total. */              \
    2317                 :         memmove(&interface_list[i], &interface_list[i+1],                     \
    2318                 :                 sizeof(nsIID*) * (count - (i+1)));                            \
    2319                 :         /* Make sure to examine the new pointer we ended up with at this */   \
    2320                 :         /* slot, since it may be null too */                                  \
    2321                 :         --i;                                                                  \
    2322                 :         --count;                                                              \
    2323                 :       }                                                                       \
    2324                 :     }                                                                         \
    2325                 :                                                                               \
    2326                 :     d.mInterfaces = interface_list;                                           \
    2327                 :   }
    2328                 : 
    2329                 : #define DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES                                    \
    2330                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL)                                \
    2331                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                \
    2332                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator)                             \
    2333                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)                               \
    2334                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                           \
    2335                 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMDocumentTouch,                  \
    2336                 :                                         nsDOMTouchEvent::PrefEnabled())
    2337                 : 
    2338                 : 
    2339                 : #define DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES                                \
    2340                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle)                      \
    2341                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                \
    2342                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)                                  \
    2343                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)                               \
    2344                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                           \
    2345                 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,                \
    2346                 :                                         nsDOMTouchEvent::PrefEnabled())
    2347                 : 
    2348                 : #define DOM_CLASSINFO_EVENT_MAP_ENTRIES                                       \
    2349                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)                                      \
    2350                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent)                                    \
    2351                 : 
    2352                 : #define DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES                                    \
    2353                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMUIEvent)                                    \
    2354                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2355                 : 
    2356                 : #define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db)                  \
    2357                 :   DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)                                        \
    2358                 :   DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)                                      \
    2359                 :   DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                   \
    2360                 :   DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                              \
    2361                 :   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB,                  \
    2362                 :                                       _support_indexed_db)                     \
    2363                 :   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance,                 \
    2364                 :                                       nsGlobalWindow::HasPerformanceSupport()) \
    2365                 :   DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,                   \
    2366                 :                                       nsDOMTouchEvent::PrefEnabled())
    2367                 : 
    2368                 : nsresult
    2369             306 : nsDOMClassInfo::Init()
    2370                 : {
    2371                 :   /* Errors that can trigger early returns are done first,
    2372                 :      otherwise nsDOMClassInfo is left in a half inited state. */
    2373                 :   NS_ASSERTION(sizeof(PtrBits) == sizeof(void*),
    2374                 :                "BAD! You'll need to adjust the size of PtrBits to the size "
    2375                 :                "of a pointer on your platform.");
    2376                 : 
    2377             306 :   NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
    2378                 : 
    2379             306 :   nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
    2380             306 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    2381                 : 
    2382             306 :   nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
    2383             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2384                 : 
    2385             612 :   nsCOMPtr<nsIXPCFunctionThisTranslator> old;
    2386                 : 
    2387             612 :   nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
    2388             306 :   NS_ENSURE_TRUE(elt, NS_ERROR_OUT_OF_MEMORY);
    2389                 : 
    2390                 :   sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener),
    2391             306 :                                         elt, getter_AddRefs(old));
    2392                 : 
    2393                 :   nsCOMPtr<nsIScriptSecurityManager> sm =
    2394             612 :     do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
    2395             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2396                 : 
    2397             306 :   sSecMan = sm;
    2398             306 :   NS_ADDREF(sSecMan);
    2399                 : 
    2400                 :   nsCOMPtr<nsIThreadJSContextStack> stack =
    2401             612 :     do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
    2402             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2403                 : 
    2404             306 :   JSContext *cx = nsnull;
    2405                 : 
    2406             306 :   rv = stack->GetSafeJSContext(&cx);
    2407             306 :   NS_ENSURE_SUCCESS(rv, rv);
    2408                 : 
    2409             306 :   DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
    2410             918 :     DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
    2411            1224 :   DOM_CLASSINFO_MAP_END
    2412                 : 
    2413             306 :   DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
    2414                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
    2415             306 :   DOM_CLASSINFO_MAP_END
    2416                 : 
    2417             306 :   DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
    2418                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
    2419             306 :   DOM_CLASSINFO_MAP_END
    2420                 : 
    2421             306 :   DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
    2422                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
    2423                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
    2424             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorDesktopNotification,
    2425                 :                                         Navigator::HasDesktopNotificationSupport())
    2426                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
    2427             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorBattery,
    2428                 :                                         battery::BatteryManager::HasSupport())
    2429                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozNavigatorSms)
    2430                 : #ifdef MOZ_B2G_RIL
    2431                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorTelephony)
    2432                 : #endif
    2433             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorNetwork,
    2434                 :                                         network::IsAPIEnabled())
    2435                 : #ifdef MOZ_B2G_BT
    2436                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth)
    2437                 : #endif
    2438            1224 :   DOM_CLASSINFO_MAP_END
    2439                 : 
    2440             306 :   DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
    2441                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin)
    2442             306 :   DOM_CLASSINFO_MAP_END
    2443                 : 
    2444             306 :   DOM_CLASSINFO_MAP_BEGIN(PluginArray, nsIDOMPluginArray)
    2445                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPluginArray)
    2446             306 :   DOM_CLASSINFO_MAP_END
    2447                 : 
    2448             306 :   DOM_CLASSINFO_MAP_BEGIN(MimeType, nsIDOMMimeType)
    2449                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeType)
    2450             306 :   DOM_CLASSINFO_MAP_END
    2451                 : 
    2452             306 :   DOM_CLASSINFO_MAP_BEGIN(MimeTypeArray, nsIDOMMimeTypeArray)
    2453                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeTypeArray)
    2454             306 :   DOM_CLASSINFO_MAP_END
    2455                 : 
    2456             306 :   DOM_CLASSINFO_MAP_BEGIN(BarProp, nsIDOMBarProp)
    2457                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBarProp)
    2458             306 :   DOM_CLASSINFO_MAP_END
    2459                 : 
    2460             306 :   DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
    2461                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
    2462             306 :   DOM_CLASSINFO_MAP_END
    2463                 : 
    2464             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceTiming, nsIDOMPerformanceTiming,
    2465                 :                                         !nsGlobalWindow::HasPerformanceSupport())
    2466                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceTiming)
    2467             306 :   DOM_CLASSINFO_MAP_END
    2468                 : 
    2469             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceNavigation, nsIDOMPerformanceNavigation,
    2470                 :                                         !nsGlobalWindow::HasPerformanceSupport())
    2471                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceNavigation)
    2472             306 :   DOM_CLASSINFO_MAP_END
    2473                 : 
    2474             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Performance, nsIDOMPerformance,
    2475                 :                                         !nsGlobalWindow::HasPerformanceSupport())
    2476                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance)
    2477             306 :   DOM_CLASSINFO_MAP_END
    2478                 : 
    2479             306 :   DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
    2480                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
    2481             306 :   DOM_CLASSINFO_MAP_END
    2482                 : 
    2483             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
    2484                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
    2485             306 :   DOM_CLASSINFO_MAP_END
    2486                 : 
    2487             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
    2488                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
    2489             306 :   DOM_CLASSINFO_MAP_END
    2490                 : 
    2491             306 :   DOM_CLASSINFO_MAP_BEGIN(XMLDocument, nsIDOMXMLDocument)
    2492                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
    2493                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXMLDocument)
    2494             306 :     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
    2495             612 :   DOM_CLASSINFO_MAP_END
    2496                 : 
    2497             306 :   DOM_CLASSINFO_MAP_BEGIN(DocumentType, nsIDOMDocumentType)
    2498                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentType)
    2499                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2500             306 :   DOM_CLASSINFO_MAP_END
    2501                 : 
    2502             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMImplementation, nsIDOMDOMImplementation)
    2503                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMImplementation)
    2504             306 :   DOM_CLASSINFO_MAP_END
    2505                 : 
    2506             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMException, nsIDOMDOMException)
    2507                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMException)
    2508                 :     DOM_CLASSINFO_MAP_ENTRY(nsIException)
    2509             306 :   DOM_CLASSINFO_MAP_END
    2510                 : 
    2511             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMTokenList, nsIDOMDOMTokenList)
    2512                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMTokenList)
    2513             306 :   DOM_CLASSINFO_MAP_END
    2514                 : 
    2515             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMSettableTokenList, nsIDOMDOMSettableTokenList)
    2516                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMSettableTokenList)
    2517             306 :   DOM_CLASSINFO_MAP_END
    2518                 : 
    2519             306 :   DOM_CLASSINFO_MAP_BEGIN(DocumentFragment, nsIDOMDocumentFragment)
    2520                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentFragment)
    2521                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
    2522                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2523             306 :   DOM_CLASSINFO_MAP_END
    2524                 : 
    2525             306 :   DOM_CLASSINFO_MAP_BEGIN(Element, nsIDOMElement)
    2526                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
    2527                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
    2528                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2529                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
    2530                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
    2531             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
    2532                 :                                         nsDOMTouchEvent::PrefEnabled())
    2533             612 :   DOM_CLASSINFO_MAP_END
    2534                 : 
    2535             306 :   DOM_CLASSINFO_MAP_BEGIN(Attr, nsIDOMAttr)
    2536                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMAttr)
    2537                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2538             306 :   DOM_CLASSINFO_MAP_END
    2539                 : 
    2540             306 :   DOM_CLASSINFO_MAP_BEGIN(Text, nsIDOMText)
    2541                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMText)
    2542                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2543             306 :   DOM_CLASSINFO_MAP_END
    2544                 : 
    2545             306 :   DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment)
    2546                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMComment)
    2547                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2548             306 :   DOM_CLASSINFO_MAP_END
    2549                 : 
    2550             306 :   DOM_CLASSINFO_MAP_BEGIN(CDATASection, nsIDOMCDATASection)
    2551                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCDATASection)
    2552                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2553             306 :   DOM_CLASSINFO_MAP_END
    2554                 : 
    2555             306 :   DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)
    2556                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
    2557                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCharacterData)
    2558                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    2559             306 :   DOM_CLASSINFO_MAP_END
    2560                 : 
    2561             306 :   DOM_CLASSINFO_MAP_BEGIN(NodeList, nsIDOMNodeList)
    2562                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
    2563             306 :   DOM_CLASSINFO_MAP_END
    2564                 : 
    2565             306 :   DOM_CLASSINFO_MAP_BEGIN(NamedNodeMap, nsIDOMNamedNodeMap)
    2566                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNamedNodeMap)
    2567             306 :   DOM_CLASSINFO_MAP_END
    2568                 : 
    2569             306 :   DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
    2570                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2571             306 :   DOM_CLASSINFO_MAP_END
    2572                 : 
    2573             306 :   DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
    2574                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
    2575                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2576             306 :   DOM_CLASSINFO_MAP_END
    2577                 : 
    2578             306 :   DOM_CLASSINFO_MAP_BEGIN(DeviceOrientationEvent, nsIDOMDeviceOrientationEvent)
    2579                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
    2580                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2581             306 :   DOM_CLASSINFO_MAP_END
    2582                 : 
    2583             306 :   DOM_CLASSINFO_MAP_BEGIN(DeviceMotionEvent, nsIDOMDeviceMotionEvent)
    2584                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceMotionEvent)
    2585                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2586             306 :   DOM_CLASSINFO_MAP_END
    2587                 : 
    2588             306 :   DOM_CLASSINFO_MAP_BEGIN(DeviceAcceleration, nsIDOMDeviceAcceleration)
    2589                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceAcceleration)
    2590                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2591             306 :   DOM_CLASSINFO_MAP_END
    2592                 : 
    2593             306 :   DOM_CLASSINFO_MAP_BEGIN(DeviceRotationRate, nsIDOMDeviceRotationRate)
    2594                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceRotationRate)
    2595                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2596             306 :   DOM_CLASSINFO_MAP_END
    2597                 : 
    2598             306 :   DOM_CLASSINFO_MAP_BEGIN(SmartCardEvent, nsIDOMSmartCardEvent)
    2599                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
    2600             306 :   DOM_CLASSINFO_MAP_END
    2601                 : 
    2602             306 :   DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
    2603                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPageTransitionEvent)
    2604                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2605             306 :   DOM_CLASSINFO_MAP_END
    2606                 : 
    2607             306 :   DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
    2608                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
    2609                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2610             306 :   DOM_CLASSINFO_MAP_END
    2611                 : 
    2612             306 :   DOM_CLASSINFO_MAP_BEGIN(UIEvent, nsIDOMUIEvent)
    2613                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2614             306 :   DOM_CLASSINFO_MAP_END
    2615                 :   
    2616             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(KeyboardEvent, nsIDOMKeyEvent)
    2617                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
    2618                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2619             306 :   DOM_CLASSINFO_MAP_END
    2620                 : 
    2621             306 :   DOM_CLASSINFO_MAP_BEGIN(CompositionEvent, nsIDOMCompositionEvent)
    2622                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCompositionEvent)
    2623                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2624             306 :   DOM_CLASSINFO_MAP_END
    2625                 : 
    2626             306 :   DOM_CLASSINFO_MAP_BEGIN(MouseEvent, nsIDOMMouseEvent)
    2627                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
    2628                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2629             306 :   DOM_CLASSINFO_MAP_END
    2630                 : 
    2631             306 :   DOM_CLASSINFO_MAP_BEGIN(MouseScrollEvent, nsIDOMMouseScrollEvent)
    2632                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseScrollEvent)
    2633                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
    2634                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2635             306 :   DOM_CLASSINFO_MAP_END
    2636                 : 
    2637             306 :   DOM_CLASSINFO_MAP_BEGIN(DragEvent, nsIDOMDragEvent)
    2638                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDragEvent)
    2639                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
    2640                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    2641             306 :   DOM_CLASSINFO_MAP_END
    2642                 : 
    2643             306 :   DOM_CLASSINFO_MAP_BEGIN(PopStateEvent, nsIDOMPopStateEvent)
    2644                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopStateEvent)
    2645                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2646             306 :   DOM_CLASSINFO_MAP_END
    2647                 : 
    2648             306 :   DOM_CLASSINFO_MAP_BEGIN(HashChangeEvent, nsIDOMHashChangeEvent)
    2649                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHashChangeEvent)
    2650                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    2651             306 :   DOM_CLASSINFO_MAP_END
    2652                 : 
    2653             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLDocument, nsIDOMHTMLDocument)
    2654                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
    2655             306 :     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
    2656             612 :   DOM_CLASSINFO_MAP_END
    2657                 : 
    2658             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLOptionsCollection, nsIDOMHTMLOptionsCollection)
    2659                 :     // Order is significant.  nsIDOMHTMLOptionsCollection.length shadows
    2660                 :     // nsIDOMHTMLCollection.length, which is readonly.
    2661                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionsCollection)
    2662                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
    2663             306 :   DOM_CLASSINFO_MAP_END
    2664                 : 
    2665             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLCollection, nsIDOMHTMLCollection)
    2666                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
    2667             306 :   DOM_CLASSINFO_MAP_END
    2668                 : 
    2669             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLElement, nsIDOMHTMLElement)
    2670                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
    2671             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2672             612 :   DOM_CLASSINFO_MAP_END
    2673                 : 
    2674             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLAnchorElement, nsIDOMHTMLAnchorElement)
    2675                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAnchorElement)
    2676             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2677             612 :   DOM_CLASSINFO_MAP_END
    2678                 : 
    2679             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLAppletElement, nsIDOMHTMLAppletElement)
    2680                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAppletElement)
    2681             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2682             612 :   DOM_CLASSINFO_MAP_END
    2683                 : 
    2684             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLAreaElement, nsIDOMHTMLAreaElement)
    2685                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAreaElement)
    2686             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2687             612 :   DOM_CLASSINFO_MAP_END
    2688                 : 
    2689             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLBRElement, nsIDOMHTMLBRElement)
    2690                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBRElement)
    2691             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2692             612 :   DOM_CLASSINFO_MAP_END
    2693                 : 
    2694             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLBaseElement, nsIDOMHTMLBaseElement)
    2695                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBaseElement)
    2696             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2697             612 :   DOM_CLASSINFO_MAP_END
    2698                 : 
    2699             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLBodyElement, nsIDOMHTMLBodyElement)
    2700                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBodyElement)
    2701             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2702             612 :   DOM_CLASSINFO_MAP_END
    2703                 : 
    2704             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLButtonElement, nsIDOMHTMLButtonElement)
    2705                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLButtonElement)
    2706             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2707             612 :   DOM_CLASSINFO_MAP_END
    2708                 : 
    2709             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLDataListElement, nsIDOMHTMLDataListElement)
    2710                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDataListElement)
    2711             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2712             612 :   DOM_CLASSINFO_MAP_END
    2713                 : 
    2714             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLDListElement, nsIDOMHTMLDListElement)
    2715                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDListElement)
    2716             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2717             612 :   DOM_CLASSINFO_MAP_END
    2718                 : 
    2719             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLDirectoryElement, nsIDOMHTMLDirectoryElement)
    2720                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDirectoryElement)
    2721             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2722             612 :   DOM_CLASSINFO_MAP_END
    2723                 : 
    2724             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLDivElement, nsIDOMHTMLDivElement)
    2725                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDivElement)
    2726             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2727             612 :   DOM_CLASSINFO_MAP_END
    2728                 : 
    2729             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLEmbedElement, nsIDOMHTMLEmbedElement)
    2730                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLEmbedElement)
    2731                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
    2732             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2733             612 :   DOM_CLASSINFO_MAP_END
    2734                 : 
    2735             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLFieldSetElement, nsIDOMHTMLFieldSetElement)
    2736                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFieldSetElement)
    2737             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2738             612 :   DOM_CLASSINFO_MAP_END
    2739                 : 
    2740             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLFontElement, nsIDOMHTMLFontElement)
    2741                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFontElement)
    2742             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2743             612 :   DOM_CLASSINFO_MAP_END
    2744                 : 
    2745             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLFormElement, nsIDOMHTMLFormElement)
    2746                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFormElement)
    2747             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2748             612 :   DOM_CLASSINFO_MAP_END
    2749                 : 
    2750             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLFrameElement, nsIDOMHTMLFrameElement)
    2751                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameElement)
    2752                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
    2753             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2754             612 :   DOM_CLASSINFO_MAP_END
    2755                 : 
    2756             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLFrameSetElement, nsIDOMHTMLFrameSetElement)
    2757                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameSetElement)
    2758             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2759             612 :   DOM_CLASSINFO_MAP_END
    2760                 : 
    2761             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLHRElement, nsIDOMHTMLHRElement)
    2762                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHRElement)
    2763             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2764             612 :   DOM_CLASSINFO_MAP_END
    2765                 : 
    2766             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLHeadElement, nsIDOMHTMLHeadElement)
    2767                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadElement)
    2768             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2769             612 :   DOM_CLASSINFO_MAP_END
    2770                 : 
    2771             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLHeadingElement, nsIDOMHTMLHeadingElement)
    2772                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadingElement)
    2773             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2774             612 :   DOM_CLASSINFO_MAP_END
    2775                 : 
    2776             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLHtmlElement, nsIDOMHTMLHtmlElement)
    2777                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHtmlElement)
    2778             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2779             612 :   DOM_CLASSINFO_MAP_END
    2780                 : 
    2781             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLIFrameElement, nsIDOMHTMLIFrameElement)
    2782                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIFrameElement)
    2783                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
    2784                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
    2785             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2786             612 :   DOM_CLASSINFO_MAP_END
    2787                 : 
    2788             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLImageElement, nsIDOMHTMLImageElement)
    2789                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLImageElement)
    2790             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2791             612 :   DOM_CLASSINFO_MAP_END
    2792                 : 
    2793             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLInputElement, nsIDOMHTMLInputElement)
    2794                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLInputElement)
    2795             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2796             612 :   DOM_CLASSINFO_MAP_END
    2797                 : 
    2798             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLLIElement, nsIDOMHTMLLIElement)
    2799                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLIElement)
    2800             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2801             612 :   DOM_CLASSINFO_MAP_END
    2802                 : 
    2803             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLLabelElement, nsIDOMHTMLLabelElement)
    2804                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLabelElement)
    2805             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2806             612 :   DOM_CLASSINFO_MAP_END
    2807                 : 
    2808             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLLegendElement, nsIDOMHTMLLegendElement)
    2809                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLegendElement)
    2810             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2811             612 :   DOM_CLASSINFO_MAP_END
    2812                 : 
    2813             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLLinkElement, nsIDOMHTMLLinkElement)
    2814                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLinkElement)
    2815                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
    2816             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2817             612 :   DOM_CLASSINFO_MAP_END
    2818                 : 
    2819             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLMapElement, nsIDOMHTMLMapElement)
    2820                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMapElement)
    2821             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2822             612 :   DOM_CLASSINFO_MAP_END
    2823                 : 
    2824             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLMenuElement, nsIDOMHTMLMenuElement)
    2825                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMenuElement)
    2826             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2827             612 :   DOM_CLASSINFO_MAP_END
    2828                 : 
    2829             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLMenuItemElement, nsIDOMHTMLMenuItemElement)
    2830                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMenuItemElement)
    2831             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2832             612 :   DOM_CLASSINFO_MAP_END
    2833                 : 
    2834             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLMetaElement, nsIDOMHTMLMetaElement)
    2835                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMetaElement)
    2836             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2837             612 :   DOM_CLASSINFO_MAP_END
    2838                 : 
    2839             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLModElement, nsIDOMHTMLModElement)
    2840                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLModElement)
    2841             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2842             612 :   DOM_CLASSINFO_MAP_END
    2843                 : 
    2844             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLOListElement, nsIDOMHTMLOListElement)
    2845                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOListElement)
    2846             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2847             612 :   DOM_CLASSINFO_MAP_END
    2848                 : 
    2849             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLObjectElement, nsIDOMHTMLObjectElement)
    2850                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLObjectElement)
    2851                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
    2852             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2853             612 :   DOM_CLASSINFO_MAP_END
    2854                 : 
    2855             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLOptGroupElement, nsIDOMHTMLOptGroupElement)
    2856                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptGroupElement)
    2857             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2858             612 :   DOM_CLASSINFO_MAP_END
    2859                 : 
    2860             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLOptionElement, nsIDOMHTMLOptionElement)
    2861                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionElement)
    2862             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2863             612 :   DOM_CLASSINFO_MAP_END
    2864                 : 
    2865             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLOutputElement, nsIDOMHTMLOutputElement)
    2866                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOutputElement)
    2867             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2868             612 :   DOM_CLASSINFO_MAP_END
    2869                 : 
    2870             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLParagraphElement, nsIDOMHTMLParagraphElement)
    2871                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParagraphElement)
    2872             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2873             612 :   DOM_CLASSINFO_MAP_END
    2874                 : 
    2875             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLParamElement, nsIDOMHTMLParamElement)
    2876                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParamElement)
    2877             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2878             612 :   DOM_CLASSINFO_MAP_END
    2879                 : 
    2880             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLPreElement, nsIDOMHTMLPreElement)
    2881                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLPreElement)
    2882             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2883             612 :   DOM_CLASSINFO_MAP_END
    2884                 : 
    2885             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLProgressElement, nsIDOMHTMLProgressElement)
    2886                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLProgressElement)
    2887             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2888             612 :   DOM_CLASSINFO_MAP_END
    2889                 : 
    2890             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLQuoteElement, nsIDOMHTMLQuoteElement)
    2891                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLQuoteElement)
    2892             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2893             612 :   DOM_CLASSINFO_MAP_END
    2894                 : 
    2895             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLScriptElement, nsIDOMHTMLScriptElement)
    2896                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLScriptElement)
    2897             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2898             612 :   DOM_CLASSINFO_MAP_END
    2899                 : 
    2900             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLSelectElement, nsIDOMHTMLSelectElement)
    2901                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement)
    2902             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2903             612 :   DOM_CLASSINFO_MAP_END
    2904                 : 
    2905             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLSpanElement, nsIDOMHTMLElement)
    2906                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
    2907             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2908             612 :   DOM_CLASSINFO_MAP_END
    2909                 : 
    2910             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLStyleElement, nsIDOMHTMLStyleElement)
    2911                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLStyleElement)
    2912                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
    2913             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2914             612 :   DOM_CLASSINFO_MAP_END
    2915                 : 
    2916             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableCaptionElement,
    2917                 :                           nsIDOMHTMLTableCaptionElement)
    2918                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCaptionElement)
    2919             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2920             612 :   DOM_CLASSINFO_MAP_END
    2921                 : 
    2922             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableCellElement, nsIDOMHTMLTableCellElement)
    2923                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCellElement)
    2924             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2925             612 :   DOM_CLASSINFO_MAP_END
    2926                 : 
    2927             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableColElement, nsIDOMHTMLTableColElement)
    2928                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableColElement)
    2929             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2930             612 :   DOM_CLASSINFO_MAP_END
    2931                 : 
    2932             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableElement, nsIDOMHTMLTableElement)
    2933                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableElement)
    2934             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2935             612 :   DOM_CLASSINFO_MAP_END
    2936                 : 
    2937             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableRowElement, nsIDOMHTMLTableRowElement)
    2938                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableRowElement)
    2939             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2940             612 :   DOM_CLASSINFO_MAP_END
    2941                 : 
    2942             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTableSectionElement,
    2943                 :                           nsIDOMHTMLTableSectionElement)
    2944                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableSectionElement)
    2945             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2946             612 :   DOM_CLASSINFO_MAP_END
    2947                 : 
    2948             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTextAreaElement, nsIDOMHTMLTextAreaElement)
    2949                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
    2950             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2951             612 :   DOM_CLASSINFO_MAP_END
    2952                 : 
    2953             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLTitleElement, nsIDOMHTMLTitleElement)
    2954                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTitleElement)
    2955             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2956             612 :   DOM_CLASSINFO_MAP_END
    2957                 : 
    2958             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLUListElement, nsIDOMHTMLUListElement)
    2959                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLUListElement)
    2960             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2961             612 :   DOM_CLASSINFO_MAP_END
    2962                 : 
    2963             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLUnknownElement, nsIDOMHTMLUnknownElement)
    2964                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLUnknownElement)
    2965             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    2966             612 :   DOM_CLASSINFO_MAP_END
    2967                 : 
    2968             306 :   DOM_CLASSINFO_MAP_BEGIN(ValidityState, nsIDOMValidityState)
    2969                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMValidityState)
    2970             306 :   DOM_CLASSINFO_MAP_END
    2971                 : 
    2972             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSStyleRule, nsIDOMCSSStyleRule)
    2973                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
    2974             306 :   DOM_CLASSINFO_MAP_END
    2975                 : 
    2976             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSCharsetRule, nsIDOMCSSCharsetRule)
    2977                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSCharsetRule)
    2978             306 :   DOM_CLASSINFO_MAP_END
    2979                 : 
    2980             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSImportRule, nsIDOMCSSImportRule)
    2981                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSImportRule)
    2982             306 :   DOM_CLASSINFO_MAP_END
    2983                 : 
    2984             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
    2985                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
    2986             306 :   DOM_CLASSINFO_MAP_END
    2987                 : 
    2988             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSNameSpaceRule, nsIDOMCSSRule)
    2989                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
    2990             306 :   DOM_CLASSINFO_MAP_END
    2991                 : 
    2992             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSRuleList, nsIDOMCSSRuleList)
    2993                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
    2994             306 :   DOM_CLASSINFO_MAP_END
    2995                 : 
    2996             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSGroupRuleRuleList, nsIDOMCSSRuleList)
    2997                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
    2998             306 :   DOM_CLASSINFO_MAP_END
    2999                 : 
    3000             306 :   DOM_CLASSINFO_MAP_BEGIN(MediaList, nsIDOMMediaList)
    3001                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaList)
    3002             306 :   DOM_CLASSINFO_MAP_END
    3003                 : 
    3004             306 :   DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
    3005                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
    3006             306 :   DOM_CLASSINFO_MAP_END
    3007                 : 
    3008             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
    3009                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
    3010             306 :   DOM_CLASSINFO_MAP_END
    3011                 : 
    3012             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSStyleDeclaration, nsIDOMCSSStyleDeclaration)
    3013                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
    3014                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
    3015             306 :   DOM_CLASSINFO_MAP_END
    3016                 : 
    3017             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ROCSSPrimitiveValue,
    3018                 :                                       nsIDOMCSSPrimitiveValue)
    3019                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSPrimitiveValue)
    3020             306 :   DOM_CLASSINFO_MAP_END
    3021                 : 
    3022             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSValueList, nsIDOMCSSValueList)
    3023                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSValueList)
    3024             306 :   DOM_CLASSINFO_MAP_END
    3025                 : 
    3026             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRect, nsIDOMRect)
    3027                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMRect)
    3028             306 :   DOM_CLASSINFO_MAP_END
    3029                 : 
    3030             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRGBColor, nsIDOMRGBColor)
    3031                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMRGBColor)
    3032                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSRGBAColor)
    3033             306 :   DOM_CLASSINFO_MAP_END
    3034                 : 
    3035             306 :   DOM_CLASSINFO_MAP_BEGIN(Range, nsIDOMRange)
    3036                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMRange)
    3037             306 :   DOM_CLASSINFO_MAP_END
    3038                 : 
    3039             306 :   DOM_CLASSINFO_MAP_BEGIN(NodeIterator, nsIDOMNodeIterator)
    3040                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeIterator)
    3041             306 :   DOM_CLASSINFO_MAP_END
    3042                 : 
    3043             306 :   DOM_CLASSINFO_MAP_BEGIN(TreeWalker, nsIDOMTreeWalker)
    3044                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTreeWalker)
    3045             306 :   DOM_CLASSINFO_MAP_END
    3046                 : 
    3047             306 :   DOM_CLASSINFO_MAP_BEGIN(Selection, nsISelection)
    3048                 :     DOM_CLASSINFO_MAP_ENTRY(nsISelection)
    3049             306 :   DOM_CLASSINFO_MAP_END
    3050                 : 
    3051                 : #ifdef MOZ_XUL
    3052             306 :   DOM_CLASSINFO_MAP_BEGIN(XULDocument, nsIDOMXULDocument)
    3053                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
    3054                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULDocument)
    3055             306 :     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
    3056             612 :   DOM_CLASSINFO_MAP_END
    3057                 : 
    3058             306 :   DOM_CLASSINFO_MAP_BEGIN(XULElement, nsIDOMXULElement)
    3059                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULElement)
    3060                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3061                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
    3062                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle)
    3063                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
    3064                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
    3065             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
    3066                 :                                         nsDOMTouchEvent::PrefEnabled())
    3067             612 :   DOM_CLASSINFO_MAP_END
    3068                 : 
    3069             306 :   DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
    3070                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
    3071             306 :   DOM_CLASSINFO_MAP_END
    3072                 : #endif
    3073                 : 
    3074             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControllers, nsIControllers)
    3075                 :     DOM_CLASSINFO_MAP_ENTRY(nsIControllers)
    3076             306 :   DOM_CLASSINFO_MAP_END
    3077                 : 
    3078             306 :   DOM_CLASSINFO_MAP_BEGIN(BoxObject, nsIBoxObject)
    3079                 :     DOM_CLASSINFO_MAP_ENTRY(nsIBoxObject)
    3080             306 :   DOM_CLASSINFO_MAP_END
    3081                 : 
    3082                 : #ifdef MOZ_XUL
    3083             306 :   DOM_CLASSINFO_MAP_BEGIN(TreeSelection, nsITreeSelection)
    3084                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeSelection)
    3085             306 :   DOM_CLASSINFO_MAP_END
    3086                 : 
    3087             306 :   DOM_CLASSINFO_MAP_BEGIN(TreeContentView, nsITreeContentView)
    3088                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeContentView)
    3089                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
    3090             306 :   DOM_CLASSINFO_MAP_END
    3091                 : #endif
    3092                 : 
    3093             306 :   DOM_CLASSINFO_MAP_BEGIN(Crypto, nsIDOMCrypto)
    3094                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCrypto)
    3095             306 :   DOM_CLASSINFO_MAP_END
    3096                 : 
    3097             306 :   DOM_CLASSINFO_MAP_BEGIN(CRMFObject, nsIDOMCRMFObject)
    3098                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject)
    3099             306 :   DOM_CLASSINFO_MAP_END
    3100                 : 
    3101             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLStylesheetProcessingInstruction, nsIDOMProcessingInstruction)
    3102                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
    3103                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
    3104                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3105             306 :   DOM_CLASSINFO_MAP_END
    3106                 : 
    3107             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
    3108             612 :     DOM_CLASSINFO_WINDOW_MAP_ENTRIES(true)
    3109                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
    3110             918 :   DOM_CLASSINFO_MAP_END
    3111                 : 
    3112             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentList, nsIDOMHTMLCollection)
    3113                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
    3114                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
    3115             306 :   DOM_CLASSINFO_MAP_END
    3116                 : 
    3117             306 :   DOM_CLASSINFO_MAP_BEGIN(ImageDocument, nsIImageDocument)
    3118                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
    3119                 :     DOM_CLASSINFO_MAP_ENTRY(nsIImageDocument)
    3120             306 :     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
    3121             612 :   DOM_CLASSINFO_MAP_END
    3122                 : 
    3123                 : #ifdef MOZ_XUL
    3124             306 :   DOM_CLASSINFO_MAP_BEGIN(XULTemplateBuilder, nsIXULTemplateBuilder)
    3125                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
    3126             306 :   DOM_CLASSINFO_MAP_END
    3127                 : 
    3128             306 :   DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
    3129                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
    3130                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
    3131             306 :   DOM_CLASSINFO_MAP_END
    3132                 : #endif
    3133                 : 
    3134             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
    3135                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
    3136             306 :   DOM_CLASSINFO_MAP_END
    3137                 : 
    3138                 : #ifdef MOZ_XUL
    3139             306 :   DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
    3140                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
    3141             306 :   DOM_CLASSINFO_MAP_END
    3142                 : 
    3143             306 :   DOM_CLASSINFO_MAP_BEGIN(TreeColumns, nsITreeColumns)
    3144                 :     DOM_CLASSINFO_MAP_ENTRY(nsITreeColumns)
    3145             306 :   DOM_CLASSINFO_MAP_END
    3146                 : #endif
    3147                 : 
    3148             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
    3149                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
    3150             306 :   DOM_CLASSINFO_MAP_END
    3151                 : 
    3152             306 :   DOM_CLASSINFO_MAP_BEGIN(BeforeUnloadEvent, nsIDOMBeforeUnloadEvent)
    3153                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
    3154                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3155             306 :   DOM_CLASSINFO_MAP_END
    3156                 : 
    3157                 : #define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES                           \
    3158                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                          \
    3159                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement)                           \
    3160                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)                            \
    3161                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)                         \
    3162                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)                     \
    3163                 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,          \
    3164                 :                                         nsDOMTouchEvent::PrefEnabled())
    3165                 : 
    3166                 : #define DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES \
    3167                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)   \
    3168                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)                \
    3169                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)             \
    3170                 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3171                 : 
    3172                 : #define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \
    3173                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)       \
    3174                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable)   \
    3175                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)        \
    3176                 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3177                 : 
    3178                 :   // XXX - the proto chain stuff is sort of hackish, because of the MI in
    3179                 :   // the SVG interfaces. I doubt that extending the proto on one interface
    3180                 :   // works properly on an element which inherits off multiple interfaces.
    3181                 :   // Tough luck. - bbaetz
    3182                 : 
    3183                 :   // The SVG document
    3184                 : 
    3185             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGDocument, nsIDOMSVGDocument)
    3186                 :     // Order is significant.  nsIDOMDocument.title shadows
    3187                 :     // nsIDOMSVGDocument.title, which is readonly.
    3188                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
    3189                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDocument)
    3190             306 :     DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
    3191             612 :   DOM_CLASSINFO_MAP_END
    3192                 : 
    3193                 :   // SVG element classes
    3194                 : 
    3195             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAElement, nsIDOMSVGAElement)
    3196                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAElement)
    3197                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3198                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3199             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3200             612 :   DOM_CLASSINFO_MAP_END
    3201                 : 
    3202             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAltGlyphElement, nsIDOMSVGAltGlyphElement)
    3203                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
    3204                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3205             306 :     DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
    3206             612 :   DOM_CLASSINFO_MAP_END
    3207                 : 
    3208             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimateElement, nsIDOMSVGAnimateElement)
    3209                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
    3210                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3211                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateElement)
    3212                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
    3213             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3214             612 :   DOM_CLASSINFO_MAP_END
    3215                 : 
    3216             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimateTransformElement,
    3217                 :                           nsIDOMSVGAnimateTransformElement)
    3218                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
    3219                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3220                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateTransformElement)
    3221                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
    3222             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3223             612 :   DOM_CLASSINFO_MAP_END
    3224                 : 
    3225             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimateMotionElement,
    3226                 :                           nsIDOMSVGAnimateMotionElement)
    3227                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
    3228                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3229                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateMotionElement)
    3230                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
    3231             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3232             612 :   DOM_CLASSINFO_MAP_END
    3233                 : 
    3234             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGSetElement,
    3235                 :                           nsIDOMSVGSetElement)
    3236                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
    3237                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3238                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSetElement)
    3239                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
    3240             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3241             612 :   DOM_CLASSINFO_MAP_END
    3242                 : 
    3243             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGMpathElement, nsIDOMSVGMpathElement)
    3244                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3245             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3246             612 :   DOM_CLASSINFO_MAP_END
    3247                 : 
    3248             306 :   DOM_CLASSINFO_MAP_BEGIN(TimeEvent, nsIDOMTimeEvent)
    3249                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeEvent)
    3250                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3251             306 :   DOM_CLASSINFO_MAP_END
    3252                 : 
    3253             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGCircleElement, nsIDOMSVGCircleElement)
    3254                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGCircleElement)
    3255                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3256             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3257             612 :   DOM_CLASSINFO_MAP_END
    3258                 : 
    3259             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGClipPathElement, nsIDOMSVGClipPathElement)
    3260                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGClipPathElement)
    3261                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3262                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3263             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3264             612 :   DOM_CLASSINFO_MAP_END
    3265                 : 
    3266             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGDefsElement, nsIDOMSVGDefsElement)
    3267                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDefsElement)
    3268                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3269             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3270             612 :   DOM_CLASSINFO_MAP_END
    3271                 : 
    3272             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGDescElement, nsIDOMSVGDescElement)
    3273                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDescElement)
    3274                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3275             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3276             612 :   DOM_CLASSINFO_MAP_END
    3277                 : 
    3278             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGEllipseElement, nsIDOMSVGEllipseElement)
    3279                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEllipseElement)
    3280                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3281             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3282             612 :   DOM_CLASSINFO_MAP_END
    3283                 : 
    3284             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEBlendElement, nsIDOMSVGFEBlendElement)
    3285                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEBlendElement)
    3286                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3287                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3288             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3289             612 :   DOM_CLASSINFO_MAP_END
    3290                 : 
    3291             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEColorMatrixElement, nsIDOMSVGFEColorMatrixElement)
    3292                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEColorMatrixElement)
    3293                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3294                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3295             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3296             612 :   DOM_CLASSINFO_MAP_END
    3297                 : 
    3298             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEComponentTransferElement, nsIDOMSVGFEComponentTransferElement)
    3299                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEComponentTransferElement)
    3300                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3301                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3302             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3303             612 :   DOM_CLASSINFO_MAP_END
    3304                 : 
    3305             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFECompositeElement, nsIDOMSVGFECompositeElement)
    3306                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFECompositeElement)
    3307                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3308                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3309             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3310             612 :   DOM_CLASSINFO_MAP_END
    3311                 : 
    3312             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEConvolveMatrixElement, nsIDOMSVGFEConvolveMatrixElement)
    3313                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEConvolveMatrixElement)
    3314                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3315                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3316             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3317             612 :   DOM_CLASSINFO_MAP_END
    3318                 : 
    3319             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEDiffuseLightingElement, nsIDOMSVGFEDiffuseLightingElement)
    3320                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement)
    3321                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3322                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3323             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3324             612 :   DOM_CLASSINFO_MAP_END
    3325                 : 
    3326             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEDisplacementMapElement, nsIDOMSVGFEDisplacementMapElement)
    3327                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement)
    3328                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3329                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3330             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3331             612 :   DOM_CLASSINFO_MAP_END
    3332                 : 
    3333             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEDistantLightElement, nsIDOMSVGFEDistantLightElement)
    3334                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDistantLightElement)
    3335             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3336             612 :   DOM_CLASSINFO_MAP_END
    3337                 : 
    3338             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEFloodElement, nsIDOMSVGFEFloodElement)
    3339                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFloodElement)
    3340                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3341                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3342             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3343             612 :   DOM_CLASSINFO_MAP_END
    3344                 : 
    3345             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncAElement, nsIDOMSVGFEFuncAElement)
    3346                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncAElement)
    3347             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3348             612 :   DOM_CLASSINFO_MAP_END
    3349                 : 
    3350             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncBElement, nsIDOMSVGFEFuncBElement)
    3351                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncBElement)
    3352             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3353             612 :   DOM_CLASSINFO_MAP_END
    3354                 : 
    3355             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncGElement, nsIDOMSVGFEFuncGElement)
    3356                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncGElement)
    3357             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3358             612 :   DOM_CLASSINFO_MAP_END
    3359                 : 
    3360             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncRElement, nsIDOMSVGFEFuncRElement)
    3361                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncRElement)
    3362             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3363             612 :   DOM_CLASSINFO_MAP_END
    3364                 : 
    3365             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEGaussianBlurElement, nsIDOMSVGFEGaussianBlurElement)
    3366                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEGaussianBlurElement)
    3367                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3368                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3369             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3370             612 :   DOM_CLASSINFO_MAP_END
    3371                 : 
    3372             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEImageElement, nsIDOMSVGFEImageElement)
    3373                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEImageElement)
    3374                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3375                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3376                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3377             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3378             612 :   DOM_CLASSINFO_MAP_END
    3379                 : 
    3380             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeElement, nsIDOMSVGFEMergeElement)
    3381                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeElement)
    3382                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3383                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3384             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3385             612 :   DOM_CLASSINFO_MAP_END
    3386                 : 
    3387             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEMorphologyElement, nsIDOMSVGFEMorphologyElement)
    3388                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMorphologyElement)
    3389                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3390                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3391             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3392             612 :   DOM_CLASSINFO_MAP_END
    3393                 : 
    3394             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeNodeElement, nsIDOMSVGFEMergeNodeElement)
    3395                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeNodeElement)
    3396             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3397             612 :   DOM_CLASSINFO_MAP_END
    3398                 : 
    3399             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEOffsetElement, nsIDOMSVGFEOffsetElement)
    3400                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEOffsetElement)
    3401                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3402                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3403             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3404             612 :   DOM_CLASSINFO_MAP_END
    3405                 : 
    3406             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFEPointLightElement, nsIDOMSVGFEPointLightElement)
    3407                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEPointLightElement)
    3408             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3409             612 :   DOM_CLASSINFO_MAP_END
    3410                 : 
    3411             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFESpecularLightingElement, nsIDOMSVGFESpecularLightingElement)
    3412                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement)
    3413                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3414                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3415             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3416             612 :   DOM_CLASSINFO_MAP_END
    3417                 : 
    3418             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFESpotLightElement, nsIDOMSVGFESpotLightElement)
    3419                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpotLightElement)
    3420             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3421             612 :   DOM_CLASSINFO_MAP_END
    3422                 : 
    3423             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFETileElement, nsIDOMSVGFETileElement)
    3424                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETileElement)
    3425                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3426                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3427             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3428             612 :   DOM_CLASSINFO_MAP_END
    3429                 : 
    3430             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement)
    3431                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
    3432                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
    3433                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3434             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3435             612 :   DOM_CLASSINFO_MAP_END
    3436                 : 
    3437             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGFilterElement, nsIDOMSVGFilterElement)
    3438                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterElement)
    3439                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3440                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3441                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3442                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3443             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3444             612 :   DOM_CLASSINFO_MAP_END
    3445                 : 
    3446             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement)
    3447                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
    3448                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3449             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3450             612 :   DOM_CLASSINFO_MAP_END
    3451                 : 
    3452             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGGElement, nsIDOMSVGGElement)
    3453                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGElement)
    3454                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3455             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3456             612 :   DOM_CLASSINFO_MAP_END
    3457                 : 
    3458             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGImageElement, nsIDOMSVGImageElement)
    3459                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGImageElement)
    3460                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3461                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3462             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3463             612 :   DOM_CLASSINFO_MAP_END
    3464                 : 
    3465             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGLinearGradientElement, nsIDOMSVGLinearGradientElement)
    3466                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
    3467                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
    3468                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3469                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3470                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3471                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3472             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3473             612 :   DOM_CLASSINFO_MAP_END
    3474                 : 
    3475             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGLineElement, nsIDOMSVGLineElement)
    3476                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLineElement)
    3477                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3478             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3479             612 :   DOM_CLASSINFO_MAP_END
    3480                 : 
    3481             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGMarkerElement, nsIDOMSVGMarkerElement)
    3482                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMarkerElement)
    3483                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3484                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
    3485             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3486             612 :   DOM_CLASSINFO_MAP_END
    3487                 : 
    3488             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGMaskElement, nsIDOMSVGMaskElement)
    3489                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMaskElement)
    3490                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3491                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3492                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3493             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3494             612 :   DOM_CLASSINFO_MAP_END
    3495                 : 
    3496             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGMetadataElement, nsIDOMSVGMetadataElement)
    3497                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMetadataElement)
    3498             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3499             612 :   DOM_CLASSINFO_MAP_END
    3500                 : 
    3501             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathElement, nsIDOMSVGPathElement)
    3502                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathElement)
    3503                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3504                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
    3505             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3506             612 :   DOM_CLASSINFO_MAP_END
    3507                 : 
    3508             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPatternElement, nsIDOMSVGPatternElement)
    3509                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPatternElement)
    3510                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3511                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
    3512                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3513                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3514                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3515             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3516             612 :   DOM_CLASSINFO_MAP_END
    3517                 : 
    3518             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPolygonElement, nsIDOMSVGPolygonElement)
    3519                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolygonElement)
    3520                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3521                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
    3522             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3523             612 :   DOM_CLASSINFO_MAP_END
    3524                 : 
    3525             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPolylineElement, nsIDOMSVGPolylineElement)
    3526                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolylineElement)
    3527                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3528                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
    3529             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3530             612 :   DOM_CLASSINFO_MAP_END
    3531                 : 
    3532             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGRadialGradientElement, nsIDOMSVGRadialGradientElement)
    3533                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
    3534                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
    3535                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3536                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3537                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3538                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
    3539             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3540             612 :   DOM_CLASSINFO_MAP_END
    3541                 : 
    3542             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGRectElement, nsIDOMSVGRectElement)
    3543                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRectElement)
    3544                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3545             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3546             612 :   DOM_CLASSINFO_MAP_END
    3547                 : 
    3548             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGScriptElement, nsIDOMSVGScriptElement)
    3549                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGScriptElement)
    3550                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3551             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3552             612 :   DOM_CLASSINFO_MAP_END
    3553                 : 
    3554             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGStopElement, nsIDOMSVGStopElement)
    3555                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStopElement)
    3556                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3557             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3558             612 :   DOM_CLASSINFO_MAP_END
    3559                 :   
    3560             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGStyleElement, nsIDOMSVGStyleElement)
    3561                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStyleElement)
    3562                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
    3563             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3564             612 :   DOM_CLASSINFO_MAP_END
    3565                 : 
    3566             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGSVGElement, nsIDOMSVGSVGElement)
    3567                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSVGElement)
    3568                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
    3569                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
    3570                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3571                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3572                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomAndPan)
    3573             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3574             612 :   DOM_CLASSINFO_MAP_END
    3575                 : 
    3576             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGSwitchElement, nsIDOMSVGSwitchElement)
    3577                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSwitchElement)
    3578                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3579             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3580             612 :   DOM_CLASSINFO_MAP_END
    3581                 : 
    3582             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGSymbolElement, nsIDOMSVGSymbolElement)
    3583                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3584                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSymbolElement)
    3585                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3586                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
    3587                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3588             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3589             612 :   DOM_CLASSINFO_MAP_END
    3590                 : 
    3591             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTextElement, nsIDOMSVGTextElement)
    3592                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
    3593                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
    3594                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3595             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3596             612 :   DOM_CLASSINFO_MAP_END
    3597                 : 
    3598             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTextPathElement, nsIDOMSVGTextPathElement)
    3599                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3600             306 :     DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
    3601             612 :   DOM_CLASSINFO_MAP_END
    3602                 : 
    3603             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTitleElement, nsIDOMSVGTitleElement)
    3604                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTitleElement)
    3605                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
    3606             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3607             612 :   DOM_CLASSINFO_MAP_END
    3608                 : 
    3609             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTSpanElement, nsIDOMSVGTSpanElement)
    3610                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
    3611             306 :     DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
    3612             612 :   DOM_CLASSINFO_MAP_END
    3613                 : 
    3614             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGUnknownElement, nsIDOMSVGElement)
    3615             306 :     DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
    3616             612 :   DOM_CLASSINFO_MAP_END
    3617                 : 
    3618             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGUseElement, nsIDOMSVGUseElement)
    3619                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUseElement)
    3620                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
    3621                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
    3622             306 :     DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
    3623             612 :   DOM_CLASSINFO_MAP_END
    3624                 : 
    3625                 :   // other SVG classes
    3626                 : 
    3627             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAngle, nsIDOMSVGAngle)
    3628                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAngle)
    3629             306 :   DOM_CLASSINFO_MAP_END
    3630                 : 
    3631             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedAngle, nsIDOMSVGAnimatedAngle)
    3632                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedAngle)
    3633             306 :   DOM_CLASSINFO_MAP_END
    3634                 : 
    3635             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedBoolean, nsIDOMSVGAnimatedBoolean)
    3636                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedBoolean)
    3637             306 :   DOM_CLASSINFO_MAP_END
    3638                 : 
    3639             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedEnumeration, nsIDOMSVGAnimatedEnumeration)
    3640                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
    3641             306 :   DOM_CLASSINFO_MAP_END
    3642                 : 
    3643             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger)
    3644                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
    3645             306 :   DOM_CLASSINFO_MAP_END
    3646                 : 
    3647             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLength, nsIDOMSVGAnimatedLength)
    3648                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLength)
    3649             306 :   DOM_CLASSINFO_MAP_END
    3650                 : 
    3651             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLengthList, nsIDOMSVGAnimatedLengthList)
    3652                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLengthList)
    3653             306 :   DOM_CLASSINFO_MAP_END
    3654                 : 
    3655             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber)
    3656                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber)
    3657             306 :   DOM_CLASSINFO_MAP_END
    3658                 : 
    3659             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumberList, nsIDOMSVGAnimatedNumberList)
    3660                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumberList)
    3661             306 :   DOM_CLASSINFO_MAP_END
    3662                 : 
    3663             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedPreserveAspectRatio, nsIDOMSVGAnimatedPreserveAspectRatio)
    3664                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPreserveAspectRatio)
    3665             306 :   DOM_CLASSINFO_MAP_END
    3666                 : 
    3667             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedRect, nsIDOMSVGAnimatedRect)
    3668                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedRect)
    3669             306 :   DOM_CLASSINFO_MAP_END
    3670                 : 
    3671             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedString, nsIDOMSVGAnimatedString)
    3672                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedString)
    3673             306 :   DOM_CLASSINFO_MAP_END
    3674                 : 
    3675             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedTransformList, nsIDOMSVGAnimatedTransformList)
    3676                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
    3677             306 :   DOM_CLASSINFO_MAP_END
    3678                 : 
    3679             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGEvent, nsIDOMSVGEvent)
    3680                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEvent)
    3681                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3682             306 :   DOM_CLASSINFO_MAP_END
    3683                 : 
    3684             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGException, nsIDOMSVGException)
    3685                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGException)
    3686                 :     DOM_CLASSINFO_MAP_ENTRY(nsIException)
    3687             306 :   DOM_CLASSINFO_MAP_END
    3688                 : 
    3689             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength)
    3690                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength)
    3691             306 :   DOM_CLASSINFO_MAP_END
    3692                 : 
    3693             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGLengthList, nsIDOMSVGLengthList)
    3694                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLengthList)
    3695             306 :   DOM_CLASSINFO_MAP_END
    3696                 : 
    3697             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGMatrix, nsIDOMSVGMatrix)
    3698                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMatrix)
    3699             306 :   DOM_CLASSINFO_MAP_END
    3700                 : 
    3701             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGNumber, nsIDOMSVGNumber)
    3702                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber)
    3703             306 :   DOM_CLASSINFO_MAP_END
    3704                 : 
    3705             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGNumberList, nsIDOMSVGNumberList)
    3706                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumberList)
    3707             306 :   DOM_CLASSINFO_MAP_END
    3708                 : 
    3709             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcAbs, nsIDOMSVGPathSegArcAbs)
    3710                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcAbs)
    3711                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3712             306 :   DOM_CLASSINFO_MAP_END
    3713                 : 
    3714             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcRel, nsIDOMSVGPathSegArcRel)
    3715                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcRel)
    3716                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3717             306 :   DOM_CLASSINFO_MAP_END
    3718                 : 
    3719             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegClosePath, nsIDOMSVGPathSegClosePath)
    3720                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegClosePath)
    3721                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3722             306 :   DOM_CLASSINFO_MAP_END
    3723                 : 
    3724             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicAbs, nsIDOMSVGPathSegCurvetoCubicAbs)
    3725                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicAbs)
    3726                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3727             306 :   DOM_CLASSINFO_MAP_END
    3728                 : 
    3729             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicRel, nsIDOMSVGPathSegCurvetoCubicRel)
    3730                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicRel)
    3731                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3732             306 :   DOM_CLASSINFO_MAP_END
    3733                 : 
    3734             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothAbs, nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
    3735                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
    3736                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3737             306 :   DOM_CLASSINFO_MAP_END
    3738                 : 
    3739             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothRel, nsIDOMSVGPathSegCurvetoCubicSmoothRel)
    3740                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothRel)
    3741                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3742             306 :   DOM_CLASSINFO_MAP_END
    3743                 : 
    3744             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticAbs, nsIDOMSVGPathSegCurvetoQuadraticAbs)
    3745                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticAbs)
    3746                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3747             306 :   DOM_CLASSINFO_MAP_END
    3748                 : 
    3749             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticRel, nsIDOMSVGPathSegCurvetoQuadraticRel)
    3750                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticRel)
    3751                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3752             306 :   DOM_CLASSINFO_MAP_END
    3753                 : 
    3754             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothAbs, nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
    3755                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
    3756                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3757             306 :   DOM_CLASSINFO_MAP_END
    3758                 : 
    3759             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothRel, nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
    3760                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
    3761                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3762             306 :   DOM_CLASSINFO_MAP_END
    3763                 : 
    3764             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoAbs, nsIDOMSVGPathSegLinetoAbs)
    3765                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoAbs)
    3766                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3767             306 :   DOM_CLASSINFO_MAP_END
    3768                 : 
    3769             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalAbs, nsIDOMSVGPathSegLinetoHorizontalAbs)
    3770                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalAbs)
    3771                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3772             306 :   DOM_CLASSINFO_MAP_END
    3773                 : 
    3774             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalRel, nsIDOMSVGPathSegLinetoHorizontalRel)
    3775                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalRel)
    3776                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3777             306 :   DOM_CLASSINFO_MAP_END
    3778                 : 
    3779             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoRel, nsIDOMSVGPathSegLinetoRel)
    3780                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoRel)
    3781                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3782             306 :   DOM_CLASSINFO_MAP_END
    3783                 : 
    3784             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalAbs, nsIDOMSVGPathSegLinetoVerticalAbs)
    3785                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalAbs)
    3786                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3787             306 :   DOM_CLASSINFO_MAP_END
    3788                 : 
    3789             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalRel, nsIDOMSVGPathSegLinetoVerticalRel)
    3790                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalRel)
    3791                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3792             306 :   DOM_CLASSINFO_MAP_END
    3793                 : 
    3794             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegList, nsIDOMSVGPathSegList)
    3795                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegList)
    3796             306 :   DOM_CLASSINFO_MAP_END
    3797                 : 
    3798             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoAbs, nsIDOMSVGPathSegMovetoAbs)
    3799                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoAbs)
    3800                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3801             306 :   DOM_CLASSINFO_MAP_END
    3802                 : 
    3803             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoRel, nsIDOMSVGPathSegMovetoRel)
    3804                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoRel)
    3805                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
    3806             306 :   DOM_CLASSINFO_MAP_END
    3807                 : 
    3808             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPoint, nsIDOMSVGPoint)
    3809                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPoint)
    3810             306 :   DOM_CLASSINFO_MAP_END
    3811                 : 
    3812             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPointList, nsIDOMSVGPointList)
    3813                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPointList)
    3814             306 :   DOM_CLASSINFO_MAP_END
    3815                 : 
    3816             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGPreserveAspectRatio, nsIDOMSVGPreserveAspectRatio)
    3817                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPreserveAspectRatio)
    3818             306 :   DOM_CLASSINFO_MAP_END
    3819                 : 
    3820             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGRect, nsIDOMSVGRect)
    3821                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRect)
    3822             306 :   DOM_CLASSINFO_MAP_END
    3823                 : 
    3824             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGStringList, nsIDOMSVGStringList)
    3825                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStringList)
    3826             306 :   DOM_CLASSINFO_MAP_END
    3827                 : 
    3828             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTransform, nsIDOMSVGTransform)
    3829                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransform)
    3830             306 :   DOM_CLASSINFO_MAP_END
    3831                 : 
    3832             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGTransformList, nsIDOMSVGTransformList)
    3833                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
    3834             306 :   DOM_CLASSINFO_MAP_END
    3835                 : 
    3836             306 :   DOM_CLASSINFO_MAP_BEGIN(SVGZoomEvent, nsIDOMSVGZoomEvent)
    3837                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
    3838                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    3839             306 :   DOM_CLASSINFO_MAP_END
    3840                 : 
    3841             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
    3842                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
    3843             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    3844             612 :   DOM_CLASSINFO_MAP_END
    3845                 : 
    3846             306 :   DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D)
    3847                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasRenderingContext2D)
    3848             306 :   DOM_CLASSINFO_MAP_END
    3849                 : 
    3850             306 :   DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
    3851                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
    3852             306 :   DOM_CLASSINFO_MAP_END
    3853                 : 
    3854             306 :   DOM_CLASSINFO_MAP_BEGIN(CanvasPattern, nsIDOMCanvasPattern)
    3855                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasPattern)
    3856             306 :   DOM_CLASSINFO_MAP_END
    3857                 : 
    3858             306 :   DOM_CLASSINFO_MAP_BEGIN(TextMetrics, nsIDOMTextMetrics)
    3859                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTextMetrics)
    3860             306 :   DOM_CLASSINFO_MAP_END
    3861                 : 
    3862             306 :   DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
    3863                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
    3864                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
    3865             306 :   DOM_CLASSINFO_MAP_END
    3866                 : 
    3867             306 :   DOM_CLASSINFO_MAP_BEGIN(XPathEvaluator, nsIDOMXPathEvaluator)
    3868                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator)
    3869             306 :   DOM_CLASSINFO_MAP_END
    3870                 : 
    3871             306 :   DOM_CLASSINFO_MAP_BEGIN(XPathException, nsIDOMXPathException)
    3872                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathException)
    3873                 :     DOM_CLASSINFO_MAP_ENTRY(nsIException)
    3874             306 :   DOM_CLASSINFO_MAP_END
    3875                 : 
    3876             306 :   DOM_CLASSINFO_MAP_BEGIN(XPathExpression, nsIDOMXPathExpression)
    3877                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathExpression)
    3878                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSXPathExpression)
    3879             306 :   DOM_CLASSINFO_MAP_END
    3880                 : 
    3881             306 :   DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
    3882                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
    3883             306 :   DOM_CLASSINFO_MAP_END
    3884                 : 
    3885             306 :   DOM_CLASSINFO_MAP_BEGIN(XPathResult, nsIDOMXPathResult)
    3886                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathResult)
    3887             306 :   DOM_CLASSINFO_MAP_END
    3888                 : 
    3889             306 :   DOM_CLASSINFO_MAP_BEGIN(StorageObsolete, nsIDOMStorageObsolete)
    3890                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageObsolete)
    3891             306 :   DOM_CLASSINFO_MAP_END
    3892                 : 
    3893             306 :   DOM_CLASSINFO_MAP_BEGIN(Storage, nsIDOMStorage)
    3894                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
    3895             306 :   DOM_CLASSINFO_MAP_END
    3896                 : 
    3897             306 :   DOM_CLASSINFO_MAP_BEGIN(StorageList, nsIDOMStorageList)
    3898                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageList)
    3899             306 :   DOM_CLASSINFO_MAP_END
    3900                 : 
    3901             306 :   DOM_CLASSINFO_MAP_BEGIN(StorageItem, nsIDOMStorageItem)
    3902                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageItem)
    3903                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMToString)
    3904             306 :   DOM_CLASSINFO_MAP_END
    3905                 : 
    3906             306 :   DOM_CLASSINFO_MAP_BEGIN(StorageEvent, nsIDOMStorageEvent)
    3907                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEvent)
    3908                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3909             306 :   DOM_CLASSINFO_MAP_END
    3910                 : 
    3911             306 :   DOM_CLASSINFO_MAP_BEGIN(StorageEventObsolete, nsIDOMStorageEventObsolete)
    3912                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEventObsolete)
    3913             306 :   DOM_CLASSINFO_MAP_END
    3914                 : 
    3915             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMParser, nsIDOMParser)
    3916                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMParser)
    3917                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMParserJS)
    3918             306 :   DOM_CLASSINFO_MAP_END
    3919                 : 
    3920             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLSerializer, nsIDOMSerializer)
    3921                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSerializer)
    3922             306 :   DOM_CLASSINFO_MAP_END
    3923                 : 
    3924             306 :   DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequest, nsIXMLHttpRequest)
    3925                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequest)
    3926                 :     DOM_CLASSINFO_MAP_ENTRY(nsIJSXMLHttpRequest)
    3927                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
    3928                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3929                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
    3930             306 :   DOM_CLASSINFO_MAP_END
    3931                 : 
    3932             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLHttpProgressEvent, nsIDOMEvent)
    3933                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMLSProgressEvent)
    3934                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
    3935                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3936             306 :   DOM_CLASSINFO_MAP_END
    3937                 : 
    3938             306 :   DOM_CLASSINFO_MAP_BEGIN(EventSource, nsIEventSource)
    3939                 :     DOM_CLASSINFO_MAP_ENTRY(nsIEventSource)
    3940                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3941             306 :   DOM_CLASSINFO_MAP_END
    3942                 : 
    3943             306 :   DOM_CLASSINFO_MAP_BEGIN(XULCommandEvent, nsIDOMXULCommandEvent)
    3944                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandEvent)
    3945                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    3946             306 :   DOM_CLASSINFO_MAP_END
    3947                 : 
    3948             306 :   DOM_CLASSINFO_MAP_BEGIN(CommandEvent, nsIDOMCommandEvent)
    3949                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCommandEvent)
    3950                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    3951             306 :   DOM_CLASSINFO_MAP_END
    3952                 : 
    3953             306 :   DOM_CLASSINFO_MAP_BEGIN(OfflineResourceList, nsIDOMOfflineResourceList)
    3954                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMOfflineResourceList)
    3955                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    3956             306 :   DOM_CLASSINFO_MAP_END
    3957                 : 
    3958             306 :   DOM_CLASSINFO_MAP_BEGIN(ClientRect, nsIDOMClientRect)
    3959                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRect)
    3960             306 :    DOM_CLASSINFO_MAP_END
    3961                 :  
    3962             306 :   DOM_CLASSINFO_MAP_BEGIN(ClientRectList, nsIDOMClientRectList)
    3963                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRectList)
    3964             306 :   DOM_CLASSINFO_MAP_END
    3965                 : 
    3966             306 :   DOM_CLASSINFO_MAP_BEGIN(FileList, nsIDOMFileList)
    3967                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileList)
    3968             306 :   DOM_CLASSINFO_MAP_END
    3969                 : 
    3970             306 :   DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
    3971                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
    3972                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob_GECKO_13)
    3973             306 :   DOM_CLASSINFO_MAP_END
    3974                 : 
    3975             306 :   DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
    3976                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
    3977                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob_GECKO_13)
    3978                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
    3979             306 :   DOM_CLASSINFO_MAP_END
    3980                 : 
    3981             306 :   DOM_CLASSINFO_MAP_BEGIN(FileException, nsIDOMFileException)
    3982                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileException)
    3983                 :     DOM_CLASSINFO_MAP_ENTRY(nsIException)
    3984             306 :   DOM_CLASSINFO_MAP_END
    3985                 : 
    3986             306 :   DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
    3987                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
    3988                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
    3989             306 :   DOM_CLASSINFO_MAP_END
    3990                 : 
    3991             306 :   DOM_CLASSINFO_MAP_BEGIN(MozURLProperty, nsIDOMMozURLProperty)
    3992                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozURLProperty)
    3993             306 :   DOM_CLASSINFO_MAP_END
    3994                 : 
    3995             306 :   DOM_CLASSINFO_MAP_BEGIN(MozBlobBuilder, nsIDOMMozBlobBuilder)
    3996                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBlobBuilder)
    3997             306 :   DOM_CLASSINFO_MAP_END
    3998                 : 
    3999             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMStringMap, nsIDOMDOMStringMap)
    4000                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringMap)
    4001             306 :   DOM_CLASSINFO_MAP_END
    4002                 : 
    4003             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
    4004             918 :     DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
    4005                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
    4006            1224 :   DOM_CLASSINFO_MAP_END
    4007                 : 
    4008             306 :   DOM_CLASSINFO_MAP_BEGIN(DataContainerEvent, nsIDOMDataContainerEvent)
    4009                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataContainerEvent)
    4010                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4011             306 :   DOM_CLASSINFO_MAP_END
    4012                 : 
    4013             306 :   DOM_CLASSINFO_MAP_BEGIN(MessageEvent, nsIDOMMessageEvent)
    4014                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMessageEvent)
    4015                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4016             306 :   DOM_CLASSINFO_MAP_END
    4017                 : 
    4018             306 :   DOM_CLASSINFO_MAP_BEGIN(GeoGeolocation, nsIDOMGeoGeolocation)
    4019                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoGeolocation)
    4020             306 :   DOM_CLASSINFO_MAP_END
    4021                 : 
    4022             306 :   DOM_CLASSINFO_MAP_BEGIN(GeoPosition, nsIDOMGeoPosition)
    4023                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPosition)
    4024             306 :   DOM_CLASSINFO_MAP_END
    4025                 : 
    4026             306 :   DOM_CLASSINFO_MAP_BEGIN(GeoPositionCoords, nsIDOMGeoPositionCoords)
    4027                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionCoords)
    4028             306 :   DOM_CLASSINFO_MAP_END
    4029                 : 
    4030             306 :   DOM_CLASSINFO_MAP_BEGIN(GeoPositionAddress, nsIDOMGeoPositionAddress)
    4031                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionAddress)
    4032             306 :   DOM_CLASSINFO_MAP_END
    4033                 : 
    4034             306 :   DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError)
    4035                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
    4036             306 :   DOM_CLASSINFO_MAP_END
    4037                 : 
    4038             306 :   DOM_CLASSINFO_MAP_BEGIN(MozBatteryManager, nsIDOMMozBatteryManager)
    4039                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBatteryManager)
    4040                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4041             306 :   DOM_CLASSINFO_MAP_END
    4042                 : 
    4043             306 :   DOM_CLASSINFO_MAP_BEGIN(MozPowerManager, nsIDOMMozPowerManager)
    4044                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozPowerManager)
    4045             306 :   DOM_CLASSINFO_MAP_END
    4046                 : 
    4047             306 :   DOM_CLASSINFO_MAP_BEGIN(MozWakeLock, nsIDOMMozWakeLock)
    4048                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozWakeLock)
    4049             306 :   DOM_CLASSINFO_MAP_END
    4050                 : 
    4051             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsManager, nsIDOMMozSmsManager)
    4052                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsManager)
    4053             306 :   DOM_CLASSINFO_MAP_END
    4054                 : 
    4055             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
    4056                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
    4057             306 :   DOM_CLASSINFO_MAP_END
    4058                 : 
    4059             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsEvent, nsIDOMMozSmsEvent)
    4060                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsEvent)
    4061                 :      DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4062             306 :   DOM_CLASSINFO_MAP_END
    4063                 : 
    4064             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsRequest, nsIDOMMozSmsRequest)
    4065                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsRequest)
    4066                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4067             306 :   DOM_CLASSINFO_MAP_END
    4068                 : 
    4069             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
    4070                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
    4071             306 :   DOM_CLASSINFO_MAP_END
    4072                 : 
    4073             306 :   DOM_CLASSINFO_MAP_BEGIN(MozSmsCursor, nsIDOMMozSmsCursor)
    4074                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
    4075             306 :   DOM_CLASSINFO_MAP_END
    4076                 : 
    4077             306 :   DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
    4078                 :      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
    4079             306 :   DOM_CLASSINFO_MAP_END
    4080                 : 
    4081             306 :   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
    4082                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
    4083             306 :   DOM_CLASSINFO_MAP_END
    4084                 : 
    4085             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
    4086                 :                                       nsIDOMCSSStyleDeclaration)
    4087                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
    4088             306 :   DOM_CLASSINFO_MAP_END
    4089                 : 
    4090                 : #if defined (MOZ_MEDIA)
    4091             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLVideoElement, nsIDOMHTMLVideoElement)
    4092                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLVideoElement)
    4093             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    4094             612 :   DOM_CLASSINFO_MAP_END
    4095                 : 
    4096             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLSourceElement, nsIDOMHTMLSourceElement)
    4097                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSourceElement)
    4098             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    4099             612 :   DOM_CLASSINFO_MAP_END
    4100                 : 
    4101             306 :   DOM_CLASSINFO_MAP_BEGIN(MediaError, nsIDOMMediaError)
    4102                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaError)
    4103             306 :   DOM_CLASSINFO_MAP_END
    4104                 : 
    4105             306 :   DOM_CLASSINFO_MAP_BEGIN(HTMLAudioElement, nsIDOMHTMLAudioElement)
    4106                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAudioElement)
    4107             306 :     DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
    4108             612 :   DOM_CLASSINFO_MAP_END
    4109                 : 
    4110             306 :   DOM_CLASSINFO_MAP_BEGIN(TimeRanges, nsIDOMTimeRanges)
    4111                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeRanges)
    4112             306 :   DOM_CLASSINFO_MAP_END  
    4113                 : #endif
    4114                 : 
    4115             306 :   DOM_CLASSINFO_MAP_BEGIN(ProgressEvent, nsIDOMProgressEvent)
    4116                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
    4117                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4118             306 :   DOM_CLASSINFO_MAP_END
    4119                 : 
    4120             306 :   DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequestUpload, nsIXMLHttpRequestUpload)
    4121                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
    4122                 :     DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestUpload)
    4123                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4124             306 :   DOM_CLASSINFO_MAP_END
    4125                 : 
    4126             306 :   DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer)
    4127                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer)
    4128             306 :   DOM_CLASSINFO_MAP_END
    4129                 : 
    4130             306 :   DOM_CLASSINFO_MAP_BEGIN(NotifyPaintEvent, nsIDOMNotifyPaintEvent)
    4131                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyPaintEvent)
    4132                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4133             306 :   DOM_CLASSINFO_MAP_END
    4134                 : 
    4135             306 :   DOM_CLASSINFO_MAP_BEGIN(NotifyAudioAvailableEvent, nsIDOMNotifyAudioAvailableEvent)
    4136                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyAudioAvailableEvent)
    4137                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4138             306 :   DOM_CLASSINFO_MAP_END
    4139                 : 
    4140             306 :   DOM_CLASSINFO_MAP_BEGIN(SimpleGestureEvent, nsIDOMSimpleGestureEvent)
    4141                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSimpleGestureEvent)
    4142                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
    4143                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    4144             306 :   DOM_CLASSINFO_MAP_END
    4145                 : 
    4146             306 :   DOM_CLASSINFO_MAP_BEGIN(MozTouchEvent, nsIDOMMozTouchEvent)
    4147                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTouchEvent)
    4148                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
    4149                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    4150             306 :   DOM_CLASSINFO_MAP_END
    4151                 : 
    4152             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(MathMLElement, nsIDOMElement)
    4153                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
    4154                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
    4155                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4156                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
    4157                 :     DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
    4158             306 :     DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
    4159                 :                                         nsDOMTouchEvent::PrefEnabled())
    4160             612 :   DOM_CLASSINFO_MAP_END
    4161                 : 
    4162             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLRenderingContext, nsIDOMWebGLRenderingContext)
    4163                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWebGLRenderingContext)
    4164             306 :   DOM_CLASSINFO_MAP_END
    4165                 : 
    4166             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLBuffer, nsIWebGLBuffer)
    4167                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLBuffer)
    4168             306 :   DOM_CLASSINFO_MAP_END
    4169                 : 
    4170             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLTexture, nsIWebGLTexture)
    4171                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLTexture)
    4172             306 :   DOM_CLASSINFO_MAP_END
    4173                 : 
    4174             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLProgram, nsIWebGLProgram)
    4175                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLProgram)
    4176             306 :   DOM_CLASSINFO_MAP_END
    4177                 : 
    4178             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLShader, nsIWebGLShader)
    4179                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShader)
    4180             306 :   DOM_CLASSINFO_MAP_END
    4181                 : 
    4182             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLFramebuffer, nsIWebGLFramebuffer)
    4183                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLFramebuffer)
    4184             306 :   DOM_CLASSINFO_MAP_END
    4185                 : 
    4186             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLRenderbuffer, nsIWebGLRenderbuffer)
    4187                 :      DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
    4188             306 :   DOM_CLASSINFO_MAP_END
    4189                 : 
    4190             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLShaderPrecisionFormat, nsIWebGLShaderPrecisionFormat)
    4191                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShaderPrecisionFormat)
    4192             306 :   DOM_CLASSINFO_MAP_END
    4193                 : 
    4194             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLUniformLocation, nsIWebGLUniformLocation)
    4195                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLUniformLocation)
    4196             306 :   DOM_CLASSINFO_MAP_END
    4197                 : 
    4198             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLActiveInfo, nsIWebGLActiveInfo)
    4199                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLActiveInfo)
    4200             306 :   DOM_CLASSINFO_MAP_END
    4201                 : 
    4202             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLExtension, nsIWebGLExtension)
    4203                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtension)
    4204             306 :   DOM_CLASSINFO_MAP_END
    4205                 :   
    4206             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionStandardDerivatives, nsIWebGLExtensionStandardDerivatives)
    4207                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionStandardDerivatives)
    4208             306 :   DOM_CLASSINFO_MAP_END
    4209                 :   
    4210             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionTextureFilterAnisotropic, nsIWebGLExtensionTextureFilterAnisotropic)
    4211                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionTextureFilterAnisotropic)
    4212             306 :   DOM_CLASSINFO_MAP_END
    4213                 : 
    4214             306 :   DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionLoseContext, nsIWebGLExtensionLoseContext)
    4215                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionLoseContext)
    4216             306 :   DOM_CLASSINFO_MAP_END
    4217                 : 
    4218             306 :   DOM_CLASSINFO_MAP_BEGIN(PaintRequest, nsIDOMPaintRequest)
    4219                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequest)
    4220             306 :    DOM_CLASSINFO_MAP_END
    4221                 :  
    4222             306 :   DOM_CLASSINFO_MAP_BEGIN(PaintRequestList, nsIDOMPaintRequestList)
    4223                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequestList)
    4224             306 :   DOM_CLASSINFO_MAP_END
    4225                 : 
    4226             306 :   DOM_CLASSINFO_MAP_BEGIN(ScrollAreaEvent, nsIDOMScrollAreaEvent)
    4227                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMScrollAreaEvent)
    4228                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    4229             306 :   DOM_CLASSINFO_MAP_END
    4230                 : 
    4231             306 :   DOM_CLASSINFO_MAP_BEGIN(EventListenerInfo, nsIEventListenerInfo)
    4232                 :     DOM_CLASSINFO_MAP_ENTRY(nsIEventListenerInfo)
    4233             306 :   DOM_CLASSINFO_MAP_END
    4234                 : 
    4235             306 :   DOM_CLASSINFO_MAP_BEGIN(TransitionEvent, nsIDOMTransitionEvent)
    4236                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTransitionEvent)
    4237                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4238             306 :   DOM_CLASSINFO_MAP_END
    4239                 : 
    4240             306 :   DOM_CLASSINFO_MAP_BEGIN(AnimationEvent, nsIDOMAnimationEvent)
    4241                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMAnimationEvent)
    4242                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4243             306 :   DOM_CLASSINFO_MAP_END
    4244                 : 
    4245             306 :   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsIContentFrameMessageManager)
    4246                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4247                 :     DOM_CLASSINFO_MAP_ENTRY(nsIFrameMessageManager)
    4248                 :     DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
    4249                 :     DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
    4250             306 :   DOM_CLASSINFO_MAP_END
    4251                 : 
    4252             306 :   DOM_CLASSINFO_MAP_BEGIN(FormData, nsIDOMFormData)
    4253                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMFormData)
    4254             306 :   DOM_CLASSINFO_MAP_END
    4255                 : 
    4256             306 :   DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
    4257                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
    4258             306 :   DOM_CLASSINFO_MAP_END
    4259                 : 
    4260             306 :   DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
    4261                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
    4262             306 :   DOM_CLASSINFO_MAP_END
    4263                 : 
    4264             306 :   DOM_CLASSINFO_MAP_BEGIN(WebSocket, nsIWebSocket)
    4265                 :     DOM_CLASSINFO_MAP_ENTRY(nsIWebSocket)
    4266                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4267             306 :   DOM_CLASSINFO_MAP_END
    4268                 : 
    4269             306 :   DOM_CLASSINFO_MAP_BEGIN(CloseEvent, nsIDOMCloseEvent)
    4270                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCloseEvent)
    4271                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4272             306 :   DOM_CLASSINFO_MAP_END
    4273                 : 
    4274             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBFactory, nsIIDBFactory)
    4275                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBFactory)
    4276             306 :   DOM_CLASSINFO_MAP_END
    4277                 : 
    4278             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
    4279                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
    4280                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4281             306 :   DOM_CLASSINFO_MAP_END
    4282                 : 
    4283             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase)
    4284                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase)
    4285                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4286             306 :   DOM_CLASSINFO_MAP_END
    4287                 : 
    4288             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
    4289                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
    4290             306 :   DOM_CLASSINFO_MAP_END
    4291                 : 
    4292             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBTransaction, nsIIDBTransaction)
    4293                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBTransaction)
    4294                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4295             306 :   DOM_CLASSINFO_MAP_END
    4296                 : 
    4297             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
    4298                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
    4299             306 :   DOM_CLASSINFO_MAP_END
    4300                 : 
    4301             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBCursorWithValue, nsIIDBCursorWithValue)
    4302                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
    4303                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursorWithValue)
    4304             306 :   DOM_CLASSINFO_MAP_END
    4305                 : 
    4306             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBKeyRange, nsIIDBKeyRange)
    4307                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
    4308             306 :   DOM_CLASSINFO_MAP_END
    4309                 : 
    4310             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
    4311                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
    4312             306 :   DOM_CLASSINFO_MAP_END
    4313                 : 
    4314             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBVersionChangeEvent, nsIIDBVersionChangeEvent)
    4315                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBVersionChangeEvent)
    4316                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
    4317             306 :   DOM_CLASSINFO_MAP_END
    4318                 : 
    4319             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
    4320                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
    4321                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
    4322                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4323             306 :   DOM_CLASSINFO_MAP_END
    4324                 : 
    4325             306 :   DOM_CLASSINFO_MAP_BEGIN(IDBDatabaseException, nsIIDBDatabaseException)
    4326                 :     DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabaseException)
    4327                 :     DOM_CLASSINFO_MAP_ENTRY(nsIException)
    4328             306 :   DOM_CLASSINFO_MAP_END
    4329                 : 
    4330             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Touch, nsIDOMTouch,
    4331                 :                                         !nsDOMTouchEvent::PrefEnabled())
    4332                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouch)
    4333             306 :   DOM_CLASSINFO_MAP_END
    4334                 : 
    4335             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(TouchList, nsIDOMTouchList,
    4336                 :                                         !nsDOMTouchEvent::PrefEnabled())
    4337                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouchList)
    4338             306 :   DOM_CLASSINFO_MAP_END
    4339                 :   
    4340             306 :   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(TouchEvent, nsIDOMTouchEvent,
    4341                 :                                         !nsDOMTouchEvent::PrefEnabled())
    4342                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouchEvent)
    4343                 :     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
    4344             306 :   DOM_CLASSINFO_MAP_END
    4345                 : 
    4346             306 :   DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframeRule, nsIDOMMozCSSKeyframeRule)
    4347                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
    4348             306 :   DOM_CLASSINFO_MAP_END
    4349                 : 
    4350             306 :   DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframesRule, nsIDOMMozCSSKeyframesRule)
    4351                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
    4352             306 :   DOM_CLASSINFO_MAP_END
    4353                 : 
    4354             306 :   DOM_CLASSINFO_MAP_BEGIN(MediaQueryList, nsIDOMMediaQueryList)
    4355                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaQueryList)
    4356             306 :   DOM_CLASSINFO_MAP_END
    4357                 : 
    4358             306 :   DOM_CLASSINFO_MAP_BEGIN(CustomEvent, nsIDOMCustomEvent)
    4359                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCustomEvent)
    4360                 :     DOM_CLASSINFO_EVENT_MAP_ENTRIES
    4361             306 :   DOM_CLASSINFO_MAP_END
    4362                 : 
    4363                 : #ifdef MOZ_B2G_RIL
    4364                 :   DOM_CLASSINFO_MAP_BEGIN(Telephony, nsIDOMTelephony)
    4365                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephony)
    4366                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4367                 :   DOM_CLASSINFO_MAP_END
    4368                 : 
    4369                 :   DOM_CLASSINFO_MAP_BEGIN(TelephonyCall, nsIDOMTelephonyCall)
    4370                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephonyCall)
    4371                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4372                 :   DOM_CLASSINFO_MAP_END
    4373                 : 
    4374                 :   DOM_CLASSINFO_MAP_BEGIN(CallEvent, nsIDOMCallEvent)
    4375                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCallEvent)
    4376                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
    4377                 :   DOM_CLASSINFO_MAP_END
    4378                 : #endif
    4379                 : 
    4380                 : #ifdef MOZ_B2G_BT
    4381                 :   DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
    4382                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
    4383                 :   DOM_CLASSINFO_MAP_END
    4384                 : #endif
    4385                 : 
    4386             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMError, nsIDOMDOMError)
    4387                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMError)
    4388             306 :   DOM_CLASSINFO_MAP_END
    4389                 : 
    4390             306 :   DOM_CLASSINFO_MAP_BEGIN(DOMRequest, nsIDOMDOMRequest)
    4391                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
    4392                 :     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
    4393             306 :   DOM_CLASSINFO_MAP_END
    4394                 : 
    4395                 : #ifdef NS_DEBUG
    4396                 :   {
    4397             306 :     PRUint32 i = ArrayLength(sClassInfoData);
    4398                 : 
    4399             306 :     if (i != eDOMClassInfoIDCount) {
    4400                 :       NS_ERROR("The number of items in sClassInfoData doesn't match the "
    4401               0 :                "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
    4402                 : 
    4403               0 :       return NS_ERROR_NOT_INITIALIZED;
    4404                 :     }
    4405                 : 
    4406          115668 :     for (i = 0; i < eDOMClassInfoIDCount; i++) {
    4407          115362 :       if (!sClassInfoData[i].u.mConstructorFptr ||
    4408                 :           sClassInfoData[i].mDebugID != i) {
    4409                 :         NS_ERROR("Class info data out of sync, you forgot to update "
    4410                 :                  "nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
    4411               0 :                  "mozilla will not work without this fixed!");
    4412                 : 
    4413               0 :         return NS_ERROR_NOT_INITIALIZED;
    4414                 :       }
    4415                 :     }
    4416                 : 
    4417          115668 :     for (i = 0; i < eDOMClassInfoIDCount; i++) {
    4418          115362 :       if (!sClassInfoData[i].mInterfaces) {
    4419                 :         NS_ERROR("Class info data without an interface list! Fix this, "
    4420               0 :                  "mozilla will not work without this fixed!");
    4421                 : 
    4422               0 :         return NS_ERROR_NOT_INITIALIZED;
    4423                 :       }
    4424                 :     }
    4425                 :   }
    4426                 : #endif
    4427                 : 
    4428                 :   // Initialize static JSString's
    4429             306 :   DefineStaticJSVals(cx);
    4430                 : 
    4431                 :   PRInt32 i;
    4432                 : 
    4433          115668 :   for (i = 0; i < eDOMClassInfoIDCount; ++i) {
    4434          115362 :     RegisterClassName(i);
    4435                 :   }
    4436                 : 
    4437          115668 :   for (i = 0; i < eDOMClassInfoIDCount; ++i) {
    4438          115362 :     RegisterClassProtos(i);
    4439                 :   }
    4440                 : 
    4441             306 :   RegisterExternalClasses();
    4442                 : 
    4443                 :   sDisableDocumentAllSupport =
    4444             306 :     Preferences::GetBool("browser.dom.document.all.disabled");
    4445                 : 
    4446                 :   sDisableGlobalScopePollutionSupport =
    4447             306 :     Preferences::GetBool("browser.dom.global_scope_pollution.disabled");
    4448                 : 
    4449             306 :   mozilla::dom::binding::Register(sClassInfoData);
    4450                 : 
    4451             306 :   sIsInitialized = true;
    4452                 : 
    4453             306 :   return NS_OK;
    4454                 : }
    4455                 : 
    4456                 : // static
    4457                 : PRInt32
    4458              34 : nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, jsid id, bool *aIsNumber)
    4459                 : {
    4460              34 :   if (aIsNumber) {
    4461              34 :     *aIsNumber = false;
    4462                 :   }
    4463                 : 
    4464                 :   int i;
    4465              34 :   if (JSID_IS_INT(id)) {
    4466               4 :       i = JSID_TO_INT(id);
    4467                 :   } else {
    4468              60 :       JSAutoRequest ar(cx);
    4469                 : 
    4470                 :       jsval idval;
    4471                 :       double array_index;
    4472              90 :       if (!::JS_IdToValue(cx, id, &idval) ||
    4473              30 :           !::JS_ValueToNumber(cx, idval, &array_index) ||
    4474              30 :           !::JS_DoubleIsInt32(array_index, &i)) {
    4475              30 :         return -1;
    4476                 :       }
    4477                 :   }
    4478                 : 
    4479               4 :   if (aIsNumber) {
    4480               4 :     *aIsNumber = true;
    4481                 :   }
    4482                 : 
    4483               4 :   return i;
    4484                 : }
    4485                 : 
    4486                 : NS_IMETHODIMP
    4487            2635 : nsDOMClassInfo::GetInterfaces(PRUint32 *aCount, nsIID ***aArray)
    4488                 : {
    4489            2635 :   PRUint32 count = 0;
    4490                 : 
    4491           15627 :   while (mData->mInterfaces[count]) {
    4492           10357 :     count++;
    4493                 :   }
    4494                 : 
    4495            2635 :   *aCount = count;
    4496                 : 
    4497            2635 :   if (!count) {
    4498               0 :     *aArray = nsnull;
    4499                 : 
    4500               0 :     return NS_OK;
    4501                 :   }
    4502                 : 
    4503            2635 :   *aArray = static_cast<nsIID **>(nsMemory::Alloc(count * sizeof(nsIID *)));
    4504            2635 :   NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY);
    4505                 : 
    4506                 :   PRUint32 i;
    4507           12992 :   for (i = 0; i < count; i++) {
    4508           10357 :     nsIID *iid = static_cast<nsIID *>(nsMemory::Clone(mData->mInterfaces[i],
    4509           10357 :                                                          sizeof(nsIID)));
    4510                 : 
    4511           10357 :     if (!iid) {
    4512               0 :       NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, *aArray);
    4513                 : 
    4514               0 :       return NS_ERROR_OUT_OF_MEMORY;
    4515                 :     }
    4516                 : 
    4517           10357 :     *((*aArray) + i) = iid;
    4518                 :   }
    4519                 : 
    4520            2635 :   return NS_OK;
    4521                 : }
    4522                 : 
    4523                 : NS_IMETHODIMP
    4524               0 : nsDOMClassInfo::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
    4525                 : {
    4526               0 :   if (language == nsIProgrammingLanguage::JAVASCRIPT) {
    4527               0 :     *_retval = static_cast<nsIXPCScriptable *>(this);
    4528                 : 
    4529               0 :     NS_ADDREF(*_retval);
    4530                 :   } else {
    4531               0 :     *_retval = nsnull;
    4532                 :   }
    4533                 : 
    4534               0 :   return NS_OK;
    4535                 : }
    4536                 : 
    4537                 : NS_IMETHODIMP
    4538               0 : nsDOMClassInfo::GetContractID(char **aContractID)
    4539                 : {
    4540               0 :   *aContractID = nsnull;
    4541                 : 
    4542               0 :   return NS_OK;
    4543                 : }
    4544                 : 
    4545                 : NS_IMETHODIMP
    4546               0 : nsDOMClassInfo::GetClassDescription(char **aClassDescription)
    4547                 : {
    4548               0 :   return GetClassName(aClassDescription);
    4549                 : }
    4550                 : 
    4551                 : NS_IMETHODIMP
    4552               0 : nsDOMClassInfo::GetClassID(nsCID **aClassID)
    4553                 : {
    4554               0 :   *aClassID = nsnull;
    4555               0 :   return NS_OK;
    4556                 : }
    4557                 : 
    4558                 : NS_IMETHODIMP
    4559               0 : nsDOMClassInfo::GetClassIDNoAlloc(nsCID *aClassID)
    4560                 : {
    4561               0 :   return NS_ERROR_NOT_AVAILABLE;
    4562                 : }
    4563                 : 
    4564                 : NS_IMETHODIMP
    4565               0 : nsDOMClassInfo::GetImplementationLanguage(PRUint32 *aImplLanguage)
    4566                 : {
    4567               0 :   *aImplLanguage = nsIProgrammingLanguage::CPLUSPLUS;
    4568                 : 
    4569               0 :   return NS_OK;
    4570                 : }
    4571                 : 
    4572                 : NS_IMETHODIMP
    4573           11077 : nsDOMClassInfo::GetFlags(PRUint32 *aFlags)
    4574                 : {
    4575           11077 :   *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
    4576                 : 
    4577           11077 :   return NS_OK;
    4578                 : }
    4579                 : 
    4580                 : // nsIXPCScriptable
    4581                 : 
    4582                 : NS_IMETHODIMP
    4583            2781 : nsDOMClassInfo::GetClassName(char **aClassName)
    4584                 : {
    4585            2781 :   *aClassName = NS_strdup(mData->mName);
    4586                 : 
    4587            2781 :   return NS_OK;
    4588                 : }
    4589                 : 
    4590                 : NS_IMETHODIMP
    4591           31443 : nsDOMClassInfo::GetScriptableFlags(PRUint32 *aFlags)
    4592                 : {
    4593           31443 :   *aFlags = mData->mScriptableFlags;
    4594                 : 
    4595           31443 :   return NS_OK;
    4596                 : }
    4597                 : 
    4598                 : NS_IMETHODIMP
    4599            7077 : nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
    4600                 :                           JSObject *globalObj, JSObject **parentObj)
    4601                 : {
    4602            7077 :   *parentObj = globalObj;
    4603                 : 
    4604           14154 :   nsCOMPtr<nsPIDOMWindow> piwin = do_QueryWrapper(cx, globalObj);
    4605                 : 
    4606            7077 :   if (!piwin) {
    4607            7077 :     return NS_OK;
    4608                 :   }
    4609                 : 
    4610               0 :   if (piwin->IsOuterWindow()) {
    4611               0 :     *parentObj = ((nsGlobalWindow *)piwin.get())->
    4612               0 :       GetCurrentInnerWindowInternal()->GetGlobalJSObject();
    4613                 :   }
    4614                 : 
    4615               0 :   return NS_OK;
    4616                 : }
    4617                 : 
    4618                 : NS_IMETHODIMP
    4619               0 : nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
    4620                 :                        JSContext *cx, JSObject *obj)
    4621                 : {
    4622               0 :   NS_WARNING("nsDOMClassInfo::Create Don't call me!");
    4623                 : 
    4624               0 :   return NS_ERROR_UNEXPECTED;
    4625                 : }
    4626                 : 
    4627                 : NS_IMETHODIMP
    4628               0 : nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
    4629                 :                            JSContext *cx, JSObject *obj)
    4630                 : {
    4631               0 :   NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
    4632                 : 
    4633               0 :   return NS_ERROR_UNEXPECTED;
    4634                 : }
    4635                 : 
    4636                 : NS_IMETHODIMP
    4637               0 : nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4638                 :                             JSObject *obj, jsid id, jsval *vp,
    4639                 :                             bool *_retval)
    4640                 : {
    4641               0 :   NS_WARNING("nsDOMClassInfo::AddProperty Don't call me!");
    4642                 : 
    4643               0 :   return NS_ERROR_UNEXPECTED;
    4644                 : }
    4645                 : 
    4646                 : NS_IMETHODIMP
    4647               0 : nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4648                 :                             JSObject *obj, jsid id, jsval *vp,
    4649                 :                             bool *_retval)
    4650                 : {
    4651               0 :   NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
    4652                 : 
    4653               0 :   return NS_ERROR_UNEXPECTED;
    4654                 : }
    4655                 : 
    4656                 : NS_IMETHODIMP
    4657               0 : nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4658                 :                             JSObject *obj, jsid id, jsval *vp,
    4659                 :                             bool *_retval)
    4660                 : {
    4661               0 :   NS_WARNING("nsDOMClassInfo::GetProperty Don't call me!");
    4662                 : 
    4663               0 :   return NS_OK;
    4664                 : }
    4665                 : 
    4666                 : NS_IMETHODIMP
    4667               0 : nsDOMClassInfo::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4668                 :                             JSObject *obj, jsid id, jsval *vp,
    4669                 :                             bool *_retval)
    4670                 : {
    4671               0 :   NS_WARNING("nsDOMClassInfo::SetProperty Don't call me!");
    4672                 : 
    4673               0 :   return NS_ERROR_UNEXPECTED;
    4674                 : }
    4675                 : 
    4676                 : NS_IMETHODIMP
    4677               0 : nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4678                 :                           JSObject *obj, bool *_retval)
    4679                 : {
    4680                 : #ifdef DEBUG
    4681               0 :   if (!sSecMan) {
    4682               0 :     NS_ERROR("No security manager!!!");
    4683               0 :     return NS_OK;
    4684                 :   }
    4685                 : 
    4686                 :   // Ask the security manager if it's OK to enumerate
    4687                 :   nsresult rv =
    4688                 :     sSecMan->CheckPropertyAccess(cx, obj, mData->mName, sEnumerate_id,
    4689               0 :                                  nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
    4690                 : 
    4691               0 :   NS_ASSERTION(NS_SUCCEEDED(rv),
    4692                 :                "XOWs should have stopped us from getting here!!!");
    4693                 : #endif
    4694                 : 
    4695               0 :   return NS_OK;
    4696                 : }
    4697                 : 
    4698                 : NS_IMETHODIMP
    4699               0 : nsDOMClassInfo::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
    4700                 :                              JSContext *cx, JSObject *obj, PRUint32 enum_op,
    4701                 :                              jsval *statep, jsid *idp, bool *_retval)
    4702                 : {
    4703               0 :   NS_WARNING("nsDOMClassInfo::NewEnumerate Don't call me!");
    4704                 : 
    4705               0 :   return NS_ERROR_UNEXPECTED;
    4706                 : }
    4707                 : 
    4708                 : nsresult
    4709               0 : nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *obj,
    4710                 :                                    JSObject **objp)
    4711                 : {
    4712               0 :   JSObject *global = ::JS_GetGlobalForObject(cx, obj);
    4713                 : 
    4714                 :   jsval val;
    4715               0 :   JSAutoRequest ar(cx);
    4716               0 :   if (!::JS_LookupProperty(cx, global, mData->mName, &val)) {
    4717               0 :     return NS_ERROR_UNEXPECTED;
    4718                 :   }
    4719                 : 
    4720               0 :   if (!JSVAL_IS_PRIMITIVE(val)) {
    4721                 :     // If val is not an (non-null) object there either is no
    4722                 :     // constructor for this class, or someone messed with
    4723                 :     // window.classname, just fall through and let the JS engine
    4724                 :     // return the Object constructor.
    4725                 : 
    4726               0 :     if (!::JS_DefinePropertyById(cx, obj, sConstructor_id, val, nsnull, nsnull,
    4727               0 :                                  JSPROP_ENUMERATE)) {
    4728               0 :       return NS_ERROR_UNEXPECTED;
    4729                 :     }
    4730                 : 
    4731               0 :     *objp = obj;
    4732                 :   }
    4733                 : 
    4734               0 :   return NS_OK;
    4735                 : }
    4736                 : 
    4737                 : NS_IMETHODIMP
    4738           20760 : nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4739                 :                            JSObject *obj, jsid id, PRUint32 flags,
    4740                 :                            JSObject **objp, bool *_retval)
    4741                 : {
    4742           20760 :   if (id == sConstructor_id && !(flags & JSRESOLVE_ASSIGNING)) {
    4743               0 :     return ResolveConstructor(cx, obj, objp);
    4744                 :   }
    4745                 : 
    4746           20760 :   return NS_OK;
    4747                 : }
    4748                 : 
    4749                 : NS_IMETHODIMP
    4750               0 : nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4751                 :                         JSObject *obj, PRUint32 type, jsval *vp,
    4752                 :                         bool *_retval)
    4753                 : {
    4754               0 :   NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
    4755                 : 
    4756               0 :   return NS_ERROR_UNEXPECTED;
    4757                 : }
    4758                 : 
    4759                 : NS_IMETHODIMP
    4760               0 : nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4761                 :                          JSObject *obj)
    4762                 : {
    4763               0 :   NS_WARNING("nsDOMClassInfo::Finalize Don't call me!");
    4764                 : 
    4765               0 :   return NS_ERROR_UNEXPECTED;
    4766                 : }
    4767                 : 
    4768                 : NS_IMETHODIMP
    4769               0 : nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4770                 :                             JSObject *obj, jsid id, PRUint32 mode,
    4771                 :                             jsval *vp, bool *_retval)
    4772                 : {
    4773               0 :   PRUint32 mode_type = mode & JSACC_TYPEMASK;
    4774                 : 
    4775               0 :   if ((mode_type == JSACC_WATCH ||
    4776                 :        mode_type == JSACC_PROTO ||
    4777                 :        mode_type == JSACC_PARENT) &&
    4778                 :       sSecMan) {
    4779                 : 
    4780                 :     nsresult rv;
    4781                 :     JSObject *real_obj;
    4782               0 :     if (wrapper) {
    4783               0 :       rv = wrapper->GetJSObject(&real_obj);
    4784               0 :       NS_ENSURE_SUCCESS(rv, rv);
    4785                 :     }
    4786                 :     else {
    4787               0 :       real_obj = obj;
    4788                 :     }
    4789                 : 
    4790                 :     rv =
    4791                 :       sSecMan->CheckPropertyAccess(cx, real_obj, mData->mName, id,
    4792               0 :                                    nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
    4793                 : 
    4794               0 :     if (NS_FAILED(rv)) {
    4795                 :       // Let XPConnect know that the access was not granted.
    4796               0 :       *_retval = false;
    4797                 :     }
    4798                 :   }
    4799                 : 
    4800               0 :   return NS_OK;
    4801                 : }
    4802                 : 
    4803                 : NS_IMETHODIMP
    4804               0 : nsDOMClassInfo::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4805                 :                      JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
    4806                 :                      bool *_retval)
    4807                 : {
    4808               0 :   NS_WARNING("nsDOMClassInfo::Call Don't call me!");
    4809                 : 
    4810               0 :   return NS_ERROR_UNEXPECTED;
    4811                 : }
    4812                 : 
    4813                 : NS_IMETHODIMP
    4814               0 : nsDOMClassInfo::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4815                 :                           JSObject *obj, PRUint32 argc, jsval *argv,
    4816                 :                           jsval *vp, bool *_retval)
    4817                 : {
    4818               0 :   NS_WARNING("nsDOMClassInfo::Construct Don't call me!");
    4819                 : 
    4820               0 :   return NS_ERROR_UNEXPECTED;
    4821                 : }
    4822                 : 
    4823                 : NS_IMETHODIMP
    4824               0 : nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    4825                 :                             JSObject *obj, const jsval &val, bool *bp,
    4826                 :                             bool *_retval)
    4827                 : {
    4828               0 :   NS_WARNING("nsDOMClassInfo::HasInstance Don't call me!");
    4829                 : 
    4830               0 :   return NS_ERROR_UNEXPECTED;
    4831                 : }
    4832                 : 
    4833                 : NS_IMETHODIMP
    4834               0 : nsDOMClassInfo::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
    4835                 :                          JSObject * obj, const jsval &val, bool *bp)
    4836                 : {
    4837               0 :   NS_WARNING("nsDOMClassInfo::Equality Don't call me!");
    4838                 : 
    4839               0 :   return NS_ERROR_UNEXPECTED;
    4840                 : }
    4841                 : 
    4842                 : NS_IMETHODIMP
    4843               0 : nsDOMClassInfo::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
    4844                 :                             JSObject * obj, JSObject * *_retval)
    4845                 : {
    4846               0 :   NS_WARNING("nsDOMClassInfo::OuterObject Don't call me!");
    4847                 : 
    4848               0 :   return NS_ERROR_UNEXPECTED;
    4849                 : }
    4850                 : 
    4851                 : static nsresult
    4852               0 : GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
    4853                 :                      const nsString &aName,
    4854                 :                      const nsGlobalNameStruct *aStruct,
    4855                 :                      const nsGlobalNameStruct **aResult)
    4856                 : {
    4857               0 :   NS_ASSERTION(aStruct->mType ==
    4858                 :                  nsGlobalNameStruct::eTypeExternalClassInfoCreator,
    4859                 :                "Wrong type!");
    4860                 : 
    4861                 :   nsresult rv;
    4862               0 :   nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
    4863               0 :   NS_ENSURE_SUCCESS(rv, rv);
    4864                 : 
    4865               0 :   nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
    4866               0 :   NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
    4867                 : 
    4868               0 :   rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
    4869               0 :   NS_ENSURE_SUCCESS(rv, rv);
    4870                 : 
    4871                 :   const nsGlobalNameStruct *name_struct;
    4872               0 :   rv = aNameSpaceManager->LookupName(aName, &name_struct);
    4873               0 :   if (NS_SUCCEEDED(rv) && name_struct &&
    4874                 :       name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    4875               0 :     *aResult = name_struct;
    4876                 :   }
    4877                 :   else {
    4878               0 :     NS_ERROR("Couldn't get the DOM ClassInfo data.");
    4879                 : 
    4880               0 :     *aResult = nsnull;
    4881                 :   }
    4882                 : 
    4883               0 :   return NS_OK;
    4884                 : }
    4885                 : 
    4886                 : 
    4887                 : static nsresult
    4888                 : ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
    4889                 :                  JSObject *obj, const PRUnichar *name,
    4890                 :                  const nsDOMClassInfoData *ci_data,
    4891                 :                  const nsGlobalNameStruct *name_struct,
    4892                 :                  nsScriptNameSpaceManager *nameSpaceManager,
    4893                 :                  JSObject *dot_prototype, bool install, bool *did_resolve);
    4894                 : 
    4895                 : 
    4896                 : NS_IMETHODIMP
    4897            2781 : nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
    4898                 : {
    4899                 :   PRUint32 flags = (mData->mScriptableFlags & DONT_ENUM_STATIC_PROPS)
    4900                 :                    ? 0
    4901            2781 :                    : JSPROP_ENUMERATE;
    4902                 : 
    4903            2781 :   PRUint32 count = 0;
    4904           16664 :   while (mData->mInterfaces[count]) {
    4905           11102 :     count++;
    4906                 :   }
    4907                 : 
    4908            2781 :   if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
    4909            2781 :                                        count, mData->mInterfaces)) {
    4910               0 :     JS_ClearPendingException(cx);
    4911                 :   }
    4912                 : 
    4913                 :   // This is called before any other location that requires
    4914                 :   // sObjectClass, so compute it here. We assume that nobody has had a
    4915                 :   // chance to monkey around with proto's prototype chain before this.
    4916            2781 :   if (!sObjectClass) {
    4917             306 :     FindObjectClass(proto);
    4918             306 :     NS_ASSERTION(sObjectClass && !strcmp(sObjectClass->name, "Object"),
    4919                 :                  "Incorrect object class!");
    4920                 :   }
    4921                 : 
    4922            2781 :   NS_ASSERTION(::JS_GetPrototype(proto) &&
    4923                 :                JS_GetClass(::JS_GetPrototype(proto)) == sObjectClass,
    4924                 :                "Hmm, somebody did something evil?");
    4925                 : 
    4926                 : #ifdef DEBUG
    4927            2781 :   if (mData->mHasClassInterface && mData->mProtoChainInterface &&
    4928                 :       mData->mProtoChainInterface != &NS_GET_IID(nsISupports)) {
    4929                 :     nsCOMPtr<nsIInterfaceInfoManager>
    4930            4968 :       iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
    4931                 : 
    4932            2484 :     if (iim) {
    4933            4968 :       nsCOMPtr<nsIInterfaceInfo> if_info;
    4934            2484 :       iim->GetInfoForIID(mData->mProtoChainInterface,
    4935            2484 :                          getter_AddRefs(if_info));
    4936                 : 
    4937            2484 :       if (if_info) {
    4938            4968 :         nsXPIDLCString name;
    4939            2484 :         if_info->GetName(getter_Copies(name));
    4940            2484 :         NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
    4941                 :                      "Class name and proto chain interface name mismatch!");
    4942                 :       }
    4943                 :     }
    4944                 :   }
    4945                 : #endif
    4946                 : 
    4947                 :   // Make prototype delegation work correctly. Consider if a site sets
    4948                 :   // HTMLElement.prototype.foopy = function () { ... } Now, calling
    4949                 :   // document.body.foopy() needs to ensure that looking up foopy on
    4950                 :   // document.body's prototype will find the right function.
    4951            2781 :   JSObject *global = ::JS_GetGlobalForObject(cx, proto);
    4952                 : 
    4953                 :   // Only do this if the global object is a window.
    4954                 :   // XXX Is there a better way to check this?
    4955            2781 :   nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
    4956            5562 :   nsCOMPtr<nsPIDOMWindow> piwin = do_QueryInterface(globalNative);
    4957            2781 :   if (!piwin) {
    4958            2781 :     return NS_OK;
    4959                 :   }
    4960                 : 
    4961               0 :   nsGlobalWindow *win = nsGlobalWindow::FromSupports(globalNative);
    4962               0 :   if (win->IsClosedOrClosing()) {
    4963               0 :     return NS_OK;
    4964                 :   }
    4965                 : 
    4966                 :   // If the window is in a different compartment than the global object, then
    4967                 :   // it's likely that global is a sandbox object whose prototype is a window.
    4968                 :   // Don't do anything in this case.
    4969               0 :   if (win->FastGetGlobalJSObject() &&
    4970               0 :       js::GetObjectCompartment(global) != js::GetObjectCompartment(win->FastGetGlobalJSObject())) {
    4971               0 :     return NS_OK;
    4972                 :   }
    4973                 : 
    4974               0 :   if (win->IsOuterWindow()) {
    4975                 :     // XXXjst: Do security checks here when we remove the security
    4976                 :     // checks on the inner window.
    4977                 : 
    4978               0 :     win = win->GetCurrentInnerWindowInternal();
    4979                 : 
    4980               0 :     if (!win || !(global = win->GetGlobalJSObject()) ||
    4981               0 :         win->IsClosedOrClosing()) {
    4982               0 :       return NS_OK;
    4983                 :     }
    4984                 :   }
    4985                 : 
    4986                 :   // Don't overwrite a property set by content.
    4987                 :   JSBool found;
    4988               0 :   if (!::JS_AlreadyHasOwnUCProperty(cx, global, reinterpret_cast<const jschar*>(mData->mNameUTF16),
    4989               0 :                                     nsCRT::strlen(mData->mNameUTF16), &found)) {
    4990               0 :     return NS_ERROR_FAILURE;
    4991                 :   }
    4992                 : 
    4993                 :   nsScriptNameSpaceManager *nameSpaceManager =
    4994               0 :     nsJSRuntime::GetNameSpaceManager();
    4995               0 :   NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
    4996                 : 
    4997                 :   bool unused;
    4998                 :   return ResolvePrototype(sXPConnect, win, cx, global, mData->mNameUTF16,
    4999                 :                           mData, nsnull, nameSpaceManager, proto, !found,
    5000               0 :                           &unused);
    5001                 : }
    5002                 : 
    5003                 : // static
    5004                 : nsIClassInfo *
    5005           26886 : NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
    5006                 : {
    5007           26886 :   if (aID >= eDOMClassInfoIDCount) {
    5008               0 :     NS_ERROR("Bad ID!");
    5009                 : 
    5010               0 :     return nsnull;
    5011                 :   }
    5012                 : 
    5013           26886 :   if (!nsDOMClassInfo::sIsInitialized) {
    5014             306 :     nsresult rv = nsDOMClassInfo::Init();
    5015                 : 
    5016             306 :     NS_ENSURE_SUCCESS(rv, nsnull);
    5017                 :   }
    5018                 : 
    5019           26886 :   if (!sClassInfoData[aID].mCachedClassInfo) {
    5020            1684 :     nsDOMClassInfoData& data = sClassInfoData[aID];
    5021                 : 
    5022            1684 :     data.mCachedClassInfo = data.u.mConstructorFptr(&data);
    5023            1684 :     NS_ENSURE_TRUE(data.mCachedClassInfo, nsnull);
    5024                 : 
    5025            1684 :     NS_ADDREF(data.mCachedClassInfo);
    5026                 :   }
    5027                 : 
    5028           26886 :   NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
    5029                 :                "This is bad, internal class marked as external!");
    5030                 : 
    5031           26886 :   return sClassInfoData[aID].mCachedClassInfo;
    5032                 : }
    5033                 : 
    5034                 : // static
    5035                 : nsIClassInfo *
    5036               0 : nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
    5037                 : {
    5038               0 :   NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
    5039                 :                || !aData->mCachedClassInfo,
    5040                 :                "This is bad, external class marked as internal!");
    5041                 : 
    5042               0 :   if (!aData->mCachedClassInfo) {
    5043               0 :     if (aData->u.mExternalConstructorFptr) {
    5044                 :       aData->mCachedClassInfo =
    5045               0 :         aData->u.mExternalConstructorFptr(aData->mName);
    5046                 :     } else {
    5047               0 :       aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
    5048                 :     }
    5049               0 :     NS_ENSURE_TRUE(aData->mCachedClassInfo, nsnull);
    5050                 : 
    5051               0 :     NS_ADDREF(aData->mCachedClassInfo);
    5052               0 :     aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
    5053                 :   }
    5054                 : 
    5055               0 :   return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
    5056                 : }
    5057                 : 
    5058                 : 
    5059                 : // static
    5060                 : void
    5061            1453 : nsDOMClassInfo::ShutDown()
    5062                 : {
    5063            1453 :   if (sClassInfoData[0].u.mConstructorFptr) {
    5064                 :     PRUint32 i;
    5065                 : 
    5066          549234 :     for (i = 0; i < eDOMClassInfoIDCount; i++) {
    5067          547781 :       NS_IF_RELEASE(sClassInfoData[i].mCachedClassInfo);
    5068                 :     }
    5069                 :   }
    5070                 : 
    5071            1453 :   sParent_id          = JSID_VOID;
    5072            1453 :   sScrollbars_id      = JSID_VOID;
    5073            1453 :   sLocation_id        = JSID_VOID;
    5074            1453 :   sConstructor_id     = JSID_VOID;
    5075            1453 :   s_content_id        = JSID_VOID;
    5076            1453 :   sContent_id         = JSID_VOID;
    5077            1453 :   sMenubar_id         = JSID_VOID;
    5078            1453 :   sToolbar_id         = JSID_VOID;
    5079            1453 :   sLocationbar_id     = JSID_VOID;
    5080            1453 :   sPersonalbar_id     = JSID_VOID;
    5081            1453 :   sStatusbar_id       = JSID_VOID;
    5082            1453 :   sDialogArguments_id = JSID_VOID;
    5083            1453 :   sControllers_id     = JSID_VOID;
    5084            1453 :   sLength_id          = JSID_VOID;
    5085            1453 :   sInnerHeight_id     = JSID_VOID;
    5086            1453 :   sInnerWidth_id      = JSID_VOID;
    5087            1453 :   sOuterHeight_id     = JSID_VOID;
    5088            1453 :   sOuterWidth_id      = JSID_VOID;
    5089            1453 :   sScreenX_id         = JSID_VOID;
    5090            1453 :   sScreenY_id         = JSID_VOID;
    5091            1453 :   sStatus_id          = JSID_VOID;
    5092            1453 :   sName_id            = JSID_VOID;
    5093            1453 :   sScrollX_id         = JSID_VOID;
    5094            1453 :   sScrollY_id         = JSID_VOID;
    5095            1453 :   sScrollMaxX_id      = JSID_VOID;
    5096            1453 :   sScrollMaxY_id      = JSID_VOID;
    5097            1453 :   sItem_id            = JSID_VOID;
    5098            1453 :   sEnumerate_id       = JSID_VOID;
    5099            1453 :   sNavigator_id       = JSID_VOID;
    5100            1453 :   sDocument_id        = JSID_VOID;
    5101            1453 :   sFrames_id          = JSID_VOID;
    5102            1453 :   sSelf_id            = JSID_VOID;
    5103            1453 :   sOpener_id          = JSID_VOID;
    5104            1453 :   sAll_id             = JSID_VOID;
    5105            1453 :   sTags_id            = JSID_VOID;
    5106            1453 :   sAddEventListener_id= JSID_VOID;
    5107            1453 :   sBaseURIObject_id   = JSID_VOID;
    5108            1453 :   sNodePrincipal_id   = JSID_VOID;
    5109            1453 :   sDocumentURIObject_id=JSID_VOID;
    5110            1453 :   sJava_id            = JSID_VOID;
    5111            1453 :   sPackages_id        = JSID_VOID;
    5112            1453 :   sWrappedJSObject_id = JSID_VOID;
    5113            1453 :   sKeyPath_id         = JSID_VOID;
    5114            1453 :   sAutoIncrement_id   = JSID_VOID;
    5115            1453 :   sUnique_id          = JSID_VOID;
    5116            1453 :   sMultiEntry_id      = JSID_VOID;
    5117            1453 :   sOnload_id          = JSID_VOID;
    5118            1453 :   sOnerror_id         = JSID_VOID;
    5119                 : 
    5120            1453 :   NS_IF_RELEASE(sXPConnect);
    5121            1453 :   NS_IF_RELEASE(sSecMan);
    5122            1453 :   sIsInitialized = false;
    5123            1453 : }
    5124                 : 
    5125                 : // Window helper
    5126                 : 
    5127                 : NS_IMETHODIMP
    5128               0 : nsWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    5129                 :                       JSObject *globalObj, JSObject **parentObj)
    5130                 : {
    5131                 :   // Normally ::PreCreate() is used to give XPConnect the parent
    5132                 :   // object for the object that's being wrapped, this parent object is
    5133                 :   // set as the parent of the wrapper and it's also used to find the
    5134                 :   // right scope for the object being wrapped. Now, in the case of the
    5135                 :   // global object the wrapper shouldn't have a parent but we supply
    5136                 :   // one here anyway (the global object itself) and this will be used
    5137                 :   // by XPConnect only to find the right scope, once the scope is
    5138                 :   // found XPConnect will find the existing wrapper (which always
    5139                 :   // exists since it's created on window construction), since an
    5140                 :   // existing wrapper is found the parent we supply here is ignored
    5141                 :   // after the wrapper is found.
    5142                 : 
    5143               0 :   nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeObj));
    5144               0 :   NS_ASSERTION(sgo, "nativeObj not a global object!");
    5145                 : 
    5146               0 :   nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
    5147               0 :   NS_ASSERTION(win->IsInnerWindow(), "Should be inner window.");
    5148                 : 
    5149               0 :   JSObject *winObj = win->FastGetGlobalJSObject();
    5150               0 :   if (!winObj) {
    5151                 : 
    5152                 :     // See bug 691178 comment 11 for why this is necessary.
    5153               0 :     if (win->IsClosedOrClosing())
    5154               0 :       return NS_ERROR_FAILURE;
    5155                 : 
    5156               0 :     NS_ASSERTION(win->GetOuterWindowInternal()->IsCreatingInnerWindow(),
    5157                 :                  "should have a JS object by this point");
    5158               0 :     return NS_OK;
    5159                 :   }
    5160                 : 
    5161               0 :   *parentObj = winObj;
    5162               0 :   return NS_OK;
    5163                 : }
    5164                 : 
    5165                 : // This JS class piggybacks on nsHTMLDocumentSH::ReleaseDocument()...
    5166                 : 
    5167                 : static JSClass sGlobalScopePolluterClass = {
    5168                 :   "Global Scope Polluter",
    5169                 :   JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE,
    5170                 :   nsWindowSH::SecurityCheckOnAddDelProp,
    5171                 :   nsWindowSH::SecurityCheckOnAddDelProp,
    5172                 :   nsWindowSH::GlobalScopePolluterGetProperty,
    5173                 :   nsWindowSH::SecurityCheckOnSetProp,
    5174                 :   JS_EnumerateStub,
    5175                 :   (JSResolveOp)nsWindowSH::GlobalScopePolluterNewResolve,
    5176                 :   JS_ConvertStub,
    5177                 :   nsHTMLDocumentSH::ReleaseDocument
    5178                 : };
    5179                 : 
    5180                 : 
    5181                 : // static
    5182                 : JSBool
    5183               0 : nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
    5184                 :                                            jsid id, jsval *vp)
    5185                 : {
    5186                 :   // Someone is accessing a element by referencing its name/id in the
    5187                 :   // global scope, do a security check to make sure that's ok.
    5188                 : 
    5189                 :   nsresult rv =
    5190                 :     sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
    5191                 :                                  "Window", id,
    5192               0 :                                  nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
    5193                 : 
    5194               0 :   if (NS_FAILED(rv)) {
    5195                 :     // The security check failed. The security manager set a JS
    5196                 :     // exception for us.
    5197                 : 
    5198               0 :     return JS_FALSE;
    5199                 :   }
    5200                 : 
    5201                 :   // Print a warning on the console so developers have a chance to
    5202                 :   // catch and fix these mistakes.
    5203               0 :   PrintWarningOnConsole(cx, "GlobalScopeElementReference");
    5204                 : 
    5205               0 :   return JS_TRUE;
    5206                 : }
    5207                 : 
    5208                 : // static
    5209                 : JSBool
    5210               0 : nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
    5211                 :                                       jsval *vp)
    5212                 : {
    5213                 :   // Someone is accessing a element by referencing its name/id in the
    5214                 :   // global scope, do a security check to make sure that's ok.
    5215                 : 
    5216                 :   nsresult rv =
    5217                 :     sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
    5218                 :                                  "Window", id,
    5219               0 :                                  nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
    5220                 : 
    5221                 :   // If !NS_SUCCEEDED(rv) the security check failed. The security
    5222                 :   // manager set a JS exception for us.
    5223               0 :   return NS_SUCCEEDED(rv);
    5224                 : }
    5225                 : 
    5226                 : // static
    5227                 : JSBool
    5228               0 : nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
    5229                 :                                    jsval *vp)
    5230                 : {
    5231               0 :   return SecurityCheckOnAddDelProp(cx, obj, id, vp);
    5232                 : }
    5233                 : 
    5234                 : static nsHTMLDocument*
    5235               0 : GetDocument(JSObject *obj)
    5236                 : {
    5237                 :   return static_cast<nsHTMLDocument*>(
    5238               0 :     static_cast<nsIHTMLDocument*>(::JS_GetPrivate(obj)));
    5239                 : }
    5240                 : 
    5241                 : // static
    5242                 : JSBool
    5243               0 : nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
    5244                 :                                           jsid id, unsigned flags,
    5245                 :                                           JSObject **objp)
    5246                 : {
    5247               0 :   if (flags & (JSRESOLVE_ASSIGNING | JSRESOLVE_DECLARING |
    5248                 :                JSRESOLVE_CLASSNAME | JSRESOLVE_QUALIFIED) ||
    5249               0 :       !JSID_IS_STRING(id)) {
    5250                 :     // Nothing to do here if we're either assigning or declaring,
    5251                 :     // resolving a class name, doing a qualified resolve, or
    5252                 :     // resolving a number.
    5253                 : 
    5254               0 :     return JS_TRUE;
    5255                 :   }
    5256                 : 
    5257               0 :   nsHTMLDocument *document = GetDocument(obj);
    5258                 : 
    5259               0 :   if (!document ||
    5260               0 :       document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
    5261                 :     // If we don't have a document, or if the document is not in
    5262                 :     // quirks mode, return early.
    5263                 : 
    5264               0 :     return JS_TRUE;
    5265                 :   }
    5266                 : 
    5267               0 :   JSObject *proto = ::JS_GetPrototype(obj);
    5268                 :   JSBool hasProp;
    5269                 : 
    5270               0 :   if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
    5271                 :       hasProp) {
    5272                 :     // No prototype, or the property exists on the prototype. Do
    5273                 :     // nothing.
    5274                 : 
    5275               0 :     return JS_TRUE;
    5276                 :   }
    5277                 : 
    5278               0 :   nsDependentJSString str(id);
    5279               0 :   nsCOMPtr<nsISupports> result;
    5280                 :   nsWrapperCache *cache;
    5281                 :   {
    5282               0 :     Element *element = document->GetElementById(str);
    5283               0 :     result = element;
    5284               0 :     cache = element;
    5285                 :   }
    5286                 : 
    5287               0 :   if (!result) {
    5288               0 :     document->ResolveName(str, nsnull, getter_AddRefs(result), &cache);
    5289                 :   }
    5290                 : 
    5291               0 :   if (result) {
    5292                 :     jsval v;
    5293               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    5294                 :     nsresult rv = WrapNative(cx, obj, result, cache, true, &v,
    5295               0 :                              getter_AddRefs(holder));
    5296               0 :     NS_ENSURE_SUCCESS(rv, JS_FALSE);
    5297                 : 
    5298               0 :     if (!JS_WrapValue(cx, &v) ||
    5299               0 :         !JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
    5300               0 :       return JS_FALSE;
    5301                 :     }
    5302                 : 
    5303               0 :     *objp = obj;
    5304                 :   }
    5305                 : 
    5306               0 :   return JS_TRUE;
    5307                 : }
    5308                 : 
    5309                 : // static
    5310                 : void
    5311               0 : nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj)
    5312                 : {
    5313                 :   JSObject *proto;
    5314                 : 
    5315               0 :   JSAutoRequest ar(cx);
    5316                 : 
    5317               0 :   while ((proto = ::JS_GetPrototype(obj))) {
    5318               0 :     if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
    5319               0 :       nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(proto);
    5320                 : 
    5321               0 :       NS_IF_RELEASE(doc);
    5322                 : 
    5323               0 :       ::JS_SetPrivate(proto, nsnull);
    5324                 : 
    5325                 :       // Pull the global scope polluter out of the prototype chain so
    5326                 :       // that it can be freed.
    5327               0 :       ::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(proto));
    5328                 : 
    5329               0 :       break;
    5330                 :     }
    5331                 : 
    5332               0 :     obj = proto;
    5333                 :   }
    5334               0 : }
    5335                 : 
    5336                 : // static
    5337                 : nsresult
    5338               0 : nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
    5339                 :                                        nsIHTMLDocument *doc)
    5340                 : {
    5341                 :   // If global scope pollution is disabled, or if our document is not
    5342                 :   // a HTML document, do nothing
    5343               0 :   if (sDisableGlobalScopePollutionSupport || !doc) {
    5344               0 :     return NS_OK;
    5345                 :   }
    5346                 : 
    5347               0 :   JSAutoRequest ar(cx);
    5348                 : 
    5349               0 :   JSObject *gsp = ::JS_NewObjectWithUniqueType(cx, &sGlobalScopePolluterClass, nsnull, obj);
    5350               0 :   if (!gsp) {
    5351               0 :     return NS_ERROR_OUT_OF_MEMORY;
    5352                 :   }
    5353                 : 
    5354               0 :   JSObject *o = obj, *proto;
    5355                 : 
    5356                 :   // Find the place in the prototype chain where we want this global
    5357                 :   // scope polluter (right before Object.prototype).
    5358                 : 
    5359               0 :   while ((proto = ::JS_GetPrototype(o))) {
    5360               0 :     if (JS_GetClass(proto) == sObjectClass) {
    5361                 :       // Set the global scope polluters prototype to Object.prototype
    5362               0 :       ::JS_SplicePrototype(cx, gsp, proto);
    5363                 : 
    5364               0 :       break;
    5365                 :     }
    5366                 : 
    5367               0 :     o = proto;
    5368                 :   }
    5369                 : 
    5370                 :   // And then set the prototype of the object whose prototype was
    5371                 :   // Object.prototype to be the global scope polluter.
    5372               0 :   ::JS_SplicePrototype(cx, o, gsp);
    5373                 : 
    5374               0 :   ::JS_SetPrivate(gsp, doc);
    5375                 : 
    5376                 :   // The global scope polluter will release doc on destruction (or
    5377                 :   // invalidation).
    5378               0 :   NS_ADDREF(doc);
    5379                 : 
    5380               0 :   return NS_OK;
    5381                 : }
    5382                 : 
    5383                 : static
    5384                 : already_AddRefed<nsIDOMWindow>
    5385               0 : GetChildFrame(nsGlobalWindow *win, PRUint32 index)
    5386                 : {
    5387               0 :   nsCOMPtr<nsIDOMWindowCollection> frames;
    5388               0 :   win->GetFrames(getter_AddRefs(frames));
    5389                 : 
    5390               0 :   nsIDOMWindow *frame = nsnull;
    5391                 : 
    5392               0 :   if (frames) {
    5393               0 :     frames->Item(index, &frame);
    5394                 :   }
    5395                 : 
    5396               0 :   return frame;
    5397                 : }
    5398                 : 
    5399                 : NS_IMETHODIMP
    5400               0 : nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    5401                 :                         JSObject *obj, jsid id, jsval *vp, bool *_retval)
    5402                 : {
    5403               0 :   nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
    5404                 : 
    5405               0 :   JSAutoRequest ar(cx);
    5406                 : 
    5407                 : #ifdef DEBUG_SH_FORWARDING
    5408                 :   {
    5409                 :     JSString *jsstr = ::JS_ValueToString(cx, id);
    5410                 :     if (jsstr) {
    5411                 :       nsDependentJSString str(jsstr);
    5412                 : 
    5413                 :       if (win->IsInnerWindow()) {
    5414                 : #ifdef DEBUG_PRINT_INNER
    5415                 :         printf("Property '%s' get on inner window %p\n",
    5416                 :               NS_ConvertUTF16toUTF8(str).get(), (void *)win);
    5417                 : #endif
    5418                 :       } else {
    5419                 :         printf("Property '%s' get on outer window %p\n",
    5420                 :               NS_ConvertUTF16toUTF8(str).get(), (void *)win);
    5421                 :       }
    5422                 :     }
    5423                 :   }
    5424                 : #endif
    5425                 : 
    5426                 :   // The order in which things are done in this method are a bit
    5427                 :   // whacky, that's because this method is *extremely* performace
    5428                 :   // critical. Don't touch this unless you know what you're doing.
    5429                 : 
    5430               0 :   if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
    5431                 :     // If we're accessing a numeric property we'll treat that as if
    5432                 :     // window.frames[n] is accessed (since window.frames === window),
    5433                 :     // if window.frames[n] is a child frame, wrap the frame and return
    5434                 :     // it without doing a security check.
    5435               0 :     PRUint32 index = PRUint32(JSID_TO_INT(id));
    5436               0 :     nsresult rv = NS_OK;
    5437               0 :     if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
    5438                 :       // A numeric property accessed and the numeric property is a
    5439                 :       // child frame, wrap the child frame without doing a security
    5440                 :       // check and return.
    5441                 : 
    5442               0 :       nsGlobalWindow *frameWin = (nsGlobalWindow *)frame.get();
    5443               0 :       NS_ASSERTION(frameWin->IsOuterWindow(), "GetChildFrame gave us an inner?");
    5444                 : 
    5445               0 :       frameWin->EnsureInnerWindow();
    5446                 : 
    5447               0 :       nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    5448                 :       jsval v;
    5449               0 :       rv = WrapNative(cx, frameWin->GetGlobalJSObject(), frame,
    5450                 :                       &NS_GET_IID(nsIDOMWindow), true, &v,
    5451               0 :                       getter_AddRefs(holder));
    5452               0 :       NS_ENSURE_SUCCESS(rv, rv);
    5453                 : 
    5454               0 :       if (!JS_WrapValue(cx, &v)) {
    5455               0 :         return NS_ERROR_FAILURE;
    5456                 :       }
    5457                 : 
    5458               0 :       *vp = v;
    5459                 :     }
    5460                 : 
    5461               0 :     return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
    5462                 :   }
    5463                 : 
    5464               0 :   if (JSID_IS_STRING(id) && !JSVAL_IS_PRIMITIVE(*vp) &&
    5465               0 :       ::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) {
    5466                 :     // A named property accessed which could have been resolved to a
    5467                 :     // child frame in nsWindowSH::NewResolve() (*vp will tell us if
    5468                 :     // that's the case). If *vp is a window object (i.e. a child
    5469                 :     // frame), return without doing a security check.
    5470                 :     //
    5471                 :     // Calling GetWrappedNativeOfJSObject() is not all that cheap, so
    5472                 :     // only do that if the JSClass name is one that is likely to be a
    5473                 :     // window object.
    5474                 : 
    5475               0 :     const char *name = JS_GetClass(JSVAL_TO_OBJECT(*vp))->name;
    5476                 : 
    5477                 :     // The list of Window class names here need to be kept in sync
    5478                 :     // with the actual class names! The class name
    5479                 :     // XPCCrossOriginWrapper needs to be handled here too as XOWs
    5480                 :     // define child frame names with a XOW as the value, and thus
    5481                 :     // we'll need to get through here with XOWs class name too.
    5482               0 :     if ((*name == 'W' && strcmp(name, "Window") == 0) ||
    5483               0 :         (*name == 'C' && strcmp(name, "ChromeWindow") == 0) ||
    5484               0 :         (*name == 'M' && strcmp(name, "ModalContentWindow") == 0) ||
    5485                 :         (*name == 'I' &&
    5486               0 :          (strcmp(name, "InnerWindow") == 0 ||
    5487               0 :           strcmp(name, "InnerChromeWindow") == 0 ||
    5488               0 :           strcmp(name, "InnerModalContentWindow") == 0)) ||
    5489               0 :         (*name == 'X' && strcmp(name, "XPCCrossOriginWrapper") == 0)) {
    5490               0 :       nsCOMPtr<nsIDOMWindow> window = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
    5491                 : 
    5492               0 :       if (window) {
    5493                 :         // Yup, *vp is a window object, return early (*vp is already
    5494                 :         // the window, so no need to wrap it again).
    5495                 : 
    5496               0 :         return NS_SUCCESS_I_DID_SOMETHING;
    5497                 :       }
    5498                 :     }
    5499                 :   }
    5500                 : 
    5501               0 :   if (id == sWrappedJSObject_id &&
    5502               0 :       xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
    5503               0 :     obj = JS_ObjectToOuterObject(cx, obj);
    5504               0 :     *vp = OBJECT_TO_JSVAL(obj);
    5505               0 :     return NS_SUCCESS_I_DID_SOMETHING;
    5506                 :   }
    5507                 : 
    5508               0 :   return NS_OK;
    5509                 : }
    5510                 : 
    5511                 : NS_IMETHODIMP
    5512               0 : nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    5513                 :                       JSObject *obj, bool *_retval)
    5514                 : {
    5515               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    5516               0 :     *_retval = JS_EnumerateStandardClasses(cx, obj);
    5517                 :   }
    5518                 : 
    5519               0 :   return NS_OK;
    5520                 : }
    5521                 : 
    5522                 : static const char*
    5523               0 : FindConstructorContractID(const nsDOMClassInfoData *aDOMClassInfoData)
    5524                 : {
    5525                 :   PRUint32 i;
    5526               0 :   for (i = 0; i < ArrayLength(kConstructorMap); ++i) {
    5527               0 :     if (&sClassInfoData[kConstructorMap[i].mDOMClassInfoID] ==
    5528                 :         aDOMClassInfoData) {
    5529               0 :       return kConstructorMap[i].mContractID;
    5530                 :     }
    5531                 :   }
    5532               0 :   return nsnull;
    5533                 : }
    5534                 : 
    5535                 : static nsDOMConstructorFunc
    5536               0 : FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
    5537                 : {
    5538               0 :   for (PRUint32 i = 0; i < ArrayLength(kConstructorFuncMap); ++i) {
    5539               0 :     if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
    5540                 :         aDOMClassInfoData) {
    5541               0 :       return kConstructorFuncMap[i].mConstructorFunc;
    5542                 :     }
    5543                 :   }
    5544               0 :   return nsnull;
    5545                 : }
    5546                 : 
    5547                 : static nsresult
    5548               0 : BaseStubConstructor(nsIWeakReference* aWeakOwner,
    5549                 :                     const nsGlobalNameStruct *name_struct, JSContext *cx,
    5550                 :                     JSObject *obj, unsigned argc, jsval *argv, jsval *rval)
    5551                 : {
    5552                 :   nsresult rv;
    5553               0 :   nsCOMPtr<nsISupports> native;
    5554               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    5555                 :     const nsDOMClassInfoData* ci_data =
    5556               0 :       &sClassInfoData[name_struct->mDOMClassInfoID];
    5557               0 :     const char *contractid = FindConstructorContractID(ci_data);
    5558               0 :     if (contractid) {
    5559               0 :       native = do_CreateInstance(contractid, &rv);
    5560                 :     }
    5561                 :     else {
    5562               0 :       nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
    5563               0 :       if (func) {
    5564               0 :         rv = func(getter_AddRefs(native));
    5565                 :       }
    5566                 :       else {
    5567               0 :         rv = NS_ERROR_NOT_AVAILABLE;
    5568                 :       }
    5569                 :     }
    5570               0 :   } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
    5571               0 :     native = do_CreateInstance(name_struct->mCID, &rv);
    5572               0 :   } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
    5573               0 :     native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
    5574                 :   } else {
    5575               0 :     native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
    5576                 :   }
    5577               0 :   if (NS_FAILED(rv)) {
    5578               0 :     NS_ERROR("Failed to create the object");
    5579               0 :     return rv;
    5580                 :   }
    5581                 : 
    5582               0 :   nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
    5583               0 :   if (initializer) {
    5584                 :     // Initialize object using the current inner window, but only if
    5585                 :     // the caller can access it.
    5586               0 :     nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
    5587               0 :     nsPIDOMWindow* outerWindow = owner ? owner->GetOuterWindow() : nsnull;
    5588                 :     nsPIDOMWindow* currentInner =
    5589               0 :       outerWindow ? outerWindow->GetCurrentInnerWindow() : nsnull;
    5590               0 :     if (!currentInner ||
    5591               0 :         (owner != currentInner &&
    5592               0 :          !nsContentUtils::CanCallerAccess(currentInner))) {
    5593               0 :       return NS_ERROR_DOM_SECURITY_ERR;
    5594                 :     }
    5595                 : 
    5596               0 :     rv = initializer->Initialize(currentInner, cx, obj, argc, argv);
    5597               0 :     if (NS_FAILED(rv)) {
    5598               0 :       return rv;
    5599                 :     }
    5600                 :   }
    5601                 : 
    5602               0 :   nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
    5603               0 :   if (owner) {
    5604               0 :     nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
    5605               0 :     if (!context) {
    5606               0 :       return NS_ERROR_UNEXPECTED;
    5607                 :     }
    5608                 : 
    5609                 :     JSObject* new_obj;
    5610               0 :     rv = owner->GetScriptObject(context, (void**)&new_obj);
    5611                 : 
    5612               0 :     if (NS_SUCCEEDED(rv)) {
    5613               0 :       *rval = OBJECT_TO_JSVAL(new_obj);
    5614                 :     }
    5615                 : 
    5616               0 :     return rv;
    5617                 :   }
    5618                 : 
    5619               0 :   return WrapNative(cx, obj, native, true, rval);
    5620                 : }
    5621                 : 
    5622                 : static nsresult
    5623               0 : DefineInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
    5624                 : {
    5625                 :   nsCOMPtr<nsIInterfaceInfoManager>
    5626               0 :     iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
    5627               0 :   NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
    5628                 : 
    5629               0 :   nsCOMPtr<nsIInterfaceInfo> if_info;
    5630                 : 
    5631               0 :   nsresult rv = iim->GetInfoForIID(aIID, getter_AddRefs(if_info));
    5632               0 :   NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && if_info, rv);
    5633                 : 
    5634                 :   PRUint16 constant_count;
    5635                 : 
    5636               0 :   if_info->GetConstantCount(&constant_count);
    5637                 : 
    5638               0 :   if (!constant_count) {
    5639               0 :     return NS_OK;
    5640                 :   }
    5641                 : 
    5642               0 :   nsCOMPtr<nsIInterfaceInfo> parent_if_info;
    5643                 : 
    5644               0 :   rv = if_info->GetParent(getter_AddRefs(parent_if_info));
    5645               0 :   NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && parent_if_info, rv);
    5646                 : 
    5647                 :   PRUint16 parent_constant_count, i;
    5648               0 :   parent_if_info->GetConstantCount(&parent_constant_count);
    5649                 : 
    5650               0 :   for (i = parent_constant_count; i < constant_count; i++) {
    5651               0 :     const nsXPTConstant *c = nsnull;
    5652                 : 
    5653               0 :     rv = if_info->GetConstant(i, &c);
    5654               0 :     NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && c, rv);
    5655                 : 
    5656               0 :     PRUint16 type = c->GetType().TagPart();
    5657                 : 
    5658                 :     jsval v;
    5659               0 :     switch (type) {
    5660                 :       case nsXPTType::T_I8:
    5661                 :       case nsXPTType::T_U8:
    5662                 :       {
    5663               0 :         v = INT_TO_JSVAL(c->GetValue()->val.u8);
    5664               0 :         break;
    5665                 :       }
    5666                 :       case nsXPTType::T_I16:
    5667                 :       case nsXPTType::T_U16:
    5668                 :       {
    5669               0 :         v = INT_TO_JSVAL(c->GetValue()->val.u16);
    5670               0 :         break;
    5671                 :       }
    5672                 :       case nsXPTType::T_I32:
    5673                 :       {
    5674               0 :         if (!JS_NewNumberValue(cx, c->GetValue()->val.i32, &v)) {
    5675               0 :           return NS_ERROR_UNEXPECTED;
    5676                 :         }
    5677               0 :         break;
    5678                 :       }
    5679                 :       case nsXPTType::T_U32:
    5680                 :       {
    5681               0 :         if (!JS_NewNumberValue(cx, c->GetValue()->val.u32, &v)) {
    5682               0 :           return NS_ERROR_UNEXPECTED;
    5683                 :         }
    5684               0 :         break;
    5685                 :       }
    5686                 :       default:
    5687                 :       {
    5688                 : #ifdef NS_DEBUG
    5689               0 :         NS_ERROR("Non-numeric constant found in interface.");
    5690                 : #endif
    5691               0 :         continue;
    5692                 :       }
    5693                 :     }
    5694                 : 
    5695               0 :     if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull,
    5696               0 :                              JSPROP_ENUMERATE)) {
    5697               0 :       return NS_ERROR_UNEXPECTED;
    5698                 :     }
    5699                 :   }
    5700                 : 
    5701               0 :   return NS_OK;
    5702                 : }
    5703                 : 
    5704                 : // This code is temporary until we remove support for the constants defined
    5705                 : // on IDBCursor/IDBRequest/IDBTransaction
    5706                 : 
    5707                 : struct IDBConstant
    5708                 : {
    5709                 :   const char* interface;
    5710                 :   const char* name;
    5711                 :   const char* value;
    5712                 :   
    5713                 :   static const char* IDBCursor;
    5714                 :   static const char* IDBRequest;
    5715                 :   static const char* IDBTransaction;
    5716                 : };
    5717                 : 
    5718                 : const char* IDBConstant::IDBCursor = "IDBCursor";
    5719                 : const char* IDBConstant::IDBRequest = "IDBRequest";
    5720                 : const char* IDBConstant::IDBTransaction = "IDBTransaction";
    5721                 : 
    5722                 : static const IDBConstant sIDBConstants[] = {
    5723                 :   { IDBConstant::IDBCursor,      "NEXT",              "next" },
    5724                 :   { IDBConstant::IDBCursor,      "NEXT_NO_DUPLICATE", "nextunique" },
    5725                 :   { IDBConstant::IDBCursor,      "PREV",              "prev" },
    5726                 :   { IDBConstant::IDBCursor,      "PREV_NO_DUPLICATE", "prevunique" },
    5727                 :   { IDBConstant::IDBRequest,     "LOADING",           "pending" },
    5728                 :   { IDBConstant::IDBRequest,     "DONE",              "done" },
    5729                 :   { IDBConstant::IDBTransaction, "READ_ONLY",         "readonly" },
    5730                 :   { IDBConstant::IDBTransaction, "READ_WRITE",        "readwrite" },
    5731                 :   { IDBConstant::IDBTransaction, "VERSION_CHANGE",    "versionchange" },
    5732            1464 : };
    5733                 : 
    5734                 : static JSBool
    5735               0 : IDBConstantGetter(JSContext *cx, JSObject *obj, jsid id, jsval* vp)
    5736                 : {
    5737               0 :   MOZ_ASSERT(JSID_IS_INT(id));
    5738                 :   
    5739               0 :   int8_t index = JSID_TO_INT(id);
    5740                 :   
    5741               0 :   MOZ_ASSERT((uint8_t)index < mozilla::ArrayLength(sIDBConstants));
    5742                 : 
    5743               0 :   const IDBConstant& c = sIDBConstants[index];
    5744                 : 
    5745                 :   // Put a warning on the console
    5746                 :   nsString warnText =
    5747               0 :     NS_LITERAL_STRING("The constant ") +
    5748               0 :     NS_ConvertASCIItoUTF16(c.interface) +
    5749               0 :     NS_LITERAL_STRING(".") +
    5750               0 :     NS_ConvertASCIItoUTF16(c.name) +
    5751               0 :     NS_LITERAL_STRING(" has been deprecated. Use the string value \"") +
    5752               0 :     NS_ConvertASCIItoUTF16(c.value) +
    5753               0 :     NS_LITERAL_STRING("\" instead.");
    5754                 : 
    5755               0 :   PRUint64 windowID = 0;
    5756               0 :   nsIScriptContext* context = GetScriptContextFromJSContext(cx);
    5757               0 :   if (context) {
    5758                 :     nsCOMPtr<nsPIDOMWindow> window =
    5759               0 :       do_QueryInterface(context->GetGlobalObject());
    5760               0 :     if (window) {
    5761               0 :       window = window->GetCurrentInnerWindow();
    5762                 :     }
    5763               0 :     NS_WARN_IF_FALSE(window, "Missing a window, got a door?");
    5764               0 :     if (window) {
    5765               0 :       windowID = window->WindowID();
    5766                 :     }
    5767                 :   }
    5768                 : 
    5769                 :   nsCOMPtr<nsIScriptError> errorObject =
    5770               0 :     do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
    5771               0 :   NS_WARN_IF_FALSE(errorObject, "Failed to create error object");
    5772               0 :   if (errorObject) {
    5773               0 :     nsresult rv = errorObject->InitWithWindowID(warnText.get(),
    5774                 :                                                 nsnull, // file name
    5775                 :                                                 nsnull, // source line
    5776                 :                                                 0, 0, // Line/col number
    5777                 :                                                 nsIScriptError::warningFlag,
    5778               0 :                                                 "DOM Core", windowID);
    5779               0 :     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init error object");
    5780                 : 
    5781               0 :     if (NS_SUCCEEDED(rv)) {
    5782                 :       nsCOMPtr<nsIConsoleService> consoleServ =
    5783               0 :         do_GetService(NS_CONSOLESERVICE_CONTRACTID);
    5784               0 :       if (consoleServ) {
    5785               0 :         consoleServ->LogMessage(errorObject);
    5786                 :       }
    5787                 :     }
    5788                 :   }
    5789                 : 
    5790                 :   // Redefine property to remove getter
    5791               0 :   NS_ConvertASCIItoUTF16 valStr(c.value);
    5792                 :   jsval value;
    5793               0 :   if (!xpc::StringToJsval(cx, valStr, &value)) {
    5794               0 :     return JS_FALSE;
    5795                 :   }
    5796               0 :   if (!::JS_DefineProperty(cx, obj, c.name, value, nsnull, nsnull,
    5797               0 :                            JSPROP_ENUMERATE)) {
    5798               0 :     return JS_FALSE;
    5799                 :   }
    5800                 : 
    5801                 :   // Return value
    5802               0 :   *vp = value;
    5803               0 :   return JS_TRUE;
    5804                 : }
    5805                 : 
    5806                 : static nsresult
    5807               0 : DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
    5808                 : {
    5809                 :   const char* interface;
    5810               0 :   if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
    5811               0 :     interface = IDBConstant::IDBCursor;
    5812                 :   }
    5813               0 :   else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
    5814               0 :     interface = IDBConstant::IDBRequest;
    5815                 :   }
    5816               0 :   else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
    5817               0 :     interface = IDBConstant::IDBTransaction;
    5818                 :   }
    5819                 : 
    5820               0 :   for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
    5821               0 :     const IDBConstant& c = sIDBConstants[i];
    5822               0 :     if (c.interface != interface) {
    5823               0 :       continue;
    5824                 :     }
    5825                 : 
    5826               0 :     if (!::JS_DefinePropertyWithTinyId(cx, obj, c.name, i, JSVAL_VOID,
    5827                 :                                        IDBConstantGetter, nsnull,
    5828               0 :                                        JSPROP_ENUMERATE)) {
    5829               0 :       return NS_ERROR_UNEXPECTED;
    5830                 :     }
    5831                 :   }
    5832                 : 
    5833               0 :   return NS_OK;
    5834                 : }
    5835                 : 
    5836                 : class nsDOMConstructor : public nsIDOMDOMConstructor
    5837               0 : {
    5838                 : protected:
    5839               0 :   nsDOMConstructor(const PRUnichar* aName,
    5840                 :                    bool aIsConstructable,
    5841                 :                    nsPIDOMWindow* aOwner)
    5842                 :     : mClassName(aName),
    5843                 :       mConstructable(aIsConstructable),
    5844               0 :       mWeakOwner(do_GetWeakReference(aOwner))
    5845                 :   {
    5846               0 :   }
    5847                 : 
    5848                 : public:
    5849                 : 
    5850                 :   static nsresult Create(const PRUnichar* aName,
    5851                 :                          const nsDOMClassInfoData* aData,
    5852                 :                          const nsGlobalNameStruct* aNameStruct,
    5853                 :                          nsPIDOMWindow* aOwner,
    5854                 :                          nsDOMConstructor** aResult);
    5855                 : 
    5856                 :   NS_DECL_ISUPPORTS
    5857                 :   NS_DECL_NSIDOMDOMCONSTRUCTOR
    5858                 : 
    5859                 :   nsresult PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj);
    5860                 : 
    5861                 :   nsresult Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    5862                 :                      JSObject *obj, PRUint32 argc, jsval *argv,
    5863                 :                      jsval *vp, bool *_retval);
    5864                 : 
    5865                 :   nsresult HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    5866                 :                        JSObject *obj, const jsval &val, bool *bp,
    5867                 :                        bool *_retval);
    5868                 : 
    5869               0 :   nsresult Install(JSContext *cx, JSObject *target, jsval thisAsVal)
    5870                 :   {
    5871                 :     // The 'attrs' argument used to be JSPROP_PERMANENT. See bug 628612.
    5872               0 :     JSBool ok = JS_WrapValue(cx, &thisAsVal) &&
    5873                 :       ::JS_DefineUCProperty(cx, target,
    5874                 :                             reinterpret_cast<const jschar *>(mClassName),
    5875                 :                             nsCRT::strlen(mClassName), thisAsVal, nsnull,
    5876               0 :                             nsnull, 0);
    5877                 : 
    5878               0 :     return ok ? NS_OK : NS_ERROR_UNEXPECTED;
    5879                 :   }
    5880                 : 
    5881                 :   nsresult ResolveInterfaceConstants(JSContext *cx, JSObject *obj);
    5882                 : 
    5883                 : private:
    5884               0 :   const nsGlobalNameStruct *GetNameStruct()
    5885                 :   {
    5886               0 :     if (!mClassName) {
    5887               0 :       NS_ERROR("Can't get name");
    5888               0 :       return nsnull;
    5889                 :     }
    5890                 : 
    5891                 :     const nsGlobalNameStruct *nameStruct;
    5892                 : #ifdef DEBUG
    5893                 :     nsresult rv =
    5894                 : #endif
    5895               0 :       GetNameStruct(nsDependentString(mClassName), &nameStruct);
    5896                 : 
    5897               0 :     NS_ASSERTION(NS_FAILED(rv) || nameStruct, "Name isn't in hash.");
    5898                 : 
    5899               0 :     return nameStruct;
    5900                 :   }
    5901                 : 
    5902               0 :   static nsresult GetNameStruct(const nsAString& aName,
    5903                 :                                 const nsGlobalNameStruct **aNameStruct)
    5904                 :   {
    5905               0 :     *aNameStruct = nsnull;
    5906                 : 
    5907                 :     nsScriptNameSpaceManager *nameSpaceManager =
    5908               0 :       nsJSRuntime::GetNameSpaceManager();
    5909               0 :     if (!nameSpaceManager) {
    5910               0 :       NS_ERROR("Can't get namespace manager.");
    5911               0 :       return NS_ERROR_UNEXPECTED;
    5912                 :     }
    5913                 : 
    5914               0 :     nameSpaceManager->LookupName(aName, aNameStruct);
    5915                 : 
    5916                 :     // Return NS_OK here, aName just isn't a DOM class but nothing failed.
    5917               0 :     return NS_OK;
    5918                 :   }
    5919                 : 
    5920               0 :   static bool IsConstructable(const nsDOMClassInfoData *aData)
    5921                 :   {
    5922               0 :     if (IS_EXTERNAL(aData->mCachedClassInfo)) {
    5923                 :       const nsExternalDOMClassInfoData* data =
    5924               0 :         static_cast<const nsExternalDOMClassInfoData*>(aData);
    5925               0 :       return data->mConstructorCID != nsnull;
    5926                 :     }
    5927                 : 
    5928               0 :     return FindConstructorContractID(aData) || FindConstructorFunc(aData);
    5929                 :   }
    5930               0 :   static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
    5931                 :   {
    5932                 :     return
    5933                 :       (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
    5934               0 :        IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
    5935                 :       (aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
    5936               0 :        IsConstructable(aNameStruct->mData)) ||
    5937                 :       aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor ||
    5938               0 :       aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias;
    5939                 :   }
    5940                 : 
    5941                 :   const PRUnichar*   mClassName;
    5942                 :   const bool mConstructable;
    5943                 :   nsWeakPtr          mWeakOwner;
    5944                 : };
    5945                 : 
    5946                 : //static
    5947                 : nsresult
    5948               0 : nsDOMConstructor::Create(const PRUnichar* aName,
    5949                 :                          const nsDOMClassInfoData* aData,
    5950                 :                          const nsGlobalNameStruct* aNameStruct,
    5951                 :                          nsPIDOMWindow* aOwner,
    5952                 :                          nsDOMConstructor** aResult)
    5953                 : {
    5954               0 :   *aResult = nsnull;
    5955                 :   // Prevent creating a constructor if aOwner is inner window which doesn't have
    5956                 :   // an outer window. If the outer window doesn't have an inner window or the
    5957                 :   // caller can't access the outer window's current inner window then try to use
    5958                 :   // the owner (so long as it is, in fact, an inner window). If that doesn't
    5959                 :   // work then prevent creation also.
    5960               0 :   nsPIDOMWindow* outerWindow = aOwner->GetOuterWindow();
    5961                 :   nsPIDOMWindow* currentInner =
    5962               0 :     outerWindow ? outerWindow->GetCurrentInnerWindow() : aOwner;
    5963               0 :   if (!currentInner ||
    5964                 :       (aOwner != currentInner &&
    5965               0 :        !nsContentUtils::CanCallerAccess(currentInner) &&
    5966               0 :        !(currentInner = aOwner)->IsInnerWindow())) {
    5967               0 :     return NS_ERROR_DOM_SECURITY_ERR;
    5968                 :   }
    5969                 : 
    5970                 :   bool constructable = aNameStruct ?
    5971                 :                          IsConstructable(aNameStruct) :
    5972               0 :                          IsConstructable(aData);
    5973                 : 
    5974               0 :   *aResult = new nsDOMConstructor(aName, constructable, currentInner);
    5975               0 :   NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
    5976               0 :   NS_ADDREF(*aResult);
    5977               0 :   return NS_OK;
    5978                 : }
    5979                 : 
    5980               0 : NS_IMPL_ADDREF(nsDOMConstructor)
    5981               0 : NS_IMPL_RELEASE(nsDOMConstructor)
    5982               0 : NS_INTERFACE_MAP_BEGIN(nsDOMConstructor)
    5983               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMDOMConstructor)
    5984               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
    5985               0 :   if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
    5986                 : #ifdef DEBUG
    5987                 :     {
    5988               0 :       const nsGlobalNameStruct *name_struct = GetNameStruct();
    5989               0 :       NS_ASSERTION(!name_struct ||
    5990                 :                    mConstructable == IsConstructable(name_struct),
    5991                 :                    "Can't change constructability dynamically!");
    5992                 :     }
    5993                 : #endif
    5994                 :     foundInterface =
    5995                 :       NS_GetDOMClassInfoInstance(mConstructable ?
    5996                 :                                  eDOMClassInfo_DOMConstructor_id :
    5997               0 :                                  eDOMClassInfo_DOMPrototype_id);
    5998               0 :     if (!foundInterface) {
    5999               0 :       *aInstancePtr = nsnull;
    6000               0 :       return NS_ERROR_OUT_OF_MEMORY;
    6001                 :     }
    6002                 :   } else
    6003               0 : NS_INTERFACE_MAP_END
    6004                 : 
    6005                 : nsresult
    6006               0 : nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
    6007                 : {
    6008               0 :   nsCOMPtr<nsPIDOMWindow> owner(do_QueryReferent(mWeakOwner));
    6009               0 :   if (!owner) {
    6010                 :     // Can't do anything.
    6011               0 :     return NS_OK;
    6012                 :   }
    6013                 : 
    6014               0 :   nsGlobalWindow *win = static_cast<nsGlobalWindow *>(owner.get());
    6015               0 :   *parentObj = win->FastGetGlobalJSObject();
    6016               0 :   return NS_OK;
    6017                 : }
    6018                 : 
    6019                 : nsresult
    6020               0 : nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
    6021                 :                             JSObject * obj, PRUint32 argc, jsval * argv,
    6022                 :                             jsval * vp, bool *_retval)
    6023                 : {
    6024               0 :   JSObject* class_obj = JSVAL_TO_OBJECT(argv[-2]);
    6025               0 :   if (!class_obj) {
    6026               0 :     NS_ERROR("nsDOMConstructor::Construct couldn't get constructor object.");
    6027               0 :     return NS_ERROR_UNEXPECTED;
    6028                 :   }
    6029                 : 
    6030               0 :   const nsGlobalNameStruct *name_struct = GetNameStruct();
    6031               0 :   NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE);
    6032                 : 
    6033               0 :   if (!IsConstructable(name_struct)) {
    6034                 :     // ignore return value, we return JS_FALSE anyway
    6035               0 :     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
    6036                 :   }
    6037                 : 
    6038               0 :   return BaseStubConstructor(mWeakOwner, name_struct, cx, obj, argc, argv, vp);
    6039                 : }
    6040                 : 
    6041                 : nsresult
    6042               0 : nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
    6043                 :                               JSContext * cx, JSObject * obj,
    6044                 :                               const jsval &v, bool *bp, bool *_retval)
    6045                 : 
    6046                 : {
    6047                 :   // No need to look these up in the hash.
    6048               0 :   *bp = false;
    6049               0 :   if (JSVAL_IS_PRIMITIVE(v)) {
    6050               0 :     return NS_OK;
    6051                 :   }
    6052                 : 
    6053               0 :   JSObject *dom_obj = JSVAL_TO_OBJECT(v);
    6054               0 :   NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
    6055                 : 
    6056                 :   // This might not be the right object, if XPCNativeWrapping
    6057                 :   // happened.  Get the wrapped native for this object, then get its
    6058                 :   // JS object.
    6059                 :   JSObject *wrapped_obj;
    6060               0 :   nsresult rv = nsContentUtils::XPConnect()->GetJSObjectOfWrapper(cx, dom_obj,
    6061               0 :                                                                   &wrapped_obj);
    6062               0 :   if (NS_SUCCEEDED(rv)) {
    6063               0 :     dom_obj = wrapped_obj;
    6064                 :   }
    6065                 : 
    6066               0 :   JSClass *dom_class = JS_GetClass(dom_obj);
    6067               0 :   if (!dom_class) {
    6068               0 :     NS_ERROR("nsDOMConstructor::HasInstance can't get class.");
    6069               0 :     return NS_ERROR_UNEXPECTED;
    6070                 :   }
    6071                 : 
    6072                 :   const nsGlobalNameStruct *name_struct;
    6073               0 :   rv = GetNameStruct(NS_ConvertASCIItoUTF16(dom_class->name), &name_struct);
    6074               0 :   if (NS_FAILED(rv)) {
    6075               0 :     return rv;
    6076                 :   }
    6077                 : 
    6078               0 :   if (!name_struct) {
    6079                 :     // This isn't a normal DOM object, see if this constructor lives on its
    6080                 :     // prototype chain.
    6081                 :     jsval val;
    6082               0 :     if (!JS_GetProperty(cx, obj, "prototype", &val)) {
    6083               0 :       return NS_ERROR_UNEXPECTED;
    6084                 :     }
    6085                 : 
    6086               0 :     JS_ASSERT(!JSVAL_IS_PRIMITIVE(val));
    6087               0 :     JSObject *dot_prototype = JSVAL_TO_OBJECT(val);
    6088                 : 
    6089               0 :     JSObject *proto = JS_GetPrototype(dom_obj);
    6090               0 :     for ( ; proto; proto = JS_GetPrototype(proto)) {
    6091               0 :       if (proto == dot_prototype) {
    6092               0 :         *bp = true;
    6093               0 :         break;
    6094                 :       }
    6095                 :     }
    6096                 : 
    6097               0 :     return NS_OK;
    6098                 :   }
    6099                 : 
    6100               0 :   if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
    6101                 :       name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo &&
    6102                 :       name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructorAlias) {
    6103                 :     // Doesn't have DOM interfaces.
    6104               0 :     return NS_OK;
    6105                 :   }
    6106                 : 
    6107               0 :   const nsGlobalNameStruct *class_name_struct = GetNameStruct();
    6108               0 :   NS_ENSURE_TRUE(class_name_struct, NS_ERROR_FAILURE);
    6109                 : 
    6110               0 :   if (name_struct == class_name_struct) {
    6111               0 :     *bp = JS_TRUE;
    6112                 : 
    6113               0 :     return NS_OK;
    6114                 :   }
    6115                 : 
    6116                 :   nsScriptNameSpaceManager *nameSpaceManager =
    6117               0 :     nsJSRuntime::GetNameSpaceManager();
    6118               0 :   NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?");
    6119                 : 
    6120                 :   const nsIID *class_iid;
    6121               0 :   if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
    6122                 :       class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
    6123               0 :     class_iid = &class_name_struct->mIID;
    6124               0 :   } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6125                 :     class_iid =
    6126               0 :       sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
    6127               0 :   } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6128               0 :     class_iid = class_name_struct->mData->mProtoChainInterface;
    6129               0 :   } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
    6130                 :     const nsGlobalNameStruct* alias_struct =
    6131               0 :       nameSpaceManager->GetConstructorProto(class_name_struct);
    6132               0 :     if (!alias_struct) {
    6133               0 :       NS_ERROR("Couldn't get constructor prototype.");
    6134               0 :       return NS_ERROR_UNEXPECTED;
    6135                 :     }
    6136                 : 
    6137               0 :     if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6138                 :       class_iid =
    6139               0 :         sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface;
    6140               0 :     } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6141               0 :       class_iid = alias_struct->mData->mProtoChainInterface;
    6142                 :     } else {
    6143               0 :       NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo.");
    6144               0 :       return NS_ERROR_UNEXPECTED;
    6145                 :     }
    6146                 :   } else {
    6147               0 :     *bp = JS_FALSE;
    6148                 : 
    6149               0 :     return NS_OK;
    6150                 :   }
    6151                 : 
    6152               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
    6153               0 :     name_struct = nameSpaceManager->GetConstructorProto(name_struct);
    6154               0 :     if (!name_struct) {
    6155               0 :       NS_ERROR("Couldn't get constructor prototype.");
    6156               0 :       return NS_ERROR_UNEXPECTED;
    6157                 :     }
    6158                 :   }
    6159                 : 
    6160               0 :   NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
    6161                 :                name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
    6162                 :                "The constructor was set up with a struct of the wrong type.");
    6163                 : 
    6164               0 :   const nsDOMClassInfoData *ci_data = nsnull;
    6165               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
    6166                 :       name_struct->mDOMClassInfoID >= 0) {
    6167               0 :     ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
    6168               0 :   } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6169               0 :     ci_data = name_struct->mData;
    6170                 :   }
    6171                 : 
    6172                 :   nsCOMPtr<nsIInterfaceInfoManager>
    6173               0 :     iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
    6174               0 :   if (!iim) {
    6175               0 :     NS_ERROR("nsDOMConstructor::HasInstance can't get interface info mgr.");
    6176               0 :     return NS_ERROR_UNEXPECTED;
    6177                 :   }
    6178                 : 
    6179               0 :   nsCOMPtr<nsIInterfaceInfo> if_info;
    6180               0 :   PRUint32 count = 0;
    6181                 :   const nsIID* class_interface;
    6182               0 :   while ((class_interface = ci_data->mInterfaces[count++])) {
    6183               0 :     if (class_iid->Equals(*class_interface)) {
    6184               0 :       *bp = JS_TRUE;
    6185                 : 
    6186               0 :       return NS_OK;
    6187                 :     }
    6188                 : 
    6189               0 :     iim->GetInfoForIID(class_interface, getter_AddRefs(if_info));
    6190               0 :     if (!if_info) {
    6191               0 :       NS_ERROR("nsDOMConstructor::HasInstance can't get interface info.");
    6192               0 :       return NS_ERROR_UNEXPECTED;
    6193                 :     }
    6194                 : 
    6195               0 :     if_info->HasAncestor(class_iid, bp);
    6196                 : 
    6197               0 :     if (*bp) {
    6198               0 :       return NS_OK;
    6199                 :     }
    6200                 :   }
    6201                 : 
    6202               0 :   return NS_OK;
    6203                 : }
    6204                 : 
    6205                 : nsresult
    6206               0 : nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JSObject *obj)
    6207                 : {
    6208               0 :   const nsGlobalNameStruct *class_name_struct = GetNameStruct();
    6209               0 :   if (!class_name_struct)
    6210               0 :     return NS_ERROR_UNEXPECTED;
    6211                 : 
    6212                 :   const nsIID *class_iid;
    6213               0 :   if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
    6214                 :       class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
    6215               0 :     class_iid = &class_name_struct->mIID;
    6216               0 :   } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6217                 :     class_iid =
    6218               0 :       sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
    6219               0 :   } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6220               0 :     class_iid = class_name_struct->mData->mProtoChainInterface;
    6221                 :   } else {
    6222               0 :     return NS_OK;
    6223                 :   }
    6224                 : 
    6225               0 :   nsresult rv = DefineInterfaceConstants(cx, obj, class_iid);
    6226               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6227                 : 
    6228                 :   // Special case for |Event|, Event needs constants from NSEvent
    6229                 :   // too for backwards compatibility.
    6230               0 :   if (class_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
    6231                 :     rv = DefineInterfaceConstants(cx, obj,
    6232               0 :                                   &NS_GET_IID(nsIDOMNSEvent));
    6233               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6234                 :   }
    6235                 : 
    6236                 :   // Special case for |IDBKeyRange| which gets funny "static" functions.
    6237               0 :   if (class_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
    6238               0 :       !indexedDB::IDBKeyRange::DefineConstructors(cx, obj)) {
    6239               0 :     return NS_ERROR_FAILURE;
    6240                 :   }
    6241                 : 
    6242                 :   // Special case a few IDB interfaces which for now are getting transitional
    6243                 :   // constants.
    6244               0 :   if (class_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
    6245               0 :       class_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
    6246               0 :       class_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
    6247               0 :     rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
    6248               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6249                 :   }
    6250                 : 
    6251               0 :   return NS_OK;
    6252                 : }
    6253                 : 
    6254                 : NS_IMETHODIMP
    6255               0 : nsDOMConstructor::ToString(nsAString &aResult)
    6256                 : {
    6257               0 :   aResult.AssignLiteral("[object ");
    6258               0 :   aResult.Append(mClassName);
    6259               0 :   aResult.Append(PRUnichar(']'));
    6260                 : 
    6261               0 :   return NS_OK;
    6262                 : }
    6263                 : 
    6264                 : 
    6265                 : static nsresult
    6266               0 : GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
    6267                 :             const nsGlobalNameStruct *aNameStruct,
    6268                 :             nsIXPConnectJSObjectHolder **aProto)
    6269                 : {
    6270               0 :   NS_ASSERTION(aNameStruct->mType ==
    6271                 :                  nsGlobalNameStruct::eTypeClassConstructor ||
    6272                 :                aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
    6273                 :                "Wrong type!");
    6274                 : 
    6275               0 :   nsCOMPtr<nsIClassInfo> ci;
    6276               0 :   if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6277               0 :     PRInt32 id = aNameStruct->mDOMClassInfoID;
    6278               0 :     NS_ABORT_IF_FALSE(id >= 0, "Negative DOM classinfo?!?");
    6279                 : 
    6280               0 :     nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
    6281                 : 
    6282               0 :     ci = NS_GetDOMClassInfoInstance(ci_id);
    6283                 : 
    6284                 :     // In most cases we want to find the wrapped native prototype in
    6285                 :     // aWin's scope and use that prototype for
    6286                 :     // ClassName.prototype. But in the case where we're setting up
    6287                 :     // "Window.prototype" or "ChromeWindow.prototype" we want to do
    6288                 :     // the look up in aWin's outer window's scope since the inner
    6289                 :     // window's wrapped native prototype comes from the outer
    6290                 :     // window's scope.
    6291               0 :     if (ci_id == eDOMClassInfo_Window_id ||
    6292                 :         ci_id == eDOMClassInfo_ModalContentWindow_id ||
    6293                 :         ci_id == eDOMClassInfo_ChromeWindow_id) {
    6294               0 :       nsGlobalWindow *scopeWindow = aWin->GetOuterWindowInternal();
    6295                 : 
    6296               0 :       if (scopeWindow) {
    6297               0 :         aWin = scopeWindow;
    6298                 :       }
    6299                 :     }
    6300                 :   }
    6301                 :   else {
    6302               0 :     ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
    6303                 :   }
    6304               0 :   NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
    6305                 : 
    6306                 :   nsresult rv =
    6307               0 :     aXPConnect->GetWrappedNativePrototype(cx, aWin->GetGlobalJSObject(), ci,
    6308               0 :                                           aProto);
    6309               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6310                 : 
    6311                 :   JSObject *proto_obj;
    6312               0 :   (*aProto)->GetJSObject(&proto_obj);
    6313               0 :   if (!JS_WrapObject(cx, &proto_obj)) {
    6314               0 :     return NS_ERROR_FAILURE;
    6315                 :   }
    6316                 : 
    6317               0 :   NS_IF_RELEASE(*aProto);
    6318               0 :   return aXPConnect->HoldObject(cx, proto_obj, aProto);
    6319                 : }
    6320                 : 
    6321                 : // Either ci_data must be non-null or name_struct must be non-null and of type
    6322                 : // eTypeClassProto.
    6323                 : static nsresult
    6324               0 : ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
    6325                 :                  JSObject *obj, const PRUnichar *name,
    6326                 :                  const nsDOMClassInfoData *ci_data,
    6327                 :                  const nsGlobalNameStruct *name_struct,
    6328                 :                  nsScriptNameSpaceManager *nameSpaceManager,
    6329                 :                  JSObject *dot_prototype, bool install, bool *did_resolve)
    6330                 : {
    6331               0 :   NS_ASSERTION(ci_data ||
    6332                 :                (name_struct &&
    6333                 :                 name_struct->mType == nsGlobalNameStruct::eTypeClassProto),
    6334                 :                "Wrong type or missing ci_data!");
    6335                 : 
    6336               0 :   nsRefPtr<nsDOMConstructor> constructor;
    6337                 :   nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin,
    6338               0 :                                          getter_AddRefs(constructor));
    6339               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6340                 : 
    6341               0 :   nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    6342                 :   jsval v;
    6343                 : 
    6344                 :   rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
    6345               0 :                   false, &v, getter_AddRefs(holder));
    6346               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6347                 : 
    6348               0 :   if (install) {
    6349               0 :     rv = constructor->Install(cx, obj, v);
    6350               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6351                 :   }
    6352                 : 
    6353                 :   JSObject *class_obj;
    6354               0 :   holder->GetJSObject(&class_obj);
    6355               0 :   NS_ASSERTION(class_obj, "The return value lied");
    6356                 : 
    6357               0 :   const nsIID *primary_iid = &NS_GET_IID(nsISupports);
    6358                 : 
    6359               0 :   if (!ci_data) {
    6360               0 :     primary_iid = &name_struct->mIID;
    6361                 :   }
    6362               0 :   else if (ci_data->mProtoChainInterface) {
    6363               0 :     primary_iid = ci_data->mProtoChainInterface;
    6364                 :   }
    6365                 : 
    6366               0 :   nsCOMPtr<nsIInterfaceInfo> if_info;
    6367               0 :   nsCOMPtr<nsIInterfaceInfo> parent;
    6368               0 :   const char *class_parent_name = nsnull;
    6369                 : 
    6370               0 :   if (!primary_iid->Equals(NS_GET_IID(nsISupports))) {
    6371               0 :     JSAutoEnterCompartment ac;
    6372                 : 
    6373               0 :     if (!ac.enter(cx, class_obj)) {
    6374               0 :       return NS_ERROR_FAILURE;
    6375                 :     }
    6376                 : 
    6377               0 :     rv = DefineInterfaceConstants(cx, class_obj, primary_iid);
    6378               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6379                 : 
    6380                 :     // Special case for |Event|, Event needs constants from NSEvent
    6381                 :     // too for backwards compatibility.
    6382               0 :     if (primary_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
    6383                 :       rv = DefineInterfaceConstants(cx, class_obj,
    6384               0 :                                     &NS_GET_IID(nsIDOMNSEvent));
    6385               0 :       NS_ENSURE_SUCCESS(rv, rv);
    6386                 :     }
    6387                 : 
    6388                 :     // Special case for |IDBKeyRange| which gets funny "static" functions.
    6389               0 :     if (primary_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
    6390               0 :         !indexedDB::IDBKeyRange::DefineConstructors(cx, class_obj)) {
    6391               0 :       return NS_ERROR_FAILURE;
    6392                 :     }
    6393                 : 
    6394                 :     // Special case a few IDB interfaces which for now are getting transitional
    6395                 :     // constants.
    6396               0 :     if (primary_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
    6397               0 :         primary_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
    6398               0 :         primary_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
    6399               0 :       rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
    6400               0 :       NS_ENSURE_SUCCESS(rv, rv);
    6401                 :     }
    6402                 : 
    6403                 :     nsCOMPtr<nsIInterfaceInfoManager>
    6404               0 :       iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
    6405               0 :     NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
    6406                 : 
    6407               0 :     iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
    6408               0 :     NS_ENSURE_TRUE(if_info, NS_ERROR_UNEXPECTED);
    6409                 : 
    6410               0 :     const nsIID *iid = nsnull;
    6411                 : 
    6412               0 :     if (ci_data && !ci_data->mHasClassInterface) {
    6413               0 :       if_info->GetIIDShared(&iid);
    6414                 :     } else {
    6415               0 :       if_info->GetParent(getter_AddRefs(parent));
    6416               0 :       NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
    6417                 : 
    6418               0 :       parent->GetIIDShared(&iid);
    6419                 :     }
    6420                 : 
    6421               0 :     if (iid) {
    6422               0 :       if (!iid->Equals(NS_GET_IID(nsISupports))) {
    6423               0 :         if (ci_data && !ci_data->mHasClassInterface) {
    6424                 :           // If the class doesn't have a class interface the primary
    6425                 :           // interface is the interface that should be
    6426                 :           // constructor.prototype.__proto__.
    6427                 : 
    6428               0 :           if_info->GetNameShared(&class_parent_name);
    6429                 :         } else {
    6430                 :           // If the class does have a class interface (or there's no
    6431                 :           // real class for this name) then the parent of the
    6432                 :           // primary interface is what we want on
    6433                 :           // constructor.prototype.__proto__.
    6434                 : 
    6435               0 :           NS_ASSERTION(parent, "Whoa, this is bad, null parent here!");
    6436                 : 
    6437               0 :           parent->GetNameShared(&class_parent_name);
    6438                 :         }
    6439                 :       }
    6440                 :     }
    6441                 :   }
    6442                 : 
    6443                 :   {
    6444               0 :     JSObject *winobj = aWin->FastGetGlobalJSObject();
    6445                 : 
    6446               0 :     JSObject *proto = nsnull;
    6447                 : 
    6448               0 :     if (class_parent_name) {
    6449                 :       jsval val;
    6450                 : 
    6451               0 :       JSAutoEnterCompartment ac;
    6452               0 :       if (!ac.enter(cx, winobj)) {
    6453               0 :         return NS_ERROR_UNEXPECTED;
    6454                 :       }
    6455                 : 
    6456               0 :       if (!::JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
    6457               0 :         return NS_ERROR_UNEXPECTED;
    6458                 :       }
    6459                 : 
    6460               0 :       JSObject *tmp = JSVAL_IS_OBJECT(val) ? JSVAL_TO_OBJECT(val) : nsnull;
    6461                 : 
    6462               0 :       if (tmp) {
    6463               0 :         if (!::JS_LookupProperty(cx, tmp, "prototype", &val)) {
    6464               0 :           return NS_ERROR_UNEXPECTED;
    6465                 :         }
    6466                 : 
    6467               0 :         if (JSVAL_IS_OBJECT(val)) {
    6468               0 :           proto = JSVAL_TO_OBJECT(val);
    6469                 :         }
    6470                 :       }
    6471                 :     }
    6472                 : 
    6473               0 :     if (dot_prototype) {
    6474               0 :       JSAutoEnterCompartment ac;
    6475               0 :       if (!ac.enter(cx, dot_prototype)) {
    6476               0 :         return NS_ERROR_UNEXPECTED;
    6477                 :       }
    6478                 : 
    6479               0 :       JSObject *xpc_proto_proto = ::JS_GetPrototype(dot_prototype);
    6480                 : 
    6481               0 :       if (proto &&
    6482                 :           (!xpc_proto_proto ||
    6483               0 :            JS_GetClass(xpc_proto_proto) == sObjectClass)) {
    6484               0 :         if (!JS_WrapObject(cx, &proto) ||
    6485               0 :             !JS_SetPrototype(cx, dot_prototype, proto)) {
    6486               0 :           return NS_ERROR_UNEXPECTED;
    6487                 :         }
    6488                 :       }
    6489                 :     } else {
    6490               0 :       JSAutoEnterCompartment ac;
    6491               0 :       if (!ac.enter(cx, winobj)) {
    6492               0 :         return NS_ERROR_UNEXPECTED;
    6493                 :       }
    6494                 : 
    6495                 :       dot_prototype = ::JS_NewObject(cx, &sDOMConstructorProtoClass, proto,
    6496               0 :                                      winobj);
    6497               0 :       NS_ENSURE_TRUE(dot_prototype, NS_ERROR_OUT_OF_MEMORY);
    6498                 :     }
    6499                 :   }
    6500                 : 
    6501               0 :   v = OBJECT_TO_JSVAL(dot_prototype);
    6502                 : 
    6503               0 :   JSAutoEnterCompartment ac;
    6504               0 :   if (!ac.enter(cx, class_obj)) {
    6505               0 :     return NS_ERROR_UNEXPECTED;
    6506                 :   }
    6507                 : 
    6508                 :   // Per ECMA, the prototype property is {DontEnum, DontDelete, ReadOnly}
    6509               0 :   if (!JS_WrapValue(cx, &v) ||
    6510                 :       !JS_DefineProperty(cx, class_obj, "prototype", v, nsnull, nsnull,
    6511               0 :                          JSPROP_PERMANENT | JSPROP_READONLY)) {
    6512               0 :     return NS_ERROR_UNEXPECTED;
    6513                 :   }
    6514                 : 
    6515               0 :   *did_resolve = true;
    6516                 : 
    6517               0 :   return NS_OK;
    6518                 : }
    6519                 : 
    6520                 : 
    6521                 : // static
    6522                 : nsresult
    6523               0 : nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
    6524                 :                           JSObject *obj, jsid id, bool *did_resolve)
    6525                 : {
    6526               0 :   *did_resolve = false;
    6527                 : 
    6528                 :   nsScriptNameSpaceManager *nameSpaceManager =
    6529               0 :     nsJSRuntime::GetNameSpaceManager();
    6530               0 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    6531                 : 
    6532               0 :   nsDependentJSString name(id);
    6533                 : 
    6534               0 :   const nsGlobalNameStruct *name_struct = nsnull;
    6535               0 :   const PRUnichar *class_name = nsnull;
    6536                 : 
    6537               0 :   nameSpaceManager->LookupName(name, &name_struct, &class_name);
    6538                 : 
    6539               0 :   if (!name_struct) {
    6540               0 :     return NS_OK;
    6541                 :   }
    6542                 : 
    6543               0 :   NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
    6544                 : 
    6545               0 :   nsresult rv = NS_OK;
    6546                 : 
    6547               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
    6548                 :     rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
    6549               0 :                               &name_struct);
    6550               0 :     if (NS_FAILED(rv) || !name_struct) {
    6551               0 :       return rv;
    6552                 :     }
    6553                 :   }
    6554                 : 
    6555               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
    6556                 :     // We're resolving a name of a DOM interface for which there is no
    6557                 :     // direct DOM class, create a constructor object...
    6558                 : 
    6559               0 :     nsRefPtr<nsDOMConstructor> constructor;
    6560                 :     rv = nsDOMConstructor::Create(class_name,
    6561                 :                                   nsnull,
    6562                 :                                   name_struct,
    6563                 :                                   static_cast<nsPIDOMWindow*>(aWin),
    6564               0 :                                   getter_AddRefs(constructor));
    6565               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6566                 : 
    6567               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    6568                 :     jsval v;
    6569                 :     rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
    6570               0 :                     false, &v, getter_AddRefs(holder));
    6571               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6572                 : 
    6573               0 :     rv = constructor->Install(cx, obj, v);
    6574               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6575                 : 
    6576                 :     JSObject *class_obj;
    6577               0 :     holder->GetJSObject(&class_obj);
    6578               0 :     NS_ASSERTION(class_obj, "The return value lied");
    6579                 : 
    6580                 :     // ... and define the constants from the DOM interface on that
    6581                 :     // constructor object.
    6582                 : 
    6583               0 :     rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
    6584               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6585                 : 
    6586               0 :     *did_resolve = true;
    6587                 : 
    6588               0 :     return NS_OK;
    6589                 :   }
    6590                 : 
    6591               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
    6592                 :       name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6593                 :     // Don't expose chrome only constructors to content windows.
    6594               0 :     if (name_struct->mChromeOnly &&
    6595               0 :         !nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal())) {
    6596               0 :       return NS_OK;
    6597                 :     }
    6598                 : 
    6599                 :     // For now don't expose web sockets unless user has explicitly enabled them
    6600               0 :     if (name_struct->mDOMClassInfoID == eDOMClassInfo_WebSocket_id) {
    6601               0 :       if (!nsWebSocket::PrefEnabled()) {
    6602               0 :         return NS_OK;
    6603                 :       }
    6604                 :     }
    6605                 : 
    6606                 :     // For now don't expose server events unless user has explicitly enabled them
    6607               0 :     if (name_struct->mDOMClassInfoID == eDOMClassInfo_EventSource_id) {
    6608               0 :       if (!nsEventSource::PrefEnabled()) {
    6609               0 :         return NS_OK;
    6610                 :       }
    6611                 :     }
    6612                 : 
    6613                 :     // Lookup new DOM bindings.
    6614               0 :     if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6615                 :       mozilla::dom::binding::DefineInterface define =
    6616               0 :         sClassInfoData[name_struct->mDOMClassInfoID].mDefineDOMInterface;
    6617               0 :       if (define && mozilla::dom::binding::DefineConstructor(cx, obj, define, &rv)) {
    6618               0 :         *did_resolve = NS_SUCCEEDED(rv);
    6619                 : 
    6620               0 :         return rv;
    6621                 :       }
    6622                 :     }
    6623                 : 
    6624                 :     // Create the XPConnect prototype for our classinfo, PostCreateProto will
    6625                 :     // set up the prototype chain.
    6626               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
    6627                 :     rv = GetXPCProto(sXPConnect, cx, aWin, name_struct,
    6628               0 :                      getter_AddRefs(proto_holder));
    6629                 : 
    6630               0 :     if (NS_SUCCEEDED(rv) && obj != aWin->GetGlobalJSObject()) {
    6631                 :       JSObject* dot_prototype;
    6632               0 :       rv = proto_holder->GetJSObject(&dot_prototype);
    6633               0 :       NS_ENSURE_SUCCESS(rv, rv);
    6634                 : 
    6635                 :       const nsDOMClassInfoData *ci_data;
    6636               0 :       if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6637               0 :         ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
    6638                 :       } else {
    6639               0 :         ci_data = name_struct->mData;
    6640                 :       }
    6641                 : 
    6642                 :       return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
    6643                 :                               name_struct, nameSpaceManager, dot_prototype,
    6644               0 :                               true, did_resolve);
    6645                 :     }
    6646                 : 
    6647               0 :     *did_resolve = NS_SUCCEEDED(rv);
    6648                 : 
    6649               0 :     return rv;
    6650                 :   }
    6651                 : 
    6652               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
    6653                 :     // We don't have a XPConnect prototype object, let ResolvePrototype create
    6654                 :     // one.
    6655                 :     return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, nsnull,
    6656                 :                             name_struct, nameSpaceManager, nsnull, true,
    6657               0 :                             did_resolve);
    6658                 :   }
    6659                 : 
    6660               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
    6661                 :     const nsGlobalNameStruct *alias_struct =
    6662               0 :       nameSpaceManager->GetConstructorProto(name_struct);
    6663               0 :     NS_ENSURE_TRUE(alias_struct, NS_ERROR_UNEXPECTED);
    6664                 : 
    6665                 :     // We need to use the XPConnect prototype for the DOM class that this
    6666                 :     // constructor is an alias for (for example for Image we need the prototype
    6667                 :     // for HTMLImageElement).
    6668               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
    6669                 :     rv = GetXPCProto(sXPConnect, cx, aWin, alias_struct,
    6670               0 :                      getter_AddRefs(proto_holder));
    6671               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6672                 : 
    6673                 :     JSObject* dot_prototype;
    6674               0 :     rv = proto_holder->GetJSObject(&dot_prototype);
    6675               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6676                 : 
    6677                 :     const nsDOMClassInfoData *ci_data;
    6678               0 :     if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
    6679               0 :       ci_data = &sClassInfoData[alias_struct->mDOMClassInfoID];
    6680               0 :     } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
    6681               0 :       ci_data = alias_struct->mData;
    6682                 :     } else {
    6683               0 :       return NS_ERROR_UNEXPECTED;
    6684                 :     }
    6685                 : 
    6686                 :     return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
    6687                 :                             name_struct, nameSpaceManager, nsnull, true,
    6688               0 :                             did_resolve);
    6689                 :   }
    6690                 : 
    6691               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
    6692               0 :     nsRefPtr<nsDOMConstructor> constructor;
    6693                 :     rv = nsDOMConstructor::Create(class_name, nsnull, name_struct,
    6694                 :                                   static_cast<nsPIDOMWindow*>(aWin),
    6695               0 :                                   getter_AddRefs(constructor));
    6696               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6697                 : 
    6698                 :     jsval val;
    6699               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    6700                 :     rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
    6701               0 :                     false, &val, getter_AddRefs(holder));
    6702               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6703                 : 
    6704               0 :     rv = constructor->Install(cx, obj, val);
    6705               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6706                 : 
    6707                 :     JSObject* class_obj;
    6708               0 :     holder->GetJSObject(&class_obj);
    6709               0 :     NS_ASSERTION(class_obj, "Why didn't we get a JSObject?");
    6710                 : 
    6711               0 :     *did_resolve = true;
    6712                 : 
    6713               0 :     return NS_OK;
    6714                 :   }
    6715                 : 
    6716               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) {
    6717               0 :     if (name_struct->mChromeOnly && !nsContentUtils::IsCallerChrome())
    6718               0 :       return NS_OK;
    6719                 : 
    6720               0 :     nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
    6721               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6722                 : 
    6723               0 :     jsval prop_val = JSVAL_VOID; // Property value.
    6724                 : 
    6725               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    6726               0 :     nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
    6727               0 :     if (owner) {
    6728               0 :       nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
    6729               0 :       NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
    6730                 : 
    6731               0 :       JSObject *prop_obj = nsnull;
    6732               0 :       rv = owner->GetScriptObject(context, (void**)&prop_obj);
    6733               0 :       NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && prop_obj, NS_ERROR_UNEXPECTED);
    6734                 : 
    6735               0 :       prop_val = OBJECT_TO_JSVAL(prop_obj);
    6736                 :     } else {
    6737               0 :       nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
    6738                 : 
    6739               0 :       if (gpi) {
    6740               0 :         rv = gpi->Init(aWin, &prop_val);
    6741               0 :         NS_ENSURE_SUCCESS(rv, rv);
    6742                 :       }
    6743                 :     }
    6744                 : 
    6745               0 :     if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
    6746                 :       JSObject *scope;
    6747                 : 
    6748               0 :       if (aWin->IsOuterWindow()) {
    6749               0 :         nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
    6750               0 :         NS_ENSURE_TRUE(inner, NS_ERROR_UNEXPECTED);
    6751                 : 
    6752               0 :         scope = inner->GetGlobalJSObject();
    6753                 :       } else {
    6754               0 :         scope = aWin->GetGlobalJSObject();
    6755                 :       }
    6756                 : 
    6757                 :       rv = WrapNative(cx, scope, native, true, &prop_val,
    6758               0 :                       getter_AddRefs(holder));
    6759                 :     }
    6760                 : 
    6761               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6762                 : 
    6763               0 :     if (!JS_WrapValue(cx, &prop_val)) {
    6764               0 :       return NS_ERROR_UNEXPECTED;
    6765                 :     }
    6766                 : 
    6767                 :     JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
    6768               0 :                                         JSPROP_ENUMERATE);
    6769                 : 
    6770               0 :     *did_resolve = true;
    6771                 : 
    6772               0 :     return ok ? NS_OK : NS_ERROR_FAILURE;
    6773                 :   }
    6774                 : 
    6775               0 :   if (name_struct->mType == nsGlobalNameStruct::eTypeDynamicNameSet) {
    6776                 :     nsCOMPtr<nsIScriptExternalNameSet> nameset =
    6777               0 :       do_CreateInstance(name_struct->mCID, &rv);
    6778               0 :     NS_ENSURE_SUCCESS(rv, rv);
    6779                 : 
    6780               0 :     nsIScriptContext *context = aWin->GetContext();
    6781               0 :     NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
    6782                 : 
    6783               0 :     rv = nameset->InitializeNameSet(context);
    6784                 : 
    6785               0 :     *did_resolve = true;
    6786                 :   }
    6787                 : 
    6788               0 :   return rv;
    6789                 : }
    6790                 : 
    6791                 : // Native code for window._content getter, this simply maps
    6792                 : // window._content to window.content for backwards compatibility only.
    6793                 : static JSBool
    6794               0 : ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
    6795                 : {
    6796               0 :   JSObject *obj = JS_THIS_OBJECT(cx, vp);
    6797               0 :   if (!obj)
    6798               0 :     return JS_FALSE;
    6799                 : 
    6800               0 :   return ::JS_GetProperty(cx, obj, "content", vp);
    6801                 : }
    6802                 : 
    6803                 : static JSNewResolveOp sOtherResolveFuncs[] = {
    6804                 :   mozilla::dom::workers::ResolveWorkerClasses
    6805                 : };
    6806                 : 
    6807                 : template<class Interface>
    6808                 : static nsresult
    6809               0 : LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
    6810                 : {
    6811                 :   // This function duplicates some of the logic in XPC_WN_HelperSetProperty
    6812                 :   XPCWrappedNative *wrapper =
    6813               0 :     XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
    6814                 : 
    6815                 :   // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
    6816               0 :   NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
    6817                 : 
    6818               0 :   nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper, obj);
    6819               0 :   NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
    6820                 : 
    6821               0 :   nsCOMPtr<nsIDOMLocation> location;
    6822               0 :   nsresult rv = xpcomObj->GetLocation(getter_AddRefs(location));
    6823               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6824                 : 
    6825                 :   // Grab the value we're being set to before we stomp on |vp|
    6826               0 :   JSString *val = ::JS_ValueToString(cx, *vp);
    6827               0 :   NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
    6828                 : 
    6829                 :   // Make sure |val| stays alive below
    6830               0 :   JS::Anchor<JSString *> anchor(val);
    6831                 : 
    6832                 :   // We have to wrap location into vp before null-checking location, to
    6833                 :   // avoid assigning the wrong thing into the slot.
    6834               0 :   nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    6835               0 :   rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
    6836                 :                   &NS_GET_IID(nsIDOMLocation), true, vp,
    6837                 :                   getter_AddRefs(holder));
    6838               0 :   NS_ENSURE_SUCCESS(rv, rv);
    6839                 : 
    6840               0 :   if (!location) {
    6841                 :     // Make this a no-op
    6842               0 :     return NS_OK;
    6843                 :   }
    6844                 : 
    6845               0 :   nsDependentJSString depStr;
    6846               0 :   NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
    6847                 :   
    6848               0 :   return location->SetHref(depStr);
    6849                 : }
    6850                 : 
    6851                 : template<class Interface>
    6852                 : static JSBool
    6853               0 : LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
    6854                 :                jsval *vp)
    6855                 : {
    6856               0 :   nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp);
    6857               0 :   if (NS_FAILED(rv)) {
    6858               0 :     if (!::JS_IsExceptionPending(cx)) {
    6859               0 :       nsDOMClassInfo::ThrowJSException(cx, rv);
    6860                 :     }
    6861               0 :     return JS_FALSE;
    6862                 :   }
    6863                 : 
    6864               0 :   return JS_TRUE;
    6865                 : }
    6866                 : 
    6867                 : static JSBool
    6868               0 : LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
    6869                 :                         jsval *vp)
    6870                 : {
    6871               0 :   JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
    6872               0 :   if (wrapped) {
    6873               0 :     obj = wrapped;
    6874                 :   }
    6875                 : 
    6876               0 :   return LocationSetter<nsIDOMWindow>(cx, obj, id, strict, vp);
    6877                 : }
    6878                 : 
    6879                 : NS_IMETHODIMP
    6880               0 : nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    6881                 :                        JSObject *obj, jsid id, PRUint32 flags,
    6882                 :                        JSObject **objp, bool *_retval)
    6883                 : {
    6884               0 :   nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
    6885                 : 
    6886               0 :   if (!JSID_IS_STRING(id)) {
    6887               0 :     if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0 && !(flags & JSRESOLVE_ASSIGNING)) {
    6888                 :       // If we're resolving a numeric property, treat that as if
    6889                 :       // window.frames[n] is resolved (since window.frames ===
    6890                 :       // window), if window.frames[n] is a child frame, define a
    6891                 :       // property for this index.
    6892               0 :       PRUint32 index = PRUint32(JSID_TO_INT(id));
    6893               0 :       if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
    6894                 :         // A numeric property accessed and the numeric property is a
    6895                 :         // child frame. Define a property for this index.
    6896                 : 
    6897                 :         *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID,
    6898               0 :                                       nsnull, nsnull, JSPROP_SHARED);
    6899                 : 
    6900               0 :         if (*_retval) {
    6901               0 :           *objp = obj;
    6902                 :         }
    6903                 :       }
    6904                 :     }
    6905                 : 
    6906               0 :     return NS_OK;
    6907                 :   }
    6908                 : 
    6909               0 :   nsIScriptContext *my_context = win->GetContextInternal();
    6910                 : 
    6911               0 :   nsresult rv = NS_OK;
    6912                 : 
    6913                 :   // Resolve standard classes on my_context's JSContext (or on cx,
    6914                 :   // if we don't have a my_context yet), in case the two contexts
    6915                 :   // have different origins.  We want lazy standard class
    6916                 :   // initialization to behave as if it were done eagerly, on each
    6917                 :   // window's own context (not on some other window-caller's
    6918                 :   // context).
    6919                 : 
    6920               0 :   JSBool did_resolve = JS_FALSE;
    6921                 :   JSContext *my_cx;
    6922                 : 
    6923               0 :   JSBool ok = JS_TRUE;
    6924               0 :   jsval exn = JSVAL_VOID;
    6925               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    6926               0 :     JSAutoEnterCompartment ac;
    6927                 : 
    6928               0 :     if (!my_context) {
    6929               0 :       my_cx = cx;
    6930                 :     } else {
    6931               0 :       my_cx = my_context->GetNativeContext();
    6932                 : 
    6933               0 :       if (my_cx != cx) {
    6934               0 :         if (!ac.enter(my_cx, obj)) {
    6935               0 :           return NS_ERROR_UNEXPECTED;
    6936                 :         }
    6937                 :       }
    6938                 :     }
    6939                 : 
    6940               0 :     JSAutoRequest transfer(my_cx);
    6941                 : 
    6942                 :     // Don't resolve standard classes on XPCNativeWrapper etc, only
    6943                 :     // resolve them if we're resolving on the real global object.
    6944               0 :     ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
    6945                 : 
    6946               0 :     if (!ok) {
    6947                 :       // Trust the JS engine (or the script security manager) to set
    6948                 :       // the exception in the JS engine.
    6949                 : 
    6950               0 :       if (!JS_GetPendingException(my_cx, &exn)) {
    6951               0 :         return NS_ERROR_UNEXPECTED;
    6952                 :       }
    6953                 : 
    6954                 :       // Return NS_OK to avoid stomping over the exception that was passed
    6955                 :       // down from the ResolveStandardClass call.
    6956                 :       // Note that the order of the JS_ClearPendingException and
    6957                 :       // JS_SetPendingException is important in the case that my_cx == cx.
    6958                 : 
    6959               0 :       JS_ClearPendingException(my_cx);
    6960                 :     }
    6961                 :   }
    6962                 : 
    6963               0 :   if (!ok) {
    6964               0 :     JS_SetPendingException(cx, exn);
    6965               0 :     *_retval = JS_FALSE;
    6966               0 :     return NS_OK;
    6967                 :   }
    6968                 : 
    6969               0 :   if (did_resolve) {
    6970               0 :     *objp = obj;
    6971                 : 
    6972               0 :     return NS_OK;
    6973                 :   }
    6974                 : 
    6975               0 :   if (!(flags & JSRESOLVE_ASSIGNING)) {
    6976                 :     // We want this code to be before the child frame lookup code
    6977                 :     // below so that a child frame named 'constructor' doesn't
    6978                 :     // shadow the window's constructor property.
    6979               0 :     if (id == sConstructor_id) {
    6980               0 :       return ResolveConstructor(cx, obj, objp);
    6981                 :     }
    6982                 :   }
    6983                 : 
    6984               0 :   if (!my_context || !my_context->IsContextInitialized()) {
    6985                 :     // The context is not yet initialized so there's nothing we can do
    6986                 :     // here yet.
    6987                 : 
    6988               0 :     return NS_OK;
    6989                 :   }
    6990                 : 
    6991               0 :   if (id == sLocation_id) {
    6992                 :     // This must be done even if we're just getting the value of
    6993                 :     // window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
    6994                 :     // here) since we must define window.location to prevent the
    6995                 :     // getter from being overriden (for security reasons).
    6996                 : 
    6997                 :     // Note: Because we explicitly don't forward to the inner window
    6998                 :     // above, we have to ensure here that our window has a current
    6999                 :     // inner window so that the location object we return will work.
    7000                 : 
    7001               0 :     if (win->IsOuterWindow()) {
    7002               0 :       win->EnsureInnerWindow();
    7003                 :     }
    7004                 : 
    7005               0 :     nsCOMPtr<nsIDOMLocation> location;
    7006               0 :     rv = win->GetLocation(getter_AddRefs(location));
    7007               0 :     NS_ENSURE_SUCCESS(rv, rv);
    7008                 : 
    7009                 :     // Make sure we wrap the location object in the inner window's
    7010                 :     // scope if we've got an inner window.
    7011               0 :     JSObject *scope = nsnull;
    7012               0 :     if (win->IsOuterWindow()) {
    7013               0 :       nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
    7014                 : 
    7015               0 :       if (innerWin) {
    7016               0 :         scope = innerWin->GetGlobalJSObject();
    7017                 :       }
    7018                 :     }
    7019                 : 
    7020               0 :     if (!scope) {
    7021               0 :       wrapper->GetJSObject(&scope);
    7022                 :     }
    7023                 : 
    7024               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7025                 :     jsval v;
    7026                 :     rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), true,
    7027               0 :                     &v, getter_AddRefs(holder));
    7028               0 :     NS_ENSURE_SUCCESS(rv, rv);
    7029                 : 
    7030               0 :     JSBool ok = JS_WrapValue(cx, &v) &&
    7031                 :                 JS_DefinePropertyById(cx, obj, id, v, nsnull,
    7032                 :                                       LocationSetterUnwrapper,
    7033               0 :                                       JSPROP_PERMANENT | JSPROP_ENUMERATE);
    7034                 : 
    7035               0 :     if (!ok) {
    7036               0 :       return NS_ERROR_FAILURE;
    7037                 :     }
    7038                 : 
    7039               0 :     *objp = obj;
    7040                 : 
    7041               0 :     return NS_OK;
    7042                 :   }
    7043                 : 
    7044                 :   // Hmm, we do an awful lot of QIs here; maybe we should add a
    7045                 :   // method on an interface that would let us just call into the
    7046                 :   // window code directly...
    7047                 : 
    7048               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    7049               0 :     nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
    7050                 : 
    7051               0 :     PRInt32 count = 0;
    7052                 : 
    7053               0 :     if (dsn) {
    7054               0 :       dsn->GetChildCount(&count);
    7055                 :     }
    7056                 : 
    7057               0 :     if (count > 0) {
    7058               0 :       nsCOMPtr<nsIDocShellTreeItem> child;
    7059                 : 
    7060               0 :       const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
    7061                 : 
    7062               0 :       dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
    7063                 :                              false, true, nsnull, nsnull,
    7064               0 :                              getter_AddRefs(child));
    7065                 : 
    7066               0 :       nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
    7067                 : 
    7068               0 :       if (child_win) {
    7069                 :         // We found a subframe of the right name, define the property
    7070                 :         // on the wrapper so that ::NewResolve() doesn't get called
    7071                 :         // again for this property name.
    7072                 : 
    7073                 :         JSObject *wrapperObj;
    7074               0 :         wrapper->GetJSObject(&wrapperObj);
    7075                 : 
    7076                 :         jsval v;
    7077               0 :         nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7078                 :         rv = WrapNative(cx, wrapperObj, child_win,
    7079                 :                         &NS_GET_IID(nsIDOMWindow), true, &v,
    7080               0 :                         getter_AddRefs(holder));
    7081               0 :         NS_ENSURE_SUCCESS(rv, rv);
    7082                 : 
    7083               0 :         JSAutoRequest ar(cx);
    7084                 : 
    7085               0 :         bool ok = JS_WrapValue(cx, &v) &&
    7086               0 :                     JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
    7087               0 :         if (!ok) {
    7088               0 :           return NS_ERROR_FAILURE;
    7089                 :         }
    7090                 : 
    7091               0 :         *objp = obj;
    7092                 : 
    7093               0 :         return NS_OK;
    7094                 :       }
    7095                 :     }
    7096                 :   }
    7097                 : 
    7098                 :   // It is not worth calling GlobalResolve() if we are resolving
    7099                 :   // for assignment, since only read-write properties get dealt
    7100                 :   // with there.
    7101               0 :   if (!(flags & JSRESOLVE_ASSIGNING)) {
    7102               0 :     JSAutoRequest ar(cx);
    7103                 : 
    7104                 :     // Resolve special classes.
    7105               0 :     for (PRUint32 i = 0; i < ArrayLength(sOtherResolveFuncs); i++) {
    7106               0 :       if (!sOtherResolveFuncs[i](cx, obj, id, flags, objp)) {
    7107               0 :         return NS_ERROR_FAILURE;
    7108                 :       }
    7109               0 :       if (*objp) {
    7110               0 :         return NS_OK;
    7111                 :       }
    7112                 :     }
    7113                 : 
    7114                 :     // Call GlobalResolve() after we call FindChildWithName() so
    7115                 :     // that named child frames will override external properties
    7116                 :     // which have been registered with the script namespace manager.
    7117                 : 
    7118               0 :     bool did_resolve = false;
    7119               0 :     rv = GlobalResolve(win, cx, obj, id, &did_resolve);
    7120               0 :     NS_ENSURE_SUCCESS(rv, rv);
    7121                 : 
    7122               0 :     if (did_resolve) {
    7123                 :       // GlobalResolve() resolved something, so we're done here.
    7124               0 :       *objp = obj;
    7125                 : 
    7126               0 :       return NS_OK;
    7127                 :     }
    7128                 :   }
    7129                 : 
    7130               0 :   if (id == s_content_id) {
    7131                 :     // Map window._content to window.content for backwards
    7132                 :     // compatibility, this should spit out an message on the JS
    7133                 :     // console.
    7134                 : 
    7135               0 :     JSObject *windowObj = win->GetGlobalJSObject();
    7136                 : 
    7137               0 :     JSAutoRequest ar(cx);
    7138                 : 
    7139                 :     JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
    7140               0 :                                        windowObj, "_content");
    7141               0 :     if (!fun) {
    7142               0 :       return NS_ERROR_OUT_OF_MEMORY;
    7143                 :     }
    7144                 : 
    7145               0 :     JSObject *funObj = ::JS_GetFunctionObject(fun);
    7146                 : 
    7147               0 :     if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
    7148                 :                                  JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
    7149                 :                                  nsnull,
    7150                 :                                  JSPROP_ENUMERATE | JSPROP_GETTER |
    7151               0 :                                  JSPROP_SHARED)) {
    7152               0 :       return NS_ERROR_FAILURE;
    7153                 :     }
    7154                 : 
    7155               0 :     *objp = obj;
    7156                 : 
    7157               0 :     return NS_OK;
    7158                 :   }
    7159                 : 
    7160               0 :   if (flags & JSRESOLVE_ASSIGNING) {
    7161               0 :     if (IsReadonlyReplaceable(id) ||
    7162               0 :         (!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) {
    7163                 :       // A readonly "replaceable" property is being set, or a
    7164                 :       // readwrite "replaceable" property is being set w/o being
    7165                 :       // fully qualified. Define the property on obj with the value
    7166                 :       // undefined to override the predefined property. This is done
    7167                 :       // for compatibility with other browsers.
    7168               0 :       JSAutoRequest ar(cx);
    7169                 : 
    7170               0 :       if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
    7171               0 :                                    JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
    7172               0 :         return NS_ERROR_FAILURE;
    7173                 :       }
    7174               0 :       *objp = obj;
    7175                 : 
    7176               0 :       return NS_OK;
    7177                 :     }
    7178                 :   } else {
    7179               0 :     if (id == sNavigator_id) {
    7180               0 :       nsCOMPtr<nsIDOMNavigator> navigator;
    7181               0 :       rv = win->GetNavigator(getter_AddRefs(navigator));
    7182               0 :       NS_ENSURE_SUCCESS(rv, rv);
    7183                 : 
    7184                 :       jsval v;
    7185               0 :       nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7186                 :       rv = WrapNative(cx, obj, navigator, &NS_GET_IID(nsIDOMNavigator), true,
    7187               0 :                       &v, getter_AddRefs(holder));
    7188               0 :       NS_ENSURE_SUCCESS(rv, rv);
    7189                 : 
    7190                 :       // Hold on to the navigator object as a global property so we
    7191                 :       // don't need to worry about losing expando properties etc.
    7192               0 :       if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
    7193                 :                                    JSPROP_READONLY | JSPROP_PERMANENT |
    7194               0 :                                    JSPROP_ENUMERATE)) {
    7195               0 :         return NS_ERROR_FAILURE;
    7196                 :       }
    7197               0 :       *objp = obj;
    7198                 : 
    7199               0 :       return NS_OK;
    7200                 :     }
    7201                 : 
    7202               0 :     if (id == sDocument_id) {
    7203               0 :       nsCOMPtr<nsIDOMDocument> document;
    7204               0 :       rv = win->GetDocument(getter_AddRefs(document));
    7205               0 :       NS_ENSURE_SUCCESS(rv, rv);
    7206                 : 
    7207                 :       // FIXME Ideally we'd have an nsIDocument here and get nsWrapperCache
    7208                 :       //       from it.
    7209                 :       jsval v;
    7210               0 :       nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7211                 :       rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), document,
    7212                 :                       &NS_GET_IID(nsIDOMDocument), false, &v,
    7213               0 :                       getter_AddRefs(holder));
    7214               0 :       NS_ENSURE_SUCCESS(rv, rv);
    7215                 : 
    7216                 :       // The PostCreate hook for the document will handle defining the
    7217                 :       // property
    7218               0 :       *objp = obj;
    7219                 : 
    7220                 :       // NB: We need to do this for any Xray wrapper.
    7221               0 :       if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
    7222                 :         // Unless our object is a native wrapper, in which case we have to
    7223                 :         // define it ourselves.
    7224                 : 
    7225               0 :         *_retval = JS_WrapValue(cx, &v) &&
    7226                 :                    JS_DefineProperty(cx, obj, "document", v, NULL, NULL,
    7227               0 :                                      JSPROP_READONLY | JSPROP_ENUMERATE);
    7228               0 :         if (!*_retval) {
    7229               0 :           return NS_ERROR_UNEXPECTED;
    7230                 :         }
    7231                 :       }
    7232                 : 
    7233               0 :       return NS_OK;
    7234                 :     }
    7235                 : 
    7236               0 :     if (id == sJava_id || id == sPackages_id) {
    7237                 :       static bool isResolvingJavaProperties;
    7238                 : 
    7239               0 :       if (!isResolvingJavaProperties) {
    7240               0 :         isResolvingJavaProperties = true;
    7241                 : 
    7242                 :         // Tell the window to initialize the Java properties. The
    7243                 :         // window needs to do this as we need to do this only once,
    7244                 :         // and detecting that reliably from here is hard.
    7245                 : 
    7246               0 :         win->InitJavaProperties(); 
    7247                 : 
    7248                 :         JSBool hasProp;
    7249               0 :         bool ok = ::JS_HasPropertyById(cx, obj, id, &hasProp);
    7250                 : 
    7251               0 :         isResolvingJavaProperties = false;
    7252                 : 
    7253               0 :         if (!ok) {
    7254               0 :           return NS_ERROR_FAILURE;
    7255                 :         }
    7256                 : 
    7257               0 :         if (hasProp) {
    7258               0 :           *objp = obj;
    7259                 : 
    7260               0 :           return NS_OK;
    7261                 :         }
    7262                 :       }
    7263               0 :     } else if (id == sDialogArguments_id && win->IsModalContentWindow()) {
    7264               0 :       nsCOMPtr<nsIArray> args;
    7265               0 :       ((nsGlobalModalWindow *)win)->GetDialogArguments(getter_AddRefs(args));
    7266                 : 
    7267               0 :       nsIScriptContext *script_cx = win->GetContext();
    7268               0 :       if (script_cx) {
    7269               0 :         JSAutoSuspendRequest asr(cx);
    7270                 : 
    7271                 :         // Make nsJSContext::SetProperty()'s magic argument array
    7272                 :         // handling happen.
    7273               0 :         rv = script_cx->SetProperty(obj, "dialogArguments", args);
    7274               0 :         NS_ENSURE_SUCCESS(rv, rv);
    7275                 : 
    7276               0 :         *objp = obj;
    7277                 :       }
    7278                 : 
    7279               0 :       return NS_OK;
    7280                 :     }
    7281                 :   }
    7282                 : 
    7283               0 :   JSObject *oldobj = *objp;
    7284                 :   rv = nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
    7285               0 :                                   _retval);
    7286                 : 
    7287               0 :   if (NS_FAILED(rv) || *objp != oldobj) {
    7288                 :     // Something went wrong, or the property got resolved. Return.
    7289               0 :     return rv;
    7290                 :   }
    7291                 : 
    7292                 :   // Make a fast expando if we're assigning to (not declaring or
    7293                 :   // binding a name) a new undefined property that's not already
    7294                 :   // defined on our prototype chain. This way we can access this
    7295                 :   // expando w/o ever getting back into XPConnect.
    7296               0 :   if ((flags & JSRESOLVE_ASSIGNING) && !(flags & JSRESOLVE_WITH)) {
    7297                 :     JSObject *realObj;
    7298               0 :     wrapper->GetJSObject(&realObj);
    7299                 : 
    7300               0 :     if (obj == realObj) {
    7301               0 :       JSObject *proto = js::GetObjectProto(obj);
    7302               0 :       if (proto) {
    7303               0 :         JSObject *pobj = NULL;
    7304                 :         jsval val;
    7305                 : 
    7306               0 :         if (!::JS_LookupPropertyWithFlagsById(cx, proto, id, flags,
    7307               0 :                                               &pobj, &val)) {
    7308               0 :           *_retval = JS_FALSE;
    7309                 : 
    7310               0 :           return NS_OK;
    7311                 :         }
    7312                 : 
    7313               0 :         if (pobj) {
    7314                 :           // A property was found on the prototype chain.
    7315               0 :           *objp = pobj;
    7316               0 :           return NS_OK;
    7317                 :         }
    7318                 :       }
    7319                 : 
    7320                 :       // Define a fast expando, the key here is to use JS_PropertyStub
    7321                 :       // as the getter/setter, which makes us stay out of XPConnect
    7322                 :       // when using this property.
    7323                 :       //
    7324                 :       // We don't need to worry about property attributes here as we
    7325                 :       // know here we're dealing with an undefined property set, so
    7326                 :       // we're not declaring readonly or permanent properties.
    7327                 :       //
    7328                 :       // Since we always create the undeclared property here without given a
    7329                 :       // chance for the interpreter to report applicable strict mode warnings,
    7330                 :       // we must take care to check those warnings here.
    7331               0 :       JSString *str = JSID_TO_STRING(id);
    7332               0 :       if ((!(flags & JSRESOLVE_QUALIFIED) &&
    7333               0 :            !js::CheckUndeclaredVarAssignment(cx, str)) ||
    7334                 :           !::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
    7335               0 :                                    JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
    7336               0 :         *_retval = JS_FALSE;
    7337                 : 
    7338               0 :         return NS_OK;
    7339                 :       }
    7340                 : 
    7341               0 :       *objp = obj;
    7342                 :     }
    7343                 :   }
    7344                 : 
    7345               0 :   return NS_OK;
    7346                 : }
    7347                 : 
    7348                 : NS_IMETHODIMP
    7349               0 : nsWindowSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7350                 :                      JSObject *obj)
    7351                 : {
    7352               0 :   nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryWrappedNative(wrapper));
    7353               0 :   NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
    7354                 : 
    7355               0 :   sgo->OnFinalize(obj);
    7356                 : 
    7357               0 :   return NS_OK;
    7358                 : }
    7359                 : 
    7360                 : NS_IMETHODIMP
    7361               0 : nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
    7362                 :                         JSObject * obj, JSObject * *_retval)
    7363                 : {
    7364               0 :   nsGlobalWindow *origWin = nsGlobalWindow::FromWrapper(wrapper);
    7365               0 :   nsGlobalWindow *win = origWin->GetOuterWindowInternal();
    7366                 : 
    7367               0 :   if (!win) {
    7368                 :     // If we no longer have an outer window. No code should ever be
    7369                 :     // running on a window w/o an outer, which means this hook should
    7370                 :     // never be called when we have no outer. But just in case, return
    7371                 :     // null to prevent leaking an inner window to code in a different
    7372                 :     // window.
    7373               0 :     *_retval = nsnull;
    7374               0 :     return NS_ERROR_UNEXPECTED;
    7375                 :   }
    7376                 : 
    7377               0 :   JSObject *winObj = win->FastGetGlobalJSObject();
    7378               0 :   if (!winObj) {
    7379               0 :     NS_ASSERTION(origWin->IsOuterWindow(), "What window is this?");
    7380               0 :     *_retval = obj;
    7381               0 :     return NS_OK;
    7382                 :   }
    7383                 : 
    7384               0 :   if (!JS_WrapObject(cx, &winObj)) {
    7385               0 :     *_retval = nsnull;
    7386               0 :     return NS_ERROR_UNEXPECTED;
    7387                 :   }
    7388                 : 
    7389               0 :   *_retval = winObj;
    7390               0 :   return NS_OK;
    7391                 : }
    7392                 : 
    7393                 : // DOM Location helper
    7394                 : 
    7395                 : NS_IMETHODIMP
    7396               0 : nsLocationSH::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7397                 :                           JSObject *obj, jsid id, PRUint32 mode,
    7398                 :                           jsval *vp, bool *_retval)
    7399                 : {
    7400               0 :   if ((mode & JSACC_TYPEMASK) == JSACC_PROTO && (mode & JSACC_WRITE)) {
    7401                 :     // No setting location.__proto__, ever!
    7402                 : 
    7403                 :     // Let XPConnect know that the access was not granted.
    7404               0 :     *_retval = false;
    7405                 : 
    7406               0 :     return NS_ERROR_DOM_SECURITY_ERR;
    7407                 :   }
    7408                 : 
    7409               0 :   return nsDOMGenericSH::CheckAccess(wrapper, cx, obj, id, mode, vp, _retval);
    7410                 : }
    7411                 : 
    7412                 : NS_IMETHODIMP
    7413               0 : nsLocationSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    7414                 :                         JSObject *globalObj, JSObject **parentObj)
    7415                 : {
    7416                 :   // window.location can be held onto by both evil pages that want to track the
    7417                 :   // user's progress on the web and bookmarklets that want to use the location
    7418                 :   // object. Parent it to the outer window so that access checks do the Right
    7419                 :   // Thing.
    7420               0 :   *parentObj = globalObj;
    7421                 : 
    7422               0 :   nsCOMPtr<nsIDOMLocation> safeLoc(do_QueryInterface(nativeObj));
    7423               0 :   if (!safeLoc) {
    7424                 :     // Oops, this wasn't really a location object. This can happen if someone
    7425                 :     // tries to use our scriptable helper as a real object and tries to wrap
    7426                 :     // it, see bug 319296
    7427               0 :     return NS_OK;
    7428                 :   }
    7429                 : 
    7430               0 :   nsLocation *loc = (nsLocation *)safeLoc.get();
    7431               0 :   nsIDocShell *ds = loc->GetDocShell();
    7432               0 :   if (!ds) {
    7433               0 :     NS_WARNING("Refusing to create a location in the wrong scope");
    7434               0 :     return NS_ERROR_UNEXPECTED;
    7435                 :   }
    7436                 : 
    7437               0 :   nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
    7438               0 :   if (!sgo) {
    7439                 :     NS_WARNING("Refusing to create a location in the wrong scope because the "
    7440               0 :                "docshell is being destroyed");
    7441               0 :     return NS_ERROR_UNEXPECTED;
    7442                 :   }
    7443                 : 
    7444               0 :   *parentObj = sgo->GetGlobalJSObject();
    7445               0 :   return NS_OK;
    7446                 : }
    7447                 : 
    7448                 : // DOM Navigator helper
    7449                 : 
    7450                 : NS_IMETHODIMP
    7451               0 : nsNavigatorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7452                 :                           JSObject *obj, jsid id, PRUint32 flags,
    7453                 :                           JSObject **objp, bool *_retval)
    7454                 : {
    7455               0 :   if (!JSID_IS_STRING(id) || (flags & JSRESOLVE_ASSIGNING)) {
    7456               0 :     return NS_OK;
    7457                 :   }
    7458                 : 
    7459                 :   nsScriptNameSpaceManager *nameSpaceManager =
    7460               0 :     nsJSRuntime::GetNameSpaceManager();
    7461               0 :   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
    7462                 : 
    7463               0 :   nsDependentJSString name(id);
    7464                 : 
    7465               0 :   const nsGlobalNameStruct *name_struct = nsnull;
    7466                 : 
    7467               0 :   nameSpaceManager->LookupNavigatorName(name, &name_struct);
    7468                 : 
    7469               0 :   if (!name_struct) {
    7470               0 :     return NS_OK;
    7471                 :   }
    7472               0 :   NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeNavigatorProperty,
    7473                 :                "unexpected type");
    7474                 : 
    7475               0 :   nsresult rv = NS_OK;
    7476                 : 
    7477               0 :   nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
    7478               0 :   NS_ENSURE_SUCCESS(rv, rv);
    7479                 : 
    7480               0 :   jsval prop_val = JSVAL_VOID; // Property value.
    7481                 : 
    7482               0 :   nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
    7483                 : 
    7484               0 :   if (gpi) {
    7485               0 :     JSObject *global = JS_GetGlobalForObject(cx, obj);
    7486                 : 
    7487               0 :     nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
    7488               0 :     nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(globalNative);
    7489                 : 
    7490               0 :     if (!window) {
    7491               0 :       return NS_ERROR_UNEXPECTED;
    7492                 :     }
    7493                 : 
    7494               0 :     rv = gpi->Init(window, &prop_val);
    7495               0 :     NS_ENSURE_SUCCESS(rv, rv);
    7496                 :   }
    7497                 : 
    7498               0 :   if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
    7499               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7500                 :     rv = WrapNative(cx, obj, native, true, &prop_val,
    7501               0 :                     getter_AddRefs(holder));
    7502                 : 
    7503               0 :     NS_ENSURE_SUCCESS(rv, rv);
    7504                 :   }
    7505                 : 
    7506               0 :   if (!JS_WrapValue(cx, &prop_val)) {
    7507               0 :     return NS_ERROR_UNEXPECTED;
    7508                 :   }
    7509                 : 
    7510                 :   JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
    7511               0 :                                       JSPROP_ENUMERATE);
    7512                 : 
    7513               0 :   *_retval = true;
    7514               0 :   *objp = obj;
    7515                 : 
    7516               0 :   return ok ? NS_OK : NS_ERROR_FAILURE;
    7517                 : }
    7518                 : 
    7519                 : // static
    7520                 : nsresult
    7521               0 : nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    7522                 :                          JSObject *globalObj, JSObject **parentObj)
    7523                 : {
    7524                 :   // window.navigator can hold expandos and thus we need to only ever
    7525                 :   // create one wrapper per navigator object so that expandos are
    7526                 :   // visible independently of who's looking it up.
    7527               0 :   *parentObj = globalObj;
    7528                 : 
    7529               0 :   nsCOMPtr<nsIDOMNavigator> safeNav(do_QueryInterface(nativeObj));
    7530               0 :   if (!safeNav) {
    7531                 :     // Oops, this wasn't really a navigator object. This can happen if someone
    7532                 :     // tries to use our scriptable helper as a real object and tries to wrap
    7533                 :     // it, see bug 319296.
    7534               0 :     return NS_OK;
    7535                 :   }
    7536                 : 
    7537               0 :   Navigator *nav = static_cast<Navigator*>(safeNav.get());
    7538               0 :   nsGlobalWindow *win = static_cast<nsGlobalWindow*>(nav->GetWindow());
    7539               0 :   if (!win) {
    7540               0 :     NS_WARNING("Refusing to create a navigator in the wrong scope");
    7541                 : 
    7542               0 :     return NS_ERROR_UNEXPECTED;
    7543                 :   }
    7544                 : 
    7545               0 :   JSObject *global = win->GetGlobalJSObject();
    7546                 : 
    7547               0 :   if (global) {
    7548               0 :     *parentObj = global;
    7549                 :   }
    7550                 : 
    7551               0 :   return NS_OK;
    7552                 : }
    7553                 : 
    7554                 : // DOM Node helper
    7555                 : 
    7556                 : template<nsresult (*func)(JSContext *cx, JSObject *obj, jsval *vp)>
    7557                 : static JSBool
    7558               0 : GetterShim(JSContext *cx, JSObject *obj, jsid /* unused */, jsval *vp)
    7559                 : {
    7560               0 :   nsresult rv = (*func)(cx, obj, vp);
    7561               0 :   if (NS_FAILED(rv)) {
    7562               0 :     if (!::JS_IsExceptionPending(cx)) {
    7563               0 :       nsDOMClassInfo::ThrowJSException(cx, rv);
    7564                 :     }
    7565               0 :     return JS_FALSE;
    7566                 :   }
    7567                 : 
    7568               0 :   return JS_TRUE;  
    7569                 : }
    7570                 : 
    7571                 : // Can't be static so GetterShim will compile
    7572                 : nsresult
    7573               0 : BaseURIObjectGetter(JSContext *cx, JSObject *obj, jsval *vp)
    7574                 : {
    7575                 :   // This function duplicates some of the logic in XPC_WN_HelperGetProperty
    7576                 :   XPCWrappedNative *wrapper =
    7577               0 :     XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
    7578                 : 
    7579                 :   // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
    7580               0 :   NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
    7581                 : 
    7582               0 :   nsCOMPtr<nsINode> node = do_QueryWrappedNative(wrapper, obj);
    7583               0 :   NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
    7584                 : 
    7585               0 :   nsCOMPtr<nsIURI> uri = node->GetBaseURI();
    7586                 :   return WrapNative(cx, JS_GetGlobalForScopeChain(cx), uri,
    7587               0 :                     &NS_GET_IID(nsIURI), true, vp);
    7588                 : }
    7589                 : 
    7590                 : // Can't be static so GetterShim will compile
    7591                 : nsresult
    7592               0 : NodePrincipalGetter(JSContext *cx, JSObject *obj, jsval *vp)
    7593                 : {
    7594                 :   // This function duplicates some of the logic in XPC_WN_HelperGetProperty
    7595                 :   XPCWrappedNative *wrapper =
    7596               0 :     XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
    7597                 : 
    7598                 :   // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
    7599               0 :   NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
    7600                 : 
    7601               0 :   nsCOMPtr<nsINode> node = do_QueryWrappedNative(wrapper, obj);
    7602               0 :   NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
    7603                 : 
    7604               0 :   return WrapNative(cx, JS_GetGlobalForScopeChain(cx), node->NodePrincipal(),
    7605               0 :                     &NS_GET_IID(nsIPrincipal), true, vp);
    7606                 : }
    7607                 : 
    7608                 : NS_IMETHODIMP
    7609            1488 : nsNodeSH::PostCreatePrototype(JSContext * cx, JSObject * proto)
    7610                 : {
    7611                 :   // set up our proto first
    7612            1488 :   nsresult rv = nsDOMGenericSH::PostCreatePrototype(cx, proto);
    7613                 : 
    7614            1488 :   if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto))) {
    7615                 :     // Stick nodePrincipal and baseURIObject  properties on there
    7616                 :     JS_DefinePropertyById(cx, proto, sNodePrincipal_id,
    7617                 :                           JSVAL_VOID, GetterShim<NodePrincipalGetter>,
    7618                 :                           nsnull,
    7619            1488 :                           JSPROP_READONLY | JSPROP_SHARED);
    7620                 :     JS_DefinePropertyById(cx, proto, sBaseURIObject_id,
    7621                 :                           JSVAL_VOID, GetterShim<BaseURIObjectGetter>,
    7622                 :                           nsnull,
    7623            1488 :                           JSPROP_READONLY | JSPROP_SHARED);
    7624                 :   }
    7625                 : 
    7626            1488 :   return rv;
    7627                 : }
    7628                 : 
    7629                 : bool
    7630           17082 : nsNodeSH::IsCapabilityEnabled(const char* aCapability)
    7631                 : {
    7632                 :   bool enabled;
    7633                 :   return sSecMan &&
    7634           17082 :     NS_SUCCEEDED(sSecMan->IsCapabilityEnabled(aCapability, &enabled)) &&
    7635           34164 :     enabled;
    7636                 : }
    7637                 : 
    7638                 : NS_IMETHODIMP
    7639           17082 : nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
    7640                 :                     JSObject **parentObj)
    7641                 : {
    7642           17082 :   nsINode *node = static_cast<nsINode*>(nativeObj);
    7643                 :   
    7644                 : #ifdef DEBUG
    7645                 :   {
    7646           34164 :     nsCOMPtr<nsINode> node_qi(do_QueryInterface(nativeObj));
    7647                 : 
    7648                 :     // If this assertion fires the QI implementation for the object in
    7649                 :     // question doesn't use the nsINode pointer as the nsISupports
    7650                 :     // pointer. That must be fixed, or we'll crash...
    7651           17082 :     NS_ABORT_IF_FALSE(node_qi == node, "Uh, fix QI!");
    7652                 :   }
    7653                 : #endif
    7654                 : 
    7655                 :   // Make sure that we get the owner document of the content node, in case
    7656                 :   // we're in document teardown.  If we are, it's important to *not* use
    7657                 :   // globalObj as the nodes parent since that would give the node the
    7658                 :   // principal of globalObj (i.e. the principal of the document that's being
    7659                 :   // loaded) and not the principal of the document that's being unloaded.
    7660                 :   // See http://bugzilla.mozilla.org/show_bug.cgi?id=227417
    7661           17082 :   nsIDocument* doc = node->OwnerDoc();
    7662                 : 
    7663                 :   // If we have a document, make sure one of these is true
    7664                 :   // (1) it has a script handling object,
    7665                 :   // (2) has had one, or has been marked to have had one,
    7666                 :   // (3) we are running a privileged script.
    7667                 :   // Event handling is possible only if (1). If (2) event handling is prevented.
    7668                 :   // If document has never had a script handling object,
    7669                 :   // untrusted scripts (3) shouldn't touch it!
    7670           17082 :   bool hasHadScriptHandlingObject = false;
    7671           17082 :   NS_ENSURE_STATE(doc->GetScriptHandlingObject(hasHadScriptHandlingObject) ||
    7672                 :                   hasHadScriptHandlingObject ||
    7673                 :                   IsPrivilegedScript());
    7674                 : 
    7675                 :   nsINode *native_parent;
    7676                 : 
    7677           17082 :   bool nodeIsElement = node->IsElement();
    7678           17082 :   if (nodeIsElement && node->AsElement()->IsXUL()) {
    7679                 :     // For XUL elements, use the parent, if any.
    7680              12 :     native_parent = node->GetParent();
    7681                 : 
    7682              12 :     if (!native_parent) {
    7683               2 :       native_parent = doc;
    7684                 :     }
    7685           17070 :   } else if (!node->IsNodeOfType(nsINode::eDOCUMENT)) {
    7686           15146 :     NS_ASSERTION(node->IsNodeOfType(nsINode::eCONTENT) ||
    7687                 :                  node->IsNodeOfType(nsINode::eATTRIBUTE),
    7688                 :                  "Unexpected node type");
    7689                 :                  
    7690                 :     // For attributes and non-XUL content, use the document as scope parent.
    7691           15146 :     native_parent = doc;
    7692                 : 
    7693                 :     // But for HTML form controls, use the form as scope parent.
    7694           15146 :     if (nodeIsElement) {
    7695            8234 :       if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
    7696               2 :         nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
    7697                 : 
    7698               1 :         if (form_control) {
    7699               1 :           Element *form = form_control->GetFormElement();
    7700                 : 
    7701               1 :           if (form) {
    7702                 :             // Found a form, use it.
    7703               0 :             native_parent = form;
    7704                 :           }
    7705                 :         }
    7706                 :       }
    7707                 :       else {
    7708                 :         // Legend isn't an HTML form control but should have its fieldset form
    7709                 :         // as scope parent at least for backward compatibility.
    7710                 :         nsHTMLLegendElement *legend =
    7711            8233 :           nsHTMLLegendElement::FromContent(node->AsElement());
    7712            8233 :         if (legend) {
    7713               0 :           Element *form = legend->GetFormElement();
    7714                 : 
    7715               0 :           if (form) {
    7716               0 :             native_parent = form;
    7717                 :           }
    7718                 :         }
    7719                 :       }
    7720                 :     }
    7721                 :   } else {
    7722                 :     // We're called for a document object; set the parent to be the
    7723                 :     // document's global object, if there is one
    7724                 : 
    7725                 :     // Get the scope object from the document.
    7726            1924 :     nsISupports *scope = doc->GetScopeObject();
    7727                 : 
    7728            1924 :     if (scope) {
    7729                 :         jsval v;
    7730               0 :         nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    7731                 :         nsresult rv = WrapNative(cx, globalObj, scope, false, &v,
    7732               0 :                                  getter_AddRefs(holder));
    7733               0 :         NS_ENSURE_SUCCESS(rv, rv);
    7734                 : 
    7735               0 :         holder->GetJSObject(parentObj);
    7736                 :     }
    7737                 :     else {
    7738                 :       // No global object reachable from this document, use the
    7739                 :       // global object that was passed to this method.
    7740                 : 
    7741            1924 :       *parentObj = globalObj;
    7742                 :     }
    7743                 : 
    7744                 :     // No slim wrappers for a document's scope object.
    7745            1924 :     return node->IsInNativeAnonymousSubtree() ?
    7746            1924 :       NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
    7747                 :   }
    7748                 : 
    7749                 :   // XXXjst: Maybe we need to find the global to use from the
    7750                 :   // nsIScriptGlobalObject that's reachable from the node we're about
    7751                 :   // to wrap here? But that's not always reachable, let's use
    7752                 :   // globalObj for now...
    7753                 : 
    7754                 :   nsresult rv = WrapNativeParent(cx, globalObj, native_parent, native_parent,
    7755           15158 :                                  parentObj);
    7756           15158 :   NS_ENSURE_SUCCESS(rv, rv);
    7757                 : 
    7758           15158 :   return node->IsInNativeAnonymousSubtree() ?
    7759           15158 :     NS_SUCCESS_CHROME_ACCESS_ONLY : NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
    7760                 : }
    7761                 : 
    7762                 : NS_IMETHODIMP
    7763               2 : nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7764                 :                       JSObject *obj, jsid id, jsval *vp, bool *_retval)
    7765                 : {
    7766               2 :   nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
    7767               2 :   return NS_OK;
    7768                 : }
    7769                 : 
    7770                 : NS_IMETHODIMP
    7771           11002 : nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7772                 :                      JSObject *obj, jsid id, PRUint32 flags,
    7773                 :                      JSObject **objp, bool *_retval)
    7774                 : {
    7775           11002 :   if (id == sOnload_id || id == sOnerror_id) {
    7776                 :     // Make sure that this node can't go away while waiting for a
    7777                 :     // network load that could fire an event handler.
    7778                 :     // XXXbz won't this fail if the listener is added using
    7779                 :     // addEventListener?  On the other hand, even if I comment this
    7780                 :     // code out I can't seem to reproduce the bug it was trying to
    7781                 :     // fix....
    7782               0 :     nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
    7783                 :   }
    7784                 : 
    7785                 :   return nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
    7786           11002 :                                     _retval);
    7787                 : }
    7788                 : 
    7789                 : NS_IMETHODIMP
    7790           14158 : nsNodeSH::GetFlags(PRUint32 *aFlags)
    7791                 : {
    7792           14158 :   *aFlags = DOMCLASSINFO_STANDARD_FLAGS | nsIClassInfo::CONTENT_NODE;
    7793                 : 
    7794           14158 :   return NS_OK;
    7795                 : }
    7796                 : 
    7797                 : void
    7798               2 : nsNodeSH::PreserveWrapper(nsISupports *aNative)
    7799                 : {
    7800               2 :   nsINode *node = static_cast<nsINode*>(aNative);
    7801               2 :   nsContentUtils::PreserveWrapper(aNative, node);
    7802               2 : }
    7803                 : 
    7804                 : // EventTarget helper
    7805                 : 
    7806                 : NS_IMETHODIMP
    7807            1238 : nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    7808                 :                            JSObject *globalObj, JSObject **parentObj)
    7809                 : {
    7810                 :   nsDOMEventTargetHelper *target =
    7811            1238 :     nsDOMEventTargetHelper::FromSupports(nativeObj);
    7812                 : 
    7813            2476 :   nsCOMPtr<nsIScriptGlobalObject> native_parent;
    7814            1238 :   target->GetParentObject(getter_AddRefs(native_parent));
    7815                 : 
    7816            1238 :   *parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;
    7817                 : 
    7818            1238 :   return NS_OK;
    7819                 : }
    7820                 : 
    7821                 : NS_IMETHODIMP
    7822               1 : nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7823                 :                              JSObject *obj, jsid id, jsval *vp, bool *_retval)
    7824                 : {
    7825               1 :   if (id == sAddEventListener_id) {
    7826               0 :     return NS_OK;
    7827                 :   }
    7828                 : 
    7829               1 :   nsEventTargetSH::PreserveWrapper(GetNative(wrapper, obj));
    7830                 : 
    7831               1 :   return NS_OK;
    7832                 : }
    7833                 : 
    7834                 : void
    7835               1 : nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
    7836                 : {
    7837                 :   nsDOMEventTargetHelper *target =
    7838               1 :     nsDOMEventTargetHelper::FromSupports(aNative);
    7839               1 :   nsContentUtils::PreserveWrapper(aNative, target);
    7840               1 : }
    7841                 : 
    7842                 : // IDBEventTarget helper
    7843                 : 
    7844                 : NS_IMETHODIMP
    7845            6048 : IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
    7846                 :                             JSObject *aGlobalObj, JSObject **aParentObj)
    7847                 : {
    7848            6048 :   IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNativeObj);
    7849            6048 :   JSObject *parent = target->GetParentObject();
    7850            6048 :   *aParentObj = parent ? parent : aGlobalObj;
    7851            6048 :   return NS_OK;
    7852                 : }
    7853                 : 
    7854                 : // Element helper
    7855                 : 
    7856                 : static bool
    7857            7957 : GetBindingURL(Element *aElement, nsIDocument *aDocument,
    7858                 :               nsCSSValue::URL **aResult)
    7859                 : {
    7860                 :   // If we have a frame the frame has already loaded the binding.  And
    7861                 :   // otherwise, don't do anything else here unless we're dealing with
    7862                 :   // XUL.
    7863            7957 :   nsIPresShell *shell = aDocument->GetShell();
    7864            7957 :   if (!shell || aElement->GetPrimaryFrame() || !aElement->IsXUL()) {
    7865            7957 :     *aResult = nsnull;
    7866                 : 
    7867            7957 :     return true;
    7868                 :   }
    7869                 : 
    7870                 :   // Get the computed -moz-binding directly from the style context
    7871               0 :   nsPresContext *pctx = shell->GetPresContext();
    7872               0 :   NS_ENSURE_TRUE(pctx, false);
    7873                 : 
    7874                 :   nsRefPtr<nsStyleContext> sc = pctx->StyleSet()->ResolveStyleFor(aElement,
    7875               0 :                                                                   nsnull);
    7876               0 :   NS_ENSURE_TRUE(sc, false);
    7877                 : 
    7878               0 :   *aResult = sc->GetStyleDisplay()->mBinding;
    7879                 : 
    7880               0 :   return true;
    7881                 : }
    7882                 : 
    7883                 : NS_IMETHODIMP
    7884            8246 : nsElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    7885                 :                        JSObject *globalObj, JSObject **parentObj)
    7886                 : {
    7887            8246 :   nsresult rv = nsNodeSH::PreCreate(nativeObj, cx, globalObj, parentObj);
    7888            8246 :   NS_ENSURE_SUCCESS(rv, rv);
    7889                 : 
    7890            8246 :   Element *element = static_cast<Element*>(nativeObj);
    7891                 : 
    7892                 : #ifdef DEBUG
    7893                 :   {
    7894           16492 :     nsCOMPtr<nsIContent> content_qi(do_QueryInterface(nativeObj));
    7895                 : 
    7896                 :     // If this assertion fires the QI implementation for the object in
    7897                 :     // question doesn't use the nsIContent pointer as the nsISupports
    7898                 :     // pointer. That must be fixed, or we'll crash...
    7899            8246 :     NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
    7900                 :   }
    7901                 : #endif
    7902                 : 
    7903            8246 :   nsIDocument *doc = element->HasFlag(NODE_FORCE_XBL_BINDINGS) ?
    7904               0 :                      element->OwnerDoc() :
    7905            8246 :                      element->GetCurrentDoc();
    7906                 : 
    7907            8246 :   if (!doc) {
    7908             289 :     return rv;
    7909                 :   }
    7910                 : 
    7911            7957 :   if (element->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
    7912               0 :       doc->BindingManager()->GetBinding(element)) {
    7913                 :     // Don't allow slim wrappers.
    7914               0 :     return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
    7915                 :   }
    7916                 : 
    7917                 :   nsCSSValue::URL *bindingURL;
    7918            7957 :   bool ok = GetBindingURL(element, doc, &bindingURL);
    7919            7957 :   NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
    7920                 : 
    7921                 :   // Only allow slim wrappers if there's no binding.
    7922            7957 :   if (!bindingURL) {
    7923            7957 :     return rv;
    7924                 :   }
    7925                 : 
    7926               0 :   element->SetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
    7927                 : 
    7928               0 :   return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
    7929                 : }
    7930                 : 
    7931                 : NS_IMETHODIMP
    7932             202 : nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    7933                 :                         JSObject *obj)
    7934                 : {
    7935             202 :   Element *element = static_cast<Element*>(wrapper->Native());
    7936                 : 
    7937                 : #ifdef DEBUG
    7938                 :   {
    7939             404 :     nsCOMPtr<nsIContent> content_qi(do_QueryWrappedNative(wrapper));
    7940                 : 
    7941                 :     // If this assertion fires the QI implementation for the object in
    7942                 :     // question doesn't use the nsIContent pointer as the nsISupports
    7943                 :     // pointer. That must be fixed, or we'll crash...
    7944             202 :     NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
    7945                 :   }
    7946                 : #endif
    7947                 : 
    7948                 :   nsIDocument* doc;
    7949             202 :   if (element->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
    7950               0 :     doc = element->OwnerDoc();
    7951                 :   }
    7952                 :   else {
    7953             202 :     doc = element->GetCurrentDoc();
    7954                 :   }
    7955                 : 
    7956             202 :   if (!doc) {
    7957                 :     // There's no baseclass that cares about this call so we just
    7958                 :     // return here.
    7959                 : 
    7960               0 :     return NS_OK;
    7961                 :   }
    7962                 : 
    7963                 :   // We must ensure that the XBL Binding is installed before we hand
    7964                 :   // back this object.
    7965                 : 
    7966             202 :   if (!element->HasFlag(NODE_ATTACH_BINDING_ON_POSTCREATE)) {
    7967                 :     // There's already a binding for this element so nothing left to
    7968                 :     // be done here.
    7969                 : 
    7970                 :     // In theory we could call ExecuteAttachedHandler here when it's safe to
    7971                 :     // run script if we also removed the binding from the PAQ queue, but that
    7972                 :     // seems like a scary change that would mosly just add more
    7973                 :     // inconsistencies.
    7974                 : 
    7975             202 :     return NS_OK;
    7976                 :   }
    7977                 : 
    7978               0 :   element->UnsetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
    7979                 : 
    7980                 :   // Make sure the style context goes away _before_ we load the binding
    7981                 :   // since that can destroy the relevant presshell.
    7982                 :   nsCSSValue::URL *bindingURL;
    7983               0 :   bool ok = GetBindingURL(element, doc, &bindingURL);
    7984               0 :   NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
    7985                 : 
    7986               0 :   if (!bindingURL) {
    7987                 :     // No binding, nothing left to do here.
    7988               0 :     return NS_OK;
    7989                 :   }
    7990                 : 
    7991               0 :   nsCOMPtr<nsIURI> uri = bindingURL->GetURI();
    7992               0 :   nsCOMPtr<nsIPrincipal> principal = bindingURL->mOriginPrincipal;
    7993                 : 
    7994                 :   // We have a binding that must be installed.
    7995                 :   bool dummy;
    7996                 : 
    7997               0 :   nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
    7998               0 :   NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
    7999                 : 
    8000               0 :   nsRefPtr<nsXBLBinding> binding;
    8001               0 :   xblService->LoadBindings(element, uri, principal, false,
    8002               0 :                            getter_AddRefs(binding), &dummy);
    8003                 :   
    8004               0 :   if (binding) {
    8005               0 :     if (nsContentUtils::IsSafeToRunScript()) {
    8006               0 :       binding->ExecuteAttachedHandler();
    8007                 :     }
    8008                 :     else {
    8009                 :       nsContentUtils::AddScriptRunner(
    8010               0 :         NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
    8011                 :     }
    8012                 :   }
    8013                 : 
    8014               0 :   return NS_OK;
    8015                 : }
    8016                 : 
    8017                 : NS_IMETHODIMP
    8018               0 : nsElementSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8019                 :                        JSObject *obj, bool *_retval)
    8020                 : {
    8021                 :   // Make sure to not call the superclass here!
    8022               0 :   nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
    8023               0 :   NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
    8024                 : 
    8025               0 :   nsIDocument* doc = content->OwnerDoc();
    8026                 : 
    8027               0 :   nsRefPtr<nsXBLBinding> binding = doc->BindingManager()->GetBinding(content);
    8028               0 :   if (!binding) {
    8029                 :     // Nothing else to do here
    8030               0 :     return NS_OK;
    8031                 :   }
    8032                 : 
    8033               0 :   *_retval = binding->ResolveAllFields(cx, obj);
    8034                 :   
    8035               0 :   return NS_OK;
    8036                 : }
    8037                 :   
    8038                 : 
    8039                 : // Generic array scriptable helper.
    8040                 : 
    8041                 : NS_IMETHODIMP
    8042              91 : nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8043                 :                              JSObject *obj, jsid id, PRUint32 flags,
    8044                 :                              JSObject **objp, bool *_retval)
    8045                 : {
    8046              91 :   if (id == sLength_id) {
    8047                 :     // Bail early; this isn't something we're interested in
    8048              59 :     return NS_OK;
    8049                 :   }
    8050                 :   
    8051              32 :   bool is_number = false;
    8052              32 :   PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
    8053                 : 
    8054              32 :   if (is_number && n >= 0) {
    8055                 :     // XXX The following is a cheap optimization to avoid hitting xpconnect to
    8056                 :     // get the length. We may want to consider asking our concrete
    8057                 :     // implementation for the length, and falling back onto the GetProperty if
    8058                 :     // it doesn't provide one.
    8059                 : 
    8060                 :     PRUint32 length;
    8061               2 :     nsresult rv = GetLength(wrapper, cx, obj, &length);
    8062               2 :     NS_ENSURE_SUCCESS(rv, rv);
    8063                 : 
    8064               2 :     PRUint32 index = PRUint32(n);
    8065               2 :     if (index < length) {
    8066                 :       *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID, nsnull, nsnull,
    8067               2 :                                     JSPROP_ENUMERATE | JSPROP_SHARED);
    8068               2 :       *objp = obj;
    8069                 :     }
    8070                 :   }
    8071                 : 
    8072              32 :   return NS_OK;
    8073                 : }
    8074                 : 
    8075                 : nsresult
    8076               2 : nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8077                 :                              JSObject *obj, PRUint32 *length)
    8078                 : {
    8079               2 :   *length = 0;
    8080                 : 
    8081                 :   jsval lenval;
    8082               2 :   if (!JS_GetProperty(cx, obj, "length", &lenval)) {
    8083               0 :     return NS_ERROR_UNEXPECTED;
    8084                 :   }
    8085                 : 
    8086               2 :   if (!JSVAL_IS_INT(lenval)) {
    8087                 :     // This can apparently happen with some sparse array impls falling back
    8088                 :     // onto this code.
    8089               0 :     return NS_OK;
    8090                 :   }
    8091                 : 
    8092               2 :   PRInt32 slen = JSVAL_TO_INT(lenval);
    8093               2 :   if (slen < 0) {
    8094               0 :     return NS_OK;
    8095                 :   }
    8096                 : 
    8097               2 :   *length = (PRUint32)slen;
    8098                 : 
    8099               2 :   return NS_OK;
    8100                 : }
    8101                 : 
    8102                 : NS_IMETHODIMP
    8103               0 : nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8104                 :                             JSObject *obj, bool *_retval)
    8105                 : {
    8106                 :   // Recursion protection in case someone tries to be smart and call
    8107                 :   // the enumerate hook from a user defined .length getter, or
    8108                 :   // somesuch.
    8109                 : 
    8110                 :   static bool sCurrentlyEnumerating;
    8111                 : 
    8112               0 :   if (sCurrentlyEnumerating) {
    8113                 :     // Don't recurse to death.
    8114               0 :     return NS_OK;
    8115                 :   }
    8116                 : 
    8117               0 :   sCurrentlyEnumerating = true;
    8118                 : 
    8119                 :   jsval len_val;
    8120               0 :   JSAutoRequest ar(cx);
    8121               0 :   JSBool ok = ::JS_GetProperty(cx, obj, "length", &len_val);
    8122                 : 
    8123               0 :   if (ok && JSVAL_IS_INT(len_val)) {
    8124               0 :     PRInt32 length = JSVAL_TO_INT(len_val);
    8125                 : 
    8126               0 :     for (PRInt32 i = 0; ok && i < length; ++i) {
    8127                 :       ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nsnull, nsnull,
    8128               0 :                               JSPROP_ENUMERATE | JSPROP_SHARED);
    8129                 :     }
    8130                 :   }
    8131                 : 
    8132               0 :   sCurrentlyEnumerating = false;
    8133                 : 
    8134               0 :   return ok ? NS_OK : NS_ERROR_UNEXPECTED;
    8135                 : }
    8136                 : 
    8137                 : // Array scriptable helper
    8138                 : 
    8139                 : NS_IMETHODIMP
    8140               0 : nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8141                 :                        JSObject *obj, jsid id, jsval *vp, bool *_retval)
    8142                 : {
    8143               0 :   bool is_number = false;
    8144               0 :   PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
    8145                 : 
    8146               0 :   nsresult rv = NS_OK;
    8147                 : 
    8148               0 :   if (is_number) {
    8149               0 :     if (n < 0) {
    8150               0 :       return NS_ERROR_DOM_INDEX_SIZE_ERR;
    8151                 :     }
    8152                 : 
    8153                 :     // Make sure rv == NS_OK here, so GetItemAt implementations that never fail
    8154                 :     // don't have to set rv.
    8155               0 :     rv = NS_OK;
    8156               0 :     nsWrapperCache *cache = nsnull;
    8157                 :     nsISupports* array_item =
    8158               0 :       GetItemAt(GetNative(wrapper, obj), n, &cache, &rv);
    8159               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8160                 : 
    8161               0 :     if (array_item) {
    8162                 :       rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), array_item, cache,
    8163               0 :                       true, vp);
    8164               0 :       NS_ENSURE_SUCCESS(rv, rv);
    8165                 : 
    8166               0 :       rv = NS_SUCCESS_I_DID_SOMETHING;
    8167                 :     }
    8168                 :   }
    8169                 : 
    8170               0 :   return rv;
    8171                 : }
    8172                 : 
    8173                 : 
    8174                 : // StringList scriptable helper
    8175                 : 
    8176                 : nsresult
    8177               2 : nsStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
    8178                 :                             nsAString& aResult)
    8179                 : {
    8180               4 :   nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
    8181               2 :   NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
    8182                 : 
    8183               2 :   nsresult rv = list->Item(aIndex, aResult);
    8184                 : #ifdef DEBUG
    8185               2 :   if (DOMStringIsNull(aResult)) {
    8186               0 :     PRUint32 length = 0;
    8187               0 :     list->GetLength(&length);
    8188               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
    8189                 :   }
    8190                 : #endif
    8191               2 :   return rv;
    8192                 : }
    8193                 : 
    8194                 : 
    8195                 : // DOMTokenList scriptable helper
    8196                 : 
    8197                 : nsresult
    8198               0 : nsDOMTokenListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
    8199                 :                               nsAString& aResult)
    8200                 : {
    8201               0 :   nsCOMPtr<nsIDOMDOMTokenList> list(do_QueryInterface(aNative));
    8202               0 :   NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
    8203                 : 
    8204               0 :   nsresult rv = list->Item(aIndex, aResult);
    8205                 : #ifdef DEBUG
    8206               0 :   if (DOMStringIsNull(aResult)) {
    8207               0 :     PRUint32 length = 0;
    8208               0 :     list->GetLength(&length);
    8209               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
    8210                 :   }
    8211                 : #endif
    8212               0 :   return rv;
    8213                 : }
    8214                 : 
    8215                 : 
    8216                 : // Named Array helper
    8217                 : 
    8218                 : NS_IMETHODIMP
    8219             165 : nsNamedArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8220                 :                            JSObject *obj, jsid id, PRUint32 flags,
    8221                 :                            JSObject **objp, bool *_retval)
    8222                 : {
    8223             330 :   if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
    8224             165 :       !ObjectIsNativeWrapper(cx, obj)) {
    8225                 : 
    8226                 :     {
    8227                 :       JSObject *realObj;
    8228                 : 
    8229             165 :       if (wrapper) {
    8230             165 :         wrapper->GetJSObject(&realObj);
    8231                 :       } else {
    8232               0 :         realObj = obj;
    8233                 :       }
    8234                 : 
    8235             330 :       JSAutoEnterCompartment ac;
    8236                 : 
    8237             165 :       if (!ac.enter(cx, realObj)) {
    8238               0 :         *_retval = false;
    8239               0 :         return NS_ERROR_FAILURE;
    8240                 :       }
    8241                 : 
    8242             165 :       JSObject *proto = ::JS_GetPrototype(realObj);
    8243                 : 
    8244             165 :       if (proto) {
    8245                 :         JSBool hasProp;
    8246             165 :         if (!::JS_HasPropertyById(cx, proto, id, &hasProp)) {
    8247               0 :           *_retval = false;
    8248               0 :           return NS_ERROR_FAILURE;
    8249                 :         }
    8250                 : 
    8251             165 :         if (hasProp) {
    8252                 :           // We found the property we're resolving on the prototype,
    8253                 :           // nothing left to do here then.
    8254             165 :           return NS_OK;
    8255                 :         }
    8256                 :       }
    8257                 :     }
    8258                 : 
    8259                 :     // Make sure rv == NS_OK here, so GetNamedItem implementations
    8260                 :     // that never fail don't have to set rv.
    8261               0 :     nsresult rv = NS_OK;
    8262                 :     nsWrapperCache *cache;
    8263                 : 
    8264                 :     nsISupports* item = GetNamedItem(GetNative(wrapper, obj),
    8265               0 :                                      nsDependentJSString(id), &cache, &rv);
    8266               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8267                 : 
    8268               0 :     if (item) {
    8269                 :       *_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull,
    8270               0 :                                          nsnull, JSPROP_ENUMERATE | JSPROP_SHARED);
    8271                 : 
    8272               0 :       *objp = obj;
    8273                 : 
    8274               0 :       return *_retval ? NS_OK : NS_ERROR_FAILURE;
    8275                 :     }
    8276                 :   }
    8277                 : 
    8278               0 :   return nsArraySH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
    8279                 : }
    8280                 : 
    8281                 : NS_IMETHODIMP
    8282               0 : nsNamedArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8283                 :                             JSObject *obj, jsid id, jsval *vp,
    8284                 :                             bool *_retval)
    8285                 : {
    8286               0 :   if (JSID_IS_STRING(id) && !ObjectIsNativeWrapper(cx, obj)) {
    8287               0 :     nsresult rv = NS_OK;
    8288               0 :     nsWrapperCache *cache = nsnull;
    8289                 :     nsISupports* item = GetNamedItem(GetNative(wrapper, obj),
    8290               0 :                                      nsDependentJSString(id), &cache, &rv);
    8291               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8292                 : 
    8293               0 :     if (item) {
    8294                 :       rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), item, cache,
    8295               0 :                       true, vp);
    8296               0 :       NS_ENSURE_SUCCESS(rv, rv);
    8297                 : 
    8298               0 :       rv = NS_SUCCESS_I_DID_SOMETHING;
    8299                 :     }
    8300                 : 
    8301                 :     // Don't fall through to nsArraySH::GetProperty() here
    8302               0 :     return rv;
    8303                 :   }
    8304                 : 
    8305               0 :   return nsArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
    8306                 : }
    8307                 : 
    8308                 : 
    8309                 : // NamedNodeMap helper
    8310                 : 
    8311                 : nsISupports*
    8312               0 : nsNamedNodeMapSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
    8313                 :                             nsWrapperCache **aCache, nsresult *aResult)
    8314                 : {
    8315               0 :   nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
    8316                 : 
    8317                 :   nsINode *attr;
    8318               0 :   *aCache = attr = map->GetItemAt(aIndex, aResult);
    8319               0 :   return attr;
    8320                 : }
    8321                 : 
    8322                 : nsISupports*
    8323               0 : nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
    8324                 :                                nsWrapperCache **aCache, nsresult *aResult)
    8325                 : {
    8326               0 :   nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
    8327                 : 
    8328                 :   nsINode *attr;
    8329               0 :   *aCache = attr = map->GetNamedItem(aName, aResult);
    8330               0 :   return attr;
    8331                 : }
    8332                 : 
    8333                 : 
    8334                 : NS_IMETHODIMP
    8335               0 : nsDOMStringMapSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8336                 :                              JSObject *obj, jsid id, PRUint32 flags,
    8337                 :                              JSObject **objp, bool *_retval)
    8338                 : {
    8339               0 :   nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
    8340               0 :   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
    8341                 : 
    8342               0 :   nsAutoString prop;
    8343               0 :   NS_ENSURE_TRUE(JSIDToProp(id, prop), NS_ERROR_UNEXPECTED);
    8344                 : 
    8345               0 :   if (dataset->HasDataAttr(prop)) {
    8346                 :     *_retval = JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
    8347                 :                                      nsnull, nsnull,
    8348               0 :                                      JSPROP_ENUMERATE | JSPROP_SHARED); 
    8349               0 :     *objp = obj;
    8350                 :   }
    8351                 : 
    8352               0 :   return NS_OK;
    8353                 : }
    8354                 : 
    8355                 : NS_IMETHODIMP
    8356               0 : nsDOMStringMapSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8357                 :                             JSObject *obj, bool *_retval)
    8358                 : {
    8359               0 :   nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
    8360               0 :   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
    8361                 : 
    8362               0 :   nsDOMStringMap* stringMap = static_cast<nsDOMStringMap*>(dataset.get());
    8363               0 :   nsTArray<nsString> properties;
    8364               0 :   nsresult rv = stringMap->GetDataPropList(properties);
    8365               0 :   NS_ENSURE_SUCCESS(rv, rv);
    8366                 : 
    8367               0 :   for (PRUint32 i = 0; i < properties.Length(); ++i) {
    8368               0 :     nsString& prop(properties[i]);
    8369                 :     *_retval = JS_DefineUCProperty(cx, obj, prop.get(), prop.Length(),
    8370                 :                                    JSVAL_VOID, nsnull, nsnull,
    8371               0 :                                    JSPROP_ENUMERATE | JSPROP_SHARED);
    8372               0 :     NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
    8373                 :   }
    8374                 : 
    8375               0 :   return NS_OK;
    8376                 : }
    8377                 : 
    8378                 : NS_IMETHODIMP
    8379               0 : nsDOMStringMapSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    8380                 :                             JSObject *globalObj, JSObject **parentObj)
    8381                 : {
    8382               0 :   *parentObj = globalObj;
    8383                 : 
    8384               0 :   nsDOMStringMap* dataset = static_cast<nsDOMStringMap*>(nativeObj);
    8385                 : 
    8386               0 :   nsIDocument* document = dataset->GetElement()->OwnerDoc();
    8387                 : 
    8388                 :   nsCOMPtr<nsIScriptGlobalObject> sgo =
    8389               0 :       do_GetInterface(document->GetScopeObject());
    8390                 : 
    8391               0 :   if (sgo) {
    8392               0 :     JSObject *global = sgo->GetGlobalJSObject();
    8393                 : 
    8394               0 :     if (global) {
    8395               0 :       *parentObj = global;
    8396               0 :       return NS_OK;
    8397                 :     }
    8398                 :   }
    8399                 : 
    8400               0 :   return NS_OK;
    8401                 : }
    8402                 : 
    8403                 : NS_IMETHODIMP
    8404               0 : nsDOMStringMapSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
    8405                 :                               JSContext *cx, JSObject *obj, jsid id,
    8406                 :                               jsval *vp, bool *_retval)
    8407                 : {
    8408               0 :   nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
    8409               0 :   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
    8410                 : 
    8411               0 :   nsAutoString prop;
    8412               0 :   NS_ENSURE_TRUE(JSIDToProp(id, prop), NS_ERROR_UNEXPECTED);
    8413                 : 
    8414               0 :   dataset->RemoveDataAttr(prop);
    8415                 : 
    8416               0 :   return NS_OK;
    8417                 : }
    8418                 : 
    8419                 : NS_IMETHODIMP
    8420               0 : nsDOMStringMapSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8421                 :                               JSObject *obj, jsid id, jsval *vp,
    8422                 :                               bool *_retval)
    8423                 : {
    8424               0 :   nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
    8425               0 :   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
    8426                 : 
    8427               0 :   nsAutoString propName;
    8428               0 :   NS_ENSURE_TRUE(JSIDToProp(id, propName), NS_ERROR_UNEXPECTED);
    8429                 : 
    8430               0 :   nsAutoString propVal;
    8431               0 :   nsresult rv = dataset->GetDataAttr(propName, propVal);
    8432               0 :   NS_ENSURE_SUCCESS(rv, rv);
    8433                 : 
    8434               0 :   if (propVal.IsVoid()) {
    8435               0 :     *vp = JSVAL_VOID;
    8436               0 :     return NS_SUCCESS_I_DID_SOMETHING;
    8437                 :   }
    8438                 : 
    8439                 :   nsStringBuffer* valBuf;
    8440               0 :   *vp = XPCStringConvert::ReadableToJSVal(cx, propVal, &valBuf);
    8441               0 :   if (valBuf) {
    8442               0 :     propVal.ForgetSharedBuffer();
    8443                 :   }
    8444                 : 
    8445               0 :   return NS_SUCCESS_I_DID_SOMETHING;
    8446                 : }
    8447                 : 
    8448                 : NS_IMETHODIMP
    8449               0 : nsDOMStringMapSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8450                 :                               JSObject *obj, jsid id, jsval *vp,
    8451                 :                               bool *_retval)
    8452                 : {
    8453               0 :   nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
    8454               0 :   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
    8455                 : 
    8456               0 :   nsAutoString propName;
    8457               0 :   NS_ENSURE_TRUE(JSIDToProp(id, propName), NS_ERROR_UNEXPECTED);
    8458                 : 
    8459               0 :   JSString *val = JS_ValueToString(cx, *vp);
    8460               0 :   NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
    8461                 : 
    8462               0 :   nsDependentJSString propVal;
    8463               0 :   NS_ENSURE_TRUE(propVal.init(cx, val), NS_ERROR_UNEXPECTED);
    8464                 : 
    8465               0 :   nsresult rv = dataset->SetDataAttr(propName, propVal);
    8466               0 :   NS_ENSURE_SUCCESS(rv, rv);
    8467                 : 
    8468               0 :   return NS_SUCCESS_I_DID_SOMETHING;
    8469                 : }
    8470                 : 
    8471                 : bool
    8472               0 : nsDOMStringMapSH::JSIDToProp(const jsid& aId, nsAString& aResult)
    8473                 : {
    8474               0 :   if (JSID_IS_INT(aId)) {
    8475               0 :     aResult.AppendInt(JSID_TO_INT(aId));
    8476               0 :   } else if (JSID_IS_STRING(aId)) {
    8477               0 :     aResult = nsDependentJSString(aId);
    8478                 :   } else {
    8479               0 :     return false;
    8480                 :   }
    8481                 : 
    8482               0 :   return true;
    8483                 : }
    8484                 : 
    8485                 : // Can't be static so GetterShim will compile
    8486                 : nsresult
    8487               0 : DocumentURIObjectGetter(JSContext *cx, JSObject *obj, jsval *vp)
    8488                 : {
    8489                 :   // This function duplicates some of the logic in XPC_WN_HelperGetProperty
    8490                 :   XPCWrappedNative *wrapper =
    8491               0 :     XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
    8492                 : 
    8493                 :   // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
    8494               0 :   NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
    8495                 : 
    8496               0 :   nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper, obj);
    8497               0 :   NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
    8498                 : 
    8499               0 :   return WrapNative(cx, JS_GetGlobalForScopeChain(cx), doc->GetDocumentURI(),
    8500               0 :                     &NS_GET_IID(nsIURI), true, vp);
    8501                 : }
    8502                 : 
    8503                 : NS_IMETHODIMP
    8504             565 : nsDocumentSH::PostCreatePrototype(JSContext * cx, JSObject * proto)
    8505                 : {
    8506                 :   // set up our proto first
    8507             565 :   nsresult rv = nsNodeSH::PostCreatePrototype(cx, proto);
    8508                 : 
    8509             565 :   if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto))) {
    8510                 :     // Stick a documentURIObject property on there
    8511                 :     JS_DefinePropertyById(cx, proto, sDocumentURIObject_id,
    8512                 :                           JSVAL_VOID, GetterShim<DocumentURIObjectGetter>,
    8513                 :                           nsnull,
    8514             565 :                           JSPROP_READONLY | JSPROP_SHARED);
    8515                 :   }
    8516                 : 
    8517             565 :   return rv;
    8518                 : }
    8519                 : 
    8520                 : NS_IMETHODIMP
    8521            1553 : nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8522                 :                          JSObject *obj, jsid id, PRUint32 flags,
    8523                 :                          JSObject **objp, bool *_retval)
    8524                 : {
    8525                 :   nsresult rv;
    8526                 : 
    8527            1553 :   if (id == sLocation_id) {
    8528                 :     // Define the location property on the document object itself so
    8529                 :     // that we can intercept getting and setting of document.location.
    8530                 : 
    8531               0 :     nsCOMPtr<nsIDOMDocument> doc = do_QueryWrappedNative(wrapper, obj);
    8532               0 :     NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
    8533                 : 
    8534               0 :     nsCOMPtr<nsIDOMLocation> location;
    8535               0 :     rv = doc->GetLocation(getter_AddRefs(location));
    8536               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8537                 : 
    8538                 :     jsval v;
    8539                 : 
    8540               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    8541                 :     rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
    8542                 :                     &NS_GET_IID(nsIDOMLocation), true, &v,
    8543               0 :                     getter_AddRefs(holder));
    8544               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8545                 : 
    8546                 :     JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull,
    8547                 :                                         LocationSetter<nsIDOMDocument>,
    8548               0 :                                         JSPROP_PERMANENT | JSPROP_ENUMERATE);
    8549                 : 
    8550               0 :     if (!ok) {
    8551               0 :       return NS_ERROR_FAILURE;
    8552                 :     }
    8553                 : 
    8554               0 :     *objp = obj;
    8555                 : 
    8556               0 :     return NS_OK;
    8557                 :   }
    8558                 : 
    8559            1553 :   return nsNodeSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
    8560                 : }
    8561                 : 
    8562                 : NS_IMETHODIMP
    8563            1472 : nsDocumentSH::GetFlags(PRUint32* aFlags)
    8564                 : {
    8565            1472 :   *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
    8566                 : 
    8567            1472 :   return NS_OK;
    8568                 : }
    8569                 : 
    8570                 : NS_IMETHODIMP
    8571             962 : nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    8572                 :                          JSObject *obj)
    8573                 : {
    8574                 :   // If this is the current document for the window that's the script global
    8575                 :   // object of this document, then define this document object on the window.
    8576                 :   // That will make sure that the document is referenced (via window.document)
    8577                 :   // and prevent it from going away in GC.
    8578            1924 :   nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper);
    8579             962 :   if (!doc) {
    8580               0 :     return NS_ERROR_UNEXPECTED;
    8581                 :   }
    8582                 : 
    8583             962 :   nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
    8584            1924 :   nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(sgo);
    8585             962 :   if (!win) {
    8586                 :     // No window, nothing else to do here
    8587             962 :     return NS_OK;
    8588                 :   }
    8589                 : 
    8590               0 :   nsIDOMDocument* currentDoc = win->GetExtantDocument();
    8591                 : 
    8592               0 :   if (SameCOMIdentity(doc, currentDoc)) {
    8593                 :     jsval winVal;
    8594                 : 
    8595               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    8596                 :     nsresult rv = WrapNative(cx, obj, win, &NS_GET_IID(nsIDOMWindow), false,
    8597               0 :                              &winVal, getter_AddRefs(holder));
    8598               0 :     NS_ENSURE_SUCCESS(rv, rv);
    8599                 : 
    8600               0 :     NS_NAMED_LITERAL_STRING(doc_str, "document");
    8601                 : 
    8602               0 :     if (!::JS_DefineUCProperty(cx, JSVAL_TO_OBJECT(winVal),
    8603                 :                                reinterpret_cast<const jschar *>
    8604               0 :                                                (doc_str.get()),
    8605                 :                                doc_str.Length(), OBJECT_TO_JSVAL(obj),
    8606                 :                                JS_PropertyStub, JS_StrictPropertyStub,
    8607               0 :                                JSPROP_READONLY | JSPROP_ENUMERATE)) {
    8608               0 :       return NS_ERROR_FAILURE;
    8609                 :     }
    8610                 :   }
    8611               0 :   return NS_OK;
    8612                 : }
    8613                 : 
    8614                 : // HTMLDocument helper
    8615                 : 
    8616                 : static nsresult
    8617               0 : ResolveImpl(JSContext *cx, nsIXPConnectWrappedNative *wrapper, jsid id,
    8618                 :             nsISupports **result, nsWrapperCache **aCache)
    8619                 : {
    8620                 :   nsHTMLDocument *doc =
    8621               0 :     static_cast<nsHTMLDocument*>(static_cast<nsINode*>(wrapper->Native()));
    8622                 : 
    8623                 :   // 'id' is not always a string, it can be a number since document.1
    8624                 :   // should map to <input name="1">. Thus we can't use
    8625                 :   // JSVAL_TO_STRING() here.
    8626               0 :   JSString *str = IdToString(cx, id);
    8627               0 :   NS_ENSURE_TRUE(str, NS_ERROR_UNEXPECTED);
    8628                 : 
    8629               0 :   nsDependentJSString depStr;
    8630               0 :   NS_ENSURE_TRUE(depStr.init(cx, str), NS_ERROR_UNEXPECTED);
    8631                 : 
    8632               0 :   return doc->ResolveName(depStr, nsnull, result, aCache);
    8633                 : }
    8634                 : 
    8635                 : 
    8636                 : static JSClass sHTMLDocumentAllClass = {
    8637                 :   "HTML document.all class",
    8638                 :   JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE |
    8639                 :   JSCLASS_HAS_RESERVED_SLOTS(1),
    8640                 :   JS_PropertyStub, JS_PropertyStub, nsHTMLDocumentSH::DocumentAllGetProperty,
    8641                 :   JS_StrictPropertyStub, JS_EnumerateStub,
    8642                 :   (JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve, JS_ConvertStub,
    8643                 :   nsHTMLDocumentSH::ReleaseDocument, nsnull,
    8644                 :   nsHTMLDocumentSH::CallToGetPropMapper
    8645                 : };
    8646                 : 
    8647                 : 
    8648                 : static JSClass sHTMLDocumentAllHelperClass = {
    8649                 :   "HTML document.all helper class", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
    8650                 :   JS_PropertyStub, JS_PropertyStub,
    8651                 :   nsHTMLDocumentSH::DocumentAllHelperGetProperty,
    8652                 :   JS_StrictPropertyStub, JS_EnumerateStub,
    8653                 :   (JSResolveOp)nsHTMLDocumentSH::DocumentAllHelperNewResolve, JS_ConvertStub,
    8654                 :   nsnull
    8655                 : };
    8656                 : 
    8657                 : 
    8658                 : static JSClass sHTMLDocumentAllTagsClass = {
    8659                 :   "HTML document.all.tags class",
    8660                 :   JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
    8661                 :   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
    8662                 :   JS_EnumerateStub, (JSResolveOp)nsHTMLDocumentSH::DocumentAllTagsNewResolve,
    8663                 :   JS_ConvertStub, nsHTMLDocumentSH::ReleaseDocument, nsnull,
    8664                 :   nsHTMLDocumentSH::CallToGetPropMapper
    8665                 : };
    8666                 : 
    8667                 : // static
    8668                 : JSBool
    8669               0 : nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
    8670                 :                                          nsDocument *domdoc,
    8671                 :                                          nsContentList **nodeList)
    8672                 : {
    8673                 :   // The document.all object is a mix of the node list returned by
    8674                 :   // document.getElementsByTagName("*") and a map of elements in the
    8675                 :   // document exposed by their id and/or name. To make access to the
    8676                 :   // node list part (i.e. access to elements by index) not walk the
    8677                 :   // document each time, we create a nsContentList and hold on to it
    8678                 :   // in a reserved slot (0) on the document.all JSObject.
    8679               0 :   nsresult rv = NS_OK;
    8680                 : 
    8681               0 :   jsval collection = JS_GetReservedSlot(obj, 0);
    8682                 : 
    8683               0 :   if (!JSVAL_IS_PRIMITIVE(collection)) {
    8684                 :     // We already have a node list in our reserved slot, use it.
    8685               0 :     JSObject *obj = JSVAL_TO_OBJECT(collection);
    8686               0 :     if (mozilla::dom::binding::HTMLCollection::objIsWrapper(obj)) {
    8687                 :       nsIHTMLCollection *native =
    8688               0 :         mozilla::dom::binding::HTMLCollection::getNative(obj);
    8689               0 :       NS_ADDREF(*nodeList = static_cast<nsContentList*>(native));
    8690                 :     }
    8691                 :     else {
    8692               0 :       nsISupports *native = sXPConnect->GetNativeOfWrapper(cx, obj);
    8693               0 :       if (native) {
    8694               0 :         NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
    8695                 :       }
    8696                 :       else {
    8697               0 :         rv = NS_ERROR_FAILURE;
    8698                 :       }
    8699                 :     }
    8700                 :   } else {
    8701                 :     // No node list for this document.all yet, create one...
    8702                 : 
    8703                 :     nsRefPtr<nsContentList> list =
    8704               0 :       domdoc->GetElementsByTagName(NS_LITERAL_STRING("*"));
    8705               0 :     if (!list) {
    8706               0 :       rv |= NS_ERROR_OUT_OF_MEMORY;
    8707                 :     }
    8708                 : 
    8709               0 :     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    8710                 :     rv |= WrapNative(cx, JS_GetGlobalForScopeChain(cx),
    8711               0 :                      static_cast<nsINodeList*>(list), list, false,
    8712               0 :                      &collection, getter_AddRefs(holder));
    8713                 : 
    8714               0 :     list.forget(nodeList);
    8715                 : 
    8716                 :     // ... and store it in our reserved slot.
    8717               0 :     JS_SetReservedSlot(obj, 0, collection);
    8718                 :   }
    8719                 : 
    8720               0 :   if (NS_FAILED(rv)) {
    8721               0 :     nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
    8722                 : 
    8723               0 :     return JS_FALSE;
    8724                 :   }
    8725                 : 
    8726               0 :   return *nodeList != nsnull;
    8727                 : }
    8728                 : 
    8729                 : JSBool
    8730               0 : nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
    8731                 :                                          jsid id, jsval *vp)
    8732                 : {
    8733                 :   // document.all.item and .namedItem get their value in the
    8734                 :   // newResolve hook, so nothing to do for those properties here. And
    8735                 :   // we need to return early to prevent <div id="item"> from shadowing
    8736                 :   // document.all.item(), etc.
    8737               0 :   if (id == sItem_id || id == sNamedItem_id) {
    8738               0 :     return JS_TRUE;
    8739                 :   }
    8740                 : 
    8741               0 :   while (js::GetObjectJSClass(obj) != &sHTMLDocumentAllClass) {
    8742               0 :     obj = js::GetObjectProto(obj);
    8743                 : 
    8744               0 :     if (!obj) {
    8745               0 :       NS_ERROR("The JS engine lies!");
    8746                 : 
    8747               0 :       return JS_TRUE;
    8748                 :     }
    8749                 :   }
    8750                 : 
    8751               0 :   nsHTMLDocument *doc = GetDocument(obj);
    8752                 :   nsISupports *result;
    8753                 :   nsWrapperCache *cache;
    8754               0 :   nsresult rv = NS_OK;
    8755                 : 
    8756               0 :   if (JSID_IS_STRING(id)) {
    8757               0 :     if (id == sLength_id) {
    8758                 :       // Map document.all.length to the length of the collection
    8759                 :       // document.getElementsByTagName("*"), and make sure <div
    8760                 :       // id="length"> doesn't shadow document.all.length.
    8761                 : 
    8762               0 :       nsRefPtr<nsContentList> nodeList;
    8763               0 :       if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
    8764               0 :         return JS_FALSE;
    8765                 :       }
    8766                 : 
    8767                 :       PRUint32 length;
    8768               0 :       rv = nodeList->GetLength(&length);
    8769                 : 
    8770               0 :       if (NS_FAILED(rv)) {
    8771               0 :         nsDOMClassInfo::ThrowJSException(cx, rv);
    8772                 : 
    8773               0 :         return JS_FALSE;
    8774                 :       }
    8775                 : 
    8776               0 :       *vp = INT_TO_JSVAL(length);
    8777                 : 
    8778               0 :       return JS_TRUE;
    8779               0 :     } else if (id != sTags_id) {
    8780                 :       // For all other strings, look for an element by id or name.
    8781                 : 
    8782               0 :       nsDependentJSString str(id);
    8783                 : 
    8784               0 :       result = doc->GetDocumentAllResult(str, &cache, &rv);
    8785                 : 
    8786               0 :       if (NS_FAILED(rv)) {
    8787               0 :         nsDOMClassInfo::ThrowJSException(cx, rv);
    8788                 : 
    8789               0 :         return JS_FALSE;
    8790                 :       }
    8791                 :     }
    8792                 :     else {
    8793               0 :       result = nsnull;
    8794                 :     }
    8795               0 :   } else if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
    8796                 :     // Map document.all[n] (where n is a number) to the n:th item in
    8797                 :     // the document.all node list.
    8798                 : 
    8799               0 :     nsRefPtr<nsContentList> nodeList;
    8800               0 :     if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
    8801               0 :       return JS_FALSE;
    8802                 :     }
    8803                 : 
    8804               0 :     nsIContent *node = nodeList->GetNodeAt(JSID_TO_INT(id));
    8805                 : 
    8806               0 :     result = node;
    8807               0 :     cache = node;
    8808                 :   } else {
    8809               0 :     result = nsnull;
    8810                 :   }
    8811                 : 
    8812               0 :   if (result) {
    8813               0 :     rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), result, cache, true, vp);
    8814               0 :     if (NS_FAILED(rv)) {
    8815               0 :       nsDOMClassInfo::ThrowJSException(cx, rv);
    8816                 : 
    8817               0 :       return JS_FALSE;
    8818                 :     }
    8819                 :   } else {
    8820               0 :     *vp = JSVAL_VOID;
    8821                 :   }
    8822                 : 
    8823               0 :   return JS_TRUE;
    8824                 : }
    8825                 : 
    8826                 : JSBool
    8827               0 : nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
    8828                 :                                         unsigned flags, JSObject **objp)
    8829                 : {
    8830               0 :   if (flags & JSRESOLVE_ASSIGNING) {
    8831                 :     // Nothing to do here if we're assigning
    8832                 : 
    8833               0 :     return JS_TRUE;
    8834                 :   }
    8835                 : 
    8836               0 :   jsval v = JSVAL_VOID;
    8837                 : 
    8838               0 :   if (id == sItem_id || id == sNamedItem_id) {
    8839                 :     // Define the item() or namedItem() method.
    8840                 : 
    8841                 :     JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
    8842               0 :                                               0, JSPROP_ENUMERATE);
    8843               0 :     *objp = obj;
    8844                 : 
    8845               0 :     return fnc != nsnull;
    8846                 :   }
    8847                 : 
    8848               0 :   if (id == sLength_id) {
    8849                 :     // document.all.length. Any jsval other than undefined would do
    8850                 :     // here, all we need is to get into the code below that defines
    8851                 :     // this propery on obj, the rest happens in
    8852                 :     // DocumentAllGetProperty().
    8853                 : 
    8854               0 :     v = JSVAL_ONE;
    8855               0 :   } else if (id == sTags_id) {
    8856               0 :     nsHTMLDocument *doc = GetDocument(obj);
    8857                 : 
    8858                 :     JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
    8859               0 :                                     ::JS_GetGlobalForObject(cx, obj));
    8860               0 :     if (!tags) {
    8861               0 :       return JS_FALSE;
    8862                 :     }
    8863                 : 
    8864               0 :     ::JS_SetPrivate(tags, doc);
    8865                 : 
    8866                 :     // The "tags" JSObject now also owns doc.
    8867               0 :     NS_ADDREF(doc);
    8868                 : 
    8869               0 :     v = OBJECT_TO_JSVAL(tags);
    8870                 :   } else {
    8871               0 :     if (!DocumentAllGetProperty(cx, obj, id, &v)) {
    8872               0 :       return JS_FALSE;
    8873                 :     }
    8874                 :   }
    8875                 : 
    8876               0 :   JSBool ok = JS_TRUE;
    8877                 : 
    8878               0 :   if (v != JSVAL_VOID) {
    8879               0 :     ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
    8880               0 :     *objp = obj;
    8881                 :   }
    8882                 : 
    8883               0 :   return ok;
    8884                 : }
    8885                 : 
    8886                 : // Finalize hook used by document related JS objects, but also by
    8887                 : // sGlobalScopePolluterClass!
    8888                 : 
    8889                 : void
    8890               0 : nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
    8891                 : {
    8892               0 :   nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(obj);
    8893                 : 
    8894               0 :   NS_IF_RELEASE(doc);
    8895               0 : }
    8896                 : 
    8897                 : JSBool
    8898               0 : nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
    8899                 : {
    8900                 :   // Handle document.all("foo") style access to document.all.
    8901                 : 
    8902               0 :   if (argc != 1) {
    8903                 :     // XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
    8904                 :     // and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
    8905                 :     // accepts nothing other than one arg.
    8906               0 :     nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_INVALID_ARG);
    8907                 : 
    8908               0 :     return JS_FALSE;
    8909                 :   }
    8910                 : 
    8911                 :   // Convert all types to string.
    8912               0 :   JSString *str = ::JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
    8913               0 :   if (!str) {
    8914               0 :     return JS_FALSE;
    8915                 :   }
    8916                 : 
    8917                 :   // If we are called via document.all(id) instead of document.all.item(i) or
    8918                 :   // another method, use the document.all callee object as self.
    8919                 :   JSObject *self;
    8920               0 :   if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) &&
    8921               0 :       ::JS_GetClass(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) {
    8922               0 :     self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
    8923                 :   } else {
    8924               0 :     self = JS_THIS_OBJECT(cx, vp);
    8925               0 :     if (!self)
    8926               0 :       return JS_FALSE;
    8927                 :   }
    8928                 : 
    8929                 :   size_t length;
    8930               0 :   const jschar *chars = ::JS_GetStringCharsAndLength(cx, str, &length);
    8931               0 :   if (!chars) {
    8932               0 :     return JS_FALSE;
    8933                 :   }
    8934                 : 
    8935               0 :   return ::JS_GetUCProperty(cx, self, chars, length, vp);
    8936                 : }
    8937                 : 
    8938                 : 
    8939                 : static inline JSObject *
    8940               0 : GetDocumentAllHelper(JSObject *obj)
    8941                 : {
    8942               0 :   while (obj && JS_GetClass(obj) != &sHTMLDocumentAllHelperClass) {
    8943               0 :     obj = ::JS_GetPrototype(obj);
    8944                 :   }
    8945                 : 
    8946               0 :   return obj;
    8947                 : }
    8948                 : 
    8949                 : static inline void *
    8950               0 : FlagsToPrivate(PRUint32 flags)
    8951                 : {
    8952               0 :   JS_ASSERT((flags & (1 << 31)) == 0);
    8953               0 :   return (void *)(flags << 1);
    8954                 : }
    8955                 : 
    8956                 : static inline PRUint32
    8957               0 : PrivateToFlags(void *priv)
    8958                 : {
    8959               0 :   JS_ASSERT(size_t(priv) <= PR_UINT32_MAX && (size_t(priv) & 1) == 0);
    8960               0 :   return (PRUint32)(size_t(priv) >> 1);
    8961                 : }
    8962                 : 
    8963                 : JSBool
    8964               0 : nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
    8965                 :                                                jsid id, jsval *vp)
    8966                 : {
    8967               0 :   if (id != nsDOMClassInfo::sAll_id) {
    8968               0 :     return JS_TRUE;
    8969                 :   }
    8970                 : 
    8971               0 :   JSObject *helper = GetDocumentAllHelper(obj);
    8972                 : 
    8973               0 :   if (!helper) {
    8974               0 :     NS_ERROR("Uh, how'd we get here?");
    8975                 : 
    8976                 :     // Let scripts continue, if we somehow did get here...
    8977                 : 
    8978               0 :     return JS_TRUE;
    8979                 :   }
    8980                 : 
    8981               0 :   PRUint32 flags = PrivateToFlags(::JS_GetPrivate(helper));
    8982                 : 
    8983               0 :   if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
    8984                 :     // document.all is either being detected, e.g. if (document.all),
    8985                 :     // or it was not being resolved with a qualified name. Claim that
    8986                 :     // document.all is undefined.
    8987                 : 
    8988               0 :     *vp = JSVAL_VOID;
    8989                 :   } else {
    8990                 :     // document.all is not being detected, and it resolved with a
    8991                 :     // qualified name. Expose the document.all collection.
    8992                 : 
    8993               0 :     if (!JSVAL_IS_OBJECT(*vp)) {
    8994                 :       // First time through, create the collection, and set the
    8995                 :       // document as its private nsISupports data.
    8996                 :       nsresult rv;
    8997               0 :       nsCOMPtr<nsIHTMLDocument> doc = do_QueryWrapper(cx, obj, &rv);
    8998               0 :       if (NS_FAILED(rv)) {
    8999               0 :         nsDOMClassInfo::ThrowJSException(cx, rv);
    9000                 : 
    9001               0 :         return JS_FALSE;
    9002                 :       }
    9003                 : 
    9004                 :       JSObject *all = ::JS_NewObject(cx, &sHTMLDocumentAllClass, nsnull,
    9005               0 :                                      ::JS_GetGlobalForObject(cx, obj));
    9006               0 :       if (!all) {
    9007               0 :         return JS_FALSE;
    9008                 :       }
    9009                 : 
    9010                 :       // Let the JSObject take over ownership of doc.
    9011               0 :       ::JS_SetPrivate(all, doc);
    9012                 : 
    9013               0 :       doc.forget();
    9014                 : 
    9015               0 :       *vp = OBJECT_TO_JSVAL(all);
    9016                 :     }
    9017                 :   }
    9018                 : 
    9019               0 :   return JS_TRUE;
    9020                 : }
    9021                 : 
    9022                 : JSBool
    9023               0 : nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
    9024                 :                                               jsid id, unsigned flags,
    9025                 :                                               JSObject **objp)
    9026                 : {
    9027               0 :   if (id == nsDOMClassInfo::sAll_id) {
    9028                 :     // document.all is resolved for the first time. Define it.
    9029               0 :     JSObject *helper = GetDocumentAllHelper(obj);
    9030                 : 
    9031               0 :     if (helper) {
    9032               0 :       if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
    9033               0 :                                JSPROP_ENUMERATE)) {
    9034               0 :         return JS_FALSE;
    9035                 :       }
    9036                 : 
    9037               0 :       *objp = helper;
    9038                 :     }
    9039                 :   }
    9040                 : 
    9041               0 :   return JS_TRUE;
    9042                 : }
    9043                 : 
    9044                 : 
    9045                 : JSBool
    9046               0 : nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
    9047                 :                                             jsid id, unsigned flags,
    9048                 :                                             JSObject **objp)
    9049                 : {
    9050               0 :   if (JSID_IS_STRING(id)) {
    9051               0 :     nsDocument *doc = GetDocument(obj);
    9052                 : 
    9053               0 :     JSObject *proto = ::JS_GetPrototype(obj);
    9054               0 :     if (NS_UNLIKELY(!proto)) {
    9055               0 :       return JS_TRUE;
    9056                 :     }
    9057                 : 
    9058                 :     JSBool found;
    9059               0 :     if (!::JS_HasPropertyById(cx, proto, id, &found)) {
    9060               0 :       return JS_FALSE;
    9061                 :     }
    9062                 : 
    9063               0 :     if (found) {
    9064               0 :       return JS_TRUE;
    9065                 :     }
    9066                 : 
    9067                 :     nsRefPtr<nsContentList> tags =
    9068               0 :       doc->GetElementsByTagName(nsDependentJSString(id));
    9069                 : 
    9070               0 :     if (tags) {
    9071                 :       jsval v;
    9072               0 :       nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
    9073                 :       nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
    9074               0 :                                static_cast<nsINodeList*>(tags), tags, true,
    9075               0 :                                &v, getter_AddRefs(holder));
    9076               0 :       if (NS_FAILED(rv)) {
    9077               0 :         nsDOMClassInfo::ThrowJSException(cx, rv);
    9078                 : 
    9079               0 :         return JS_FALSE;
    9080                 :       }
    9081                 : 
    9082               0 :       if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
    9083               0 :         return JS_FALSE;
    9084                 :       }
    9085                 : 
    9086               0 :       *objp = obj;
    9087                 :     }
    9088                 :   }
    9089                 : 
    9090               0 :   return JS_TRUE;
    9091                 : }
    9092                 : 
    9093                 : 
    9094                 : NS_IMETHODIMP
    9095               0 : nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    9096                 :                              JSObject *obj, jsid id, PRUint32 flags,
    9097                 :                              JSObject **objp, bool *_retval)
    9098                 : {
    9099                 :   // nsDocumentSH::NewResolve() does a security check that we'd kinda
    9100                 :   // want to do here too before doing anything else. But given that we
    9101                 :   // only define dynamic properties here before the call to
    9102                 :   // nsDocumentSH::NewResolve() we're ok, since once those properties
    9103                 :   // are accessed, we'll do the necessary security check.
    9104                 : 
    9105               0 :   if (!(flags & JSRESOLVE_ASSIGNING)) {
    9106                 :     // For native wrappers, do not resolve random names on document
    9107                 : 
    9108               0 :     JSAutoRequest ar(cx);
    9109                 : 
    9110               0 :     if (!ObjectIsNativeWrapper(cx, obj)) {
    9111               0 :       nsCOMPtr<nsISupports> result;
    9112                 :       nsWrapperCache *cache;
    9113               0 :       nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result),
    9114               0 :                                 &cache);
    9115               0 :       NS_ENSURE_SUCCESS(rv, rv);
    9116                 : 
    9117               0 :       if (result) {
    9118                 :         JSBool ok = *_retval =
    9119               0 :           ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull, nsnull, 0);
    9120               0 :         *objp = obj;
    9121                 : 
    9122               0 :         return ok ? NS_OK : NS_ERROR_FAILURE;
    9123                 :       }
    9124                 :     }
    9125                 : 
    9126               0 :     if (id == sAll_id && !sDisableDocumentAllSupport &&
    9127               0 :         !ObjectIsNativeWrapper(cx, obj)) {
    9128               0 :       nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
    9129                 : 
    9130               0 :       if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
    9131               0 :         JSObject *helper = GetDocumentAllHelper(::JS_GetPrototype(obj));
    9132                 : 
    9133               0 :         JSObject *proto = ::JS_GetPrototype(helper ? helper : obj);
    9134                 : 
    9135                 :         // Check if the property all is defined on obj's (or helper's
    9136                 :         // if obj doesn't exist) prototype, if it is, don't expose our
    9137                 :         // document.all helper.
    9138                 : 
    9139               0 :         JSBool hasAll = JS_FALSE;
    9140               0 :         if (proto && !JS_HasProperty(cx, proto, "all", &hasAll)) {
    9141               0 :           return NS_ERROR_UNEXPECTED;
    9142                 :         }
    9143                 : 
    9144               0 :         if (hasAll && helper) {
    9145                 :           // Our helper's prototype now has an "all" property, remove
    9146                 :           // the helper out of the prototype chain to prevent
    9147                 :           // shadowing of the now defined "all" property.
    9148               0 :           JSObject *tmp = obj, *tmpProto;
    9149                 : 
    9150               0 :           while ((tmpProto = ::JS_GetPrototype(tmp)) != helper) {
    9151               0 :             tmp = tmpProto;
    9152                 :           }
    9153                 : 
    9154               0 :           ::JS_SetPrototype(cx, tmp, proto);
    9155                 :         }
    9156                 : 
    9157                 :         // If we don't already have a helper, and we're resolving
    9158                 :         // document.all qualified, and we're *not* detecting
    9159                 :         // document.all, e.g. if (document.all), and "all" isn't
    9160                 :         // already defined on our prototype, create a helper.
    9161               0 :         if (!helper && flags & JSRESOLVE_QUALIFIED &&
    9162               0 :             !(flags & JSRESOLVE_DETECTING) && !hasAll) {
    9163                 :           // Print a warning so developers can stop using document.all
    9164               0 :           PrintWarningOnConsole(cx, "DocumentAllUsed");
    9165                 : 
    9166                 :           helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
    9167                 :                                   ::JS_GetPrototype(obj),
    9168               0 :                                   ::JS_GetGlobalForObject(cx, obj));
    9169                 : 
    9170               0 :           if (!helper) {
    9171               0 :             return NS_ERROR_OUT_OF_MEMORY;
    9172                 :           }
    9173                 : 
    9174                 :           // Insert the helper into our prototype chain. helper's prototype
    9175                 :           // is already obj's current prototype.
    9176               0 :           if (!::JS_SetPrototype(cx, obj, helper)) {
    9177               0 :             nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
    9178                 : 
    9179               0 :             return NS_ERROR_UNEXPECTED;
    9180                 :           }
    9181                 :         }
    9182                 : 
    9183                 :         // If we have (or just created) a helper, pass the resolve flags
    9184                 :         // to the helper as its private data.
    9185               0 :         if (helper) {
    9186               0 :           ::JS_SetPrivate(helper, FlagsToPrivate(flags));
    9187                 :         }
    9188                 :       }
    9189                 : 
    9190               0 :       return NS_OK;
    9191                 :     }
    9192                 :   }
    9193                 : 
    9194               0 :   return nsDocumentSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
    9195                 : }
    9196                 : 
    9197                 : NS_IMETHODIMP
    9198               0 : nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
    9199                 :                               JSContext *cx, JSObject *obj, jsid id,
    9200                 :                               jsval *vp, bool *_retval)
    9201                 : {
    9202                 :   // For native wrappers, do not get random names on document
    9203               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    9204               0 :     nsCOMPtr<nsISupports> result;
    9205                 : 
    9206               0 :     JSAutoRequest ar(cx);
    9207                 : 
    9208                 :     nsWrapperCache *cache;
    9209               0 :     nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result), &cache);
    9210               0 :     NS_ENSURE_SUCCESS(rv, rv);
    9211                 : 
    9212               0 :     if (result) {
    9213               0 :       rv = WrapNative(cx, obj, result, cache, true, vp);
    9214               0 :       if (NS_SUCCEEDED(rv)) {
    9215               0 :         rv = NS_SUCCESS_I_DID_SOMETHING;
    9216                 :       }
    9217               0 :       return rv;
    9218                 :     }
    9219                 :   }
    9220                 : 
    9221               0 :   return NS_OK;
    9222                 : }
    9223                 : 
    9224                 : // HTMLFormElement helper
    9225                 : 
    9226                 : // static
    9227                 : nsresult
    9228               0 : nsHTMLFormElementSH::FindNamedItem(nsIForm *aForm, jsid id,
    9229                 :                                    nsISupports **aResult,
    9230                 :                                    nsWrapperCache **aCache)
    9231                 : {
    9232               0 :   nsDependentJSString name(id);
    9233                 : 
    9234               0 :   *aResult = aForm->ResolveName(name).get();
    9235                 :   // FIXME Get the wrapper cache from nsIForm::ResolveName
    9236               0 :   *aCache = nsnull;
    9237                 : 
    9238               0 :   if (!*aResult) {
    9239               0 :     nsCOMPtr<nsIContent> content(do_QueryInterface(aForm));
    9240                 : 
    9241                 :     nsCOMPtr<nsIHTMLDocument> html_doc =
    9242               0 :       do_QueryInterface(content->GetDocument());
    9243                 : 
    9244               0 :     if (html_doc && content) {
    9245               0 :       html_doc->ResolveName(name, content, aResult, aCache);
    9246                 :     }
    9247                 :   }
    9248                 : 
    9249               0 :   return NS_OK;
    9250                 : }
    9251                 : 
    9252                 : NS_IMETHODIMP
    9253               0 : nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
    9254                 :                                 JSContext *cx, JSObject *obj, jsid id,
    9255                 :                                 PRUint32 flags, JSObject **objp,
    9256                 :                                 bool *_retval)
    9257                 : {
    9258                 :   // For native wrappers, do not resolve random names on form
    9259               0 :   if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
    9260               0 :       !ObjectIsNativeWrapper(cx, obj)) {
    9261               0 :     nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
    9262               0 :     nsCOMPtr<nsISupports> result;
    9263                 :     nsWrapperCache *cache;
    9264                 : 
    9265               0 :     FindNamedItem(form, id, getter_AddRefs(result), &cache);
    9266                 : 
    9267               0 :     if (result) {
    9268               0 :       JSAutoRequest ar(cx);
    9269                 :       *_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull,
    9270               0 :                                          nsnull, JSPROP_ENUMERATE);
    9271                 : 
    9272               0 :       *objp = obj;
    9273                 : 
    9274               0 :       return *_retval ? NS_OK : NS_ERROR_FAILURE;
    9275                 :     }
    9276                 :   }
    9277                 : 
    9278               0 :   return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
    9279                 : }
    9280                 : 
    9281                 : 
    9282                 : NS_IMETHODIMP
    9283               0 : nsHTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
    9284                 :                                  JSContext *cx, JSObject *obj, jsid id,
    9285                 :                                  jsval *vp, bool *_retval)
    9286                 : {
    9287               0 :   nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
    9288                 : 
    9289               0 :   if (JSID_IS_STRING(id)) {
    9290                 :     // For native wrappers, do not get random names on form
    9291               0 :     if (!ObjectIsNativeWrapper(cx, obj)) {
    9292               0 :       nsCOMPtr<nsISupports> result;
    9293                 :       nsWrapperCache *cache;
    9294                 : 
    9295               0 :       FindNamedItem(form, id, getter_AddRefs(result), &cache);
    9296                 : 
    9297               0 :       if (result) {
    9298                 :         // Wrap result, result can be either an element or a list of
    9299                 :         // elements
    9300               0 :         nsresult rv = WrapNative(cx, obj, result, cache, true, vp);
    9301               0 :         return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
    9302                 :       }
    9303                 :     }
    9304                 :   } else {
    9305               0 :     PRInt32 n = GetArrayIndexFromId(cx, id);
    9306                 : 
    9307               0 :     if (n >= 0) {
    9308               0 :       nsIFormControl* control = form->GetElementAt(n);
    9309                 : 
    9310               0 :       if (control) {
    9311                 :         Element *element =
    9312               0 :           static_cast<nsGenericHTMLFormElement*>(form->GetElementAt(n));
    9313                 :         nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), element,
    9314               0 :                                  element, true, vp);
    9315               0 :         return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
    9316                 :       }
    9317                 :     }
    9318                 :   }
    9319                 : 
    9320               0 :   return NS_OK;
    9321                 : }
    9322                 : 
    9323                 : NS_IMETHODIMP
    9324               0 : nsHTMLFormElementSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
    9325                 :                                   JSContext *cx, JSObject *obj,
    9326                 :                                   PRUint32 enum_op, jsval *statep,
    9327                 :                                   jsid *idp, bool *_retval)
    9328                 : {
    9329               0 :   switch (enum_op) {
    9330                 :   case JSENUMERATE_INIT:
    9331                 :   case JSENUMERATE_INIT_ALL:
    9332                 :     {
    9333               0 :       nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
    9334                 : 
    9335               0 :       if (!form) {
    9336               0 :         *statep = JSVAL_NULL;
    9337               0 :         return NS_ERROR_UNEXPECTED;
    9338                 :       }
    9339                 : 
    9340               0 :       *statep = INT_TO_JSVAL(0);
    9341                 : 
    9342               0 :       if (idp) {
    9343               0 :         PRUint32 count = form->GetElementCount();
    9344                 : 
    9345               0 :         *idp = INT_TO_JSID(count);
    9346                 :       }
    9347                 : 
    9348               0 :       break;
    9349                 :     }
    9350                 :   case JSENUMERATE_NEXT:
    9351                 :     {
    9352               0 :       nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
    9353               0 :       NS_ENSURE_TRUE(form, NS_ERROR_FAILURE);
    9354                 : 
    9355               0 :       PRInt32 index = (PRInt32)JSVAL_TO_INT(*statep);
    9356                 : 
    9357               0 :       PRUint32 count = form->GetElementCount();
    9358                 : 
    9359               0 :       if ((PRUint32)index < count) {
    9360               0 :         nsIFormControl* controlNode = form->GetElementAt(index);
    9361               0 :         NS_ENSURE_TRUE(controlNode, NS_ERROR_FAILURE);
    9362                 : 
    9363               0 :         nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(controlNode);
    9364               0 :         NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
    9365                 : 
    9366               0 :         nsAutoString attr;
    9367               0 :         domElement->GetAttribute(NS_LITERAL_STRING("name"), attr);
    9368               0 :         if (attr.IsEmpty()) {
    9369                 :           // If name is not there, use index instead
    9370               0 :           attr.AppendInt(index);
    9371                 :         }
    9372                 : 
    9373               0 :         JSAutoRequest ar(cx);
    9374                 : 
    9375                 :         JSString *jsname =
    9376                 :           JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
    9377               0 :                                                   (attr.get()),
    9378               0 :                               attr.Length());
    9379               0 :         NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
    9380                 : 
    9381               0 :         JS_ValueToId(cx, STRING_TO_JSVAL(jsname), idp);
    9382                 : 
    9383               0 :         *statep = INT_TO_JSVAL(++index);
    9384                 :       } else {
    9385               0 :         *statep = JSVAL_NULL;
    9386                 :       }
    9387                 : 
    9388               0 :       break;
    9389                 :     }
    9390                 :   case JSENUMERATE_DESTROY:
    9391               0 :     *statep = JSVAL_NULL;
    9392                 : 
    9393               0 :     break;
    9394                 :   }
    9395                 : 
    9396               0 :   return NS_OK;
    9397                 : }
    9398                 : 
    9399                 : 
    9400                 : // HTMLSelectElement helper
    9401                 : 
    9402                 : NS_IMETHODIMP
    9403               0 : nsHTMLSelectElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    9404                 :                                   JSObject *obj, jsid id, PRUint32 flags,
    9405                 :                                   JSObject **objp, bool *_retval)
    9406                 : {
    9407               0 :   PRInt32 n = GetArrayIndexFromId(cx, id);
    9408               0 :   if (n >= 0) {
    9409                 :     nsHTMLSelectElement *s =
    9410               0 :       nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
    9411                 : 
    9412               0 :     nsHTMLOptionCollection *options = s->GetOptions();
    9413               0 :     if (options) {
    9414               0 :       nsISupports *node = options->GetNodeAt(n);
    9415               0 :       if (node) {
    9416               0 :         *objp = obj;
    9417                 :         *_retval = JS_DefineElement(cx, obj, PRUint32(n), JSVAL_VOID, nsnull, nsnull,
    9418               0 :                                     JSPROP_ENUMERATE | JSPROP_SHARED);
    9419                 : 
    9420               0 :         return NS_OK;
    9421                 :       }
    9422                 :     }
    9423                 :   }
    9424                 : 
    9425               0 :   return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
    9426                 : }
    9427                 : 
    9428                 : NS_IMETHODIMP
    9429               0 : nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
    9430                 :                                    JSContext *cx, JSObject *obj, jsid id,
    9431                 :                                    jsval *vp, bool *_retval)
    9432                 : {
    9433               0 :   PRInt32 n = GetArrayIndexFromId(cx, id);
    9434                 : 
    9435               0 :   nsresult rv = NS_OK;
    9436               0 :   if (n >= 0) {
    9437                 :     nsHTMLSelectElement *s =
    9438               0 :       nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
    9439                 : 
    9440               0 :     nsHTMLOptionCollection *options = s->GetOptions();
    9441                 : 
    9442               0 :     if (options) {
    9443               0 :       nsISupports *node = options->GetNodeAt(n);
    9444                 : 
    9445                 :       rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), node,
    9446               0 :                       &NS_GET_IID(nsIDOMNode), true, vp);
    9447               0 :       if (NS_SUCCEEDED(rv)) {
    9448               0 :         rv = NS_SUCCESS_I_DID_SOMETHING;
    9449                 :       }
    9450               0 :       return rv;
    9451                 :     }
    9452                 :   }
    9453                 : 
    9454               0 :   return NS_OK;
    9455                 : }
    9456                 : 
    9457                 : // static
    9458                 : nsresult
    9459               0 : nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
    9460                 :                                  nsIDOMHTMLOptionsCollection *aOptCollection)
    9461                 : {
    9462               0 :   JSAutoRequest ar(cx);
    9463                 : 
    9464                 :   // vp must refer to an object
    9465               0 :   if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) {
    9466               0 :     return NS_ERROR_UNEXPECTED;
    9467                 :   }
    9468                 : 
    9469               0 :   nsCOMPtr<nsIDOMHTMLOptionElement> new_option;
    9470                 : 
    9471               0 :   if (!JSVAL_IS_NULL(*vp)) {
    9472               0 :     new_option = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
    9473               0 :     if (!new_option) {
    9474                 :       // Someone is trying to set an option to a non-option object.
    9475                 : 
    9476               0 :       return NS_ERROR_UNEXPECTED;
    9477                 :     }
    9478                 :   }
    9479                 : 
    9480               0 :   return aOptCollection->SetOption(aIndex, new_option);
    9481                 : }
    9482                 : 
    9483                 : NS_IMETHODIMP
    9484               0 : nsHTMLSelectElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
    9485                 :                                    JSContext *cx, JSObject *obj, jsid id,
    9486                 :                                    jsval *vp, bool *_retval)
    9487                 : {
    9488               0 :   PRInt32 n = GetArrayIndexFromId(cx, id);
    9489                 : 
    9490               0 :   if (n >= 0) {
    9491                 :     nsCOMPtr<nsIDOMHTMLSelectElement> select =
    9492               0 :       do_QueryWrappedNative(wrapper, obj);
    9493               0 :     NS_ENSURE_TRUE(select, NS_ERROR_UNEXPECTED);
    9494                 : 
    9495               0 :     nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
    9496               0 :     select->GetOptions(getter_AddRefs(options));
    9497                 : 
    9498               0 :     nsresult rv = SetOption(cx, vp, n, options);
    9499               0 :     return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
    9500                 :   }
    9501                 : 
    9502               0 :   return NS_OK;
    9503                 : }
    9504                 : 
    9505                 : 
    9506                 : // HTMLObject/EmbedElement helper
    9507                 : // Keep in mind that it is OK for this to fail to return an instance. Don't return a
    9508                 : // failure result unless something truly exceptional has happened.
    9509                 : // static
    9510                 : nsresult
    9511               0 : nsHTMLPluginObjElementSH::GetPluginInstanceIfSafe(nsIXPConnectWrappedNative *wrapper,
    9512                 :                                                   JSObject *obj,
    9513                 :                                                   nsNPAPIPluginInstance **_result)
    9514                 : {
    9515               0 :   *_result = nsnull;
    9516                 : 
    9517               0 :   nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
    9518               0 :   NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
    9519                 : 
    9520               0 :   nsCOMPtr<nsIObjectLoadingContent> objlc(do_QueryInterface(content));
    9521               0 :   NS_ASSERTION(objlc, "Object nodes must implement nsIObjectLoadingContent");
    9522                 : 
    9523               0 :   nsresult rv = objlc->GetPluginInstance(_result);
    9524               0 :   if (NS_SUCCEEDED(rv) && *_result) {
    9525               0 :     return rv;
    9526                 :   }
    9527                 : 
    9528                 :   // If it's not safe to run script we'll only return the instance if it exists.
    9529               0 :   if (!nsContentUtils::IsSafeToRunScript()) {
    9530               0 :     return rv;
    9531                 :   }
    9532                 : 
    9533                 :   // We don't care if this actually starts the plugin or not, we just want to
    9534                 :   // try to start it now if possible.
    9535               0 :   objlc->SyncStartPluginInstance();
    9536                 : 
    9537               0 :   return objlc->GetPluginInstance(_result);
    9538                 : }
    9539                 : 
    9540                 : class nsPluginProtoChainInstallRunner : public nsIRunnable
    9541               0 : {
    9542                 : public:
    9543                 :   NS_DECL_ISUPPORTS
    9544                 : 
    9545               0 :   nsPluginProtoChainInstallRunner(nsIXPConnectWrappedNative* wrapper,
    9546                 :                                   nsIScriptContext* scriptContext)
    9547                 :     : mWrapper(wrapper),
    9548               0 :       mContext(scriptContext)
    9549                 :   {
    9550               0 :   }
    9551                 : 
    9552               0 :   NS_IMETHOD Run()
    9553                 :   {
    9554               0 :     JSContext* cx = nsnull;
    9555               0 :     if (mContext) {
    9556               0 :       cx = mContext->GetNativeContext();
    9557                 :     } else {
    9558                 :       nsCOMPtr<nsIThreadJSContextStack> stack =
    9559               0 :         do_GetService("@mozilla.org/js/xpc/ContextStack;1");
    9560               0 :       NS_ENSURE_TRUE(stack, NS_OK);
    9561                 : 
    9562               0 :       stack->GetSafeJSContext(&cx);
    9563               0 :       NS_ENSURE_TRUE(cx, NS_OK);
    9564                 :     }
    9565                 : 
    9566               0 :     JSObject* obj = nsnull;
    9567               0 :     mWrapper->GetJSObject(&obj);
    9568               0 :     NS_ASSERTION(obj, "Should never be null");
    9569               0 :     nsHTMLPluginObjElementSH::SetupProtoChain(mWrapper, cx, obj);
    9570               0 :     return NS_OK;
    9571                 :   }
    9572                 : 
    9573                 : private:
    9574                 :   nsCOMPtr<nsIXPConnectWrappedNative> mWrapper;
    9575                 :   nsCOMPtr<nsIScriptContext> mContext;
    9576                 : };
    9577                 : 
    9578               0 : NS_IMPL_ISUPPORTS1(nsPluginProtoChainInstallRunner, nsIRunnable)
    9579                 : 
    9580                 : // static
    9581                 : nsresult
    9582               0 : nsHTMLPluginObjElementSH::SetupProtoChain(nsIXPConnectWrappedNative *wrapper,
    9583                 :                                           JSContext *cx,
    9584                 :                                           JSObject *obj)
    9585                 : {
    9586               0 :   NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
    9587                 :                "Shouldn't have gotten in here");
    9588                 : 
    9589               0 :   nsCxPusher cxPusher;
    9590               0 :   if (!cxPusher.Push(cx)) {
    9591               0 :     return NS_OK;
    9592                 :   }
    9593                 : 
    9594               0 :   JSAutoRequest ar(cx);
    9595                 : 
    9596               0 :   JSAutoEnterCompartment ac;
    9597               0 :   if (!ac.enter(cx, obj)) {
    9598               0 :     return NS_ERROR_UNEXPECTED;
    9599                 :   }
    9600                 : 
    9601               0 :   nsRefPtr<nsNPAPIPluginInstance> pi;
    9602               0 :   nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
    9603               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9604                 : 
    9605               0 :   if (!pi) {
    9606                 :     // No plugin around for this object.
    9607                 : 
    9608               0 :     return NS_OK;
    9609                 :   }
    9610                 : 
    9611               0 :   JSObject *pi_obj = nsnull; // XPConnect-wrapped peer object, when we get it.
    9612               0 :   JSObject *pi_proto = nsnull; // 'pi.__proto__'
    9613                 : 
    9614               0 :   rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
    9615               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9616                 : 
    9617               0 :   if (!pi_obj) {
    9618                 :     // Didn't get a plugin instance JSObject, nothing we can do then.
    9619               0 :     return NS_OK;
    9620                 :   }
    9621                 : 
    9622                 :   // If we got an xpconnect-wrapped plugin object, set obj's
    9623                 :   // prototype's prototype to the scriptable plugin.
    9624                 : 
    9625               0 :   JSObject *my_proto = nsnull;
    9626                 : 
    9627                 :   // Get 'this.__proto__'
    9628               0 :   rv = wrapper->GetJSObjectPrototype(&my_proto);
    9629               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9630                 : 
    9631                 :   // Set 'this.__proto__' to pi
    9632               0 :   if (!::JS_SetPrototype(cx, obj, pi_obj)) {
    9633               0 :     return NS_ERROR_UNEXPECTED;
    9634                 :   }
    9635                 : 
    9636               0 :   if (pi_proto && JS_GetClass(pi_proto) != sObjectClass) {
    9637                 :     // The plugin wrapper has a proto that's not Object.prototype, set
    9638                 :     // 'pi.__proto__.__proto__' to the original 'this.__proto__'
    9639               0 :     if (pi_proto != my_proto && !::JS_SetPrototype(cx, pi_proto, my_proto)) {
    9640               0 :       return NS_ERROR_UNEXPECTED;
    9641                 :     }
    9642                 :   } else {
    9643                 :     // 'pi' didn't have a prototype, or pi's proto was
    9644                 :     // 'Object.prototype' (i.e. pi is an NPRuntime wrapped JS object)
    9645                 :     // set 'pi.__proto__' to the original 'this.__proto__'
    9646               0 :     if (!::JS_SetPrototype(cx, pi_obj, my_proto)) {
    9647               0 :       return NS_ERROR_UNEXPECTED;
    9648                 :     }
    9649                 :   }
    9650                 : 
    9651                 :   // Before this proto dance the objects involved looked like this:
    9652                 :   //
    9653                 :   // this.__proto__.__proto__
    9654                 :   //   ^      ^         ^
    9655                 :   //   |      |         |__ Object.prototype
    9656                 :   //   |      |
    9657                 :   //   |      |__ xpc embed wrapper proto (shared)
    9658                 :   //   |
    9659                 :   //   |__ xpc wrapped native embed node
    9660                 :   //
    9661                 :   // pi.__proto__
    9662                 :   // ^      ^
    9663                 :   // |      |__ Object.prototype
    9664                 :   // |
    9665                 :   // |__ Plugin NPRuntime JS object wrapper
    9666                 :   //
    9667                 :   // Now, after the above prototype setup the prototype chain should
    9668                 :   // look like this:
    9669                 :   //
    9670                 :   // this.__proto__.__proto__.__proto__
    9671                 :   //   ^      ^         ^         ^
    9672                 :   //   |      |         |         |__ Object.prototype
    9673                 :   //   |      |         |
    9674                 :   //   |      |         |__ xpc embed wrapper proto (shared)
    9675                 :   //   |      |
    9676                 :   //   |      |__ Plugin NPRuntime JS object wrapper
    9677                 :   //   |
    9678                 :   //   |__ xpc wrapped native embed node
    9679                 :   //
    9680                 : 
    9681               0 :   return NS_OK;
    9682                 : }
    9683                 : 
    9684                 : NS_IMETHODIMP
    9685               0 : nsHTMLPluginObjElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    9686                 :                                     JSObject *globalObj, JSObject **parentObj)
    9687                 : {
    9688               0 :   nsresult rv = nsElementSH::PreCreate(nativeObj, cx, globalObj, parentObj);
    9689                 : 
    9690                 :   // For now we don't support slim wrappers for plugins.
    9691               0 :   return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
    9692                 : }
    9693                 : 
    9694                 : NS_IMETHODIMP
    9695               0 : nsHTMLPluginObjElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper,
    9696                 :                                      JSContext *cx, JSObject *obj)
    9697                 : {
    9698               0 :   if (nsContentUtils::IsSafeToRunScript()) {
    9699                 : #ifdef DEBUG
    9700                 :     nsresult rv =
    9701                 : #endif
    9702               0 :       SetupProtoChain(wrapper, cx, obj);
    9703                 : 
    9704                 :     // If SetupProtoChain failed then we're in real trouble. We're about to fail
    9705                 :     // PostCreate but it's more than likely that we handed our (now invalid)
    9706                 :     // wrapper to someone already. Bug 429442 is an example of the kind of crash
    9707                 :     // that can result from such a situation. We'll return NS_OK for the time
    9708                 :     // being and hope for the best.
    9709               0 :     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "SetupProtoChain failed!");
    9710               0 :     return NS_OK;
    9711                 :   }
    9712                 : 
    9713                 :   // This may be null if the JS context is not a DOM context. That's ok, we'll
    9714                 :   // use the safe context from XPConnect in the runnable.
    9715               0 :   nsCOMPtr<nsIScriptContext> scriptContext = GetScriptContextFromJSContext(cx);
    9716                 : 
    9717                 :   nsRefPtr<nsPluginProtoChainInstallRunner> runner =
    9718               0 :     new nsPluginProtoChainInstallRunner(wrapper, scriptContext);
    9719               0 :   nsContentUtils::AddScriptRunner(runner);
    9720                 : 
    9721               0 :   return NS_OK;
    9722                 : }
    9723                 : 
    9724                 : NS_IMETHODIMP
    9725               0 : nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
    9726                 :                                       JSContext *cx, JSObject *obj, jsid id,
    9727                 :                                       jsval *vp, bool *_retval)
    9728                 : {
    9729               0 :   JSAutoRequest ar(cx);
    9730                 : 
    9731               0 :   JSObject *pi_obj = ::JS_GetPrototype(obj);
    9732               0 :   if (NS_UNLIKELY(!pi_obj)) {
    9733               0 :     return NS_OK;
    9734                 :   }
    9735                 : 
    9736               0 :   JSBool found = false;
    9737                 : 
    9738               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    9739               0 :     *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
    9740               0 :     if (!*_retval) {
    9741               0 :       return NS_ERROR_UNEXPECTED;
    9742                 :     }
    9743                 :   }
    9744                 : 
    9745               0 :   if (found) {
    9746               0 :     *_retval = ::JS_GetPropertyById(cx, pi_obj, id, vp);
    9747               0 :     return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
    9748                 :   }
    9749                 : 
    9750               0 :   return NS_OK;
    9751                 : }
    9752                 : 
    9753                 : NS_IMETHODIMP
    9754               0 : nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
    9755                 :                                       JSContext *cx, JSObject *obj, jsid id,
    9756                 :                                       jsval *vp, bool *_retval)
    9757                 : {
    9758               0 :   JSAutoRequest ar(cx);
    9759                 : 
    9760               0 :   JSObject *pi_obj = ::JS_GetPrototype(obj);
    9761               0 :   if (NS_UNLIKELY(!pi_obj)) {
    9762               0 :     return NS_OK;
    9763                 :   }
    9764                 : 
    9765               0 :   JSBool found = false;
    9766                 : 
    9767               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
    9768               0 :     *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
    9769               0 :     if (!*_retval) {
    9770               0 :       return NS_ERROR_UNEXPECTED;
    9771                 :     }
    9772                 :   }
    9773                 : 
    9774               0 :   if (found) {
    9775               0 :     *_retval = ::JS_SetPropertyById(cx, pi_obj, id, vp);
    9776               0 :     return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
    9777                 :   }
    9778                 : 
    9779               0 :   return NS_OK;
    9780                 : }
    9781                 : 
    9782                 : NS_IMETHODIMP
    9783               0 : nsHTMLPluginObjElementSH::Call(nsIXPConnectWrappedNative *wrapper,
    9784                 :                                JSContext *cx, JSObject *obj, PRUint32 argc,
    9785                 :                                jsval *argv, jsval *vp, bool *_retval)
    9786                 : {
    9787               0 :   nsRefPtr<nsNPAPIPluginInstance> pi;
    9788               0 :   nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
    9789               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9790                 : 
    9791                 :   // If obj is a native wrapper, or if there's no plugin around for
    9792                 :   // this object, throw.
    9793               0 :   if (ObjectIsNativeWrapper(cx, obj) || !pi) {
    9794               0 :     return NS_ERROR_NOT_AVAILABLE;
    9795                 :   }
    9796                 : 
    9797               0 :   JSObject *pi_obj = nsnull;
    9798               0 :   JSObject *pi_proto = nsnull;
    9799                 : 
    9800               0 :   rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
    9801               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9802                 : 
    9803               0 :   if (!pi) {
    9804               0 :     return NS_ERROR_NOT_AVAILABLE;
    9805                 :   }
    9806                 : 
    9807                 :   // XPConnect passes us the XPConnect wrapper JSObject as obj, and
    9808                 :   // not the 'this' parameter that the JS engine passes in. Pass in
    9809                 :   // the real this parameter from JS (argv[-1]) here.
    9810               0 :   JSAutoRequest ar(cx);
    9811               0 :   *_retval = ::JS::Call(cx, argv[-1], pi_obj, argc, argv, vp);
    9812                 : 
    9813               0 :   return NS_OK;
    9814                 : }
    9815                 : 
    9816                 : 
    9817                 : nsresult
    9818               0 : nsHTMLPluginObjElementSH::GetPluginJSObject(JSContext *cx, JSObject *obj,
    9819                 :                                             nsNPAPIPluginInstance *plugin_inst,
    9820                 :                                             JSObject **plugin_obj,
    9821                 :                                             JSObject **plugin_proto)
    9822                 : {
    9823               0 :   *plugin_obj = nsnull;
    9824               0 :   *plugin_proto = nsnull;
    9825                 : 
    9826               0 :   JSAutoRequest ar(cx);
    9827                 : 
    9828                 :   // NB: We need an AutoEnterCompartment because we can be called from
    9829                 :   // nsObjectFrame when the plugin loads after the JS object for our content
    9830                 :   // node has been created.
    9831               0 :   JSAutoEnterCompartment ac;
    9832               0 :   if (!ac.enter(cx, obj)) {
    9833               0 :     return NS_ERROR_UNEXPECTED;
    9834                 :   }
    9835                 : 
    9836               0 :   if (plugin_inst) {
    9837               0 :     plugin_inst->GetJSObject(cx, plugin_obj);
    9838               0 :     if (*plugin_obj) {
    9839               0 :       *plugin_proto = ::JS_GetPrototype(*plugin_obj);
    9840                 :     }
    9841                 :   }
    9842                 : 
    9843               0 :   return NS_OK;
    9844                 : }
    9845                 : 
    9846                 : NS_IMETHODIMP
    9847               0 : nsHTMLPluginObjElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
    9848                 :                                      JSContext *cx, JSObject *obj, jsid id,
    9849                 :                                      PRUint32 flags, JSObject **objp,
    9850                 :                                      bool *_retval)
    9851                 : {
    9852                 :   // Make sure the plugin instance is loaded and instantiated, if
    9853                 :   // possible.
    9854                 : 
    9855               0 :   nsRefPtr<nsNPAPIPluginInstance> pi;
    9856               0 :   nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
    9857               0 :   NS_ENSURE_SUCCESS(rv, rv);
    9858                 : 
    9859                 :   return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp,
    9860               0 :                                  _retval);
    9861                 : }
    9862                 :  
    9863                 : // Plugin helper
    9864                 : 
    9865                 : nsISupports*
    9866               0 : nsPluginSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
    9867                 :                       nsWrapperCache **aCache, nsresult *aResult)
    9868                 : {
    9869               0 :   nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
    9870                 : 
    9871               0 :   return plugin->GetItemAt(aIndex, aResult);
    9872                 : }
    9873                 : 
    9874                 : nsISupports*
    9875               0 : nsPluginSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
    9876                 :                          nsWrapperCache **aCache, nsresult *aResult)
    9877                 : {
    9878               0 :   nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
    9879                 : 
    9880               0 :   return plugin->GetNamedItem(aName, aResult);
    9881                 : }
    9882                 : 
    9883                 : 
    9884                 : // PluginArray helper
    9885                 : 
    9886                 : nsISupports*
    9887               0 : nsPluginArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
    9888                 :                            nsWrapperCache **aCache, nsresult *aResult)
    9889                 : {
    9890               0 :   nsPluginArray* array = nsPluginArray::FromSupports(aNative);
    9891                 : 
    9892               0 :   return array->GetItemAt(aIndex, aResult);
    9893                 : }
    9894                 : 
    9895                 : nsISupports*
    9896               0 : nsPluginArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
    9897                 :                               nsWrapperCache **aCache, nsresult *aResult)
    9898                 : {
    9899               0 :   nsPluginArray* array = nsPluginArray::FromSupports(aNative);
    9900                 : 
    9901               0 :   return array->GetNamedItem(aName, aResult);
    9902                 : }
    9903                 : 
    9904                 : 
    9905                 : // MimeTypeArray helper
    9906                 : 
    9907                 : nsISupports*
    9908               0 : nsMimeTypeArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
    9909                 :                              nsWrapperCache **aCache, nsresult *aResult)
    9910                 : {
    9911               0 :   nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
    9912                 : 
    9913               0 :   return array->GetItemAt(aIndex, aResult);
    9914                 : }
    9915                 : 
    9916                 : nsISupports*
    9917               0 : nsMimeTypeArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
    9918                 :                                 nsWrapperCache **aCache, nsresult *aResult)
    9919                 : {
    9920               0 :   nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
    9921                 : 
    9922               0 :   return array->GetNamedItem(aName, aResult);
    9923                 : }
    9924                 : 
    9925                 : 
    9926                 : // StringArray helper
    9927                 : 
    9928                 : NS_IMETHODIMP
    9929               2 : nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    9930                 :                              JSObject *obj, jsid id, jsval *vp,
    9931                 :                              bool *_retval)
    9932                 : {
    9933               2 :   bool is_number = false;
    9934               2 :   PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
    9935                 : 
    9936               2 :   if (!is_number) {
    9937               0 :     return NS_OK;
    9938                 :   }
    9939                 : 
    9940               4 :   nsAutoString val;
    9941                 : 
    9942               2 :   nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
    9943               2 :   NS_ENSURE_SUCCESS(rv, rv);
    9944                 : 
    9945               4 :   JSAutoRequest ar(cx);
    9946                 : 
    9947               2 :   if (DOMStringIsNull(val)) {
    9948               0 :     *vp = JSVAL_VOID;
    9949                 :   } else {
    9950               2 :     nsStringBuffer* sharedBuffer = nsnull;
    9951               2 :     *vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer);
    9952               2 :     if (sharedBuffer) {
    9953               2 :       val.ForgetSharedBuffer();
    9954                 :     }
    9955                 :   }
    9956                 : 
    9957               2 :   return NS_SUCCESS_I_DID_SOMETHING;
    9958                 : }
    9959                 : 
    9960                 : 
    9961                 : // History helper
    9962                 : 
    9963                 : NS_IMETHODIMP
    9964               0 : nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,
    9965                 :                        JSObject *globalObj, JSObject **parentObj)
    9966                 : {
    9967               0 :   nsHistory *history = (nsHistory *)((nsIDOMHistory*)nativeObj);
    9968               0 :   nsCOMPtr<nsPIDOMWindow> innerWindow;
    9969               0 :   history->GetWindow(getter_AddRefs(innerWindow));
    9970               0 :   if (!innerWindow) {
    9971               0 :     NS_WARNING("refusing to create history object in the wrong scope");
    9972               0 :     return NS_ERROR_FAILURE;
    9973                 :   }
    9974                 : 
    9975               0 :   *parentObj = static_cast<nsGlobalWindow *>(innerWindow.get())->FastGetGlobalJSObject();
    9976               0 :   return NS_OK;
    9977                 : }
    9978                 : 
    9979                 : NS_IMETHODIMP
    9980               0 : nsHistorySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
    9981                 :                          JSObject *obj, jsid id, jsval *vp, bool *_retval)
    9982                 : {
    9983               0 :   bool is_number = false;
    9984               0 :   GetArrayIndexFromId(cx, id, &is_number);
    9985                 : 
    9986               0 :   if (!is_number) {
    9987               0 :     return NS_OK;
    9988                 :   }
    9989                 : 
    9990               0 :   return nsStringArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
    9991                 : }
    9992                 : 
    9993                 : nsresult
    9994               0 : nsHistorySH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
    9995                 :                          nsAString& aResult)
    9996                 : {
    9997               0 :   if (aIndex < 0) {
    9998               0 :     return NS_ERROR_DOM_INDEX_SIZE_ERR;
    9999                 :   }
   10000                 : 
   10001               0 :   nsCOMPtr<nsIDOMHistory> history(do_QueryInterface(aNative));
   10002                 : 
   10003               0 :   nsresult rv = history->Item(aIndex, aResult);
   10004                 : #ifdef DEBUG
   10005               0 :   if (DOMStringIsNull(aResult)) {
   10006               0 :     PRInt32 length = 0;
   10007               0 :     history->GetLength(&length);
   10008               0 :     NS_ASSERTION(aIndex >= length, "Item should only return null for out-of-bounds access");
   10009                 :   }
   10010                 : #endif
   10011               0 :   return rv;
   10012                 : }
   10013                 : 
   10014                 : 
   10015                 : // MediaList helper
   10016                 : 
   10017                 : nsresult
   10018               0 : nsMediaListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
   10019                 :                            nsAString& aResult)
   10020                 : {
   10021               0 :   if (aIndex < 0) {
   10022               0 :     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   10023                 :   }
   10024                 : 
   10025               0 :   nsCOMPtr<nsIDOMMediaList> media_list(do_QueryInterface(aNative));
   10026                 : 
   10027               0 :   nsresult rv = media_list->Item(PRUint32(aIndex), aResult);
   10028                 : #ifdef DEBUG
   10029               0 :   if (DOMStringIsNull(aResult)) {
   10030               0 :     PRUint32 length = 0;
   10031               0 :     media_list->GetLength(&length);
   10032               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
   10033                 :   }
   10034                 : #endif
   10035               0 :   return rv;
   10036                 : }
   10037                 : 
   10038                 : 
   10039                 : // StyleSheetList helper
   10040                 : 
   10041                 : nsISupports*
   10042               0 : nsStyleSheetListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10043                 :                               nsWrapperCache **aCache, nsresult *rv)
   10044                 : {
   10045               0 :   nsDOMStyleSheetList* list = nsDOMStyleSheetList::FromSupports(aNative);
   10046                 : 
   10047               0 :   return list->GetItemAt(aIndex);
   10048                 : }
   10049                 : 
   10050                 : 
   10051                 : // CSSValueList helper
   10052                 : 
   10053                 : nsISupports*
   10054               0 : nsCSSValueListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10055                 :                             nsWrapperCache **aCache, nsresult *aResult)
   10056                 : {
   10057               0 :   nsDOMCSSValueList* list = nsDOMCSSValueList::FromSupports(aNative);
   10058                 : 
   10059               0 :   return list->GetItemAt(aIndex);
   10060                 : }
   10061                 : 
   10062                 : 
   10063                 : // CSSStyleDeclaration helper
   10064                 : 
   10065                 : NS_IMETHODIMP
   10066               0 : nsCSSStyleDeclSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
   10067                 :                             JSObject *globalObj, JSObject **parentObj)
   10068                 : {
   10069               0 :   nsWrapperCache* cache = nsnull;
   10070               0 :   CallQueryInterface(nativeObj, &cache);
   10071               0 :   if (!cache) {
   10072               0 :     return nsDOMClassInfo::PreCreate(nativeObj, cx, globalObj, parentObj);
   10073                 :   }
   10074                 : 
   10075               0 :   nsICSSDeclaration *declaration = static_cast<nsICSSDeclaration*>(nativeObj);
   10076               0 :   nsINode *native_parent = declaration->GetParentObject();
   10077               0 :   if (!native_parent) {
   10078               0 :     return NS_ERROR_FAILURE;
   10079                 :   }
   10080                 : 
   10081                 :   nsresult rv =
   10082               0 :     WrapNativeParent(cx, globalObj, native_parent, native_parent, parentObj);
   10083               0 :   NS_ENSURE_SUCCESS(rv, rv);
   10084                 : 
   10085               0 :   return NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
   10086                 : }
   10087                 : 
   10088                 : nsresult
   10089               0 : nsCSSStyleDeclSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
   10090                 :                               nsAString& aResult)
   10091                 : {
   10092               0 :   if (aIndex < 0) {
   10093               0 :     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   10094                 :   }
   10095                 : 
   10096               0 :   nsCOMPtr<nsIDOMCSSStyleDeclaration> style_decl(do_QueryInterface(aNative));
   10097                 : 
   10098               0 :   nsresult rv = style_decl->Item(PRUint32(aIndex), aResult);
   10099                 : #ifdef DEBUG
   10100               0 :   if (DOMStringIsNull(aResult)) {
   10101               0 :     PRUint32 length = 0;
   10102               0 :     style_decl->GetLength(&length);
   10103               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
   10104                 :   }
   10105                 : #endif
   10106               0 :   return rv;
   10107                 : }
   10108                 : 
   10109                 : 
   10110                 : // CSSRuleList scriptable helper
   10111                 : 
   10112                 : nsISupports*
   10113               0 : nsCSSRuleListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10114                 :                            nsWrapperCache **aCache, nsresult *aResult)
   10115                 : {
   10116               0 :   nsICSSRuleList* list = static_cast<nsICSSRuleList*>(aNative);
   10117                 : #ifdef DEBUG
   10118                 :   {
   10119               0 :     nsCOMPtr<nsICSSRuleList> list_qi = do_QueryInterface(aNative);
   10120                 : 
   10121                 :     // If this assertion fires the QI implementation for the object in
   10122                 :     // question doesn't use the nsICSSRuleList pointer as the nsISupports
   10123                 :     // pointer. That must be fixed, or we'll crash...
   10124               0 :     NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
   10125                 :   }
   10126                 : #endif
   10127                 : 
   10128               0 :   return list->GetItemAt(aIndex, aResult);
   10129                 : }
   10130                 : 
   10131                 : // ClientRectList scriptable helper
   10132                 : 
   10133                 : nsISupports*
   10134               0 : nsClientRectListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10135                 :                               nsWrapperCache **aCache, nsresult *aResult)
   10136                 : {
   10137               0 :   nsClientRectList* list = nsClientRectList::FromSupports(aNative);
   10138                 : 
   10139               0 :   return list->GetItemAt(aIndex);
   10140                 : }
   10141                 : 
   10142                 : // PaintRequestList scriptable helper
   10143                 : 
   10144                 : nsISupports*
   10145               0 : nsPaintRequestListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10146                 :                                 nsWrapperCache **aCache, nsresult *aResult)
   10147                 : {
   10148               0 :   nsPaintRequestList* list = nsPaintRequestList::FromSupports(aNative);
   10149                 : 
   10150               0 :   return list->GetItemAt(aIndex);
   10151                 : }
   10152                 : 
   10153                 : nsISupports*
   10154               0 : nsDOMTouchListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10155                 :                             nsWrapperCache **aCache, nsresult *aResult)
   10156                 : {
   10157               0 :   nsDOMTouchList* list = static_cast<nsDOMTouchList*>(aNative);
   10158               0 :   return list->GetItemAt(aIndex);
   10159                 : }
   10160                 : 
   10161                 : #ifdef MOZ_XUL
   10162                 : // TreeColumns helper
   10163                 : 
   10164                 : nsISupports*
   10165               0 : nsTreeColumnsSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10166                 :                            nsWrapperCache **aCache, nsresult *aResult)
   10167                 : {
   10168               0 :   nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
   10169                 : 
   10170               0 :   return columns->GetColumnAt(aIndex);
   10171                 : }
   10172                 : 
   10173                 : nsISupports*
   10174               0 : nsTreeColumnsSH::GetNamedItem(nsISupports *aNative,
   10175                 :                               const nsAString& aName,
   10176                 :                               nsWrapperCache **aCache,
   10177                 :                               nsresult *aResult)
   10178                 : {
   10179               0 :   nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
   10180                 : 
   10181               0 :   return columns->GetNamedColumn(aName);
   10182                 : }
   10183                 : #endif
   10184                 : 
   10185                 : 
   10186                 : // Storage scriptable helper
   10187                 : 
   10188                 : // One reason we need a newResolve hook is that in order for
   10189                 : // enumeration of storage object keys to work the keys we're
   10190                 : // enumerating need to exist on the storage object for the JS engine
   10191                 : // to find them.
   10192                 : 
   10193                 : NS_IMETHODIMP
   10194               0 : nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10195                 :                         JSObject *obj, jsid id, PRUint32 flags,
   10196                 :                         JSObject **objp, bool *_retval)
   10197                 : {
   10198               0 :   if (ObjectIsNativeWrapper(cx, obj)) {
   10199               0 :     return NS_OK;
   10200                 :   }
   10201                 : 
   10202                 :   JSObject *realObj;
   10203               0 :   wrapper->GetJSObject(&realObj);
   10204                 : 
   10205               0 :   JSAutoEnterCompartment ac;
   10206               0 :   if (!ac.enter(cx, realObj)) {
   10207               0 :     *_retval = false;
   10208               0 :     return NS_ERROR_FAILURE;
   10209                 :   }
   10210                 : 
   10211                 :   // First check to see if the property is defined on our prototype.
   10212                 : 
   10213               0 :   JSObject *proto = ::JS_GetPrototype(realObj);
   10214                 :   JSBool hasProp;
   10215                 : 
   10216               0 :   if (proto &&
   10217               0 :       (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
   10218                 :        hasProp)) {
   10219                 :     // We found the property we're resolving on the prototype,
   10220                 :     // nothing left to do here then.
   10221                 : 
   10222               0 :     return NS_OK;
   10223                 :   }
   10224                 : 
   10225                 :   // We're resolving property that doesn't exist on the prototype,
   10226                 :   // check if the key exists in the storage object.
   10227                 : 
   10228               0 :   nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
   10229                 : 
   10230               0 :   JSString *jsstr = IdToString(cx, id);
   10231               0 :   if (!jsstr)
   10232               0 :     return JS_FALSE;
   10233                 : 
   10234               0 :   nsDependentJSString depStr;
   10235               0 :   if (!depStr.init(cx, jsstr))
   10236               0 :     return JS_FALSE;
   10237                 : 
   10238                 :   // GetItem() will return null if the caller can't access the session
   10239                 :   // storage item.
   10240               0 :   nsCOMPtr<nsIDOMStorageItem> item;
   10241               0 :   nsresult rv = storage->GetItem(depStr, getter_AddRefs(item));
   10242               0 :   NS_ENSURE_SUCCESS(rv, rv);
   10243                 : 
   10244               0 :   if (item) {
   10245               0 :     if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull, nsnull,
   10246               0 :                                  JSPROP_ENUMERATE)) {
   10247               0 :       return NS_ERROR_FAILURE;
   10248                 :     }
   10249                 : 
   10250               0 :     *objp = realObj;
   10251                 :   }
   10252                 : 
   10253               0 :   return NS_OK;
   10254                 : }
   10255                 : 
   10256                 : nsISupports*
   10257               0 : nsStorageSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
   10258                 :                           nsWrapperCache **aCache, nsresult *aResult)
   10259                 : {
   10260               0 :   nsDOMStorage* storage = nsDOMStorage::FromSupports(aNative);
   10261                 : 
   10262               0 :   return storage->GetNamedItem(aName, aResult);
   10263                 : }
   10264                 : 
   10265                 : NS_IMETHODIMP
   10266               0 : nsStorageSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
   10267                 :                          JSContext *cx, JSObject *obj, jsid id,
   10268                 :                          jsval *vp, bool *_retval)
   10269                 : {
   10270               0 :   nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
   10271               0 :   NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
   10272                 : 
   10273               0 :   JSString *key = IdToString(cx, id);
   10274               0 :   NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
   10275                 : 
   10276               0 :   nsDependentJSString keyStr;
   10277               0 :   NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
   10278                 : 
   10279               0 :   JSString *value = ::JS_ValueToString(cx, *vp);
   10280               0 :   NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
   10281                 : 
   10282               0 :   nsDependentJSString valueStr;
   10283               0 :   NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
   10284                 : 
   10285               0 :   nsresult rv = storage->SetItem(keyStr, valueStr);
   10286               0 :   if (NS_SUCCEEDED(rv)) {
   10287               0 :     rv = NS_SUCCESS_I_DID_SOMETHING;
   10288                 :   }
   10289                 : 
   10290               0 :   return rv;
   10291                 : }
   10292                 : 
   10293                 : NS_IMETHODIMP
   10294               0 : nsStorageSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
   10295                 :                          JSContext *cx, JSObject *obj, jsid id,
   10296                 :                          jsval *vp, bool *_retval)
   10297                 : {
   10298               0 :   nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
   10299               0 :   NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
   10300                 : 
   10301               0 :   JSString *key = IdToString(cx, id);
   10302               0 :   NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
   10303                 : 
   10304               0 :   nsDependentJSString keyStr;
   10305               0 :   NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
   10306                 : 
   10307               0 :   nsresult rv = storage->RemoveItem(keyStr);
   10308               0 :   if (NS_SUCCEEDED(rv)) {
   10309               0 :     rv = NS_SUCCESS_I_DID_SOMETHING;
   10310                 :   }
   10311                 : 
   10312               0 :   return rv;
   10313                 : }
   10314                 : 
   10315                 : 
   10316                 : NS_IMETHODIMP
   10317               0 : nsStorageSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10318                 :                           JSObject *obj, PRUint32 enum_op, jsval *statep,
   10319                 :                           jsid *idp, bool *_retval)
   10320                 : {
   10321               0 :   if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
   10322               0 :     nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10323                 : 
   10324                 :     // XXXndeakin need to free the keys afterwards
   10325               0 :     nsTArray<nsString> *keys = storage->GetKeys();
   10326               0 :     NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
   10327                 : 
   10328               0 :     *statep = PRIVATE_TO_JSVAL(keys);
   10329                 : 
   10330               0 :     if (idp) {
   10331               0 :       *idp = INT_TO_JSID(keys->Length());
   10332                 :     }
   10333               0 :     return NS_OK;
   10334                 :   }
   10335                 : 
   10336                 :   nsTArray<nsString> *keys =
   10337               0 :     (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
   10338                 : 
   10339               0 :   if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
   10340               0 :     nsString& key = keys->ElementAt(0);
   10341                 :     JSString *str =
   10342                 :       JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
   10343               0 :                                               (key.get()),
   10344               0 :                           key.Length());
   10345               0 :     NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
   10346                 : 
   10347               0 :     JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
   10348                 : 
   10349               0 :     keys->RemoveElementAt(0);
   10350                 : 
   10351               0 :     return NS_OK;
   10352                 :   }
   10353                 : 
   10354                 :   // destroy the keys array if we have no keys or if we're done
   10355               0 :   NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
   10356                 :                     (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
   10357                 :                     "Bad call from the JS engine");
   10358               0 :   delete keys;
   10359                 : 
   10360               0 :   *statep = JSVAL_NULL;
   10361                 : 
   10362               0 :   return NS_OK;
   10363                 : }
   10364                 : 
   10365                 : 
   10366                 : // Storage2SH
   10367                 : 
   10368                 : // One reason we need a newResolve hook is that in order for
   10369                 : // enumeration of storage object keys to work the keys we're
   10370                 : // enumerating need to exist on the storage object for the JS engine
   10371                 : // to find them.
   10372                 : 
   10373                 : NS_IMETHODIMP
   10374              80 : nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10375                 :                          JSObject *obj, jsid id, PRUint32 flags,
   10376                 :                          JSObject **objp, bool *_retval)
   10377                 : {
   10378              80 :   if (ObjectIsNativeWrapper(cx, obj)) {
   10379               0 :     return NS_OK;
   10380                 :   }
   10381                 : 
   10382                 :   JSObject *realObj;
   10383              80 :   wrapper->GetJSObject(&realObj);
   10384                 : 
   10385             160 :   JSAutoEnterCompartment ac;
   10386              80 :   if (!ac.enter(cx, realObj)) {
   10387               0 :     *_retval = false;
   10388               0 :     return NS_ERROR_FAILURE;
   10389                 :   }
   10390                 : 
   10391                 :   // First check to see if the property is defined on our prototype,
   10392                 :   // after converting id to a string if it's an integer.
   10393                 : 
   10394              80 :   JSString *jsstr = IdToString(cx, id);
   10395              80 :   if (!jsstr) {
   10396               0 :     return JS_FALSE;
   10397                 :   }
   10398                 : 
   10399              80 :   JSObject *proto = ::JS_GetPrototype(realObj);
   10400                 :   JSBool hasProp;
   10401                 : 
   10402             160 :   if (proto &&
   10403              80 :       (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
   10404                 :        hasProp)) {
   10405                 :     // We found the property we're resolving on the prototype,
   10406                 :     // nothing left to do here then.
   10407                 : 
   10408              80 :     return NS_OK;
   10409                 :   }
   10410                 : 
   10411                 :   // We're resolving property that doesn't exist on the prototype,
   10412                 :   // check if the key exists in the storage object.
   10413                 : 
   10414               0 :   nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10415                 : 
   10416               0 :   nsDependentJSString depStr;
   10417               0 :   NS_ENSURE_TRUE(depStr.init(cx, jsstr), NS_ERROR_UNEXPECTED);
   10418                 : 
   10419                 :   // GetItem() will return null if the caller can't access the session
   10420                 :   // storage item.
   10421               0 :   nsAutoString data;
   10422               0 :   nsresult rv = storage->GetItem(depStr, data);
   10423               0 :   NS_ENSURE_SUCCESS(rv, rv);
   10424                 : 
   10425               0 :   if (!DOMStringIsNull(data)) {
   10426               0 :     if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull,
   10427               0 :                                  nsnull, JSPROP_ENUMERATE)) {
   10428               0 :       return NS_ERROR_FAILURE;
   10429                 :     }
   10430                 : 
   10431               0 :     *objp = realObj;
   10432                 :   }
   10433                 : 
   10434               0 :   return NS_OK;
   10435                 : }
   10436                 : 
   10437                 : NS_IMETHODIMP
   10438               0 : nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10439                 :                           JSObject *obj, jsid id, jsval *vp, bool *_retval)
   10440                 : {
   10441               0 :   nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10442               0 :   NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
   10443                 : 
   10444               0 :   nsAutoString val;
   10445               0 :   nsresult rv = NS_OK;
   10446                 : 
   10447               0 :   if (JSID_IS_STRING(id)) {
   10448                 :     // For native wrappers, do not get random names on storage objects.
   10449               0 :     if (ObjectIsNativeWrapper(cx, obj)) {
   10450               0 :       return NS_ERROR_NOT_AVAILABLE;
   10451                 :     }
   10452                 : 
   10453               0 :     rv = storage->GetItem(nsDependentJSString(id), val);
   10454               0 :     NS_ENSURE_SUCCESS(rv, rv);
   10455                 :   } else {
   10456               0 :     PRInt32 n = GetArrayIndexFromId(cx, id);
   10457               0 :     NS_ENSURE_TRUE(n >= 0, NS_ERROR_NOT_AVAILABLE);
   10458                 : 
   10459               0 :     rv = storage->Key(n, val);
   10460               0 :     NS_ENSURE_SUCCESS(rv, rv);
   10461                 :   }
   10462                 : 
   10463               0 :   JSAutoRequest ar(cx);
   10464                 : 
   10465               0 :   if (DOMStringIsNull(val)) {
   10466               0 :       *vp = JSVAL_NULL;
   10467                 :   }
   10468                 :   else {
   10469                 :       JSString *str =
   10470               0 :         ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(val.get()),
   10471               0 :                               val.Length());
   10472               0 :       NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
   10473                 : 
   10474               0 :       *vp = STRING_TO_JSVAL(str);
   10475                 :   }
   10476                 : 
   10477               0 :   return NS_SUCCESS_I_DID_SOMETHING;
   10478                 : }
   10479                 : 
   10480                 : NS_IMETHODIMP
   10481               0 : nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
   10482                 :                           JSContext *cx, JSObject *obj, jsid id,
   10483                 :                           jsval *vp, bool *_retval)
   10484                 : {
   10485               0 :   nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10486               0 :   NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
   10487                 : 
   10488               0 :   JSString *key = IdToString(cx, id);
   10489               0 :   NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
   10490                 : 
   10491               0 :   nsDependentJSString keyStr;
   10492               0 :   NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
   10493                 : 
   10494               0 :   JSString *value = ::JS_ValueToString(cx, *vp);
   10495               0 :   NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
   10496                 : 
   10497               0 :   nsDependentJSString valueStr;
   10498               0 :   NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
   10499                 : 
   10500               0 :   nsresult rv = storage->SetItem(keyStr, valueStr);
   10501               0 :   if (NS_SUCCEEDED(rv)) {
   10502               0 :     rv = NS_SUCCESS_I_DID_SOMETHING;
   10503                 :   }
   10504                 : 
   10505               0 :   return rv;
   10506                 : }
   10507                 : 
   10508                 : NS_IMETHODIMP
   10509               0 : nsStorage2SH::DelProperty(nsIXPConnectWrappedNative *wrapper,
   10510                 :                           JSContext *cx, JSObject *obj, jsid id,
   10511                 :                           jsval *vp, bool *_retval)
   10512                 : {
   10513               0 :   nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10514               0 :   NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
   10515                 : 
   10516               0 :   JSString *key = IdToString(cx, id);
   10517               0 :   NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
   10518                 : 
   10519               0 :   nsDependentJSString keyStr;
   10520               0 :   NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
   10521                 : 
   10522               0 :   nsresult rv = storage->RemoveItem(keyStr);
   10523               0 :   if (NS_SUCCEEDED(rv)) {
   10524               0 :     rv = NS_SUCCESS_I_DID_SOMETHING;
   10525                 :   }
   10526                 : 
   10527               0 :   return rv;
   10528                 : }
   10529                 : 
   10530                 : 
   10531                 : NS_IMETHODIMP
   10532               0 : nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10533                 :                            JSObject *obj, PRUint32 enum_op, jsval *statep,
   10534                 :                            jsid *idp, bool *_retval)
   10535                 : {
   10536               0 :   if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
   10537               0 :     nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
   10538                 : 
   10539                 :     // XXXndeakin need to free the keys afterwards
   10540               0 :     nsTArray<nsString> *keys = storage->GetKeys();
   10541               0 :     NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
   10542                 : 
   10543               0 :     *statep = PRIVATE_TO_JSVAL(keys);
   10544                 : 
   10545               0 :     if (idp) {
   10546               0 :       *idp = INT_TO_JSID(keys->Length());
   10547                 :     }
   10548               0 :     return NS_OK;
   10549                 :   }
   10550                 : 
   10551                 :   nsTArray<nsString> *keys =
   10552               0 :     (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
   10553                 : 
   10554               0 :   if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
   10555               0 :     nsString& key = keys->ElementAt(0);
   10556                 :     JSString *str =
   10557                 :       JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
   10558               0 :                                               (key.get()),
   10559               0 :                           key.Length());
   10560               0 :     NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
   10561                 : 
   10562               0 :     JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
   10563                 : 
   10564               0 :     keys->RemoveElementAt(0);
   10565                 : 
   10566               0 :     return NS_OK;
   10567                 :   }
   10568                 : 
   10569                 :   // destroy the keys array if we have no keys or if we're done
   10570               0 :   NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
   10571                 :                     (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
   10572                 :                     "Bad call from the JS engine");
   10573               0 :   delete keys;
   10574                 : 
   10575               0 :   *statep = JSVAL_NULL;
   10576                 : 
   10577               0 :   return NS_OK;
   10578                 : }
   10579                 : 
   10580                 : // StorageList scriptable helper
   10581                 : 
   10582                 : nsISupports*
   10583               0 : nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
   10584                 :                               nsWrapperCache **aCache, nsresult *aResult)
   10585                 : {
   10586               0 :   nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
   10587                 : 
   10588               0 :   return storagelist->GetNamedItem(aName, aResult);
   10589                 : }
   10590                 : 
   10591                 : 
   10592                 : // nsIDOMEventListener::HandleEvent() 'this' converter helper
   10593                 : 
   10594             306 : NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
   10595             306 :   NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
   10596               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
   10597               0 : NS_INTERFACE_MAP_END
   10598                 : 
   10599                 : 
   10600             918 : NS_IMPL_ADDREF(nsEventListenerThisTranslator)
   10601             917 : NS_IMPL_RELEASE(nsEventListenerThisTranslator)
   10602                 : 
   10603                 : 
   10604                 : NS_IMETHODIMP
   10605            3965 : nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
   10606                 :                                              nsIInterfaceInfo *aInterfaceInfo,
   10607                 :                                              PRUint16 aMethodIndex,
   10608                 :                                              bool *aHideFirstParamFromJS,
   10609                 :                                              nsIID * *aIIDOfResult,
   10610                 :                                              nsISupports **_retval)
   10611                 : {
   10612            3965 :   *aHideFirstParamFromJS = false;
   10613            3965 :   *aIIDOfResult = nsnull;
   10614                 : 
   10615            7930 :   nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
   10616            3965 :   NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
   10617                 : 
   10618            7930 :   nsCOMPtr<nsIDOMEventTarget> target;
   10619            3965 :   event->GetCurrentTarget(getter_AddRefs(target));
   10620                 : 
   10621            3965 :   *_retval = target.forget().get();
   10622                 : 
   10623            3965 :   return NS_OK;
   10624                 : }
   10625                 : 
   10626                 : NS_IMETHODIMP
   10627               0 : nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
   10628                 :                               JSObject *globalObj, JSObject **parentObj)
   10629                 : {
   10630               0 :   nsDOMConstructor *wrapped = static_cast<nsDOMConstructor *>(nativeObj);
   10631                 : 
   10632                 : #ifdef DEBUG
   10633                 :   {
   10634                 :     nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
   10635               0 :       do_QueryInterface(nativeObj);
   10636               0 :     NS_ASSERTION(is_constructor, "How did we not get a constructor?");
   10637                 :   }
   10638                 : #endif
   10639                 : 
   10640               0 :   return wrapped->PreCreate(cx, globalObj, parentObj);
   10641                 : }
   10642                 : 
   10643                 : NS_IMETHODIMP
   10644               0 : nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10645                 :                                JSObject *obj, jsid id, PRUint32 flags,
   10646                 :                                JSObject **objp, bool *_retval)
   10647                 : {
   10648                 :   // For regular DOM constructors, we have our interface constants defined on
   10649                 :   // us by nsWindowSH::GlobalResolve. However, XrayWrappers can't see these
   10650                 :   // interface constants (as they look like expando properties) so we have to
   10651                 :   // specially resolve those constants here, but only for Xray wrappers.
   10652               0 :   if (!ObjectIsNativeWrapper(cx, obj)) {
   10653               0 :     return NS_OK;
   10654                 :   }
   10655                 : 
   10656               0 :   JSObject *nativePropsObj = xpc::XrayUtils::GetNativePropertiesObject(cx, obj);
   10657                 :   nsDOMConstructor *wrapped =
   10658               0 :     static_cast<nsDOMConstructor *>(wrapper->Native());
   10659               0 :   nsresult rv = wrapped->ResolveInterfaceConstants(cx, nativePropsObj);
   10660               0 :   NS_ENSURE_SUCCESS(rv, rv);
   10661                 : 
   10662                 :   // Now re-lookup the ID to see if we should report back that we resolved the
   10663                 :   // looked-for constant. Note that we don't have to worry about infinitely
   10664                 :   // recurring back here because the Xray wrapper's holder object doesn't call
   10665                 :   // NewResolve hooks.
   10666                 :   JSBool found;
   10667               0 :   if (!JS_HasPropertyById(cx, nativePropsObj, id, &found)) {
   10668               0 :     *_retval = PR_FALSE;
   10669               0 :     return NS_OK;
   10670                 :   }
   10671                 : 
   10672               0 :   if (found) {
   10673               0 :     *objp = obj;
   10674                 :   }
   10675               0 :   return NS_OK;
   10676                 : }
   10677                 : 
   10678                 : NS_IMETHODIMP
   10679               0 : nsDOMConstructorSH::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10680                 :                          JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
   10681                 :                          bool *_retval)
   10682                 : {
   10683                 :   nsDOMConstructor *wrapped =
   10684               0 :     static_cast<nsDOMConstructor *>(wrapper->Native());
   10685                 : 
   10686                 : #ifdef DEBUG
   10687                 :   {
   10688                 :     nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
   10689               0 :       do_QueryWrappedNative(wrapper);
   10690               0 :     NS_ASSERTION(is_constructor, "How did we not get a constructor?");
   10691                 :   }
   10692                 : #endif
   10693                 : 
   10694               0 :   return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
   10695                 : }
   10696                 : 
   10697                 : NS_IMETHODIMP
   10698               0 : nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
   10699                 :                               JSObject *obj, PRUint32 argc, jsval *argv,
   10700                 :                               jsval *vp, bool *_retval)
   10701                 : {
   10702                 :   nsDOMConstructor *wrapped =
   10703               0 :     static_cast<nsDOMConstructor *>(wrapper->Native());
   10704                 : 
   10705                 : #ifdef DEBUG
   10706                 :   {
   10707                 :     nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
   10708               0 :       do_QueryWrappedNative(wrapper);
   10709               0 :     NS_ASSERTION(is_constructor, "How did we not get a constructor?");
   10710                 :   }
   10711                 : #endif
   10712                 : 
   10713               0 :   return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
   10714                 : }
   10715                 : 
   10716                 : NS_IMETHODIMP
   10717               0 : nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
   10718                 :                                 JSContext *cx, JSObject *obj, const jsval &val,
   10719                 :                                 bool *bp, bool *_retval)
   10720                 : {
   10721                 :   nsDOMConstructor *wrapped =
   10722               0 :     static_cast<nsDOMConstructor *>(wrapper->Native());
   10723                 : 
   10724                 : #ifdef DEBUG
   10725                 :   {
   10726                 :     nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
   10727               0 :       do_QueryWrappedNative(wrapper);
   10728               0 :     NS_ASSERTION(is_constructor, "How did we not get a constructor?");
   10729                 :   }
   10730                 : #endif
   10731                 : 
   10732               0 :   return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
   10733                 : }
   10734                 : 
   10735                 : NS_IMETHODIMP
   10736               0 : nsNonDOMObjectSH::GetFlags(PRUint32 *aFlags)
   10737                 : {
   10738                 :   // This is NOT a DOM Object.  Use this helper class for cases when you need
   10739                 :   // to do something like implement nsISecurityCheckedComponent in a meaningful
   10740                 :   // way.
   10741               0 :   *aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
   10742               0 :   return NS_OK;
   10743                 : }
   10744                 : 
   10745                 : NS_IMETHODIMP
   10746             996 : nsAttributeSH::GetFlags(PRUint32 *aFlags)
   10747                 : {
   10748                 :   // Just like nsNodeSH, but without CONTENT_NODE
   10749             996 :   *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
   10750                 : 
   10751             996 :   return NS_OK;
   10752                 : }
   10753                 : 
   10754                 : // nsOfflineResourceListSH
   10755                 : nsresult
   10756               0 : nsOfflineResourceListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
   10757                 :                                      nsAString& aResult)
   10758                 : {
   10759               0 :   nsCOMPtr<nsIDOMOfflineResourceList> list(do_QueryInterface(aNative));
   10760               0 :   NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
   10761                 : 
   10762               0 :   nsresult rv = list->MozItem(aIndex, aResult);
   10763                 : #ifdef DEBUG
   10764               0 :   if (DOMStringIsNull(aResult)) {
   10765               0 :     PRUint32 length = 0;
   10766               0 :     list->GetMozLength(&length);
   10767               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "MozItem should only return null for out-of-bounds access");
   10768                 :   }
   10769                 : #endif
   10770               0 :   return rv;
   10771                 : }
   10772                 : 
   10773                 : // nsFileListSH
   10774                 : nsISupports*
   10775               0 : nsFileListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
   10776                 :                         nsWrapperCache **aCache, nsresult *aResult)
   10777                 : {
   10778               0 :   nsDOMFileList* list = nsDOMFileList::FromSupports(aNative);
   10779                 : 
   10780               0 :   return list->GetItemAt(aIndex);
   10781                 : }
   10782                 : 
   10783                 : // Template for SVGXXXList helpers
   10784                 : template<class ListInterfaceType, class ListType> nsISupports*
   10785                 : nsSVGListSH<ListInterfaceType, ListType>::GetItemAt(nsISupports *aNative,
   10786                 :                                                     PRUint32 aIndex,
   10787                 :                                                     nsWrapperCache **aCache,
   10788                 :                                                     nsresult *aResult)
   10789                 : {
   10790               0 :   ListType* list = static_cast<ListType*>(static_cast<ListInterfaceType*>(aNative));
   10791                 : #ifdef DEBUG
   10792                 :   {
   10793               0 :     nsCOMPtr<ListInterfaceType> list_qi = do_QueryInterface(aNative);
   10794                 : 
   10795                 :     // If this assertion fires the QI implementation for the object in
   10796                 :     // question doesn't use the nsIDOMSVGXXXList pointer as the nsISupports
   10797                 :     // pointer. That must be fixed, or we'll crash...
   10798               0 :     NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
   10799                 :   }
   10800                 : #endif
   10801                 : 
   10802               0 :   return list->GetItemAt(aIndex);
   10803                 : }
   10804                 : 
   10805                 : 
   10806                 : // SVGStringList helper
   10807                 : 
   10808                 : nsresult
   10809               0 : nsSVGStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
   10810                 :                                nsAString& aResult)
   10811                 : {
   10812               0 :   if (aIndex < 0) {
   10813               0 :     SetDOMStringToNull(aResult);
   10814               0 :     return NS_OK;
   10815                 :   }
   10816                 : 
   10817                 :   DOMSVGStringList* list = static_cast<DOMSVGStringList*>(
   10818               0 :                              static_cast<nsIDOMSVGStringList*>(aNative));
   10819                 : #ifdef DEBUG
   10820                 :   {
   10821               0 :     nsCOMPtr<nsIDOMSVGStringList> list_qi = do_QueryInterface(aNative);
   10822                 :     
   10823                 :     // If this assertion fires the QI implementation for the object in
   10824                 :     // question doesn't use the nsIDOMDOMSVGStringList pointer as the
   10825                 :     // nsISupports pointer. That must be fixed, or we'll crash...
   10826               0 :     NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
   10827                 :   }
   10828                 : #endif
   10829                 : 
   10830               0 :   nsresult rv = list->GetItem(aIndex, aResult);
   10831                 : #ifdef DEBUG
   10832               0 :   if (DOMStringIsNull(aResult)) {
   10833               0 :     PRUint32 length = 0;
   10834               0 :     list->GetLength(&length);
   10835               0 :     NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
   10836                 :   }
   10837                 : #endif
   10838               0 :   if (rv == NS_ERROR_DOM_INDEX_SIZE_ERR) {
   10839               0 :     SetDOMStringToNull(aResult);
   10840               0 :     rv = NS_OK;
   10841                 :   }
   10842               0 :   return rv;
   10843            4392 : }
   10844                 : 
   10845                 : 

Generated by: LCOV version 1.7