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

Generated by: LCOV version 1.7