Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-12-09 19:08:45 +00:00
|
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
#include "mozilla/Util.h"
|
2012-03-14 10:10:48 +00:00
|
|
|
// On top because they include basictypes.h:
|
2013-03-01 08:38:47 +00:00
|
|
|
#include "mozilla/dom/SmsFilter.h"
|
2012-01-17 18:48:58 +00:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#undef GetClassName
|
|
|
|
#endif
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2010-03-13 19:35:27 +00:00
|
|
|
// JavaScript includes
|
|
|
|
#include "jsapi.h"
|
2012-01-15 08:13:09 +00:00
|
|
|
#include "jsfriendapi.h"
|
2010-03-13 19:35:27 +00:00
|
|
|
#include "jsprvtd.h" // we are using private JS typedefs...
|
|
|
|
#include "jsdbgapi.h"
|
2010-10-10 22:41:27 +00:00
|
|
|
#include "WrapperFactory.h"
|
2010-10-10 22:42:15 +00:00
|
|
|
#include "AccessCheck.h"
|
2012-04-14 13:05:17 +00:00
|
|
|
#include "XrayWrapper.h"
|
2010-03-13 19:35:27 +00:00
|
|
|
|
2012-04-14 13:05:17 +00:00
|
|
|
#include "xpcpublic.h"
|
2011-05-20 17:23:49 +00:00
|
|
|
#include "xpcprivate.h"
|
2011-08-31 22:10:16 +00:00
|
|
|
#include "XPCWrapper.h"
|
2012-06-04 19:41:51 +00:00
|
|
|
#include "XPCQuickStubs.h"
|
|
|
|
#include "nsDOMQS.h"
|
2011-05-20 17:23:49 +00:00
|
|
|
|
2012-05-03 04:35:38 +00:00
|
|
|
#include "mozilla/dom/RegisterBindings.h"
|
2012-03-31 04:42:20 +00:00
|
|
|
|
2001-09-01 03:30:51 +00:00
|
|
|
#include "nscore.h"
|
2001-04-01 01:10:59 +00:00
|
|
|
#include "nsDOMClassInfo.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsCRT.h"
|
2006-11-12 15:15:37 +00:00
|
|
|
#include "nsCRTGlue.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2002-03-04 02:25:08 +00:00
|
|
|
#include "nsICategoryManager.h"
|
2002-04-16 11:57:17 +00:00
|
|
|
#include "nsIComponentRegistrar.h"
|
2002-09-03 23:36:13 +00:00
|
|
|
#include "nsXPCOM.h"
|
2002-03-04 02:25:08 +00:00
|
|
|
#include "nsISupportsPrimitives.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsIXPCSecurityManager.h"
|
2004-07-23 00:26:02 +00:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2004-08-18 22:19:45 +00:00
|
|
|
#include "nsIScriptError.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsReadableUtils.h"
|
2004-05-21 23:31:37 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "xptcall.h"
|
2003-09-19 08:43:14 +00:00
|
|
|
#include "prprf.h"
|
2006-05-19 05:57:36 +00:00
|
|
|
#include "nsTArray.h"
|
2007-07-18 21:56:57 +00:00
|
|
|
#include "nsCSSValue.h"
|
2008-03-14 23:08:57 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2012-02-08 02:53:33 +00:00
|
|
|
#include "nsDOMEventTargetHelper.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// General helper includes
|
2005-07-30 20:57:07 +00:00
|
|
|
#include "nsGlobalWindow.h"
|
2010-10-29 19:49:32 +00:00
|
|
|
#include "nsHistory.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIDOMEvent.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
2004-07-23 00:26:02 +00:00
|
|
|
#include "nsContentUtils.h"
|
2013-05-22 16:05:26 +00:00
|
|
|
#include "nsCxPusher.h"
|
2005-10-21 22:30:36 +00:00
|
|
|
#include "nsDOMWindowUtils.h"
|
2010-11-09 23:00:01 +00:00
|
|
|
#include "nsIDOMGlobalPropertyInitializer.h"
|
2011-05-25 06:31:59 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-08-03 04:22:40 +00:00
|
|
|
#include "nsLocation.h"
|
2012-06-15 02:31:55 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-03-04 19:08:23 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// Window scriptable helper includes
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
|
|
|
#include "nsIScriptExternalNameSet.h"
|
|
|
|
#include "nsJSUtils.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsScriptNameSpaceManager.h"
|
|
|
|
#include "nsIJSNativeInitializer.h"
|
2007-11-13 10:35:49 +00:00
|
|
|
#include "nsJSEnvironment.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// DOM base includes
|
|
|
|
#include "nsIDOMLocation.h"
|
2011-07-15 10:31:34 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2004-08-26 03:49:17 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "nsIDOMJSWindow.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIDOMWindowCollection.h"
|
|
|
|
#include "nsIDOMHistory.h"
|
|
|
|
#include "nsIDOMMediaList.h"
|
2002-02-09 03:36:55 +00:00
|
|
|
#include "nsIDOMChromeWindow.h"
|
2005-12-09 19:08:45 +00:00
|
|
|
#include "nsIDOMConstructor.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// DOM core includes
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2002-04-10 13:38:30 +00:00
|
|
|
#include "nsIDOMDOMException.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIDOMNode.h"
|
2003-10-16 00:44:20 +00:00
|
|
|
#include "nsIDOMDOMStringList.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// Event related includes
|
2011-06-24 02:18:01 +00:00
|
|
|
#include "nsEventListenerManager.h"
|
2007-05-14 09:11:38 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// CSS related includes
|
2012-08-02 00:32:12 +00:00
|
|
|
#include "nsCSSRules.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIDOMStyleSheet.h"
|
|
|
|
#include "nsIDOMStyleSheetList.h"
|
2001-05-13 22:16:45 +00:00
|
|
|
#include "nsIDOMCSSRule.h"
|
2008-10-22 14:31:14 +00:00
|
|
|
#include "nsICSSRuleList.h"
|
2002-01-11 00:15:55 +00:00
|
|
|
#include "nsIDOMRect.h"
|
2009-07-13 11:14:57 +00:00
|
|
|
#include "nsDOMCSSAttrDeclaration.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// XBL related includes.
|
2012-05-23 18:46:04 +00:00
|
|
|
#include "nsXBLService.h"
|
2005-02-25 22:07:01 +00:00
|
|
|
#include "nsXBLBinding.h"
|
2007-02-16 23:02:08 +00:00
|
|
|
#include "nsBindingManager.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2004-07-26 21:49:49 +00:00
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2005-11-18 13:39:43 +00:00
|
|
|
#include "nsMemory.h"
|
|
|
|
|
|
|
|
// Tranformiix
|
|
|
|
#include "nsIDOMXPathEvaluator.h"
|
|
|
|
#include "nsIXSLTProcessor.h"
|
2006-07-06 00:33:24 +00:00
|
|
|
#include "nsIXSLTProcessorPrivate.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2008-11-13 16:54:52 +00:00
|
|
|
#include "nsXMLHttpRequest.h"
|
2012-06-14 17:13:12 +00:00
|
|
|
#include "nsIDOMContactManager.h"
|
2012-09-19 18:19:00 +00:00
|
|
|
#include "nsIDOMPermissionSettings.h"
|
2012-06-14 23:03:55 +00:00
|
|
|
#include "nsIDOMApplicationRegistry.h"
|
2006-04-26 09:19:48 +00:00
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
// includes needed for the prototype chain interfaces
|
|
|
|
#include "nsIDOMDocumentXBL.h"
|
|
|
|
#include "nsIDOMElementCSSInlineStyle.h"
|
|
|
|
#include "nsIDOMLinkStyle.h"
|
|
|
|
#include "nsIDOMHTMLDocument.h"
|
|
|
|
#include "nsIDOMCSSCharsetRule.h"
|
|
|
|
#include "nsIDOMCSSImportRule.h"
|
|
|
|
#include "nsIDOMCSSMediaRule.h"
|
2008-08-10 21:13:49 +00:00
|
|
|
#include "nsIDOMCSSFontFaceRule.h"
|
2004-08-05 18:26:14 +00:00
|
|
|
#include "nsIDOMCSSMozDocumentRule.h"
|
2012-08-02 00:32:12 +00:00
|
|
|
#include "nsIDOMCSSSupportsRule.h"
|
2011-04-12 06:18:43 +00:00
|
|
|
#include "nsIDOMMozCSSKeyframeRule.h"
|
|
|
|
#include "nsIDOMMozCSSKeyframesRule.h"
|
2012-08-31 21:21:28 +00:00
|
|
|
#include "nsIDOMCSSPageRule.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "nsIDOMCSSStyleRule.h"
|
|
|
|
#include "nsIDOMCSSStyleSheet.h"
|
2013-05-20 19:34:12 +00:00
|
|
|
#include "nsIDOMDeviceMotionEvent.h" //nsIDOMDeviceAcceleration
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "nsIDOMXULCommandDispatcher.h"
|
2013-02-17 04:43:16 +00:00
|
|
|
#ifndef MOZ_DISABLE_CRYPTOLEGACY
|
2013-02-16 07:33:45 +00:00
|
|
|
#include "nsIDOMCRMFObject.h"
|
2013-02-17 04:43:16 +00:00
|
|
|
#include "nsIDOMCryptoLegacy.h"
|
|
|
|
#else
|
|
|
|
#include "nsIDOMCrypto.h"
|
|
|
|
#endif
|
2001-07-11 09:09:30 +00:00
|
|
|
#include "nsIControllers.h"
|
|
|
|
#include "nsISelection.h"
|
|
|
|
#include "nsIBoxObject.h"
|
2003-04-11 00:56:27 +00:00
|
|
|
#ifdef MOZ_XUL
|
2002-03-29 02:46:01 +00:00
|
|
|
#include "nsITreeSelection.h"
|
|
|
|
#include "nsITreeContentView.h"
|
|
|
|
#include "nsITreeView.h"
|
2003-07-08 21:10:52 +00:00
|
|
|
#include "nsIXULTemplateBuilder.h"
|
2008-10-22 14:31:14 +00:00
|
|
|
#include "nsTreeColumns.h"
|
2003-04-11 00:56:27 +00:00
|
|
|
#endif
|
2005-11-18 13:39:43 +00:00
|
|
|
#include "nsIDOMXPathExpression.h"
|
|
|
|
#include "nsIDOMNSXPathExpression.h"
|
|
|
|
#include "nsIDOMXPathNSResolver.h"
|
|
|
|
#include "nsIDOMXPathResult.h"
|
2012-01-20 17:02:48 +00:00
|
|
|
#include "nsIDOMMozBrowserFrame.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
#include "nsIDOMSVGLength.h"
|
2004-07-25 20:03:55 +00:00
|
|
|
#include "nsIDOMSVGNumber.h"
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2006-05-19 05:57:36 +00:00
|
|
|
// Storage includes
|
2013-04-15 12:38:48 +00:00
|
|
|
#include "DOMStorage.h"
|
2006-05-19 05:57:36 +00:00
|
|
|
|
2008-08-27 12:07:27 +00:00
|
|
|
// Drag and drop
|
|
|
|
#include "nsIDOMDataTransfer.h"
|
|
|
|
|
2008-07-15 23:37:48 +00:00
|
|
|
// Geolocation
|
2009-02-26 04:33:24 +00:00
|
|
|
#include "nsIDOMGeoPositionCoords.h"
|
2008-07-15 23:37:48 +00:00
|
|
|
|
2008-11-06 06:41:52 +00:00
|
|
|
// Workers
|
2011-07-17 19:09:13 +00:00
|
|
|
#include "mozilla/dom/workers/Workers.h"
|
2008-11-06 06:41:52 +00:00
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
#include "nsDOMFile.h"
|
2007-07-25 04:29:47 +00:00
|
|
|
|
2009-10-16 08:57:32 +00:00
|
|
|
#include "nsIEventListenerService.h"
|
2012-08-27 14:13:02 +00:00
|
|
|
#include "nsIMessageManager.h"
|
2010-05-05 18:18:05 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2010-04-30 13:12:06 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBRequest.h"
|
2010-06-28 16:46:49 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBDatabase.h"
|
2010-06-28 18:51:06 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
|
2010-06-28 16:46:21 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBTransaction.h"
|
2010-06-28 18:51:06 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBCursor.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
|
2010-06-28 18:51:06 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IDBIndex.h"
|
2010-06-23 19:46:08 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
using mozilla::dom::indexedDB::IDBWrapperCache;
|
2013-01-03 18:29:16 +00:00
|
|
|
using mozilla::dom::workers::ResolveWorkerClasses;
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2011-04-22 03:17:31 +00:00
|
|
|
#include "nsIDOMMediaQueryList.h"
|
|
|
|
|
2013-04-30 13:01:46 +00:00
|
|
|
#include "mozilla/dom/Activity.h"
|
|
|
|
|
2011-04-26 12:30:17 +00:00
|
|
|
#include "nsDOMTouchEvent.h"
|
|
|
|
|
2011-05-26 19:58:35 +00:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2012-09-05 20:49:53 +00:00
|
|
|
#include "mozilla/dom/HTMLCollectionBinding.h"
|
2011-05-26 19:58:35 +00:00
|
|
|
|
2011-11-03 23:31:32 +00:00
|
|
|
#include "BatteryManager.h"
|
2012-01-20 03:24:00 +00:00
|
|
|
#include "nsIDOMPowerManager.h"
|
2012-03-07 11:03:25 +00:00
|
|
|
#include "nsIDOMWakeLock.h"
|
2011-11-20 22:23:20 +00:00
|
|
|
#include "nsIDOMSmsManager.h"
|
2013-03-09 07:21:47 +00:00
|
|
|
#include "nsIDOMMobileMessageManager.h"
|
2013-02-07 10:43:22 +00:00
|
|
|
#include "nsIDOMMozSmsMessage.h"
|
2013-03-09 07:21:55 +00:00
|
|
|
#include "nsIDOMMozMmsMessage.h"
|
2012-01-17 18:48:58 +00:00
|
|
|
#include "nsIDOMSmsFilter.h"
|
2013-01-04 06:26:20 +00:00
|
|
|
#include "nsIDOMSmsSegmentInfo.h"
|
2013-04-09 16:37:54 +00:00
|
|
|
#include "nsIDOMMozMobileMessageThread.h"
|
2012-01-16 12:23:44 +00:00
|
|
|
#include "nsIDOMConnection.h"
|
2011-11-02 15:01:32 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
#include "Telephony.h"
|
|
|
|
#include "TelephonyCall.h"
|
2013-02-05 09:02:15 +00:00
|
|
|
#include "nsIDOMMozVoicemail.h"
|
2012-06-28 14:21:48 +00:00
|
|
|
#include "nsIDOMIccManager.h"
|
2012-12-04 02:38:25 +00:00
|
|
|
#include "nsIDOMMozCellBroadcast.h"
|
2013-02-07 11:02:12 +00:00
|
|
|
#include "nsIDOMMobileConnection.h"
|
2012-12-04 02:40:47 +00:00
|
|
|
#endif // MOZ_B2G_RIL
|
2012-01-09 22:28:47 +00:00
|
|
|
|
2012-09-19 15:23:33 +00:00
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
#include "FMRadio.h"
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
#ifdef MOZ_B2G_BT
|
2012-05-24 04:02:23 +00:00
|
|
|
#include "BluetoothManager.h"
|
2012-02-20 15:15:19 +00:00
|
|
|
#include "BluetoothAdapter.h"
|
2012-07-18 03:41:54 +00:00
|
|
|
#include "BluetoothDevice.h"
|
2012-02-20 15:15:19 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-30 21:59:05 +00:00
|
|
|
#include "DOMCameraManager.h"
|
2012-09-05 01:01:56 +00:00
|
|
|
#include "DOMCameraControl.h"
|
|
|
|
#include "DOMCameraCapabilities.h"
|
2012-06-12 22:01:25 +00:00
|
|
|
#include "nsIOpenWindowEventDetail.h"
|
2012-12-25 06:09:34 +00:00
|
|
|
#include "nsIAsyncScrollEventDetail.h"
|
2012-06-12 22:01:25 +00:00
|
|
|
#include "nsIDOMGlobalObjectConstructor.h"
|
2012-10-22 17:08:52 +00:00
|
|
|
#include "nsIDOMCanvasRenderingContext2D.h"
|
2012-06-03 16:33:52 +00:00
|
|
|
#include "LockedFile.h"
|
2012-08-13 03:52:21 +00:00
|
|
|
#include "nsDebug.h"
|
2012-04-27 08:38:14 +00:00
|
|
|
|
2012-05-22 13:46:20 +00:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2012-03-26 18:59:04 +00:00
|
|
|
|
2012-12-22 08:17:05 +00:00
|
|
|
#ifdef MOZ_TIME_MANAGER
|
|
|
|
#include "TimeManager.h"
|
|
|
|
#endif
|
|
|
|
|
2011-05-25 06:31:59 +00:00
|
|
|
using namespace mozilla;
|
2011-04-07 22:44:03 +00:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2004-07-23 00:26:02 +00:00
|
|
|
static const char kDOMStringBundleURL[] =
|
2005-02-23 16:53:28 +00:00
|
|
|
"chrome://global/locale/dom/dom.properties";
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
// NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
|
|
|
|
// are defined in nsIDOMClassInfo.h.
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2010-09-17 21:54:40 +00:00
|
|
|
#define WINDOW_SCRIPTABLE_FLAGS \
|
2013-03-15 05:38:27 +00:00
|
|
|
(nsIXPCScriptable::WANT_PRECREATE | \
|
2007-02-24 06:57:20 +00:00
|
|
|
nsIXPCScriptable::WANT_FINALIZE | \
|
2011-04-08 20:28:05 +00:00
|
|
|
nsIXPCScriptable::WANT_ENUMERATE | \
|
2010-09-17 21:54:40 +00:00
|
|
|
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
|
2012-03-05 23:22:44 +00:00
|
|
|
nsIXPCScriptable::IS_GLOBAL_OBJECT | \
|
2010-09-17 21:54:40 +00:00
|
|
|
nsIXPCScriptable::WANT_OUTER_OBJECT)
|
2010-08-07 00:10:22 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#define ARRAY_SCRIPTABLE_FLAGS \
|
2005-10-04 05:50:42 +00:00
|
|
|
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
2003-09-19 08:43:14 +00:00
|
|
|
nsIXPCScriptable::WANT_GETPROPERTY | \
|
|
|
|
nsIXPCScriptable::WANT_ENUMERATE)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2008-11-13 16:54:52 +00:00
|
|
|
#define EVENTTARGET_SCRIPTABLE_FLAGS \
|
|
|
|
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
2009-03-24 11:02:23 +00:00
|
|
|
nsIXPCScriptable::WANT_ADDPROPERTY)
|
2008-11-13 16:54:52 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
#define IDBEVENTTARGET_SCRIPTABLE_FLAGS \
|
|
|
|
(EVENTTARGET_SCRIPTABLE_FLAGS)
|
|
|
|
|
2002-08-29 04:05:39 +00:00
|
|
|
#define DOMCLASSINFO_STANDARD_FLAGS \
|
2012-07-13 12:33:25 +00:00
|
|
|
(nsIClassInfo::MAIN_THREAD_ONLY | \
|
|
|
|
nsIClassInfo::DOM_OBJECT | \
|
|
|
|
nsIClassInfo::SINGLETON_CLASSINFO)
|
2002-08-29 04:05:39 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
|
|
|
eDOMClassInfo_##_class##_id,
|
|
|
|
#else
|
|
|
|
#define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
|
|
|
// nothing
|
|
|
|
#endif
|
|
|
|
|
2012-06-04 19:41:51 +00:00
|
|
|
/**
|
|
|
|
* To generate the bitmap for a class that we're sure doesn't implement any of
|
|
|
|
* the interfaces in DOMCI_CASTABLE_INTERFACES.
|
|
|
|
*/
|
|
|
|
#define DOMCI_DATA_NO_CLASS(_dom_class) \
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t kDOMClassInfo_##_dom_class##_interfaces = \
|
2012-06-04 19:41:51 +00:00
|
|
|
0;
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2013-02-17 04:43:16 +00:00
|
|
|
#ifndef MOZ_DISABLE_CRYPTOLEGACY
|
2013-02-16 07:33:45 +00:00
|
|
|
DOMCI_DATA_NO_CLASS(CRMFObject)
|
2013-02-17 04:43:16 +00:00
|
|
|
#endif
|
|
|
|
DOMCI_DATA_NO_CLASS(Crypto)
|
|
|
|
|
2012-06-04 19:41:51 +00:00
|
|
|
DOMCI_DATA_NO_CLASS(ContentFrameMessageManager)
|
2012-08-27 14:13:02 +00:00
|
|
|
DOMCI_DATA_NO_CLASS(ChromeMessageBroadcaster)
|
|
|
|
DOMCI_DATA_NO_CLASS(ChromeMessageSender)
|
2012-06-04 19:41:51 +00:00
|
|
|
|
|
|
|
DOMCI_DATA_NO_CLASS(DOMPrototype)
|
|
|
|
DOMCI_DATA_NO_CLASS(DOMConstructor)
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
#define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper, \
|
|
|
|
_flags) \
|
|
|
|
{ #_name, \
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, \
|
2002-03-04 03:42:57 +00:00
|
|
|
{ _helper::doCreate }, \
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, \
|
|
|
|
nullptr, \
|
|
|
|
nullptr, \
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
_flags, \
|
2011-10-17 14:59:28 +00:00
|
|
|
true, \
|
2010-01-12 14:24:00 +00:00
|
|
|
0, \
|
2011-10-17 14:59:28 +00:00
|
|
|
false, \
|
|
|
|
false, \
|
2010-04-20 16:44:56 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
|
|
|
},
|
|
|
|
|
|
|
|
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _name, \
|
|
|
|
_helper, _flags) \
|
|
|
|
{ #_name, \
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, \
|
2010-04-20 16:44:56 +00:00
|
|
|
{ _helper::doCreate }, \
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, \
|
|
|
|
nullptr, \
|
|
|
|
nullptr, \
|
2010-04-20 16:44:56 +00:00
|
|
|
_flags, \
|
2011-10-17 14:59:28 +00:00
|
|
|
true, \
|
2010-04-20 16:44:56 +00:00
|
|
|
0, \
|
2011-10-17 14:59:28 +00:00
|
|
|
true, \
|
|
|
|
false, \
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
|
|
|
},
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
|
|
|
|
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
|
|
|
|
|
2010-04-20 16:44:56 +00:00
|
|
|
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
|
|
|
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
|
|
|
|
_flags)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class IDBEventTargetSH : public nsEventTargetSH
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
IDBEventTargetSH(nsDOMClassInfoData* aData) : nsEventTargetSH(aData)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual ~IDBEventTargetSH()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_IMETHOD PreCreate(nsISupports *aNativeObj, JSContext *aCx,
|
|
|
|
JSObject *aGlobalObj, JSObject **aParentObj);
|
|
|
|
|
|
|
|
static nsIClassInfo *doCreate(nsDOMClassInfoData *aData)
|
|
|
|
{
|
|
|
|
return new IDBEventTargetSH(aData);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2012-06-04 19:41:51 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
|
|
|
|
// classes their correct behavior when used through XPConnect. The
|
|
|
|
// arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
|
|
|
|
//
|
|
|
|
// 1. Class name as it should appear in JavaScript, this name is also
|
|
|
|
// used to find the id of the class in nsDOMClassInfo
|
|
|
|
// (i.e. e<classname>_id)
|
2001-05-10 09:45:46 +00:00
|
|
|
// 2. Scriptable helper class
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// 3. nsIClassInfo/nsIXPCScriptable flags (i.e. for GetScriptableFlags)
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
static nsDOMClassInfoData sClassInfoData[] = {
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// Base classes
|
2001-07-24 22:39:11 +00:00
|
|
|
|
|
|
|
// The Window class lets you QI into interfaces that are not in the
|
|
|
|
// flattened set (i.e. nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY
|
|
|
|
// is not set), because of this make sure all scriptable interfaces
|
2004-12-10 19:48:22 +00:00
|
|
|
// that are implemented by nsGlobalWindow can securely be exposed
|
2001-07-24 22:39:11 +00:00
|
|
|
// to JS.
|
|
|
|
|
|
|
|
|
2010-09-17 21:54:40 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(Window, nsWindowSH,
|
2001-07-24 22:39:11 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS |
|
2010-09-17 21:54:40 +00:00
|
|
|
WINDOW_SCRIPTABLE_FLAGS)
|
2010-06-28 23:39:00 +00:00
|
|
|
|
2002-05-22 00:34:01 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
|
2012-11-21 21:20:05 +00:00
|
|
|
((DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
|
|
|
nsIXPCScriptable::WANT_ADDPROPERTY) &
|
2010-03-04 21:44:42 +00:00
|
|
|
~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
|
2002-05-22 00:34:01 +00:00
|
|
|
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
|
2010-10-29 19:49:32 +00:00
|
|
|
ARRAY_SCRIPTABLE_FLAGS |
|
|
|
|
nsIXPCScriptable::WANT_PRECREATE)
|
2007-11-12 06:43:14 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
|
2007-05-09 12:04:59 +00:00
|
|
|
DOM_BASE_SCRIPTABLE_FLAGS |
|
2011-01-11 20:15:52 +00:00
|
|
|
nsIXPCScriptable::WANT_PRECREATE |
|
2011-09-22 02:16:50 +00:00
|
|
|
nsIXPCScriptable::WANT_NEWRESOLVE |
|
2007-06-14 10:03:44 +00:00
|
|
|
nsIXPCScriptable::WANT_HASINSTANCE |
|
|
|
|
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
|
2007-11-12 06:43:14 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMConstructorSH,
|
2007-05-09 12:04:59 +00:00
|
|
|
DOM_BASE_SCRIPTABLE_FLAGS |
|
2011-01-11 20:15:52 +00:00
|
|
|
nsIXPCScriptable::WANT_PRECREATE |
|
2011-09-22 02:16:50 +00:00
|
|
|
nsIXPCScriptable::WANT_NEWRESOLVE |
|
2007-05-09 12:04:59 +00:00
|
|
|
nsIXPCScriptable::WANT_HASINSTANCE |
|
|
|
|
nsIXPCScriptable::WANT_CALL |
|
2007-06-14 10:03:44 +00:00
|
|
|
nsIXPCScriptable::WANT_CONSTRUCT |
|
|
|
|
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// Core classes
|
2001-11-01 15:52:53 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// Misc Core related classes
|
|
|
|
|
2013-03-29 21:04:25 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(DeviceAcceleration, nsDOMGenericSH,
|
2011-06-20 05:36:17 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2013-03-29 21:04:25 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(DeviceRotationRate, nsDOMGenericSH,
|
2011-06-20 05:36:17 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// CSS classes
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
|
2001-05-15 08:26:13 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSCharsetRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2001-05-13 22:16:45 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
|
|
|
|
ARRAY_SCRIPTABLE_FLAGS)
|
2001-09-05 00:00:18 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSGroupRuleRuleList, nsCSSRuleListSH,
|
|
|
|
ARRAY_SCRIPTABLE_FLAGS)
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MediaList, nsMediaListSH,
|
2010-04-23 17:37:02 +00:00
|
|
|
ARRAY_SCRIPTABLE_FLAGS)
|
2009-06-23 10:09:13 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
|
2001-05-11 04:45:15 +00:00
|
|
|
ARRAY_SCRIPTABLE_FLAGS)
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(Selection, nsDOMGenericSH,
|
2001-05-12 05:16:57 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// XUL classes
|
2003-04-11 00:56:27 +00:00
|
|
|
#ifdef MOZ_XUL
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2003-04-11 00:56:27 +00:00
|
|
|
#endif
|
2006-02-23 03:17:11 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(XULControllers, nsNonDOMObjectSH,
|
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
2001-05-09 01:39:02 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(BoxObject, nsDOMGenericSH,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
2008-01-16 01:27:53 +00:00
|
|
|
#ifdef MOZ_XUL
|
2002-03-29 02:46:01 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(TreeSelection, nsDOMGenericSH,
|
2001-05-16 08:13:12 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
2002-03-29 02:46:01 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(TreeContentView, nsDOMGenericSH,
|
2002-01-05 07:17:10 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
2003-04-11 00:56:27 +00:00
|
|
|
#endif
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
// Crypto classes
|
2013-02-17 04:43:16 +00:00
|
|
|
#ifndef MOZ_DISABLE_CRYPTOLEGACY
|
2013-02-16 07:33:45 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2013-02-17 04:43:16 +00:00
|
|
|
#endif
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(Crypto, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
// DOM Chrome Window class.
|
2010-09-17 21:54:40 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(ChromeWindow, nsWindowSH,
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS |
|
2010-09-17 21:54:40 +00:00
|
|
|
WINDOW_SCRIPTABLE_FLAGS)
|
2010-06-28 23:39:00 +00:00
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
#ifdef MOZ_XUL
|
2005-01-17 09:24:56 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
|
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
|
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
|
|
|
|
ARRAY_SCRIPTABLE_FLAGS)
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
|
|
|
|
DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
#endif
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
// other SVG classes
|
2004-07-25 20:03:55 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
|
2001-12-12 07:59:31 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2004-07-25 20:03:55 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
|
2001-12-12 07:59:31 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2005-04-18 06:33:23 +00:00
|
|
|
|
2012-08-31 17:45:45 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozCanvasPrintState, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2005-06-02 01:17:35 +00:00
|
|
|
|
2005-10-21 22:30:36 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2005-06-29 03:51:44 +00:00
|
|
|
|
2005-11-18 13:39:43 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(XPathExpression, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(XPathResult, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2006-05-19 05:57:36 +00:00
|
|
|
// WhatWG Storage
|
|
|
|
|
|
|
|
// mrbkap says we don't need WANT_ADDPROPERTY on Storage objects
|
|
|
|
// since a call to addProperty() is always followed by a call to
|
|
|
|
// setProperty(), except in the case when a getter or setter is set
|
|
|
|
// for a property. But we don't care about getters or setters here.
|
2009-05-16 13:59:30 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
|
2009-03-18 23:43:45 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
|
|
|
nsIXPCScriptable::WANT_NEWRESOLVE |
|
|
|
|
nsIXPCScriptable::WANT_GETPROPERTY |
|
|
|
|
nsIXPCScriptable::WANT_SETPROPERTY |
|
|
|
|
nsIXPCScriptable::WANT_DELPROPERTY |
|
|
|
|
nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
|
|
|
|
nsIXPCScriptable::WANT_NEWENUMERATE)
|
2006-05-19 05:57:36 +00:00
|
|
|
|
2010-10-13 23:25:33 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2007-07-25 04:29:47 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2010-09-17 21:54:40 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
|
2010-06-28 23:39:00 +00:00
|
|
|
DEFAULT_SCRIPTABLE_FLAGS |
|
2010-09-17 21:54:40 +00:00
|
|
|
WINDOW_SCRIPTABLE_FLAGS)
|
2010-06-28 23:39:00 +00:00
|
|
|
|
2012-01-20 03:24:00 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozPowerManager, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-03-07 11:03:25 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozWakeLock, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2011-11-20 22:23:20 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozSmsManager, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2013-03-09 07:21:47 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageManager, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2011-11-22 09:34:21 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2013-03-09 07:21:55 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-01-17 18:48:58 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2013-04-09 12:54:00 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozSmsSegmentInfo, nsDOMGenericSH,
|
2013-04-09 02:21:54 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2013-04-09 16:37:54 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-01-16 12:23:44 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-08-27 17:34:10 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
2012-04-19 21:33:25 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-12-04 02:38:25 +00:00
|
|
|
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozCellBroadcast, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-08-27 17:34:10 +00:00
|
|
|
#endif
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2008-08-10 21:13:49 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2008-08-27 12:07:27 +00:00
|
|
|
// data transfer for drag and drop
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(DataTransfer, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2009-10-16 08:57:32 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(EventListenerInfo, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-08-27 14:13:02 +00:00
|
|
|
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
|
|
|
nsIXPCScriptable::IS_GLOBAL_OBJECT)
|
|
|
|
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageBroadcaster, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2010-02-25 05:58:18 +00:00
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
|
|
|
|
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
|
|
|
|
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
2010-06-28 18:51:06 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBTransaction, IDBEventTargetSH,
|
|
|
|
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
2010-06-28 18:51:06 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2011-02-11 07:47:00 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2010-06-23 19:46:08 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2010-06-28 18:51:06 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-01-24 10:03:37 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
|
|
|
|
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
2011-03-24 11:34:03 +00:00
|
|
|
|
2011-04-26 12:30:17 +00:00
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframeRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframesRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2011-04-22 03:17:31 +00:00
|
|
|
|
2012-08-31 21:21:28 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSPageRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2011-04-22 03:17:31 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MediaQueryList, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-03-26 21:49:38 +00:00
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2012-07-19 03:27:19 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozVoicemail, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2012-06-28 14:21:48 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(MozIccManager, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-01-09 22:28:47 +00:00
|
|
|
#endif
|
2012-01-24 10:13:41 +00:00
|
|
|
|
2012-09-19 15:23:33 +00:00
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(FMRadio, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
#ifdef MOZ_B2G_BT
|
2012-05-24 04:02:23 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(BluetoothManager, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2012-03-05 03:54:01 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
|
2013-01-29 06:52:30 +00:00
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2012-07-18 03:41:54 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(BluetoothDevice, nsEventTargetSH,
|
2012-03-05 03:54:01 +00:00
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2012-02-20 15:15:19 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-30 21:59:05 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CameraControl, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(CameraCapabilities, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
|
|
|
|
2012-06-12 22:01:25 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(OpenWindowEventDetail, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-12-25 06:09:34 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(AsyncScrollEventDetail, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
2012-06-03 16:33:52 +00:00
|
|
|
|
|
|
|
NS_DEFINE_CLASSINFO_DATA(LockedFile, nsEventTargetSH,
|
|
|
|
EVENTTARGET_SCRIPTABLE_FLAGS)
|
2013-05-20 02:59:20 +00:00
|
|
|
NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
|
|
|
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
};
|
|
|
|
|
2012-08-09 07:19:48 +00:00
|
|
|
#define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id) \
|
2012-12-04 01:26:16 +00:00
|
|
|
static nsresult \
|
2012-08-09 07:19:48 +00:00
|
|
|
_class##Ctor(nsISupports** aInstancePtrResult) \
|
|
|
|
{ \
|
|
|
|
nsresult rv = NS_OK; \
|
|
|
|
nsCOMPtr<nsISupports> native = do_CreateInstance(_contract_id, &rv); \
|
|
|
|
native.forget(aInstancePtrResult); \
|
|
|
|
return rv; \
|
|
|
|
}
|
2005-11-18 13:39:43 +00:00
|
|
|
|
2012-08-09 07:19:48 +00:00
|
|
|
NS_DEFINE_CONTRACT_CTOR(XSLTProcessor,
|
|
|
|
"@mozilla.org/document-transformer;1?type=xslt")
|
|
|
|
|
|
|
|
#undef NS_DEFINE_CONTRACT_CTOR
|
2005-11-18 13:39:43 +00:00
|
|
|
|
2008-11-06 06:41:52 +00:00
|
|
|
struct nsConstructorFuncMapData
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mDOMClassInfoID;
|
2008-11-06 06:41:52 +00:00
|
|
|
nsDOMConstructorFunc mConstructorFunc;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func) \
|
|
|
|
{ eDOMClassInfo_##_class##_id, _func },
|
|
|
|
|
|
|
|
static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
|
|
|
{
|
2012-03-13 04:44:56 +00:00
|
|
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, nsDOMMultipartFile::NewBlob)
|
2012-12-11 21:21:03 +00:00
|
|
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, nsDOMMultipartFile::NewFile)
|
2013-03-01 08:38:47 +00:00
|
|
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, SmsFilter::NewSmsFilter)
|
2012-08-09 07:19:48 +00:00
|
|
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
|
2008-11-06 06:41:52 +00:00
|
|
|
};
|
2012-12-04 01:26:16 +00:00
|
|
|
#undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
|
2008-11-06 06:41:52 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
|
|
|
|
nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nullptr;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsDOMClassInfo::sIsInitialized = false;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
jsid nsDOMClassInfo::sParent_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
|
2012-08-11 16:12:54 +00:00
|
|
|
jsid nsDOMClassInfo::s_content_id = JSID_VOID;
|
2010-07-15 06:19:36 +00:00
|
|
|
jsid nsDOMClassInfo::sContent_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sMenubar_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sToolbar_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sLocationbar_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sPersonalbar_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sStatusbar_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sControllers_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sLength_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sScrollX_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sScrollY_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sScrollMaxX_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sScrollMaxY_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sItem_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sNamedItem_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sEnumerate_id = JSID_VOID;
|
2012-08-25 21:56:45 +00:00
|
|
|
jsid nsDOMClassInfo::sTop_id = JSID_VOID;
|
2010-07-15 06:19:36 +00:00
|
|
|
jsid nsDOMClassInfo::sDocument_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sFrames_id = JSID_VOID;
|
|
|
|
jsid nsDOMClassInfo::sSelf_id = JSID_VOID;
|
2010-09-17 21:54:40 +00:00
|
|
|
jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
|
2011-06-28 22:37:31 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
static const JSClass *sObjectClass = nullptr;
|
2011-12-28 21:22:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set our JSClass pointer for the Object class
|
|
|
|
*/
|
|
|
|
static void
|
2012-09-03 23:42:10 +00:00
|
|
|
FindObjectClass(JSContext* cx, JSObject* aGlobalObject)
|
2011-12-28 21:22:05 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!sObjectClass,
|
|
|
|
"Double set of sObjectClass");
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx), proto(cx, aGlobalObject);
|
2011-12-28 21:22:05 +00:00
|
|
|
do {
|
|
|
|
obj = proto;
|
2013-05-05 07:03:14 +00:00
|
|
|
js::GetObjectProto(cx, obj, &proto);
|
2011-12-28 21:22:05 +00:00
|
|
|
} while (proto);
|
|
|
|
|
|
|
|
sObjectClass = js::GetObjectJSClass(obj);
|
|
|
|
}
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
static inline JSString *
|
|
|
|
IdToString(JSContext *cx, jsid id)
|
2002-08-15 21:18:20 +00:00
|
|
|
{
|
2010-07-15 06:19:36 +00:00
|
|
|
if (JSID_IS_STRING(id))
|
|
|
|
return JSID_TO_STRING(id);
|
|
|
|
jsval idval;
|
|
|
|
if (!::JS_IdToValue(cx, id, &idval))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-07-15 06:19:36 +00:00
|
|
|
return JS_ValueToString(cx, idval);
|
2002-08-15 21:18:20 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 17:50:49 +00:00
|
|
|
static inline nsresult
|
|
|
|
WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
|
|
|
nsWrapperCache *cache, const nsIID* aIID, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIXPConnectJSObjectHolder** aHolder, bool aAllowWrapping)
|
2011-04-08 17:50:49 +00:00
|
|
|
{
|
|
|
|
if (!native) {
|
|
|
|
NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!");
|
|
|
|
|
|
|
|
*vp = JSVAL_NULL;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
|
|
|
|
if (wrapper) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsDOMClassInfo::XPConnect()->WrapNativeToJSVal(cx, scope, native,
|
|
|
|
cache, aIID,
|
|
|
|
aAllowWrapping, vp,
|
|
|
|
aHolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline nsresult
|
|
|
|
WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsIID* aIID, bool aAllowWrapping, jsval *vp,
|
2011-04-08 17:50:49 +00:00
|
|
|
// If non-null aHolder will keep the jsval alive
|
|
|
|
// while there's a ref to it
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIXPConnectJSObjectHolder** aHolder = nullptr)
|
2011-04-08 17:50:49 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return WrapNative(cx, scope, native, nullptr, aIID, vp, aHolder,
|
2011-04-08 17:50:49 +00:00
|
|
|
aAllowWrapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Same as the WrapNative above, but use these if aIID is nsISupports' IID.
|
|
|
|
static inline nsresult
|
|
|
|
WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAllowWrapping, jsval *vp,
|
2011-04-08 17:50:49 +00:00
|
|
|
// If non-null aHolder will keep the jsval alive
|
|
|
|
// while there's a ref to it
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIXPConnectJSObjectHolder** aHolder = nullptr)
|
2011-04-08 17:50:49 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return WrapNative(cx, scope, native, nullptr, nullptr, vp, aHolder,
|
2011-04-08 17:50:49 +00:00
|
|
|
aAllowWrapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline nsresult
|
|
|
|
WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsWrapperCache *cache, bool aAllowWrapping, jsval *vp,
|
2011-04-08 17:50:49 +00:00
|
|
|
// If non-null aHolder will keep the jsval alive
|
|
|
|
// while there's a ref to it
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIXPConnectJSObjectHolder** aHolder = nullptr)
|
2011-04-08 17:50:49 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return WrapNative(cx, scope, native, cache, nullptr, vp, aHolder,
|
2011-04-08 17:50:49 +00:00
|
|
|
aAllowWrapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used for cases where PreCreate needs to wrap the native parent, and the
|
|
|
|
// native parent is likely to have been wrapped already. |native| must
|
|
|
|
// implement nsWrapperCache, and nativeWrapperCache must be |native|'s
|
|
|
|
// nsWrapperCache.
|
|
|
|
static inline nsresult
|
2013-05-03 18:53:32 +00:00
|
|
|
WrapNativeParent(JSContext *cx, JS::Handle<JSObject*> scope, nsISupports *native,
|
2012-06-04 19:41:51 +00:00
|
|
|
nsWrapperCache *nativeWrapperCache, JSObject **parentObj)
|
2011-04-08 17:50:49 +00:00
|
|
|
{
|
|
|
|
// In the common case, |native| is a wrapper cache with an existing wrapper
|
|
|
|
#ifdef DEBUG
|
2012-07-30 14:20:58 +00:00
|
|
|
nsWrapperCache* cache = nullptr;
|
2011-04-08 17:50:49 +00:00
|
|
|
CallQueryInterface(native, &cache);
|
|
|
|
NS_PRECONDITION(nativeWrapperCache &&
|
|
|
|
cache == nativeWrapperCache, "What happened here?");
|
|
|
|
#endif
|
2013-02-08 20:25:37 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, nativeWrapperCache->GetWrapper());
|
2011-04-08 17:50:49 +00:00
|
|
|
if (obj) {
|
|
|
|
#ifdef DEBUG
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Rooted<JS::Value> debugVal(cx);
|
2011-10-17 14:59:28 +00:00
|
|
|
nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false,
|
2013-05-29 20:16:04 +00:00
|
|
|
debugVal.address());
|
2011-04-08 17:50:49 +00:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv) && JSVAL_TO_OBJECT(debugVal) == obj,
|
|
|
|
"Unexpected object in nsWrapperCache");
|
|
|
|
#endif
|
|
|
|
*parentObj = obj;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
|
|
|
nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false, v.address());
|
2011-04-08 17:50:49 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2013-05-03 18:53:32 +00:00
|
|
|
*parentObj = v.toObjectOrNull();
|
2011-04-08 17:50:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-04 19:41:51 +00:00
|
|
|
template<class P>
|
|
|
|
static inline nsresult
|
2013-05-03 18:53:32 +00:00
|
|
|
WrapNativeParent(JSContext *cx, JS::Handle<JSObject*> scope, P *parent,
|
2012-06-04 19:41:51 +00:00
|
|
|
JSObject **parentObj)
|
|
|
|
{
|
|
|
|
return WrapNativeParent(cx, scope, ToSupports(parent), parent, parentObj);
|
|
|
|
}
|
|
|
|
|
2012-04-27 08:38:14 +00:00
|
|
|
// Helper to handle torn-down inner windows.
|
|
|
|
static inline nsresult
|
|
|
|
SetParentToWindow(nsGlobalWindow *win, JSObject **parent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(win);
|
|
|
|
MOZ_ASSERT(win->IsInnerWindow());
|
|
|
|
*parent = win->FastGetGlobalJSObject();
|
|
|
|
|
|
|
|
if (MOZ_UNLIKELY(!*parent)) {
|
2012-09-11 17:23:31 +00:00
|
|
|
// The inner window has been torn down. The scope is dying, so don't create
|
|
|
|
// any new wrappers.
|
2012-04-27 08:38:14 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// static
|
2010-03-05 00:17:05 +00:00
|
|
|
|
|
|
|
nsISupports *
|
|
|
|
nsDOMClassInfo::GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj)
|
|
|
|
{
|
2011-10-04 14:06:54 +00:00
|
|
|
return wrapper ? wrapper->Native() : static_cast<nsISupports*>(js::GetObjectPrivate(obj));
|
2010-03-05 00:17:05 +00:00
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsresult
|
2002-08-15 21:18:20 +00:00
|
|
|
nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2010-07-15 06:19:36 +00:00
|
|
|
#define SET_JSID_TO_STRING(_id, _cx, _str) \
|
|
|
|
if (JSString *str = ::JS_InternString(_cx, _str)) \
|
2011-05-17 19:15:12 +00:00
|
|
|
_id = INTERNED_STRING_TO_JSID(_cx, str); \
|
2010-07-15 06:19:36 +00:00
|
|
|
else \
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-08-15 21:18:20 +00:00
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
SET_JSID_TO_STRING(sParent_id, cx, "parent");
|
|
|
|
SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
|
|
|
|
SET_JSID_TO_STRING(sLocation_id, cx, "location");
|
|
|
|
SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
|
2012-08-11 16:12:54 +00:00
|
|
|
SET_JSID_TO_STRING(s_content_id, cx, "_content");
|
2010-07-15 06:19:36 +00:00
|
|
|
SET_JSID_TO_STRING(sContent_id, cx, "content");
|
|
|
|
SET_JSID_TO_STRING(sMenubar_id, cx, "menubar");
|
|
|
|
SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar");
|
|
|
|
SET_JSID_TO_STRING(sLocationbar_id, cx, "locationbar");
|
|
|
|
SET_JSID_TO_STRING(sPersonalbar_id, cx, "personalbar");
|
|
|
|
SET_JSID_TO_STRING(sStatusbar_id, cx, "statusbar");
|
|
|
|
SET_JSID_TO_STRING(sControllers_id, cx, "controllers");
|
|
|
|
SET_JSID_TO_STRING(sLength_id, cx, "length");
|
|
|
|
SET_JSID_TO_STRING(sScrollX_id, cx, "scrollX");
|
|
|
|
SET_JSID_TO_STRING(sScrollY_id, cx, "scrollY");
|
|
|
|
SET_JSID_TO_STRING(sScrollMaxX_id, cx, "scrollMaxX");
|
|
|
|
SET_JSID_TO_STRING(sScrollMaxY_id, cx, "scrollMaxY");
|
|
|
|
SET_JSID_TO_STRING(sItem_id, cx, "item");
|
|
|
|
SET_JSID_TO_STRING(sNamedItem_id, cx, "namedItem");
|
|
|
|
SET_JSID_TO_STRING(sEnumerate_id, cx, "enumerateProperties");
|
2012-08-25 21:56:45 +00:00
|
|
|
SET_JSID_TO_STRING(sTop_id, cx, "top");
|
2010-07-15 06:19:36 +00:00
|
|
|
SET_JSID_TO_STRING(sDocument_id, cx, "document");
|
|
|
|
SET_JSID_TO_STRING(sFrames_id, cx, "frames");
|
|
|
|
SET_JSID_TO_STRING(sSelf_id, cx, "self");
|
2010-09-17 21:54:40 +00:00
|
|
|
SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-02 20:54:53 +00:00
|
|
|
// static
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-07-02 20:54:53 +00:00
|
|
|
nsDOMClassInfo::ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
|
|
|
|
{
|
2011-02-17 04:29:14 +00:00
|
|
|
return xpc::WrapperFactory::IsXrayWrapper(obj) &&
|
2012-09-11 08:05:10 +00:00
|
|
|
xpc::AccessCheck::wrapperSubsumes(obj);
|
2010-07-02 20:54:53 +00:00
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMClassInfo::~nsDOMClassInfo()
|
|
|
|
{
|
2002-03-04 02:25:08 +00:00
|
|
|
if (IS_EXTERNAL(mData->mCachedClassInfo)) {
|
|
|
|
// Some compilers don't like delete'ing a const nsDOMClassInfo*
|
2007-07-08 07:08:04 +00:00
|
|
|
nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
|
|
|
|
delete static_cast<nsExternalDOMClassInfoData*>(data);
|
2002-03-04 02:25:08 +00:00
|
|
|
}
|
2001-04-01 01:10:59 +00:00
|
|
|
}
|
|
|
|
|
2003-09-07 22:05:34 +00:00
|
|
|
NS_IMPL_ADDREF(nsDOMClassInfo)
|
|
|
|
NS_IMPL_RELEASE(nsDOMClassInfo)
|
2001-04-01 01:10:59 +00:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMClassInfo)
|
2009-09-28 21:00:35 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsXPCClassInfo)))
|
|
|
|
foundInterface = static_cast<nsIClassInfo*>(
|
|
|
|
static_cast<nsXPCClassInfo*>(this));
|
|
|
|
else
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
|
2001-04-01 01:10:59 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
|
2009-09-28 21:00:35 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIClassInfo)
|
2001-04-01 01:10:59 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
static JSClass sDOMConstructorProtoClass = {
|
2001-07-11 09:09:30 +00:00
|
|
|
"DOM Constructor.prototype", 0,
|
2013-04-06 04:22:55 +00:00
|
|
|
JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
|
2012-07-30 14:20:58 +00:00
|
|
|
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nullptr
|
2001-07-11 09:09:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
CutPrefix(const char *aName) {
|
|
|
|
static const char prefix_nsIDOM[] = "nsIDOM";
|
|
|
|
static const char prefix_nsI[] = "nsI";
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
if (strncmp(aName, prefix_nsIDOM, sizeof(prefix_nsIDOM) - 1) == 0) {
|
2001-07-11 09:09:30 +00:00
|
|
|
return aName + sizeof(prefix_nsIDOM) - 1;
|
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
|
2001-07-11 09:09:30 +00:00
|
|
|
return aName + sizeof(prefix_nsI) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMClassInfo::RegisterClassProtos(int32_t aClassInfoID)
|
2001-07-11 09:09:30 +00:00
|
|
|
{
|
2011-09-06 19:01:01 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
2007-11-13 10:35:49 +00:00
|
|
|
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool found_old;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
const nsIID *primary_iid = sClassInfoData[aClassInfoID].mProtoChainInterface;
|
|
|
|
|
|
|
|
if (!primary_iid || primary_iid == &NS_GET_IID(nsISupports)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-11-10 16:19:44 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager>
|
|
|
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
2001-07-11 09:09:30 +00:00
|
|
|
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool first = true;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
|
|
|
|
|
|
|
|
while (if_info) {
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsIID *iid = nullptr;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2008-01-12 04:30:42 +00:00
|
|
|
if_info->GetIIDShared(&iid);
|
2001-07-11 09:09:30 +00:00
|
|
|
NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
if (iid->Equals(NS_GET_IID(nsISupports))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const char *name = nullptr;
|
2008-01-12 04:30:42 +00:00
|
|
|
if_info->GetNameShared(&name);
|
|
|
|
NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2007-11-13 10:35:49 +00:00
|
|
|
nameSpaceManager->RegisterClassProto(CutPrefix(name), iid, &found_old);
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
if (first) {
|
2011-10-17 14:59:28 +00:00
|
|
|
first = false;
|
2001-07-11 09:09:30 +00:00
|
|
|
} else if (found_old) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-10 23:45:06 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
|
2001-07-11 09:09:30 +00:00
|
|
|
tmp->GetParent(getter_AddRefs(if_info));
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
// static
|
|
|
|
nsresult
|
|
|
|
nsDOMClassInfo::RegisterExternalClasses()
|
|
|
|
{
|
2011-09-06 19:01:01 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
2007-11-13 10:35:49 +00:00
|
|
|
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2004-11-01 18:50:36 +00:00
|
|
|
nsCOMPtr<nsIComponentRegistrar> registrar;
|
2007-11-13 10:35:49 +00:00
|
|
|
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
|
2004-11-01 18:50:36 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
nsCOMPtr<nsICategoryManager> cm =
|
|
|
|
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> e;
|
|
|
|
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2002-08-26 21:20:34 +00:00
|
|
|
nsXPIDLCString contractId;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString categoryEntry;
|
2002-03-04 02:25:08 +00:00
|
|
|
nsCOMPtr<nsISupports> entry;
|
|
|
|
|
|
|
|
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
2002-08-06 00:53:19 +00:00
|
|
|
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
2002-03-04 02:25:08 +00:00
|
|
|
|
|
|
|
if (!category) {
|
2002-08-06 00:53:19 +00:00
|
|
|
NS_WARNING("Category entry not an nsISupportsCString!");
|
2002-03-04 02:25:08 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-08-26 21:20:34 +00:00
|
|
|
rv = category->GetData(categoryEntry);
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2002-08-26 21:20:34 +00:00
|
|
|
cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
|
2002-03-04 02:25:08 +00:00
|
|
|
getter_Copies(contractId));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2004-11-01 18:50:36 +00:00
|
|
|
nsCID *cid;
|
|
|
|
rv = registrar->ContractIDToCID(contractId, &cid);
|
2002-03-04 02:25:08 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Bad contract id registered with the script namespace manager");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-11-13 10:35:49 +00:00
|
|
|
rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
|
2004-11-01 18:50:36 +00:00
|
|
|
nsMemory::Free(cid);
|
2002-03-04 02:25:08 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return nameSpaceManager->RegisterExternalInterfaces(true);
|
2002-03-04 02:25:08 +00:00
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2011-04-26 12:30:17 +00:00
|
|
|
#define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if, _disabled) \
|
2001-07-11 09:09:30 +00:00
|
|
|
{ \
|
|
|
|
nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
|
|
|
|
d.mProtoChainInterface = _ifptr; \
|
2001-11-02 04:49:07 +00:00
|
|
|
d.mHasClassInterface = _has_class_if; \
|
2010-01-12 14:24:00 +00:00
|
|
|
d.mInterfacesBitmap = kDOMClassInfo_##_class##_interfaces; \
|
2011-04-26 12:30:17 +00:00
|
|
|
d.mDisabled = _disabled; \
|
2001-07-11 09:09:30 +00:00
|
|
|
static const nsIID *interface_list[] = {
|
|
|
|
|
|
|
|
#define DOM_CLASSINFO_MAP_BEGIN(_class, _interface) \
|
2011-10-17 14:59:28 +00:00
|
|
|
_DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, false)
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2011-04-26 12:30:17 +00:00
|
|
|
#define DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(_class, _interface, _disable) \
|
2011-10-17 14:59:28 +00:00
|
|
|
_DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, _disable)
|
2013-02-08 20:25:37 +00:00
|
|
|
|
2001-11-02 04:49:07 +00:00
|
|
|
#define DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(_class, _interface) \
|
2011-10-17 14:59:28 +00:00
|
|
|
_DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), false, false)
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
#define DOM_CLASSINFO_MAP_ENTRY(_if) \
|
|
|
|
&NS_GET_IID(_if),
|
|
|
|
|
2011-08-24 19:49:25 +00:00
|
|
|
#define DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(_if, _cond) \
|
2012-07-30 14:20:58 +00:00
|
|
|
(_cond) ? &NS_GET_IID(_if) : nullptr,
|
2011-08-24 19:49:25 +00:00
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
#define DOM_CLASSINFO_MAP_END \
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr \
|
2001-07-11 09:09:30 +00:00
|
|
|
}; \
|
|
|
|
\
|
2011-08-24 19:49:25 +00:00
|
|
|
/* Compact the interface list */ \
|
2011-10-11 05:50:08 +00:00
|
|
|
size_t count = ArrayLength(interface_list); \
|
2011-08-24 19:49:25 +00:00
|
|
|
/* count is the number of array entries, which is one greater than the */ \
|
|
|
|
/* number of interfaces due to the terminating null */ \
|
|
|
|
for (size_t i = 0; i < count - 1; ++i) { \
|
|
|
|
if (!interface_list[i]) { \
|
2011-12-15 04:42:15 +00:00
|
|
|
/* We are moving the element at index i+1 and successors, */ \
|
|
|
|
/* so we must move only count - (i+1) elements total. */ \
|
2011-08-24 19:49:25 +00:00
|
|
|
memmove(&interface_list[i], &interface_list[i+1], \
|
2011-12-15 04:42:15 +00:00
|
|
|
sizeof(nsIID*) * (count - (i+1))); \
|
2011-08-24 19:49:25 +00:00
|
|
|
/* Make sure to examine the new pointer we ended up with at this */ \
|
|
|
|
/* slot, since it may be null too */ \
|
|
|
|
--i; \
|
|
|
|
--count; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
2001-07-11 09:09:30 +00:00
|
|
|
d.mInterfaces = interface_list; \
|
|
|
|
}
|
|
|
|
|
2012-11-07 18:10:40 +00:00
|
|
|
#ifdef MOZ_B2G
|
2011-09-23 05:04:32 +00:00
|
|
|
#define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
|
2012-11-07 18:10:40 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowB2G) \
|
2011-09-23 05:04:32 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
|
2013-05-02 03:44:11 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance) \
|
2011-09-23 05:04:32 +00:00
|
|
|
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB, \
|
|
|
|
_support_indexed_db) \
|
|
|
|
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
|
2013-02-17 04:43:19 +00:00
|
|
|
nsDOMTouchEvent::PrefEnabled())
|
2012-11-07 18:10:40 +00:00
|
|
|
#else // !MOZ_B2G
|
|
|
|
#define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
|
2013-05-02 03:44:11 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance) \
|
2012-11-07 18:10:40 +00:00
|
|
|
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB, \
|
|
|
|
_support_indexed_db) \
|
|
|
|
DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
|
2013-02-17 04:43:19 +00:00
|
|
|
nsDOMTouchEvent::PrefEnabled())
|
2012-11-07 18:10:40 +00:00
|
|
|
#endif // MOZ_B2G
|
2011-09-23 05:04:32 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsresult
|
|
|
|
nsDOMClassInfo::Init()
|
|
|
|
{
|
2003-01-22 03:18:41 +00:00
|
|
|
/* Errors that can trigger early returns are done first,
|
|
|
|
otherwise nsDOMClassInfo is left in a half inited state. */
|
2012-10-02 08:24:11 +00:00
|
|
|
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void*),
|
|
|
|
"BAD! You'll need to adjust the size of uintptr_t to the "
|
|
|
|
"size of a pointer on your platform.");
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2003-01-22 03:18:41 +00:00
|
|
|
NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
|
|
|
|
|
2007-11-13 10:35:49 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
|
|
|
|
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
2003-01-22 03:18:41 +00:00
|
|
|
|
2003-01-31 12:10:13 +00:00
|
|
|
nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
|
2003-01-22 03:18:41 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
|
2012-10-02 08:24:08 +00:00
|
|
|
sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
|
2003-01-22 03:18:41 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager> sm =
|
|
|
|
do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
sSecMan = sm;
|
|
|
|
NS_ADDREF(sSecMan);
|
|
|
|
|
2013-05-06 13:04:17 +00:00
|
|
|
AutoSafeJSContext cx;
|
2003-01-22 03:18:41 +00:00
|
|
|
|
2011-08-24 19:49:25 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
|
2011-09-23 05:04:32 +00:00
|
|
|
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
|
2013-04-03 22:13:16 +00:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 22:12:34 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
|
2013-04-03 22:13:16 +00:00
|
|
|
#endif
|
2011-08-24 19:49:25 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2005-10-21 22:30:36 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
|
2003-02-25 01:40:18 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
|
2007-11-12 06:43:14 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
2007-05-09 12:04:59 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2007-11-12 06:43:14 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
2005-12-09 19:08:45 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-11-01 15:52:53 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DOMException, nsIDOMDOMException)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMException)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIException)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-06-20 05:36:17 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DeviceAcceleration, nsIDOMDeviceAcceleration)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceAcceleration)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DeviceRotationRate, nsIDOMDeviceRotationRate)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceRotationRate)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSStyleRule, nsIDOMCSSStyleRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSCharsetRule, nsIDOMCSSCharsetRule)
|
2002-08-06 05:26:41 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSCharsetRule)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSImportRule, nsIDOMCSSImportRule)
|
2001-08-04 21:19:53 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSImportRule)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
|
2001-09-05 00:00:18 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-11-07 07:52:41 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSNameSpaceRule, nsIDOMCSSRule)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSRuleList, nsIDOMCSSRuleList)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-11-07 07:52:41 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSGroupRuleRuleList, nsIDOMCSSRuleList)
|
2001-09-05 00:00:18 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MediaList, nsIDOMMediaList)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Selection, nsISelection)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsISelection)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2003-04-11 00:56:27 +00:00
|
|
|
#ifdef MOZ_XUL
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2003-04-11 00:56:27 +00:00
|
|
|
#endif
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2006-02-23 03:17:11 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControllers, nsIControllers)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIControllers)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(BoxObject, nsIBoxObject)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIBoxObject)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2008-01-16 01:27:53 +00:00
|
|
|
#ifdef MOZ_XUL
|
2002-03-29 02:46:01 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(TreeSelection, nsITreeSelection)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsITreeSelection)
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(TreeContentView, nsITreeContentView)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsITreeContentView)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
|
2002-01-05 07:17:10 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
2003-04-11 00:56:27 +00:00
|
|
|
#endif
|
2002-01-05 07:17:10 +00:00
|
|
|
|
2013-02-17 04:43:16 +00:00
|
|
|
#ifndef MOZ_DISABLE_CRYPTOLEGACY
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CRMFObject, nsIDOMCRMFObject)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
#endif
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Crypto, nsIDOMCrypto)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCrypto)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
|
2011-10-17 14:59:28 +00:00
|
|
|
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(true)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
|
2013-04-03 22:13:16 +00:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 22:12:34 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
|
2013-04-03 22:13:16 +00:00
|
|
|
#endif
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2005-01-17 09:24:56 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XULTemplateBuilder, nsIXULTemplateBuilder)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
|
2013-01-29 17:51:55 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 12:39:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
#endif
|
|
|
|
|
2004-08-05 18:26:14 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSSupportsRule, nsIDOMCSSSupportsRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSSupportsRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2004-07-25 20:03:55 +00:00
|
|
|
// The SVG document
|
|
|
|
|
|
|
|
// other SVG classes
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength)
|
2001-12-12 07:59:31 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2004-07-25 20:03:55 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(SVGNumber, nsIDOMSVGNumber)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber)
|
2001-12-12 07:59:31 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-08-31 17:45:45 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozCanvasPrintState, nsIDOMMozCanvasPrintState)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCanvasPrintState)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2005-11-18 13:39:43 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
|
2006-07-06 00:33:24 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
|
2005-11-18 13:39:43 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XPathExpression, nsIDOMXPathExpression)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathExpression)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSXPathExpression)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(XPathResult, nsIDOMXPathResult)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathResult)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2009-05-16 13:59:30 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Storage, nsIDOMStorage)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
|
2009-03-18 23:43:45 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-10-13 23:25:33 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2007-07-25 04:29:47 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
|
2010-10-13 23:25:33 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
|
2007-07-25 04:29:47 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2007-12-04 18:49:38 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
|
2011-09-23 05:04:32 +00:00
|
|
|
DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
|
2007-07-26 17:52:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
|
2013-04-03 22:13:16 +00:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 22:12:34 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
|
2013-04-03 22:13:16 +00:00
|
|
|
#endif
|
2007-07-26 17:52:26 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-01-20 03:24:00 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozPowerManager, nsIDOMMozPowerManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozPowerManager)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-03-07 11:03:25 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozWakeLock, nsIDOMMozWakeLock)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozWakeLock)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-11-20 22:23:20 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozSmsManager, nsIDOMMozSmsManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsManager)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-03-09 07:21:47 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageManager, nsIDOMMozMobileMessageManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageManager)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-11-22 09:34:21 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-03-09 07:21:55 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozMmsMessage, nsIDOMMozMmsMessage)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-01-17 18:48:58 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-04-09 12:54:00 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozSmsSegmentInfo, nsIDOMMozSmsSegmentInfo)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsSegmentInfo)
|
2013-04-09 02:21:54 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-04-09 16:37:54 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-01-16 12:23:44 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
|
2012-03-14 18:50:11 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
2012-01-16 12:23:44 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-08-27 17:34:10 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
2012-04-19 21:33:25 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozMobileConnection, nsIDOMMozMobileConnection)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2012-12-04 02:38:25 +00:00
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozCellBroadcast, nsIDOMMozCellBroadcast)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCellBroadcast)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2012-12-04 02:40:47 +00:00
|
|
|
#endif // MOZ_B2G_RIL
|
2012-04-19 21:33:25 +00:00
|
|
|
|
2008-08-10 21:13:49 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2008-08-27 12:07:27 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2008-09-18 09:47:21 +00:00
|
|
|
|
2009-10-16 08:57:32 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(EventListenerInfo, nsIEventListenerInfo)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIEventListenerInfo)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2009-12-23 19:10:31 +00:00
|
|
|
|
2012-08-27 14:13:02 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports)
|
2010-05-18 12:28:37 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
2012-08-27 14:13:02 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
2010-08-31 18:58:35 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
2010-05-18 12:28:37 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-08-27 14:13:02 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageBroadcaster, nsISupports)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageBroadcaster)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageSender, nsISupports)
|
2012-12-22 12:00:10 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIProcessChecker)
|
2012-08-27 14:13:02 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-28 16:46:49 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase)
|
2010-10-19 17:58:52 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-28 18:51:06 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-28 16:46:21 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBTransaction, nsIIDBTransaction)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBTransaction)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-28 18:51:06 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-02-11 07:47:00 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBCursorWithValue, nsIIDBCursorWithValue)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursorWithValue)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBKeyRange, nsIIDBKeyRange)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2010-06-28 18:51:06 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
|
2010-10-19 17:58:52 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-10-20 16:10:56 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
|
2010-10-19 17:58:52 +00:00
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
2010-06-23 19:46:08 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-04-12 06:18:43 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframeRule, nsIDOMMozCSSKeyframeRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframesRule, nsIDOMMozCSSKeyframesRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-08-31 21:21:28 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSPageRule, nsIDOMCSSPageRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSPageRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2011-04-22 03:17:31 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MediaQueryList, nsIDOMMediaQueryList)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaQueryList)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(Telephony, nsIDOMTelephony)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephony)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(TelephonyCall, nsIDOMTelephonyCall)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephonyCall)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-07-19 03:27:19 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozVoicemail, nsIDOMMozVoicemail)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozVoicemail)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-06-28 14:21:48 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(MozIccManager, nsIDOMMozIccManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozIccManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-01-09 22:28:47 +00:00
|
|
|
#endif
|
|
|
|
|
2012-09-19 15:23:33 +00:00
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(FMRadio, nsIFMRadio)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIFMRadio)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
#ifdef MOZ_B2G_BT
|
2012-05-24 04:02:23 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(BluetoothManager, nsIDOMBluetoothManager)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothManager)
|
2013-02-08 20:25:37 +00:00
|
|
|
DOM_CLASSINFO_MAP_END
|
2012-05-24 04:02:23 +00:00
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2013-01-29 06:52:30 +00:00
|
|
|
|
2012-07-18 03:41:54 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(BluetoothDevice, nsIDOMBluetoothDevice)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothDevice)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
2012-02-20 15:15:19 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-30 21:59:05 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CameraControl, nsICameraControl)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsICameraControl)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CameraCapabilities, nsICameraCapabilities)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsICameraCapabilities)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-06-12 22:01:25 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(OpenWindowEventDetail, nsIOpenWindowEventDetail)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIOpenWindowEventDetail)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-12-25 06:09:34 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(AsyncScrollEventDetail, nsIAsyncScrollEventDetail)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIAsyncScrollEventDetail)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2012-06-03 16:33:52 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(LockedFile, nsIDOMLockedFile)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLockedFile)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-05-20 02:59:20 +00:00
|
|
|
DOM_CLASSINFO_MAP_BEGIN(CSSFontFeatureValuesRule, nsIDOMCSSFontFeatureValuesRule)
|
|
|
|
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFeatureValuesRule)
|
|
|
|
DOM_CLASSINFO_MAP_END
|
|
|
|
|
2013-02-11 23:15:55 +00:00
|
|
|
MOZ_STATIC_ASSERT(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
|
|
|
|
"The number of items in sClassInfoData doesn't match the "
|
|
|
|
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-02-11 23:15:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
|
|
|
|
if (!sClassInfoData[i].u.mConstructorFptr ||
|
|
|
|
sClassInfoData[i].mDebugID != i) {
|
2013-06-29 01:38:30 +00:00
|
|
|
MOZ_CRASH("Class info data out of sync, you forgot to update "
|
2013-06-29 01:38:32 +00:00
|
|
|
"nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
|
|
|
|
"mozilla will not work without this fixed!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
2013-02-11 23:15:55 +00:00
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2013-02-11 23:15:55 +00:00
|
|
|
for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
|
|
|
|
if (!sClassInfoData[i].mInterfaces) {
|
2013-06-29 01:38:30 +00:00
|
|
|
MOZ_CRASH("Class info data without an interface list! Fix this, "
|
2013-06-29 01:38:32 +00:00
|
|
|
"mozilla will not work without this fixed!");
|
2013-02-11 23:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Initialize static JSString's
|
2002-08-15 21:18:20 +00:00
|
|
|
DefineStaticJSVals(cx);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
for (i = 0; i < eDOMClassInfoIDCount; ++i) {
|
2012-08-09 07:19:42 +00:00
|
|
|
nsDOMClassInfoData& data = sClassInfoData[i];
|
|
|
|
nameSpaceManager->RegisterClassName(data.mName, i, data.mChromeOnly,
|
|
|
|
data.mDisabled, &data.mNameUTF16);
|
2001-07-11 09:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < eDOMClassInfoIDCount; ++i) {
|
|
|
|
RegisterClassProtos(i);
|
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
RegisterExternalClasses();
|
|
|
|
|
2012-10-13 12:50:24 +00:00
|
|
|
// Register new DOM bindings
|
2012-05-03 04:35:38 +00:00
|
|
|
mozilla::dom::Register(nameSpaceManager);
|
2011-06-14 08:41:15 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
sIsInitialized = true;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-28 04:26:29 +00:00
|
|
|
// static
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t
|
2013-05-04 07:51:53 +00:00
|
|
|
nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, JS::Handle<jsid> id, bool *aIsNumber)
|
2001-06-28 04:26:29 +00:00
|
|
|
{
|
|
|
|
if (aIsNumber) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsNumber = false;
|
2001-06-28 04:26:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-02 02:54:01 +00:00
|
|
|
int i;
|
2010-07-15 06:19:36 +00:00
|
|
|
if (JSID_IS_INT(id)) {
|
|
|
|
i = JSID_TO_INT(id);
|
|
|
|
} else {
|
|
|
|
jsval idval;
|
2012-02-24 22:19:52 +00:00
|
|
|
double array_index;
|
2010-07-15 06:19:36 +00:00
|
|
|
if (!::JS_IdToValue(cx, id, &idval) ||
|
|
|
|
!::JS_ValueToNumber(cx, idval, &array_index) ||
|
|
|
|
!::JS_DoubleIsInt32(array_index, &i)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2001-06-28 04:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aIsNumber) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsNumber = true;
|
2001-06-28 04:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2001-04-01 01:10:59 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMClassInfo::GetInterfaces(uint32_t *aCount, nsIID ***aArray)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = 0;
|
2001-04-01 01:10:59 +00:00
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
while (mData->mInterfaces[count]) {
|
2001-07-11 09:09:30 +00:00
|
|
|
count++;
|
|
|
|
}
|
2001-04-01 01:10:59 +00:00
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
*aCount = count;
|
2001-04-01 01:10:59 +00:00
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
if (!count) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*aArray = nullptr;
|
2001-04-01 01:10:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
*aArray = static_cast<nsIID **>(nsMemory::Alloc(count * sizeof(nsIID *)));
|
2001-04-01 01:10:59 +00:00
|
|
|
NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i;
|
2001-07-11 09:09:30 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
2007-07-08 07:08:04 +00:00
|
|
|
nsIID *iid = static_cast<nsIID *>(nsMemory::Clone(mData->mInterfaces[i],
|
2002-08-15 21:18:20 +00:00
|
|
|
sizeof(nsIID)));
|
2001-04-01 01:10:59 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
if (!iid) {
|
|
|
|
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, *aArray);
|
2001-04-01 01:10:59 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-04-01 01:10:59 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
*((*aArray) + i) = iid;
|
2001-04-01 01:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMClassInfo::GetHelperForLanguage(uint32_t language, nsISupports **_retval)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
|
2007-07-08 07:08:04 +00:00
|
|
|
*_retval = static_cast<nsIXPCScriptable *>(this);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
NS_ADDREF(*_retval);
|
|
|
|
} else {
|
2012-07-30 14:20:58 +00:00
|
|
|
*_retval = nullptr;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
2001-04-01 01:10:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsDOMClassInfo::GetContractID(char **aContractID)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aContractID = nullptr;
|
2001-04-01 01:10:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-19 09:14:19 +00:00
|
|
|
NS_IMETHODIMP
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsDOMClassInfo::GetClassDescription(char **aClassDescription)
|
|
|
|
{
|
|
|
|
return GetClassName(aClassDescription);
|
|
|
|
}
|
|
|
|
|
2001-04-01 01:10:59 +00:00
|
|
|
NS_IMETHODIMP
|
2001-08-07 03:59:29 +00:00
|
|
|
nsDOMClassInfo::GetClassID(nsCID **aClassID)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aClassID = nullptr;
|
2001-08-07 03:59:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::GetClassIDNoAlloc(nsCID *aClassID)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2001-04-01 01:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMClassInfo::GetImplementationLanguage(uint32_t *aImplLanguage)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
*aImplLanguage = nsIProgrammingLanguage::CPLUSPLUS;
|
2001-04-01 01:10:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsDOMClassInfo::GetFlags(uint32_t *aFlags)
|
2001-04-01 01:10:59 +00:00
|
|
|
{
|
2002-08-29 04:05:39 +00:00
|
|
|
*aFlags = DOMCLASSINFO_STANDARD_FLAGS;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIXPCScriptable
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::GetClassName(char **aClassName)
|
|
|
|
{
|
2006-11-12 15:15:37 +00:00
|
|
|
*aClassName = NS_strdup(mData->mName);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-17 08:11:16 +00:00
|
|
|
// virtual
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2012-06-17 08:11:16 +00:00
|
|
|
nsDOMClassInfo::GetScriptableFlags()
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2012-06-17 08:11:16 +00:00
|
|
|
return mData->mScriptableFlags;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
|
|
|
JSObject *globalObj, JSObject **parentObj)
|
|
|
|
{
|
2005-09-13 00:26:53 +00:00
|
|
|
*parentObj = globalObj;
|
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
|
|
|
|
JSContext *cx, JSObject *obj)
|
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::Create Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
|
|
|
JSContext *cx, JSObject *obj)
|
|
|
|
{
|
2009-06-03 15:30:18 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 08:55:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::PostTransplant(nsIXPConnectWrappedNative *wrapper,
|
|
|
|
JSContext *cx, JSObject *obj)
|
|
|
|
{
|
2013-06-29 01:38:30 +00:00
|
|
|
MOZ_CRASH("nsDOMClassInfo::PostTransplant Don't call me!");
|
2012-07-13 08:55:14 +00:00
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2010-07-15 06:19:36 +00:00
|
|
|
JSObject *obj, jsid id, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::AddProperty Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-04-06 04:22:55 +00:00
|
|
|
JSObject *obj, jsid id, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2010-07-15 06:19:36 +00:00
|
|
|
JSObject *obj, jsid id, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::GetProperty Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2010-07-15 06:19:36 +00:00
|
|
|
JSObject *obj, jsid id, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::SetProperty Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject *obj, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2008-03-06 20:20:42 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (!sSecMan) {
|
|
|
|
NS_ERROR("No security manager!!!");
|
2001-09-01 03:30:51 +00:00
|
|
|
return NS_OK;
|
2008-03-06 20:20:42 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2001-09-01 03:30:51 +00:00
|
|
|
// Ask the security manager if it's OK to enumerate
|
|
|
|
nsresult rv =
|
2002-08-15 21:18:20 +00:00
|
|
|
sSecMan->CheckPropertyAccess(cx, obj, mData->mName, sEnumerate_id,
|
2001-09-01 03:30:51 +00:00
|
|
|
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
|
|
|
|
2008-03-06 20:20:42 +00:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"XOWs should have stopped us from getting here!!!");
|
|
|
|
#endif
|
2001-09-20 07:58:49 +00:00
|
|
|
|
2001-09-01 03:30:51 +00:00
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSContext *cx, JSObject *obj, uint32_t enum_op,
|
2011-09-29 06:19:26 +00:00
|
|
|
jsval *statep, jsid *idp, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::NewEnumerate Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2003-01-22 03:22:35 +00:00
|
|
|
nsresult
|
2013-05-04 07:51:53 +00:00
|
|
|
nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
|
2003-01-22 03:22:35 +00:00
|
|
|
JSObject **objp)
|
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalForObject(cx, obj));
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
|
|
|
if (!::JS_LookupProperty(cx, global, mData->mName, val.address())) {
|
2003-01-22 03:22:35 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(val)) {
|
|
|
|
// If val is not an (non-null) object there either is no
|
|
|
|
// constructor for this class, or someone messed with
|
|
|
|
// window.classname, just fall through and let the JS engine
|
|
|
|
// return the Object constructor.
|
|
|
|
|
2013-03-21 15:20:42 +00:00
|
|
|
if (!::JS_DefinePropertyById(cx, obj, sConstructor_id, val, JS_PropertyStub,
|
|
|
|
JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
|
2003-01-22 03:22:35 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
*objp = obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj, jsid id, uint32_t flags,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject **objp, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2012-12-20 00:32:34 +00:00
|
|
|
if (id == sConstructor_id) {
|
2003-01-22 03:22:35 +00:00
|
|
|
return ResolveConstructor(cx, obj, objp);
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2003-01-22 03:22:35 +00:00
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj, uint32_t type, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-03-19 14:34:55 +00:00
|
|
|
nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp *fop,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
JSObject *obj)
|
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::Finalize Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *obj, jsid aId, uint32_t mode,
|
2011-09-29 06:19:26 +00:00
|
|
|
jsval *vp, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mode_type = mode & JSACC_TYPEMASK;
|
2002-05-22 00:34:01 +00:00
|
|
|
|
2012-06-27 21:03:49 +00:00
|
|
|
if ((mode_type == JSACC_WATCH || mode_type == JSACC_PROTO) && sSecMan) {
|
2009-05-12 20:20:42 +00:00
|
|
|
nsresult rv;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> real_obj(cx);
|
2009-05-12 20:20:42 +00:00
|
|
|
if (wrapper) {
|
2013-05-20 12:44:18 +00:00
|
|
|
real_obj = wrapper->GetJSObject();
|
|
|
|
NS_ENSURE_STATE(real_obj);
|
2009-05-12 20:20:42 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
real_obj = obj;
|
|
|
|
}
|
2001-07-04 09:44:57 +00:00
|
|
|
|
2001-07-21 02:08:00 +00:00
|
|
|
rv =
|
2002-03-04 02:25:08 +00:00
|
|
|
sSecMan->CheckPropertyAccess(cx, real_obj, mData->mName, id,
|
2001-07-21 02:08:00 +00:00
|
|
|
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2001-07-04 09:44:57 +00:00
|
|
|
// Let XPConnect know that the access was not granted.
|
2011-10-17 14:59:28 +00:00
|
|
|
*_retval = false;
|
2001-07-04 09:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JSObject *obj, const JS::CallArgs &args, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::Call Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JSObject *obj, const JS::CallArgs &args,
|
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::Construct Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject *obj, const jsval &val, bool *bp,
|
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::HasInstance Don't call me!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMClassInfo::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
|
|
|
JSObject * obj, JSObject * *_retval)
|
|
|
|
{
|
2006-02-22 02:18:33 +00:00
|
|
|
NS_WARNING("nsDOMClassInfo::OuterObject Don't call me!");
|
2005-07-30 20:57:07 +00:00
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
static nsresult
|
|
|
|
GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
|
|
|
|
const nsString &aName,
|
|
|
|
const nsGlobalNameStruct *aStruct,
|
|
|
|
const nsGlobalNameStruct **aResult)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aStruct->mType ==
|
|
|
|
nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
|
|
|
"Wrong type!");
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
|
|
|
NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-03-29 18:43:13 +00:00
|
|
|
const nsGlobalNameStruct *name_struct = aNameSpaceManager->LookupName(aName);
|
|
|
|
if (name_struct &&
|
2009-03-24 11:02:30 +00:00
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
*aResult = name_struct;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("Couldn't get the DOM ClassInfo data.");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aResult = nullptr;
|
2009-03-24 11:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Handle<JSObject*> obj, const PRUnichar *name,
|
2010-10-18 22:20:47 +00:00
|
|
|
const nsDOMClassInfoData *ci_data,
|
2009-03-24 11:02:30 +00:00
|
|
|
const nsGlobalNameStruct *name_struct,
|
|
|
|
nsScriptNameSpaceManager *nameSpaceManager,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject *dot_prototype, bool install, bool *did_resolve);
|
2009-03-24 11:02:30 +00:00
|
|
|
|
|
|
|
|
2008-08-20 02:38:24 +00:00
|
|
|
NS_IMETHODIMP
|
2013-05-03 18:53:32 +00:00
|
|
|
nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * aProto)
|
2008-08-20 02:38:24 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags = (mData->mScriptableFlags & DONT_ENUM_STATIC_PROPS)
|
2008-08-20 02:38:24 +00:00
|
|
|
? 0
|
|
|
|
: JSPROP_ENUMERATE;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = 0;
|
2008-08-20 02:38:24 +00:00
|
|
|
while (mData->mInterfaces[count]) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx, aProto);
|
2012-04-14 13:05:17 +00:00
|
|
|
if (!xpc::DOM_DefineQuickStubs(cx, proto, flags, count, mData->mInterfaces)) {
|
2008-08-20 02:38:24 +00:00
|
|
|
JS_ClearPendingException(cx);
|
|
|
|
}
|
2009-03-24 11:02:30 +00:00
|
|
|
|
2011-12-28 21:22:05 +00:00
|
|
|
// This is called before any other location that requires
|
|
|
|
// sObjectClass, so compute it here. We assume that nobody has had a
|
|
|
|
// chance to monkey around with proto's prototype chain before this.
|
|
|
|
if (!sObjectClass) {
|
2012-09-03 23:42:10 +00:00
|
|
|
FindObjectClass(cx, proto);
|
2011-12-28 21:22:05 +00:00
|
|
|
NS_ASSERTION(sObjectClass && !strcmp(sObjectClass->name, "Object"),
|
|
|
|
"Incorrect object class!");
|
|
|
|
}
|
|
|
|
|
2012-09-03 23:42:17 +00:00
|
|
|
#ifdef DEBUG
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Rooted<JSObject*> proto2(cx);
|
|
|
|
JS_GetPrototype(cx, proto, proto2.address());
|
2012-09-03 23:42:17 +00:00
|
|
|
NS_ASSERTION(proto2 && JS_GetClass(proto2) == sObjectClass,
|
|
|
|
"Hmm, somebody did something evil?");
|
|
|
|
#endif
|
2011-12-28 21:22:05 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
#ifdef DEBUG
|
2009-12-08 21:46:42 +00:00
|
|
|
if (mData->mHasClassInterface && mData->mProtoChainInterface &&
|
|
|
|
mData->mProtoChainInterface != &NS_GET_IID(nsISupports)) {
|
2009-03-24 11:02:30 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager>
|
|
|
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
|
|
|
|
|
|
|
if (iim) {
|
|
|
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
|
|
iim->GetInfoForIID(mData->mProtoChainInterface,
|
|
|
|
getter_AddRefs(if_info));
|
|
|
|
|
|
|
|
if (if_info) {
|
|
|
|
nsXPIDLCString name;
|
|
|
|
if_info->GetName(getter_Copies(name));
|
2010-09-17 21:54:40 +00:00
|
|
|
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
|
2009-03-24 11:02:30 +00:00
|
|
|
"Class name and proto chain interface name mismatch!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
// Make prototype delegation work correctly. Consider if a site sets
|
|
|
|
// HTMLElement.prototype.foopy = function () { ... } Now, calling
|
|
|
|
// document.body.foopy() needs to ensure that looking up foopy on
|
|
|
|
// document.body's prototype will find the right function.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalForObject(cx, proto));
|
2009-06-03 15:30:18 +00:00
|
|
|
|
2011-12-28 21:22:05 +00:00
|
|
|
// Only do this if the global object is a window.
|
|
|
|
// XXX Is there a better way to check this?
|
|
|
|
nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> piwin = do_QueryInterface(globalNative);
|
|
|
|
if (!piwin) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow *win = nsGlobalWindow::FromSupports(globalNative);
|
|
|
|
if (win->IsClosedOrClosing()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the window is in a different compartment than the global object, then
|
|
|
|
// it's likely that global is a sandbox object whose prototype is a window.
|
|
|
|
// Don't do anything in this case.
|
|
|
|
if (win->FastGetGlobalJSObject() &&
|
|
|
|
js::GetObjectCompartment(global) != js::GetObjectCompartment(win->FastGetGlobalJSObject())) {
|
2010-12-06 22:46:49 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-28 21:22:05 +00:00
|
|
|
if (win->IsOuterWindow()) {
|
|
|
|
// XXXjst: Do security checks here when we remove the security
|
|
|
|
// checks on the inner window.
|
|
|
|
|
|
|
|
win = win->GetCurrentInnerWindowInternal();
|
|
|
|
|
|
|
|
if (!win || !(global = win->GetGlobalJSObject()) ||
|
|
|
|
win->IsClosedOrClosing()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2009-06-03 15:30:18 +00:00
|
|
|
|
2009-06-24 06:30:11 +00:00
|
|
|
// Don't overwrite a property set by content.
|
|
|
|
JSBool found;
|
2009-08-09 19:42:55 +00:00
|
|
|
if (!::JS_AlreadyHasOwnUCProperty(cx, global, reinterpret_cast<const jschar*>(mData->mNameUTF16),
|
2012-05-30 17:43:39 +00:00
|
|
|
NS_strlen(mData->mNameUTF16), &found)) {
|
2009-06-24 06:30:11 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
|
|
|
NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool unused;
|
2010-10-18 22:20:47 +00:00
|
|
|
return ResolvePrototype(sXPConnect, win, cx, global, mData->mNameUTF16,
|
2012-07-30 14:20:58 +00:00
|
|
|
mData, nullptr, nameSpaceManager, proto, !found,
|
2010-10-18 22:20:47 +00:00
|
|
|
&unused);
|
2008-08-20 02:38:24 +00:00
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// static
|
2001-07-11 09:09:30 +00:00
|
|
|
nsIClassInfo *
|
2007-03-19 09:19:16 +00:00
|
|
|
NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
|
|
|
if (aID >= eDOMClassInfoIDCount) {
|
|
|
|
NS_ERROR("Bad ID!");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2007-03-19 09:19:16 +00:00
|
|
|
if (!nsDOMClassInfo::sIsInitialized) {
|
|
|
|
nsresult rv = nsDOMClassInfo::Init();
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!sClassInfoData[aID].mCachedClassInfo) {
|
|
|
|
nsDOMClassInfoData& data = sClassInfoData[aID];
|
|
|
|
|
2002-03-04 03:37:18 +00:00
|
|
|
data.mCachedClassInfo = data.u.mConstructorFptr(&data);
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_TRUE(data.mCachedClassInfo, nullptr);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
NS_ADDREF(data.mCachedClassInfo);
|
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
|
|
|
|
"This is bad, internal class marked as external!");
|
|
|
|
|
2004-01-06 00:36:01 +00:00
|
|
|
return sClassInfoData[aID].mCachedClassInfo;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
// static
|
|
|
|
nsIClassInfo *
|
|
|
|
nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
|
|
|
|
|| !aData->mCachedClassInfo,
|
|
|
|
"This is bad, external class marked as internal!");
|
|
|
|
|
|
|
|
if (!aData->mCachedClassInfo) {
|
2002-03-04 03:37:18 +00:00
|
|
|
if (aData->u.mExternalConstructorFptr) {
|
2002-08-15 21:18:20 +00:00
|
|
|
aData->mCachedClassInfo =
|
|
|
|
aData->u.mExternalConstructorFptr(aData->mName);
|
2002-03-04 02:25:08 +00:00
|
|
|
} else {
|
|
|
|
aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ENSURE_TRUE(aData->mCachedClassInfo, nullptr);
|
2002-03-04 02:25:08 +00:00
|
|
|
|
|
|
|
NS_ADDREF(aData->mCachedClassInfo);
|
|
|
|
aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
|
|
|
|
}
|
|
|
|
|
2004-01-06 00:36:01 +00:00
|
|
|
return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
|
2002-03-04 02:25:08 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 23:18:16 +00:00
|
|
|
|
2007-01-04 22:31:26 +00:00
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsDOMClassInfo::ShutDown()
|
|
|
|
{
|
2002-03-04 03:37:18 +00:00
|
|
|
if (sClassInfoData[0].u.mConstructorFptr) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t i;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < eDOMClassInfoIDCount; i++) {
|
|
|
|
NS_IF_RELEASE(sClassInfoData[i].mCachedClassInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
sParent_id = JSID_VOID;
|
|
|
|
sScrollbars_id = JSID_VOID;
|
|
|
|
sLocation_id = JSID_VOID;
|
|
|
|
sConstructor_id = JSID_VOID;
|
2012-08-11 16:12:54 +00:00
|
|
|
s_content_id = JSID_VOID;
|
2010-07-15 06:19:36 +00:00
|
|
|
sContent_id = JSID_VOID;
|
|
|
|
sMenubar_id = JSID_VOID;
|
|
|
|
sToolbar_id = JSID_VOID;
|
|
|
|
sLocationbar_id = JSID_VOID;
|
|
|
|
sPersonalbar_id = JSID_VOID;
|
|
|
|
sStatusbar_id = JSID_VOID;
|
|
|
|
sControllers_id = JSID_VOID;
|
|
|
|
sLength_id = JSID_VOID;
|
|
|
|
sScrollX_id = JSID_VOID;
|
|
|
|
sScrollY_id = JSID_VOID;
|
|
|
|
sScrollMaxX_id = JSID_VOID;
|
|
|
|
sScrollMaxY_id = JSID_VOID;
|
|
|
|
sItem_id = JSID_VOID;
|
|
|
|
sEnumerate_id = JSID_VOID;
|
2012-08-25 21:56:45 +00:00
|
|
|
sTop_id = JSID_VOID;
|
2010-07-15 06:19:36 +00:00
|
|
|
sDocument_id = JSID_VOID;
|
|
|
|
sFrames_id = JSID_VOID;
|
|
|
|
sSelf_id = JSID_VOID;
|
2010-09-17 21:54:40 +00:00
|
|
|
sWrappedJSObject_id = JSID_VOID;
|
2011-04-26 12:30:17 +00:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IF_RELEASE(sXPConnect);
|
|
|
|
NS_IF_RELEASE(sSecMan);
|
2011-10-17 14:59:28 +00:00
|
|
|
sIsInitialized = false;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2001-11-20 23:15:32 +00:00
|
|
|
// Window helper
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-09-17 21:54:40 +00:00
|
|
|
nsWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
|
|
|
JSObject *globalObj, JSObject **parentObj)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
|
|
|
// Normally ::PreCreate() is used to give XPConnect the parent
|
|
|
|
// object for the object that's being wrapped, this parent object is
|
|
|
|
// set as the parent of the wrapper and it's also used to find the
|
|
|
|
// right scope for the object being wrapped. Now, in the case of the
|
|
|
|
// global object the wrapper shouldn't have a parent but we supply
|
|
|
|
// one here anyway (the global object itself) and this will be used
|
|
|
|
// by XPConnect only to find the right scope, once the scope is
|
|
|
|
// found XPConnect will find the existing wrapper (which always
|
|
|
|
// exists since it's created on window construction), since an
|
|
|
|
// existing wrapper is found the parent we supply here is ignored
|
|
|
|
// after the wrapper is found.
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeObj));
|
2006-03-30 18:40:56 +00:00
|
|
|
NS_ASSERTION(sgo, "nativeObj not a global object!");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2010-05-28 23:01:08 +00:00
|
|
|
nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
|
2011-08-20 13:53:34 +00:00
|
|
|
NS_ASSERTION(win->IsInnerWindow(), "Should be inner window.");
|
2010-09-17 21:54:40 +00:00
|
|
|
|
2012-04-27 08:38:14 +00:00
|
|
|
// We sometimes get a disconnected window during file api test. :-(
|
|
|
|
if (!win->GetOuterWindowInternal())
|
|
|
|
return NS_ERROR_FAILURE;
|
2012-04-26 16:22:08 +00:00
|
|
|
|
2012-04-27 08:38:14 +00:00
|
|
|
// If we're bootstrapping, we don't have a JS object yet.
|
|
|
|
if (win->GetOuterWindowInternal()->IsCreatingInnerWindow())
|
2010-08-10 22:00:26 +00:00
|
|
|
return NS_OK;
|
2010-07-27 01:08:26 +00:00
|
|
|
|
2012-04-27 08:38:14 +00:00
|
|
|
return SetParentToWindow(win, parentObj);
|
2010-08-10 22:00:26 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2004-08-26 03:49:17 +00:00
|
|
|
static JSClass sGlobalScopePolluterClass = {
|
|
|
|
"Global Scope Polluter",
|
2013-03-19 06:06:44 +00:00
|
|
|
JSCLASS_NEW_RESOLVE,
|
2013-02-07 08:08:57 +00:00
|
|
|
JS_PropertyStub,
|
2013-04-06 04:22:55 +00:00
|
|
|
JS_DeletePropertyStub,
|
2010-09-17 21:54:40 +00:00
|
|
|
nsWindowSH::GlobalScopePolluterGetProperty,
|
2013-02-07 08:08:57 +00:00
|
|
|
JS_StrictPropertyStub,
|
2010-08-02 00:39:35 +00:00
|
|
|
JS_EnumerateStub,
|
2010-09-17 21:54:40 +00:00
|
|
|
(JSResolveOp)nsWindowSH::GlobalScopePolluterNewResolve,
|
2010-08-02 00:39:35 +00:00
|
|
|
JS_ConvertStub,
|
2013-03-19 06:06:44 +00:00
|
|
|
nullptr
|
2004-08-26 03:49:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
2008-09-06 22:21:43 +00:00
|
|
|
JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JS::Handle<JSObject*> obj,
|
|
|
|
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp)
|
2004-08-26 03:49:17 +00:00
|
|
|
{
|
|
|
|
// Someone is accessing a element by referencing its name/id in the
|
|
|
|
// global scope, do a security check to make sure that's ok.
|
|
|
|
|
|
|
|
nsresult rv =
|
2007-08-09 22:19:59 +00:00
|
|
|
sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
|
|
|
|
"Window", id,
|
2004-08-26 03:49:17 +00:00
|
|
|
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// The security check failed. The security manager set a JS
|
|
|
|
// exception for us.
|
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-15 05:38:26 +00:00
|
|
|
// Gets a subframe.
|
|
|
|
static JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
ChildWindowGetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
2013-06-19 10:32:27 +00:00
|
|
|
JS::MutableHandle<JS::Value> vp)
|
2013-03-15 05:38:26 +00:00
|
|
|
{
|
2013-05-05 07:03:19 +00:00
|
|
|
MOZ_ASSERT(JSID_IS_STRING(id));
|
2013-03-15 05:38:26 +00:00
|
|
|
// Grab the native DOM window.
|
|
|
|
vp.setUndefined();
|
|
|
|
nsCOMPtr<nsISupports> winSupports =
|
|
|
|
do_QueryInterface(nsDOMClassInfo::XPConnect()->GetNativeOfWrapper(cx, obj));
|
|
|
|
if (!winSupports)
|
|
|
|
return true;
|
|
|
|
nsGlobalWindow *win = nsGlobalWindow::FromSupports(winSupports);
|
|
|
|
|
|
|
|
// Find the child, if it exists.
|
2013-05-05 07:03:19 +00:00
|
|
|
nsDependentJSString name(id);
|
|
|
|
nsCOMPtr<nsIDOMWindow> child = win->GetChildWindow(name);
|
2013-03-15 05:38:26 +00:00
|
|
|
if (!child)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Wrap the child for JS.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2013-03-15 05:38:26 +00:00
|
|
|
nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), child,
|
2013-05-03 18:53:32 +00:00
|
|
|
/* aAllowWrapping = */ true, v.address());
|
2013-03-15 05:38:26 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
vp.set(v);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-10 16:43:20 +00:00
|
|
|
static nsHTMLDocument*
|
2012-02-05 20:07:23 +00:00
|
|
|
GetDocument(JSObject *obj)
|
2010-05-10 16:43:20 +00:00
|
|
|
{
|
2013-06-12 06:55:00 +00:00
|
|
|
MOZ_ASSERT(js::GetObjectJSClass(obj) == &sHTMLDocumentAllClass);
|
2010-05-10 16:43:20 +00:00
|
|
|
return static_cast<nsHTMLDocument*>(
|
2013-06-12 06:55:00 +00:00
|
|
|
static_cast<nsINode*>(JS_GetPrivate(obj)));
|
2010-05-10 16:43:20 +00:00
|
|
|
}
|
|
|
|
|
2004-08-26 03:49:17 +00:00
|
|
|
// static
|
2008-09-06 22:21:43 +00:00
|
|
|
JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JS::Handle<JSObject*> obj,
|
|
|
|
JS::Handle<jsid> id, unsigned flags,
|
2013-04-16 23:20:44 +00:00
|
|
|
JS::MutableHandle<JSObject*> objp)
|
2004-08-26 03:49:17 +00:00
|
|
|
{
|
2012-12-20 00:32:34 +00:00
|
|
|
if (!JSID_IS_STRING(id)) {
|
|
|
|
// Nothing to do if we're resolving a non-string property.
|
2004-08-26 03:49:17 +00:00
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-20 18:08:30 +00:00
|
|
|
// Crash reports from the wild seem to get here during shutdown when there's
|
|
|
|
// no more XPConnect singleton.
|
|
|
|
nsIXPConnect *xpc = XPConnect();
|
|
|
|
NS_ENSURE_TRUE(xpc, true);
|
|
|
|
|
2013-03-19 06:06:44 +00:00
|
|
|
// Grab the DOM window.
|
|
|
|
JSObject *global = JS_GetGlobalForObject(cx, obj);
|
2013-03-20 18:08:30 +00:00
|
|
|
nsISupports *globalNative = xpc->GetNativeOfWrapper(cx, global);
|
2013-03-19 06:06:44 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(globalNative);
|
|
|
|
MOZ_ASSERT(piWin);
|
|
|
|
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(piWin.get());
|
|
|
|
|
2013-03-15 05:38:26 +00:00
|
|
|
if (win->GetLength() > 0) {
|
2013-05-05 07:03:19 +00:00
|
|
|
nsDependentJSString name(id);
|
|
|
|
nsCOMPtr<nsIDOMWindow> child_win = win->GetChildWindow(name);
|
2013-03-15 05:38:26 +00:00
|
|
|
if (child_win) {
|
|
|
|
// We found a subframe of the right name, so define the property
|
|
|
|
// on the GSP. This property is a read-only accessor. Shadowing via
|
|
|
|
// |var foo| in global scope is still allowed, since |var| only looks
|
|
|
|
// up |own| properties. But unqualified shadowing will fail, per-spec.
|
|
|
|
if (!JS_DefinePropertyById(cx, obj, id, JS::UndefinedValue(),
|
|
|
|
ChildWindowGetter, JS_StrictPropertyStub,
|
|
|
|
JSPROP_SHARED | JSPROP_ENUMERATE))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
objp.set(obj);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
|
|
|
if (!::JS_GetPrototype(cx, obj, proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
2004-08-26 03:49:17 +00:00
|
|
|
JSBool hasProp;
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
|
2004-08-26 03:49:17 +00:00
|
|
|
hasProp) {
|
|
|
|
// No prototype, or the property exists on the prototype. Do
|
|
|
|
// nothing.
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-19 06:06:47 +00:00
|
|
|
//
|
|
|
|
// The rest of this function is for HTML documents only.
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIHTMLDocument> htmlDoc =
|
2013-04-24 04:22:37 +00:00
|
|
|
do_QueryInterface(win->GetExtantDoc());
|
2013-03-19 06:06:47 +00:00
|
|
|
if (!htmlDoc)
|
|
|
|
return true;
|
|
|
|
nsHTMLDocument *document = static_cast<nsHTMLDocument*>(htmlDoc.get());
|
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString str(id);
|
2010-05-10 16:43:20 +00:00
|
|
|
nsCOMPtr<nsISupports> result;
|
|
|
|
nsWrapperCache *cache;
|
|
|
|
{
|
|
|
|
Element *element = document->GetElementById(str);
|
|
|
|
result = element;
|
|
|
|
cache = element;
|
|
|
|
}
|
2004-08-26 03:49:17 +00:00
|
|
|
|
|
|
|
if (!result) {
|
2013-03-18 09:47:32 +00:00
|
|
|
result = document->ResolveName(str, &cache);
|
2004-08-26 03:49:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result) {
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2005-09-07 02:56:15 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2013-05-03 18:53:32 +00:00
|
|
|
nsresult rv = WrapNative(cx, obj, result, cache, true, v.address(),
|
2009-05-21 08:17:51 +00:00
|
|
|
getter_AddRefs(holder));
|
2007-11-12 21:57:48 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, JS_FALSE);
|
2004-08-26 03:49:17 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapValue(cx, v.address()) ||
|
2013-03-21 15:20:42 +00:00
|
|
|
!JS_DefinePropertyById(cx, obj, id, v, JS_PropertyStub, JS_StrictPropertyStub, 0)) {
|
2004-08-26 03:49:17 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-04 18:12:16 +00:00
|
|
|
objp.set(obj);
|
2004-08-26 03:49:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2004-08-27 21:06:19 +00:00
|
|
|
// static
|
2012-09-03 23:42:17 +00:00
|
|
|
JSBool
|
2013-05-04 07:51:53 +00:00
|
|
|
nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> aObj)
|
2004-08-27 21:06:19 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2004-08-27 21:06:19 +00:00
|
|
|
|
2012-09-03 23:42:17 +00:00
|
|
|
for (;;) {
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!::JS_GetPrototype(cx, obj, proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
if (!proto) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-04 00:54:57 +00:00
|
|
|
if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
|
2004-08-27 21:06:19 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto_proto(cx);
|
|
|
|
if (!::JS_GetPrototype(cx, proto, proto_proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
// Pull the global scope polluter out of the prototype chain so
|
|
|
|
// that it can be freed.
|
2012-09-03 23:42:17 +00:00
|
|
|
::JS_SplicePrototype(cx, obj, proto_proto);
|
2004-08-31 00:04:04 +00:00
|
|
|
|
2004-08-27 21:06:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = proto;
|
|
|
|
}
|
2012-09-03 23:42:17 +00:00
|
|
|
|
|
|
|
return JS_TRUE;
|
2004-08-27 21:06:19 +00:00
|
|
|
}
|
|
|
|
|
2004-08-26 03:49:17 +00:00
|
|
|
// static
|
|
|
|
nsresult
|
2013-05-03 18:53:32 +00:00
|
|
|
nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JS::Handle<JSObject*> obj)
|
2004-08-26 03:49:17 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> gsp(cx, ::JS_NewObjectWithUniqueType(cx, &sGlobalScopePolluterClass, nullptr, obj));
|
2004-08-26 03:49:17 +00:00
|
|
|
if (!gsp) {
|
2005-07-30 20:57:07 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-08-26 03:49:17 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> o(cx, obj), proto(cx);
|
2004-08-26 03:49:17 +00:00
|
|
|
|
|
|
|
// Find the place in the prototype chain where we want this global
|
|
|
|
// scope polluter (right before Object.prototype).
|
|
|
|
|
2012-09-03 23:42:17 +00:00
|
|
|
for (;;) {
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!::JS_GetPrototype(cx, o, proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
if (!proto) {
|
|
|
|
break;
|
|
|
|
}
|
2012-02-04 00:54:57 +00:00
|
|
|
if (JS_GetClass(proto) == sObjectClass) {
|
2004-08-26 03:49:17 +00:00
|
|
|
// Set the global scope polluters prototype to Object.prototype
|
2011-05-01 01:19:35 +00:00
|
|
|
::JS_SplicePrototype(cx, gsp, proto);
|
2004-08-26 03:49:17 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
o = proto;
|
|
|
|
}
|
|
|
|
|
2004-08-27 21:06:19 +00:00
|
|
|
// And then set the prototype of the object whose prototype was
|
2004-08-26 03:49:17 +00:00
|
|
|
// Object.prototype to be the global scope polluter.
|
2011-05-01 00:53:40 +00:00
|
|
|
::JS_SplicePrototype(cx, o, gsp);
|
2004-08-26 03:49:17 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-01 17:51:57 +00:00
|
|
|
struct ResolveGlobalNameClosure
|
|
|
|
{
|
|
|
|
JSContext* cx;
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Handle<JSObject*> obj;
|
2012-11-01 17:51:57 +00:00
|
|
|
bool* retval;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
ResolveGlobalName(const nsAString& aName, void* aClosure)
|
|
|
|
{
|
|
|
|
ResolveGlobalNameClosure* closure =
|
|
|
|
static_cast<ResolveGlobalNameClosure*>(aClosure);
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Rooted<JS::Value> dummy(closure->cx);
|
2012-11-01 17:51:57 +00:00
|
|
|
bool ok = JS_LookupUCProperty(closure->cx, closure->obj,
|
|
|
|
aName.BeginReading(), aName.Length(),
|
2013-05-29 20:16:04 +00:00
|
|
|
dummy.address());
|
2012-11-01 17:51:57 +00:00
|
|
|
if (!ok) {
|
|
|
|
*closure->retval = false;
|
|
|
|
return PL_DHASH_STOP;
|
|
|
|
}
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
2011-04-08 20:28:05 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-03 18:53:32 +00:00
|
|
|
JSObject *aObj, bool *_retval)
|
2011-04-08 20:28:05 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2013-04-24 22:21:26 +00:00
|
|
|
if (!xpc::WrapperFactory::IsXrayWrapper(obj)) {
|
2011-04-08 20:28:05 +00:00
|
|
|
*_retval = JS_EnumerateStandardClasses(cx, obj);
|
2012-11-01 17:51:57 +00:00
|
|
|
if (!*_retval) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now resolve everything from the namespace manager
|
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
|
|
|
if (!nameSpaceManager) {
|
|
|
|
NS_ERROR("Can't get namespace manager.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
ResolveGlobalNameClosure closure = { cx, obj, _retval };
|
|
|
|
nameSpaceManager->EnumerateGlobalNames(ResolveGlobalName, &closure);
|
2011-04-08 20:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-06 06:41:52 +00:00
|
|
|
static nsDOMConstructorFunc
|
2009-06-03 15:30:18 +00:00
|
|
|
FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
|
2008-11-06 06:41:52 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(kConstructorFuncMap); ++i) {
|
2009-06-03 15:30:18 +00:00
|
|
|
if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
|
|
|
|
aDOMClassInfoData) {
|
2008-11-06 06:41:52 +00:00
|
|
|
return kConstructorFuncMap[i].mConstructorFunc;
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-11-06 06:41:52 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
static nsresult
|
2007-12-12 08:33:32 +00:00
|
|
|
BaseStubConstructor(nsIWeakReference* aWeakOwner,
|
|
|
|
const nsGlobalNameStruct *name_struct, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JS::Handle<JSObject*> obj, const JS::CallArgs &args)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2013-04-26 06:48:40 +00:00
|
|
|
MOZ_ASSERT(obj);
|
|
|
|
|
2003-01-22 03:22:35 +00:00
|
|
|
nsresult rv;
|
2002-03-04 02:25:08 +00:00
|
|
|
nsCOMPtr<nsISupports> native;
|
2005-11-18 13:39:43 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
2009-06-03 15:30:18 +00:00
|
|
|
const nsDOMClassInfoData* ci_data =
|
|
|
|
&sClassInfoData[name_struct->mDOMClassInfoID];
|
2012-08-09 07:19:48 +00:00
|
|
|
nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
|
|
|
|
if (func) {
|
|
|
|
rv = func(getter_AddRefs(native));
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
2008-11-06 06:41:52 +00:00
|
|
|
}
|
2005-11-18 13:39:43 +00:00
|
|
|
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
2002-03-04 02:25:08 +00:00
|
|
|
native = do_CreateInstance(name_struct->mCID, &rv);
|
2002-08-30 08:48:58 +00:00
|
|
|
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
|
|
native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
|
2002-03-04 02:25:08 +00:00
|
|
|
} else {
|
|
|
|
native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("Failed to create the object");
|
2005-12-09 19:08:45 +00:00
|
|
|
return rv;
|
2002-03-04 02:25:08 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
|
2012-06-01 21:40:14 +00:00
|
|
|
nsCOMPtr<nsIDOMGlobalObjectConstructor> constructor(do_QueryInterface(native));
|
|
|
|
if (initializer || constructor) {
|
2008-04-29 19:22:24 +00:00
|
|
|
// Initialize object using the current inner window, but only if
|
|
|
|
// the caller can access it.
|
2008-02-27 02:03:27 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
|
2012-07-30 14:20:58 +00:00
|
|
|
nsPIDOMWindow* outerWindow = owner ? owner->GetOuterWindow() : nullptr;
|
2008-04-29 19:22:24 +00:00
|
|
|
nsPIDOMWindow* currentInner =
|
2012-07-30 14:20:58 +00:00
|
|
|
outerWindow ? outerWindow->GetCurrentInnerWindow() : nullptr;
|
2008-04-29 19:22:24 +00:00
|
|
|
if (!currentInner ||
|
|
|
|
(owner != currentInner &&
|
|
|
|
!nsContentUtils::CanCallerAccess(currentInner))) {
|
|
|
|
return NS_ERROR_DOM_SECURITY_ERR;
|
|
|
|
}
|
|
|
|
|
2012-06-01 21:40:14 +00:00
|
|
|
if (initializer) {
|
2013-05-04 17:25:15 +00:00
|
|
|
rv = initializer->Initialize(currentInner, cx, obj, args);
|
2012-06-01 21:40:14 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(native);
|
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> thisObject(cx, wrappedJS->GetJSObject());
|
2013-05-04 17:25:15 +00:00
|
|
|
if (!thisObject) {
|
2012-06-01 21:40:14 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCxPusher pusher;
|
2013-02-26 19:04:11 +00:00
|
|
|
pusher.Push(cx);
|
2012-06-01 21:40:14 +00:00
|
|
|
|
2013-05-04 17:25:15 +00:00
|
|
|
JSAutoCompartment ac(cx, thisObject);
|
2012-06-01 21:40:14 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> funval(cx);
|
2013-05-04 17:25:15 +00:00
|
|
|
if (!JS_GetProperty(cx, thisObject, "constructor", funval.address()) ||
|
|
|
|
!funval.isObject()) {
|
2012-06-01 21:40:14 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the object is even callable.
|
|
|
|
NS_ENSURE_STATE(JS_ObjectIsCallable(cx, &funval.toObject()));
|
|
|
|
{
|
|
|
|
// wrap parameters in the target compartment
|
2012-08-03 15:35:00 +00:00
|
|
|
// we also pass in the calling window as the first argument
|
2013-05-04 17:25:15 +00:00
|
|
|
unsigned argc = args.length() + 1;
|
|
|
|
nsAutoArrayPtr<JS::Value> argv(new JS::Value[argc]);
|
|
|
|
JS::AutoArrayRooter rooter(cx, 0, argv);
|
2012-06-01 21:40:14 +00:00
|
|
|
|
2012-08-03 15:35:00 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
|
|
nsCOMPtr<nsIDOMWindow> currentWin(do_GetInterface(currentInner));
|
|
|
|
rv = WrapNative(cx, obj, currentWin, &NS_GET_IID(nsIDOMWindow),
|
2013-05-04 17:25:15 +00:00
|
|
|
true, &argv[0], getter_AddRefs(holder));
|
|
|
|
if (!JS_WrapValue(cx, &argv[0]))
|
2012-08-03 15:35:00 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
rooter.changeLength(1);
|
|
|
|
|
|
|
|
for (size_t i = 1; i < argc; ++i) {
|
2013-05-04 17:25:15 +00:00
|
|
|
argv[i] = args[i - 1];
|
|
|
|
if (!JS_WrapValue(cx, &argv[i]))
|
2012-06-01 21:40:14 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
rooter.changeLength(i + 1);
|
|
|
|
}
|
|
|
|
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Rooted<JS::Value> frval(cx);
|
|
|
|
bool ret = JS_CallFunctionValue(cx, thisObject, funval, argc, argv,
|
|
|
|
frval.address());
|
2012-06-01 21:40:14 +00:00
|
|
|
|
|
|
|
if (!ret) {
|
2012-06-02 21:21:03 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-06-01 21:40:14 +00:00
|
|
|
}
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-04 17:25:15 +00:00
|
|
|
return WrapNative(cx, obj, native, true, args.rval().address());
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
static nsresult
|
2013-05-03 18:53:32 +00:00
|
|
|
DefineInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *aIID)
|
2001-07-11 09:09:30 +00:00
|
|
|
{
|
2005-11-10 16:19:44 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager>
|
|
|
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
2001-07-11 09:09:30 +00:00
|
|
|
NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
|
|
|
|
|
|
nsresult rv = iim->GetInfoForIID(aIID, getter_AddRefs(if_info));
|
|
|
|
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && if_info, rv);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t constant_count;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
if_info->GetConstantCount(&constant_count);
|
|
|
|
|
|
|
|
if (!constant_count) {
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfo> parent_if_info;
|
|
|
|
|
|
|
|
rv = if_info->GetParent(getter_AddRefs(parent_if_info));
|
|
|
|
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && parent_if_info, rv);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t parent_constant_count, i;
|
2001-07-11 09:09:30 +00:00
|
|
|
parent_if_info->GetConstantCount(&parent_constant_count);
|
|
|
|
|
|
|
|
for (i = parent_constant_count; i < constant_count; i++) {
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsXPTConstant *c = nullptr;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
rv = if_info->GetConstant(i, &c);
|
|
|
|
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && c, rv);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t type = c->GetType().TagPart();
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2003-01-31 12:10:13 +00:00
|
|
|
jsval v;
|
|
|
|
switch (type) {
|
|
|
|
case nsXPTType::T_I8:
|
|
|
|
case nsXPTType::T_U8:
|
|
|
|
{
|
|
|
|
v = INT_TO_JSVAL(c->GetValue()->val.u8);
|
|
|
|
break;
|
2001-07-11 09:09:30 +00:00
|
|
|
}
|
2003-01-31 12:10:13 +00:00
|
|
|
case nsXPTType::T_I16:
|
|
|
|
case nsXPTType::T_U16:
|
|
|
|
{
|
|
|
|
v = INT_TO_JSVAL(c->GetValue()->val.u16);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsXPTType::T_I32:
|
2009-08-10 23:04:21 +00:00
|
|
|
{
|
2012-08-02 00:59:47 +00:00
|
|
|
v = JS_NumberValue(c->GetValue()->val.i32);
|
2009-08-10 23:04:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-01-31 12:10:13 +00:00
|
|
|
case nsXPTType::T_U32:
|
|
|
|
{
|
2012-08-02 00:59:47 +00:00
|
|
|
v = JS_NumberValue(c->GetValue()->val.u32);
|
2003-01-31 12:10:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2003-01-31 12:10:13 +00:00
|
|
|
NS_ERROR("Non-numeric constant found in interface.");
|
2001-07-11 09:09:30 +00:00
|
|
|
#endif
|
2003-01-31 12:10:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 15:20:42 +00:00
|
|
|
if (!::JS_DefineProperty(cx, obj, c->GetName(), v,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
2010-12-03 17:10:46 +00:00
|
|
|
JSPROP_ENUMERATE | JSPROP_READONLY |
|
|
|
|
JSPROP_PERMANENT)) {
|
2003-01-31 12:10:13 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
// This code is temporary until we remove support for the constants defined
|
|
|
|
// on IDBCursor/IDBRequest/IDBTransaction
|
|
|
|
|
|
|
|
struct IDBConstant
|
|
|
|
{
|
|
|
|
const char* interface;
|
|
|
|
const char* name;
|
|
|
|
const char* value;
|
2013-02-08 20:25:37 +00:00
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
static const char* IDBCursor;
|
|
|
|
static const char* IDBRequest;
|
|
|
|
static const char* IDBTransaction;
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* IDBConstant::IDBCursor = "IDBCursor";
|
|
|
|
const char* IDBConstant::IDBRequest = "IDBRequest";
|
|
|
|
const char* IDBConstant::IDBTransaction = "IDBTransaction";
|
|
|
|
|
|
|
|
static const IDBConstant sIDBConstants[] = {
|
|
|
|
{ IDBConstant::IDBCursor, "NEXT", "next" },
|
|
|
|
{ IDBConstant::IDBCursor, "NEXT_NO_DUPLICATE", "nextunique" },
|
|
|
|
{ IDBConstant::IDBCursor, "PREV", "prev" },
|
|
|
|
{ IDBConstant::IDBCursor, "PREV_NO_DUPLICATE", "prevunique" },
|
|
|
|
{ IDBConstant::IDBRequest, "LOADING", "pending" },
|
|
|
|
{ IDBConstant::IDBRequest, "DONE", "done" },
|
|
|
|
{ IDBConstant::IDBTransaction, "READ_ONLY", "readonly" },
|
|
|
|
{ IDBConstant::IDBTransaction, "READ_WRITE", "readwrite" },
|
|
|
|
{ IDBConstant::IDBTransaction, "VERSION_CHANGE", "versionchange" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
IDBConstantGetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
|
|
|
JS::MutableHandle<JS::Value> vp)
|
2012-03-13 04:44:45 +00:00
|
|
|
{
|
2012-06-26 20:35:34 +00:00
|
|
|
JSString *idstr = JSID_TO_STRING(id);
|
|
|
|
unsigned index;
|
|
|
|
for (index = 0; index < mozilla::ArrayLength(sIDBConstants); index++) {
|
|
|
|
JSBool match;
|
|
|
|
if (!JS_StringEqualsAscii(cx, idstr, sIDBConstants[index].name, &match)) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
if (match) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(index < mozilla::ArrayLength(sIDBConstants));
|
2012-03-13 04:44:45 +00:00
|
|
|
|
|
|
|
const IDBConstant& c = sIDBConstants[index];
|
|
|
|
|
|
|
|
// Put a warning on the console
|
|
|
|
nsString warnText =
|
|
|
|
NS_LITERAL_STRING("The constant ") +
|
|
|
|
NS_ConvertASCIItoUTF16(c.interface) +
|
|
|
|
NS_LITERAL_STRING(".") +
|
|
|
|
NS_ConvertASCIItoUTF16(c.name) +
|
|
|
|
NS_LITERAL_STRING(" has been deprecated. Use the string value \"") +
|
|
|
|
NS_ConvertASCIItoUTF16(c.value) +
|
|
|
|
NS_LITERAL_STRING("\" instead.");
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t windowID = 0;
|
2012-03-13 04:44:45 +00:00
|
|
|
nsIScriptContext* context = GetScriptContextFromJSContext(cx);
|
|
|
|
if (context) {
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window =
|
|
|
|
do_QueryInterface(context->GetGlobalObject());
|
|
|
|
if (window) {
|
|
|
|
window = window->GetCurrentInnerWindow();
|
|
|
|
}
|
|
|
|
NS_WARN_IF_FALSE(window, "Missing a window, got a door?");
|
|
|
|
if (window) {
|
|
|
|
windowID = window->WindowID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> errorObject =
|
|
|
|
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
|
|
|
NS_WARN_IF_FALSE(errorObject, "Failed to create error object");
|
|
|
|
if (errorObject) {
|
2012-09-09 23:29:12 +00:00
|
|
|
nsresult rv = errorObject->InitWithWindowID(warnText,
|
|
|
|
EmptyString(), // file name
|
|
|
|
EmptyString(), // source line
|
2012-03-13 04:44:45 +00:00
|
|
|
0, 0, // Line/col number
|
|
|
|
nsIScriptError::warningFlag,
|
|
|
|
"DOM Core", windowID);
|
|
|
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init error object");
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIConsoleService> consoleServ =
|
|
|
|
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
|
|
|
if (consoleServ) {
|
|
|
|
consoleServ->LogMessage(errorObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redefine property to remove getter
|
|
|
|
NS_ConvertASCIItoUTF16 valStr(c.value);
|
2013-05-11 02:39:45 +00:00
|
|
|
JS::Rooted<JS::Value> value(cx);
|
|
|
|
if (!xpc::StringToJsval(cx, valStr, value.address())) {
|
2012-03-13 04:44:45 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
2013-03-21 15:20:42 +00:00
|
|
|
if (!::JS_DefineProperty(cx, obj, c.name, value,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
2012-03-13 04:44:45 +00:00
|
|
|
JSPROP_ENUMERATE)) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return value
|
2012-07-30 11:19:09 +00:00
|
|
|
vp.set(value);
|
2012-03-13 04:44:45 +00:00
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2013-05-11 02:39:45 +00:00
|
|
|
DefineIDBInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *aIID)
|
2012-03-13 04:44:45 +00:00
|
|
|
{
|
|
|
|
const char* interface;
|
|
|
|
if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
|
|
|
|
interface = IDBConstant::IDBCursor;
|
2012-04-14 15:52:34 +00:00
|
|
|
}
|
|
|
|
else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
|
2012-03-13 04:44:45 +00:00
|
|
|
interface = IDBConstant::IDBRequest;
|
2012-04-14 15:52:34 +00:00
|
|
|
}
|
|
|
|
else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
|
2012-03-13 04:44:45 +00:00
|
|
|
interface = IDBConstant::IDBTransaction;
|
|
|
|
}
|
2012-07-24 23:20:26 +00:00
|
|
|
else {
|
2013-06-29 01:38:30 +00:00
|
|
|
MOZ_CRASH("unexpected IID");
|
2012-07-24 23:20:26 +00:00
|
|
|
}
|
2012-03-13 04:44:45 +00:00
|
|
|
|
|
|
|
for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
|
|
|
|
const IDBConstant& c = sIDBConstants[i];
|
|
|
|
if (c.interface != interface) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-06-26 20:35:34 +00:00
|
|
|
if (!JS_DefineProperty(cx, obj, c.name, JSVAL_VOID,
|
2013-03-21 15:20:42 +00:00
|
|
|
IDBConstantGetter, JS_StrictPropertyStub,
|
2012-06-26 20:35:34 +00:00
|
|
|
JSPROP_ENUMERATE)) {
|
2012-03-13 04:44:45 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-15 04:50:29 +00:00
|
|
|
class nsDOMConstructor MOZ_FINAL : public nsIDOMDOMConstructor
|
2003-01-22 03:22:35 +00:00
|
|
|
{
|
2008-02-27 02:03:27 +00:00
|
|
|
protected:
|
2009-06-03 15:30:18 +00:00
|
|
|
nsDOMConstructor(const PRUnichar* aName,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsConstructable,
|
2008-02-27 02:03:27 +00:00
|
|
|
nsPIDOMWindow* aOwner)
|
2007-05-09 12:04:59 +00:00
|
|
|
: mClassName(aName),
|
2009-06-03 15:30:18 +00:00
|
|
|
mConstructable(aIsConstructable),
|
2007-12-12 08:33:32 +00:00
|
|
|
mWeakOwner(do_GetWeakReference(aOwner))
|
2005-12-09 19:08:45 +00:00
|
|
|
{
|
|
|
|
}
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2008-02-27 02:03:27 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
static nsresult Create(const PRUnichar* aName,
|
2009-06-03 15:30:18 +00:00
|
|
|
const nsDOMClassInfoData* aData,
|
2008-02-27 02:03:27 +00:00
|
|
|
const nsGlobalNameStruct* aNameStruct,
|
|
|
|
nsPIDOMWindow* aOwner,
|
|
|
|
nsDOMConstructor** aResult);
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2007-11-12 06:43:14 +00:00
|
|
|
NS_DECL_NSIDOMDOMCONSTRUCTOR
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2011-01-11 20:15:52 +00:00
|
|
|
nsresult PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj);
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
nsresult Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JS::Handle<JSObject*> obj, const JS::CallArgs &args,
|
2013-05-04 17:25:15 +00:00
|
|
|
bool *_retval);
|
2005-12-09 19:08:45 +00:00
|
|
|
|
|
|
|
nsresult HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Handle<JSObject*> obj, const jsval &val, bool *bp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval);
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2013-05-04 07:51:53 +00:00
|
|
|
nsresult Install(JSContext *cx, JS::Handle<JSObject*> target,
|
|
|
|
JS::Handle<JS::Value> aThisAsVal)
|
2005-12-09 19:08:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JS::Value> thisAsVal(cx, aThisAsVal);
|
2011-01-26 01:49:10 +00:00
|
|
|
// The 'attrs' argument used to be JSPROP_PERMANENT. See bug 628612.
|
2013-05-04 07:51:53 +00:00
|
|
|
JSBool ok = JS_WrapValue(cx, thisAsVal.address()) &&
|
2006-06-05 07:18:02 +00:00
|
|
|
::JS_DefineUCProperty(cx, target,
|
2007-07-08 07:08:04 +00:00
|
|
|
reinterpret_cast<const jschar *>(mClassName),
|
2013-03-21 15:20:42 +00:00
|
|
|
NS_strlen(mClassName), thisAsVal, JS_PropertyStub,
|
|
|
|
JS_StrictPropertyStub, 0);
|
2006-06-05 07:18:02 +00:00
|
|
|
|
|
|
|
return ok ? NS_OK : NS_ERROR_UNEXPECTED;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
nsresult ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj);
|
2011-09-22 02:16:50 +00:00
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
private:
|
2007-05-09 12:04:59 +00:00
|
|
|
const nsGlobalNameStruct *GetNameStruct()
|
|
|
|
{
|
|
|
|
if (!mClassName) {
|
|
|
|
NS_ERROR("Can't get name");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2007-05-09 12:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsGlobalNameStruct *nameStruct;
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult rv =
|
|
|
|
#endif
|
|
|
|
GetNameStruct(nsDependentString(mClassName), &nameStruct);
|
|
|
|
|
|
|
|
NS_ASSERTION(NS_FAILED(rv) || nameStruct, "Name isn't in hash.");
|
|
|
|
|
|
|
|
return nameStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult GetNameStruct(const nsAString& aName,
|
|
|
|
const nsGlobalNameStruct **aNameStruct)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aNameStruct = nullptr;
|
2007-05-09 12:04:59 +00:00
|
|
|
|
2011-09-06 19:01:01 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
2007-11-13 10:35:49 +00:00
|
|
|
if (!nameSpaceManager) {
|
2007-05-09 12:04:59 +00:00
|
|
|
NS_ERROR("Can't get namespace manager.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-03-29 18:43:13 +00:00
|
|
|
*aNameStruct = nameSpaceManager->LookupName(aName);
|
2007-05-09 12:04:59 +00:00
|
|
|
|
|
|
|
// Return NS_OK here, aName just isn't a DOM class but nothing failed.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsConstructable(const nsDOMClassInfoData *aData)
|
2009-06-03 15:30:18 +00:00
|
|
|
{
|
2009-12-09 05:50:27 +00:00
|
|
|
if (IS_EXTERNAL(aData->mCachedClassInfo)) {
|
2009-06-03 15:30:18 +00:00
|
|
|
const nsExternalDOMClassInfoData* data =
|
|
|
|
static_cast<const nsExternalDOMClassInfoData*>(aData);
|
2012-07-30 14:20:58 +00:00
|
|
|
return data->mConstructorCID != nullptr;
|
2009-06-03 15:30:18 +00:00
|
|
|
}
|
|
|
|
|
2012-08-09 07:19:48 +00:00
|
|
|
return FindConstructorFunc(aData);
|
2009-06-03 15:30:18 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
|
2007-05-09 12:04:59 +00:00
|
|
|
{
|
|
|
|
return
|
|
|
|
(aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
2009-06-03 15:30:18 +00:00
|
|
|
IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
|
2007-05-09 12:04:59 +00:00
|
|
|
(aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
|
2009-06-03 15:30:18 +00:00
|
|
|
IsConstructable(aNameStruct->mData)) ||
|
2007-05-09 12:04:59 +00:00
|
|
|
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor ||
|
|
|
|
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
|
|
|
}
|
|
|
|
|
2007-12-12 08:33:32 +00:00
|
|
|
const PRUnichar* mClassName;
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool mConstructable;
|
2007-12-12 08:33:32 +00:00
|
|
|
nsWeakPtr mWeakOwner;
|
2005-12-09 19:08:45 +00:00
|
|
|
};
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2008-02-27 02:03:27 +00:00
|
|
|
//static
|
|
|
|
nsresult
|
|
|
|
nsDOMConstructor::Create(const PRUnichar* aName,
|
2009-06-03 15:30:18 +00:00
|
|
|
const nsDOMClassInfoData* aData,
|
2008-02-27 02:03:27 +00:00
|
|
|
const nsGlobalNameStruct* aNameStruct,
|
|
|
|
nsPIDOMWindow* aOwner,
|
|
|
|
nsDOMConstructor** aResult)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aResult = nullptr;
|
2008-12-28 22:42:30 +00:00
|
|
|
// Prevent creating a constructor if aOwner is inner window which doesn't have
|
|
|
|
// an outer window. If the outer window doesn't have an inner window or the
|
|
|
|
// caller can't access the outer window's current inner window then try to use
|
|
|
|
// the owner (so long as it is, in fact, an inner window). If that doesn't
|
|
|
|
// work then prevent creation also.
|
2008-04-25 09:45:58 +00:00
|
|
|
nsPIDOMWindow* outerWindow = aOwner->GetOuterWindow();
|
|
|
|
nsPIDOMWindow* currentInner =
|
2008-12-28 22:42:30 +00:00
|
|
|
outerWindow ? outerWindow->GetCurrentInnerWindow() : aOwner;
|
2010-10-25 19:15:04 +00:00
|
|
|
if (!currentInner ||
|
2008-04-25 09:45:58 +00:00
|
|
|
(aOwner != currentInner &&
|
2008-12-28 22:42:30 +00:00
|
|
|
!nsContentUtils::CanCallerAccess(currentInner) &&
|
|
|
|
!(currentInner = aOwner)->IsInnerWindow())) {
|
2008-02-27 02:03:27 +00:00
|
|
|
return NS_ERROR_DOM_SECURITY_ERR;
|
|
|
|
}
|
2009-06-03 15:30:18 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool constructable = aNameStruct ?
|
2009-06-03 15:30:18 +00:00
|
|
|
IsConstructable(aNameStruct) :
|
|
|
|
IsConstructable(aData);
|
|
|
|
|
|
|
|
*aResult = new nsDOMConstructor(aName, constructable, currentInner);
|
2008-02-27 02:03:27 +00:00
|
|
|
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_IMPL_ADDREF(nsDOMConstructor)
|
|
|
|
NS_IMPL_RELEASE(nsDOMConstructor)
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMConstructor)
|
2007-11-12 06:43:14 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMConstructor)
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2007-05-09 12:04:59 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
const nsGlobalNameStruct *name_struct = GetNameStruct();
|
|
|
|
NS_ASSERTION(!name_struct ||
|
|
|
|
mConstructable == IsConstructable(name_struct),
|
|
|
|
"Can't change constructability dynamically!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
foundInterface =
|
|
|
|
NS_GetDOMClassInfoInstance(mConstructable ?
|
2007-11-12 06:43:14 +00:00
|
|
|
eDOMClassInfo_DOMConstructor_id :
|
|
|
|
eDOMClassInfo_DOMPrototype_id);
|
2007-05-09 12:04:59 +00:00
|
|
|
if (!foundInterface) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*aInstancePtr = nullptr;
|
2007-05-09 12:04:59 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
} else
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2011-01-11 20:15:52 +00:00
|
|
|
nsresult
|
|
|
|
nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> owner(do_QueryReferent(mWeakOwner));
|
|
|
|
if (!owner) {
|
|
|
|
// Can't do anything.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow *win = static_cast<nsGlobalWindow *>(owner.get());
|
2012-04-27 08:38:14 +00:00
|
|
|
return SetParentToWindow(win, parentObj);
|
2011-01-11 20:15:52 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 19:52:04 +00:00
|
|
|
nsresult
|
2005-12-09 19:08:45 +00:00
|
|
|
nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JS::Handle<JSObject*> obj, const JS::CallArgs &args,
|
|
|
|
bool *_retval)
|
2005-12-09 19:08:45 +00:00
|
|
|
{
|
2013-04-26 06:48:40 +00:00
|
|
|
MOZ_ASSERT(obj);
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
const nsGlobalNameStruct *name_struct = GetNameStruct();
|
|
|
|
NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE);
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
if (!IsConstructable(name_struct)) {
|
2003-01-22 03:22:35 +00:00
|
|
|
// ignore return value, we return JS_FALSE anyway
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-04 17:25:15 +00:00
|
|
|
return BaseStubConstructor(mWeakOwner, name_struct, cx, obj, args);
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 19:52:04 +00:00
|
|
|
nsresult
|
2005-12-09 19:08:45 +00:00
|
|
|
nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSContext * cx, JS::Handle<JSObject*> obj,
|
2011-09-29 06:19:26 +00:00
|
|
|
const jsval &v, bool *bp, bool *_retval)
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2003-01-22 03:22:35 +00:00
|
|
|
{
|
2004-01-23 17:07:57 +00:00
|
|
|
// No need to look these up in the hash.
|
2011-10-17 14:59:28 +00:00
|
|
|
*bp = false;
|
2004-01-23 17:07:57 +00:00
|
|
|
if (JSVAL_IS_PRIMITIVE(v)) {
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> dom_obj(cx, v.toObjectOrNull());
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
|
2004-01-23 17:07:57 +00:00
|
|
|
|
2013-02-26 16:15:44 +00:00
|
|
|
// This might not be the right object, if there are wrappers. Unwrap if we can.
|
2013-04-11 18:50:18 +00:00
|
|
|
JSObject *wrapped_obj = js::CheckedUnwrap(dom_obj, /* stopAtOuter = */ false);
|
2013-02-26 16:15:44 +00:00
|
|
|
if (wrapped_obj)
|
|
|
|
dom_obj = wrapped_obj;
|
2005-05-22 21:30:15 +00:00
|
|
|
|
2012-02-04 00:54:57 +00:00
|
|
|
JSClass *dom_class = JS_GetClass(dom_obj);
|
2003-01-22 03:22:35 +00:00
|
|
|
if (!dom_class) {
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ERROR("nsDOMConstructor::HasInstance can't get class.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
const nsGlobalNameStruct *name_struct;
|
2013-02-26 16:15:44 +00:00
|
|
|
nsresult rv = GetNameStruct(NS_ConvertASCIItoUTF16(dom_class->name), &name_struct);
|
2011-07-17 19:09:13 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2007-05-09 12:04:59 +00:00
|
|
|
return rv;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2011-07-17 19:09:13 +00:00
|
|
|
if (!name_struct) {
|
|
|
|
// This isn't a normal DOM object, see if this constructor lives on its
|
|
|
|
// prototype chain.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
|
|
|
if (!JS_GetProperty(cx, obj, "prototype", val.address())) {
|
2011-07-17 19:09:13 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-02-29 17:11:03 +00:00
|
|
|
if (JSVAL_IS_PRIMITIVE(val)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> dot_prototype(cx, val.toObjectOrNull());
|
2011-07-17 19:09:13 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx, dom_obj);
|
2012-09-03 23:42:17 +00:00
|
|
|
for (;;) {
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_GetPrototype(cx, proto, proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
if (!proto) {
|
|
|
|
break;
|
|
|
|
}
|
2011-07-17 19:09:13 +00:00
|
|
|
if (proto == dot_prototype) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*bp = true;
|
2011-07-17 19:09:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-08 16:11:41 +00:00
|
|
|
if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
|
|
|
|
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo &&
|
|
|
|
name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
|
|
// Doesn't have DOM interfaces.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
const nsGlobalNameStruct *class_name_struct = GetNameStruct();
|
|
|
|
NS_ENSURE_TRUE(class_name_struct, NS_ERROR_FAILURE);
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2003-10-21 11:33:34 +00:00
|
|
|
if (name_struct == class_name_struct) {
|
|
|
|
*bp = JS_TRUE;
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-10-21 11:33:34 +00:00
|
|
|
}
|
|
|
|
|
2011-09-06 19:01:01 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
2007-11-13 10:35:49 +00:00
|
|
|
NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?");
|
2007-05-09 12:04:59 +00:00
|
|
|
|
2003-10-21 11:33:34 +00:00
|
|
|
const nsIID *class_iid;
|
|
|
|
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
|
|
|
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
|
|
|
class_iid = &class_name_struct->mIID;
|
|
|
|
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
|
|
class_iid =
|
|
|
|
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
|
|
|
|
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
class_iid = class_name_struct->mData->mProtoChainInterface;
|
|
|
|
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
|
|
const nsGlobalNameStruct* alias_struct =
|
2007-11-13 10:35:49 +00:00
|
|
|
nameSpaceManager->GetConstructorProto(class_name_struct);
|
2003-10-21 11:33:34 +00:00
|
|
|
if (!alias_struct) {
|
|
|
|
NS_ERROR("Couldn't get constructor prototype.");
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-10-21 11:33:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
|
|
class_iid =
|
|
|
|
sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface;
|
|
|
|
} else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
class_iid = alias_struct->mData->mProtoChainInterface;
|
|
|
|
} else {
|
|
|
|
NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo.");
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-10-21 11:33:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*bp = JS_FALSE;
|
2003-01-22 03:22:35 +00:00
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
2007-11-13 10:35:49 +00:00
|
|
|
name_struct = nameSpaceManager->GetConstructorProto(name_struct);
|
2003-01-22 03:22:35 +00:00
|
|
|
if (!name_struct) {
|
|
|
|
NS_ERROR("Couldn't get constructor prototype.");
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
|
|
|
"The constructor was set up with a struct of the wrong type.");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsDOMClassInfoData *ci_data = nullptr;
|
2003-01-22 03:22:35 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
|
|
|
name_struct->mDOMClassInfoID >= 0) {
|
|
|
|
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
|
|
|
|
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
ci_data = name_struct->mData;
|
|
|
|
}
|
|
|
|
|
2005-11-10 16:19:44 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager>
|
|
|
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
2003-01-22 03:22:35 +00:00
|
|
|
if (!iim) {
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ERROR("nsDOMConstructor::HasInstance can't get interface info mgr.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = 0;
|
2003-01-22 03:22:35 +00:00
|
|
|
const nsIID* class_interface;
|
|
|
|
while ((class_interface = ci_data->mInterfaces[count++])) {
|
2003-10-21 11:33:34 +00:00
|
|
|
if (class_iid->Equals(*class_interface)) {
|
2003-01-22 03:22:35 +00:00
|
|
|
*bp = JS_TRUE;
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
iim->GetInfoForIID(class_interface, getter_AddRefs(if_info));
|
|
|
|
if (!if_info) {
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ERROR("nsDOMConstructor::HasInstance can't get interface info.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2003-10-21 11:33:34 +00:00
|
|
|
if_info->HasAncestor(class_iid, bp);
|
2003-01-22 03:22:35 +00:00
|
|
|
|
|
|
|
if (*bp) {
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
return NS_OK;
|
2003-01-22 03:22:35 +00:00
|
|
|
}
|
|
|
|
|
2011-09-22 02:16:50 +00:00
|
|
|
nsresult
|
2013-05-03 18:53:32 +00:00
|
|
|
nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj)
|
2011-09-22 02:16:50 +00:00
|
|
|
{
|
|
|
|
const nsGlobalNameStruct *class_name_struct = GetNameStruct();
|
|
|
|
if (!class_name_struct)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
const nsIID *class_iid;
|
|
|
|
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
|
|
|
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
|
|
|
class_iid = &class_name_struct->mIID;
|
|
|
|
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
|
|
class_iid =
|
|
|
|
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
|
|
|
|
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
class_iid = class_name_struct->mData->mProtoChainInterface;
|
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = DefineInterfaceConstants(cx, obj, class_iid);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Special case for |IDBKeyRange| which gets funny "static" functions.
|
|
|
|
if (class_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
|
|
|
|
!indexedDB::IDBKeyRange::DefineConstructors(cx, obj)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
// Special case a few IDB interfaces which for now are getting transitional
|
|
|
|
// constants.
|
|
|
|
if (class_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
|
|
|
|
class_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
|
|
|
|
class_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
|
|
|
|
rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2011-09-22 02:16:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructor::ToString(nsAString &aResult)
|
2003-01-22 03:22:35 +00:00
|
|
|
{
|
2005-12-10 01:08:51 +00:00
|
|
|
aResult.AssignLiteral("[object ");
|
2005-12-09 19:08:45 +00:00
|
|
|
aResult.Append(mClassName);
|
|
|
|
aResult.Append(PRUnichar(']'));
|
2003-01-22 03:22:35 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2001-07-11 09:09:30 +00:00
|
|
|
}
|
|
|
|
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
static nsresult
|
2009-06-03 15:30:18 +00:00
|
|
|
GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
|
|
|
|
const nsGlobalNameStruct *aNameStruct,
|
|
|
|
nsIXPConnectJSObjectHolder **aProto)
|
2009-03-24 11:02:30 +00:00
|
|
|
{
|
2009-06-03 15:30:18 +00:00
|
|
|
NS_ASSERTION(aNameStruct->mType ==
|
2009-03-24 11:02:30 +00:00
|
|
|
nsGlobalNameStruct::eTypeClassConstructor ||
|
2009-06-03 15:30:18 +00:00
|
|
|
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
2009-03-24 11:02:30 +00:00
|
|
|
"Wrong type!");
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
nsCOMPtr<nsIClassInfo> ci;
|
|
|
|
if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t id = aNameStruct->mDOMClassInfoID;
|
2009-06-03 15:30:18 +00:00
|
|
|
NS_ABORT_IF_FALSE(id >= 0, "Negative DOM classinfo?!?");
|
2003-01-31 12:10:13 +00:00
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
ci = NS_GetDOMClassInfoInstance(ci_id);
|
|
|
|
|
|
|
|
// In most cases we want to find the wrapped native prototype in
|
|
|
|
// aWin's scope and use that prototype for
|
|
|
|
// ClassName.prototype. But in the case where we're setting up
|
|
|
|
// "Window.prototype" or "ChromeWindow.prototype" we want to do
|
|
|
|
// the look up in aWin's outer window's scope since the inner
|
|
|
|
// window's wrapped native prototype comes from the outer
|
|
|
|
// window's scope.
|
|
|
|
if (ci_id == eDOMClassInfo_Window_id ||
|
|
|
|
ci_id == eDOMClassInfo_ModalContentWindow_id ||
|
|
|
|
ci_id == eDOMClassInfo_ChromeWindow_id) {
|
|
|
|
nsGlobalWindow *scopeWindow = aWin->GetOuterWindowInternal();
|
|
|
|
|
|
|
|
if (scopeWindow) {
|
|
|
|
aWin = scopeWindow;
|
|
|
|
}
|
2009-03-24 11:02:30 +00:00
|
|
|
}
|
2009-03-26 14:53:33 +00:00
|
|
|
}
|
2009-06-03 15:30:18 +00:00
|
|
|
else {
|
|
|
|
ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
|
|
|
|
}
|
|
|
|
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2011-01-06 04:28:19 +00:00
|
|
|
nsresult rv =
|
|
|
|
aXPConnect->GetWrappedNativePrototype(cx, aWin->GetGlobalJSObject(), ci,
|
|
|
|
aProto);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> proto_obj(cx, (*aProto)->GetJSObject());
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapObject(cx, proto_obj.address())) {
|
2011-01-06 04:28:19 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_RELEASE(*aProto);
|
|
|
|
return aXPConnect->HoldObject(cx, proto_obj, aProto);
|
2009-06-03 15:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Either ci_data must be non-null or name_struct must be non-null and of type
|
|
|
|
// eTypeClassProto.
|
|
|
|
static nsresult
|
|
|
|
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Handle<JSObject*> obj, const PRUnichar *name,
|
2010-10-18 22:20:47 +00:00
|
|
|
const nsDOMClassInfoData *ci_data,
|
2009-06-03 15:30:18 +00:00
|
|
|
const nsGlobalNameStruct *name_struct,
|
|
|
|
nsScriptNameSpaceManager *nameSpaceManager,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject* aDot_prototype, bool install, bool *did_resolve)
|
2009-06-03 15:30:18 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> dot_prototype(cx, aDot_prototype);
|
2009-06-03 15:30:18 +00:00
|
|
|
NS_ASSERTION(ci_data ||
|
|
|
|
(name_struct &&
|
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeClassProto),
|
|
|
|
"Wrong type or missing ci_data!");
|
2003-11-12 14:25:03 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
nsRefPtr<nsDOMConstructor> constructor;
|
2009-06-03 15:30:18 +00:00
|
|
|
nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin,
|
2009-03-24 11:02:30 +00:00
|
|
|
getter_AddRefs(constructor));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2003-11-12 14:25:03 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2011-04-08 17:50:49 +00:00
|
|
|
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
|
2013-05-03 18:53:32 +00:00
|
|
|
false, v.address(), getter_AddRefs(holder));
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2009-06-24 06:30:11 +00:00
|
|
|
if (install) {
|
|
|
|
rv = constructor->Install(cx, obj, v);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> class_obj(cx, holder->GetJSObject());
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ASSERTION(class_obj, "The return value lied");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
const nsIID *primary_iid = &NS_GET_IID(nsISupports);
|
2002-08-30 08:48:58 +00:00
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
if (!ci_data) {
|
2009-03-24 11:02:30 +00:00
|
|
|
primary_iid = &name_struct->mIID;
|
2009-06-03 15:30:18 +00:00
|
|
|
}
|
|
|
|
else if (ci_data->mProtoChainInterface) {
|
2009-03-24 11:02:30 +00:00
|
|
|
primary_iid = ci_data->mProtoChainInterface;
|
|
|
|
}
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2011-12-28 21:22:05 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
|
|
nsCOMPtr<nsIInterfaceInfo> parent;
|
2012-07-30 14:20:58 +00:00
|
|
|
const char *class_parent_name = nullptr;
|
2011-12-28 21:22:05 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
if (!primary_iid->Equals(NS_GET_IID(nsISupports))) {
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, class_obj);
|
2011-01-11 20:15:52 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
rv = DefineInterfaceConstants(cx, class_obj, primary_iid);
|
2009-03-26 14:53:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2010-11-10 23:26:00 +00:00
|
|
|
// Special case for |IDBKeyRange| which gets funny "static" functions.
|
|
|
|
if (primary_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
|
|
|
|
!indexedDB::IDBKeyRange::DefineConstructors(cx, class_obj)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-12-28 21:22:05 +00:00
|
|
|
|
2012-03-13 04:44:45 +00:00
|
|
|
// Special case a few IDB interfaces which for now are getting transitional
|
|
|
|
// constants.
|
|
|
|
if (primary_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
|
|
|
|
primary_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
|
|
|
|
primary_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
|
|
|
|
rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2011-12-28 21:22:05 +00:00
|
|
|
nsCOMPtr<nsIInterfaceInfoManager>
|
|
|
|
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
|
|
|
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
|
|
|
iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
|
|
|
|
NS_ENSURE_TRUE(if_info, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsIID *iid = nullptr;
|
2011-12-28 21:22:05 +00:00
|
|
|
|
|
|
|
if (ci_data && !ci_data->mHasClassInterface) {
|
|
|
|
if_info->GetIIDShared(&iid);
|
|
|
|
} else {
|
|
|
|
if_info->GetParent(getter_AddRefs(parent));
|
|
|
|
NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
parent->GetIIDShared(&iid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iid) {
|
|
|
|
if (!iid->Equals(NS_GET_IID(nsISupports))) {
|
|
|
|
if (ci_data && !ci_data->mHasClassInterface) {
|
|
|
|
// If the class doesn't have a class interface the primary
|
|
|
|
// interface is the interface that should be
|
|
|
|
// constructor.prototype.__proto__.
|
|
|
|
|
|
|
|
if_info->GetNameShared(&class_parent_name);
|
|
|
|
} else {
|
|
|
|
// If the class does have a class interface (or there's no
|
|
|
|
// real class for this name) then the parent of the
|
|
|
|
// primary interface is what we want on
|
|
|
|
// constructor.prototype.__proto__.
|
|
|
|
|
|
|
|
NS_ASSERTION(parent, "Whoa, this is bad, null parent here!");
|
|
|
|
|
|
|
|
parent->GetNameShared(&class_parent_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-24 11:02:30 +00:00
|
|
|
}
|
2001-12-06 06:57:03 +00:00
|
|
|
|
2010-10-18 22:20:47 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> winobj(cx, aWin->FastGetGlobalJSObject());
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
2011-12-28 21:22:05 +00:00
|
|
|
|
|
|
|
if (class_parent_name) {
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, winobj);
|
2011-12-28 21:22:05 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
|
|
|
if (!JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), val.address())) {
|
2011-12-28 21:22:05 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-05-11 15:46:26 +00:00
|
|
|
if (val.isObject()) {
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_LookupProperty(cx, &val.toObject(), "prototype", val.address())) {
|
2011-12-28 21:22:05 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-05-11 15:46:26 +00:00
|
|
|
if (val.isObject()) {
|
|
|
|
proto = &val.toObject();
|
2011-12-28 21:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-07 07:52:41 +00:00
|
|
|
|
2010-10-18 22:20:47 +00:00
|
|
|
if (dot_prototype) {
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, dot_prototype);
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> xpc_proto_proto(cx);
|
|
|
|
if (!::JS_GetPrototype(cx, dot_prototype, xpc_proto_proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2010-10-18 22:20:47 +00:00
|
|
|
if (proto &&
|
|
|
|
(!xpc_proto_proto ||
|
2012-02-04 00:54:57 +00:00
|
|
|
JS_GetClass(xpc_proto_proto) == sObjectClass)) {
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapObject(cx, proto.address()) ||
|
2010-11-02 05:24:24 +00:00
|
|
|
!JS_SetPrototype(cx, dot_prototype, proto)) {
|
2010-10-18 22:20:47 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2009-03-26 14:53:33 +00:00
|
|
|
}
|
2010-10-18 22:20:47 +00:00
|
|
|
} else {
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, winobj);
|
2012-11-21 16:19:26 +00:00
|
|
|
if (!proto) {
|
|
|
|
proto = JS_GetObjectPrototype(cx, winobj);
|
|
|
|
}
|
|
|
|
dot_prototype = ::JS_NewObjectWithUniqueType(cx,
|
|
|
|
&sDOMConstructorProtoClass,
|
|
|
|
proto,
|
|
|
|
winobj);
|
2010-10-18 22:20:47 +00:00
|
|
|
NS_ENSURE_TRUE(dot_prototype, NS_ERROR_OUT_OF_MEMORY);
|
2009-03-24 11:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-24 11:02:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
v = OBJECT_TO_JSVAL(dot_prototype);
|
2002-08-30 08:48:58 +00:00
|
|
|
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, class_obj);
|
2011-01-11 20:15:52 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
// Per ECMA, the prototype property is {DontEnum, DontDelete, ReadOnly}
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapValue(cx, v.address()) ||
|
2013-03-21 15:20:42 +00:00
|
|
|
!JS_DefineProperty(cx, class_obj, "prototype", v,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
2010-10-18 22:20:47 +00:00
|
|
|
JSPROP_PERMANENT | JSPROP_READONLY)) {
|
2009-03-24 11:02:30 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = true;
|
2009-03-24 11:02:30 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2012-06-14 14:56:38 +00:00
|
|
|
static bool
|
2013-06-13 05:12:26 +00:00
|
|
|
OldBindingConstructorEnabled(const nsGlobalNameStruct *aStruct,
|
|
|
|
nsGlobalWindow *aWin)
|
2012-06-14 14:56:38 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
|
|
|
aStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo);
|
|
|
|
|
|
|
|
// Don't expose chrome only constructors to content windows.
|
|
|
|
if (aStruct->mChromeOnly &&
|
|
|
|
!nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-02 00:32:12 +00:00
|
|
|
// Don't expose CSSSupportsRule unless @supports processing is enabled.
|
|
|
|
if (aStruct->mDOMClassInfoID == eDOMClassInfo_CSSSupportsRule_id) {
|
|
|
|
if (!CSSSupportsRule::PrefEnabled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 14:56:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
// static
|
|
|
|
nsresult
|
2010-09-17 21:54:40 +00:00
|
|
|
nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
|
|
|
bool *did_resolve)
|
2009-03-24 11:02:30 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = false;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2011-09-06 19:01:01 +00:00
|
|
|
nsScriptNameSpaceManager *nameSpaceManager =
|
|
|
|
nsJSRuntime::GetNameSpaceManager();
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
2005-09-01 23:02:57 +00:00
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString name(id);
|
2005-09-01 23:02:57 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const PRUnichar *class_name = nullptr;
|
2012-03-29 18:43:13 +00:00
|
|
|
const nsGlobalNameStruct *name_struct =
|
|
|
|
nameSpaceManager->LookupName(name, &class_name);
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
if (!name_struct) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
nsresult rv = NS_OK;
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
|
|
|
rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
|
|
|
|
&name_struct);
|
|
|
|
if (NS_FAILED(rv) || !name_struct) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2012-06-14 14:56:38 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
|
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
|
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
|
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
2012-03-31 04:42:20 +00:00
|
|
|
// Lookup new DOM bindings.
|
2012-05-22 13:46:20 +00:00
|
|
|
mozilla::dom::DefineInterface define =
|
2012-03-31 04:42:20 +00:00
|
|
|
name_struct->mDefineDOMInterface;
|
2012-06-14 14:56:38 +00:00
|
|
|
if (define) {
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
2013-06-13 05:12:26 +00:00
|
|
|
!OldBindingConstructorEnabled(name_struct, aWin)) {
|
2012-09-05 17:37:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-09 18:50:27 +00:00
|
|
|
Maybe<JSAutoCompartment> ac;
|
2013-05-02 03:44:12 +00:00
|
|
|
JS::Rooted<JSObject*> global(cx);
|
2013-04-24 22:21:26 +00:00
|
|
|
bool defineOnXray = xpc::WrapperFactory::IsXrayWrapper(obj);
|
2012-10-09 18:50:27 +00:00
|
|
|
if (defineOnXray) {
|
2013-04-11 18:50:18 +00:00
|
|
|
global = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
2012-10-09 18:50:27 +00:00
|
|
|
if (!global) {
|
|
|
|
return NS_ERROR_DOM_SECURITY_ERR;
|
|
|
|
}
|
|
|
|
ac.construct(cx, global);
|
|
|
|
} else {
|
|
|
|
global = obj;
|
|
|
|
}
|
|
|
|
|
2013-06-13 05:12:26 +00:00
|
|
|
// Check whether our constructor is enabled after we unwrap Xrays, since
|
|
|
|
// we don't want to define an interface on the Xray if it's disabled in
|
|
|
|
// the target global, even if it's enabled in the Xray's global.
|
|
|
|
if (name_struct->mConstructorEnabled &&
|
|
|
|
!(*name_struct->mConstructorEnabled)(cx, global)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-02 08:07:36 +00:00
|
|
|
bool enabled;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> interfaceObject(cx, define(cx, global, id, &enabled));
|
2012-10-02 08:07:36 +00:00
|
|
|
if (enabled) {
|
2012-10-09 18:50:27 +00:00
|
|
|
if (!interfaceObject) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defineOnXray) {
|
|
|
|
// This really should be handled by the Xray for the window.
|
|
|
|
ac.destroy();
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapObject(cx, interfaceObject.address()) ||
|
2012-10-09 18:50:27 +00:00
|
|
|
!JS_DefinePropertyById(cx, obj, id,
|
2013-03-21 15:20:42 +00:00
|
|
|
JS::ObjectValue(*interfaceObject), JS_PropertyStub,
|
|
|
|
JS_StrictPropertyStub, 0)) {
|
2012-10-09 18:50:27 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*did_resolve = true;
|
|
|
|
|
|
|
|
return NS_OK;
|
2012-06-14 14:56:38 +00:00
|
|
|
}
|
2012-03-31 04:42:20 +00:00
|
|
|
}
|
2012-06-14 14:56:38 +00:00
|
|
|
}
|
2012-03-31 04:42:20 +00:00
|
|
|
|
2012-06-14 14:56:38 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
|
|
|
|
// We're resolving a name of a DOM interface for which there is no
|
|
|
|
// direct DOM class, create a constructor object...
|
2009-03-24 11:02:30 +00:00
|
|
|
nsRefPtr<nsDOMConstructor> constructor;
|
2009-06-03 15:30:18 +00:00
|
|
|
rv = nsDOMConstructor::Create(class_name,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr,
|
2009-03-24 11:02:30 +00:00
|
|
|
name_struct,
|
|
|
|
static_cast<nsPIDOMWindow*>(aWin),
|
|
|
|
getter_AddRefs(constructor));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-03-04 02:25:08 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2009-05-21 08:17:51 +00:00
|
|
|
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
|
2013-05-03 18:53:32 +00:00
|
|
|
false, v.address(), getter_AddRefs(holder));
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-03-24 13:47:01 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
rv = constructor->Install(cx, obj, v);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-03-24 11:02:30 +00:00
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> class_obj(cx, holder->GetJSObject());
|
2009-03-24 11:02:30 +00:00
|
|
|
NS_ASSERTION(class_obj, "The return value lied");
|
2009-03-26 14:53:33 +00:00
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
// ... and define the constants from the DOM interface on that
|
|
|
|
// constructor object.
|
|
|
|
|
2012-11-05 15:20:04 +00:00
|
|
|
JSAutoCompartment ac(cx, class_obj);
|
2009-03-24 11:02:30 +00:00
|
|
|
rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-07-11 09:09:30 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = true;
|
2001-07-11 09:09:30 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-03-24 11:02:30 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
2009-06-03 15:30:18 +00:00
|
|
|
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
2013-06-13 05:12:26 +00:00
|
|
|
if (!OldBindingConstructorEnabled(name_struct, aWin)) {
|
2010-04-20 16:44:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
// Create the XPConnect prototype for our classinfo, PostCreateProto will
|
|
|
|
// set up the prototype chain.
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
|
|
|
|
rv = GetXPCProto(sXPConnect, cx, aWin, name_struct,
|
|
|
|
getter_AddRefs(proto_holder));
|
|
|
|
|
2009-07-22 18:50:24 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && obj != aWin->GetGlobalJSObject()) {
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> dot_prototype(cx, proto_holder->GetJSObject());
|
|
|
|
NS_ENSURE_STATE(dot_prototype);
|
2009-07-22 18:50:24 +00:00
|
|
|
|
|
|
|
const nsDOMClassInfoData *ci_data;
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
|
|
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
|
|
|
|
} else {
|
|
|
|
ci_data = name_struct->mData;
|
|
|
|
}
|
|
|
|
|
2010-10-18 22:20:47 +00:00
|
|
|
return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
|
2009-07-22 18:50:24 +00:00
|
|
|
name_struct, nameSpaceManager, dot_prototype,
|
2011-10-17 14:59:28 +00:00
|
|
|
true, did_resolve);
|
2009-07-22 18:50:24 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 15:30:18 +00:00
|
|
|
*did_resolve = NS_SUCCEEDED(rv);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
|
|
|
// We don't have a XPConnect prototype object, let ResolvePrototype create
|
|
|
|
// one.
|
2012-07-30 14:20:58 +00:00
|
|
|
return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, nullptr,
|
|
|
|
name_struct, nameSpaceManager, nullptr, true,
|
2009-06-24 06:30:11 +00:00
|
|
|
did_resolve);
|
2009-06-03 15:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
|
|
const nsGlobalNameStruct *alias_struct =
|
|
|
|
nameSpaceManager->GetConstructorProto(name_struct);
|
|
|
|
NS_ENSURE_TRUE(alias_struct, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
// We need to use the XPConnect prototype for the DOM class that this
|
|
|
|
// constructor is an alias for (for example for Image we need the prototype
|
|
|
|
// for HTMLImageElement).
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
|
|
|
|
rv = GetXPCProto(sXPConnect, cx, aWin, alias_struct,
|
|
|
|
getter_AddRefs(proto_holder));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JSObject* dot_prototype = proto_holder->GetJSObject();
|
|
|
|
NS_ENSURE_STATE(dot_prototype);
|
2009-06-03 15:30:18 +00:00
|
|
|
|
|
|
|
const nsDOMClassInfoData *ci_data;
|
|
|
|
if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
|
|
ci_data = &sClassInfoData[alias_struct->mDOMClassInfoID];
|
|
|
|
} else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
|
|
ci_data = alias_struct->mData;
|
|
|
|
} else {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2010-10-18 22:20:47 +00:00
|
|
|
return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
|
2012-07-30 14:20:58 +00:00
|
|
|
name_struct, nameSpaceManager, nullptr, true,
|
2009-06-24 06:30:11 +00:00
|
|
|
did_resolve);
|
2009-03-24 11:02:30 +00:00
|
|
|
}
|
|
|
|
|
2001-07-11 09:09:30 +00:00
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
2008-02-27 02:03:27 +00:00
|
|
|
nsRefPtr<nsDOMConstructor> constructor;
|
2012-07-30 14:20:58 +00:00
|
|
|
rv = nsDOMConstructor::Create(class_name, nullptr, name_struct,
|
2008-02-27 02:03:27 +00:00
|
|
|
static_cast<nsPIDOMWindow*>(aWin),
|
|
|
|
getter_AddRefs(constructor));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
2005-12-09 19:08:45 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2008-12-16 15:46:18 +00:00
|
|
|
rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
|
2013-05-03 18:53:32 +00:00
|
|
|
false, val.address(), getter_AddRefs(holder));
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = constructor->Install(cx, obj, val);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
NS_ASSERTION(holder->GetJSObject(), "Why didn't we get a JSObject?");
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = true;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) {
|
2010-04-20 16:44:56 +00:00
|
|
|
if (name_struct->mChromeOnly && !nsContentUtils::IsCallerChrome())
|
2007-06-26 14:44:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2013-07-03 00:35:36 +00:00
|
|
|
// Before defining a global property, check for a named subframe of the
|
|
|
|
// same name. If it exists, we don't want to shadow it.
|
|
|
|
nsCOMPtr<nsIDOMWindow> childWin = aWin->GetChildWindow(name);
|
|
|
|
if (childWin)
|
|
|
|
return NS_OK;
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> prop_val(cx, JS::UndefinedValue()); // Property value.
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2005-09-07 02:56:15 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2012-07-13 22:23:59 +00:00
|
|
|
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
|
|
|
|
if (gpi) {
|
2013-05-03 18:53:32 +00:00
|
|
|
rv = gpi->Init(aWin, prop_val.address());
|
2012-07-13 22:23:59 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-11-09 23:00:01 +00:00
|
|
|
}
|
|
|
|
|
2012-01-23 00:58:30 +00:00
|
|
|
if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
|
2005-08-12 04:11:00 +00:00
|
|
|
JSObject *scope;
|
|
|
|
|
|
|
|
if (aWin->IsOuterWindow()) {
|
|
|
|
nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
|
|
|
|
NS_ENSURE_TRUE(inner, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
scope = inner->GetGlobalJSObject();
|
|
|
|
} else {
|
|
|
|
scope = aWin->GetGlobalJSObject();
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
rv = WrapNative(cx, scope, native, true, prop_val.address(),
|
2009-05-21 08:17:51 +00:00
|
|
|
getter_AddRefs(holder));
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapValue(cx, prop_val.address())) {
|
2011-02-04 17:55:21 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2013-03-21 15:20:42 +00:00
|
|
|
JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
2010-12-03 08:24:17 +00:00
|
|
|
JSPROP_ENUMERATE);
|
2005-08-17 06:01:42 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = true;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2005-08-17 06:01:42 +00:00
|
|
|
return ok ? NS_OK : NS_ERROR_FAILURE;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name_struct->mType == nsGlobalNameStruct::eTypeDynamicNameSet) {
|
|
|
|
nsCOMPtr<nsIScriptExternalNameSet> nameset =
|
|
|
|
do_CreateInstance(name_struct->mCID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
nsIScriptContext *context = aWin->GetContext();
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
rv = nameset->InitializeNameSet(context);
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*did_resolve = true;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-08-11 16:12:54 +00:00
|
|
|
// Native code for window._content getter, this simply maps
|
|
|
|
// window._content to window.content for backwards compatibility only.
|
|
|
|
static JSBool
|
|
|
|
ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
|
|
|
|
{
|
|
|
|
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
|
|
|
if (!obj)
|
|
|
|
return JS_FALSE;
|
|
|
|
|
|
|
|
return ::JS_GetProperty(cx, obj, "content", vp);
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:10:16 +00:00
|
|
|
template<class Interface>
|
|
|
|
static nsresult
|
|
|
|
LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
|
|
|
|
{
|
|
|
|
// This function duplicates some of the logic in XPC_WN_HelperSetProperty
|
2013-04-11 18:50:18 +00:00
|
|
|
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
2013-04-19 19:58:30 +00:00
|
|
|
if (!IS_WN_REFLECTOR(obj))
|
2013-03-21 15:20:45 +00:00
|
|
|
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
|
|
|
XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
|
2011-08-31 22:10:16 +00:00
|
|
|
|
|
|
|
// The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
|
2011-09-22 01:30:27 +00:00
|
|
|
NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
|
2011-08-31 22:10:16 +00:00
|
|
|
|
2011-09-22 01:30:27 +00:00
|
|
|
nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper, obj);
|
2011-08-31 22:10:16 +00:00
|
|
|
NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMLocation> location;
|
|
|
|
nsresult rv = xpcomObj->GetLocation(getter_AddRefs(location));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-09-07 02:57:46 +00:00
|
|
|
// Grab the value we're being set to before we stomp on |vp|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSString*> val(cx, ::JS_ValueToString(cx, *vp));
|
2011-08-31 22:10:16 +00:00
|
|
|
NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2011-09-07 02:57:46 +00:00
|
|
|
// Make sure |val| stays alive below
|
|
|
|
JS::Anchor<JSString *> anchor(val);
|
|
|
|
|
|
|
|
// We have to wrap location into vp before null-checking location, to
|
|
|
|
// avoid assigning the wrong thing into the slot.
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
|
|
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
|
2011-10-17 14:59:28 +00:00
|
|
|
&NS_GET_IID(nsIDOMLocation), true, vp,
|
2011-09-07 02:57:46 +00:00
|
|
|
getter_AddRefs(holder));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!location) {
|
|
|
|
// Make this a no-op
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:10:16 +00:00
|
|
|
nsDependentJSString depStr;
|
|
|
|
NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
|
2013-02-08 20:25:37 +00:00
|
|
|
|
2011-09-07 02:57:46 +00:00
|
|
|
return location->SetHref(depStr);
|
2011-08-31 22:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class Interface>
|
|
|
|
static JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
LocationSetter(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSBool strict,
|
2013-06-19 10:32:27 +00:00
|
|
|
JS::MutableHandle<JS::Value> vp)
|
2011-08-31 22:10:16 +00:00
|
|
|
{
|
2012-07-30 11:19:09 +00:00
|
|
|
nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp.address());
|
2011-08-31 22:10:16 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-19 23:01:10 +00:00
|
|
|
xpc::Throw(cx, rv);
|
2011-08-31 22:10:16 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
LocationSetterUnwrapper(JSContext *cx, JS::Handle<JSObject*> obj_, JS::Handle<jsid> id,
|
|
|
|
JSBool strict, JS::MutableHandle<JS::Value> vp)
|
2011-08-31 22:10:16 +00:00
|
|
|
{
|
2013-03-06 16:41:43 +00:00
|
|
|
JS::RootedObject obj(cx, obj_);
|
2012-05-19 22:03:45 +00:00
|
|
|
|
2011-08-31 22:10:16 +00:00
|
|
|
JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
|
|
|
|
if (wrapped) {
|
|
|
|
obj = wrapped;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LocationSetter<nsIDOMWindow>(cx, obj, id, strict, vp);
|
|
|
|
}
|
|
|
|
|
2013-03-28 01:27:26 +00:00
|
|
|
struct InterfaceShimEntry {
|
|
|
|
const char *geckoName;
|
|
|
|
const char *domName;
|
|
|
|
};
|
|
|
|
|
|
|
|
// We add shims from Components.interfaces.nsIDOMFoo to window.Foo for each
|
|
|
|
// interface that has interface constants that sites might be getting off
|
|
|
|
// of Ci.
|
|
|
|
const InterfaceShimEntry kInterfaceShimMap[] =
|
|
|
|
{ { "nsIDOMFileReader", "FileReader" },
|
|
|
|
{ "nsIXMLHttpRequest", "XMLHttpRequest" },
|
|
|
|
{ "nsIDOMDOMException", "DOMException" },
|
|
|
|
{ "nsIDOMNode", "Node" },
|
|
|
|
{ "nsIDOMUserDataHandler", "UserDataHandler" },
|
|
|
|
{ "nsIDOMCSSPrimitiveValue", "CSSPrimitiveValue" },
|
|
|
|
{ "nsIDOMCSSRule", "CSSRule" },
|
|
|
|
{ "nsIDOMCSSValue", "CSSValue" },
|
|
|
|
{ "nsIDOMEvent", "Event" },
|
|
|
|
{ "nsIDOMNSEvent", "Event" },
|
|
|
|
{ "nsIDOMKeyEvent", "KeyEvent" },
|
|
|
|
{ "nsIDOMMouseEvent", "MouseEvent" },
|
|
|
|
{ "nsIDOMMouseScrollEvent", "MouseScrollEvent" },
|
|
|
|
{ "nsIDOMMutationEvent", "MutationEvent" },
|
|
|
|
{ "nsIDOMSimpleGestureEvent", "SimpleGestureEvent" },
|
|
|
|
{ "nsIDOMUIEvent", "UIEvent" },
|
|
|
|
{ "nsIDOMGeoPositionError", "GeoPositionError" },
|
|
|
|
{ "nsIDOMHTMLMediaElement", "HTMLMediaElement" },
|
|
|
|
{ "nsIDOMMediaError", "MediaError" },
|
|
|
|
{ "nsIDOMLoadStatus", "LoadStatus" },
|
|
|
|
{ "nsIDOMOfflineResourceList", "OfflineResourceList" },
|
|
|
|
{ "nsIDOMRange", "Range" },
|
|
|
|
{ "nsIDOMSVGLength", "SVGLength" },
|
|
|
|
{ "nsIDOMNodeFilter", "NodeFilter" },
|
|
|
|
{ "nsIDOMXPathNamespace", "XPathNamespace" },
|
|
|
|
{ "nsIDOMXPathResult", "XPathResult" },
|
|
|
|
{ "nsIDOMXULButtonElement", "XULButtonElement" },
|
|
|
|
{ "nsIDOMXULCheckboxElement", "XULCheckboxElement" },
|
|
|
|
{ "nsIDOMXULPopupElement", "XULPopupElement" } };
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
DefineComponentsShim(JSContext *cx, JS::HandleObject global)
|
|
|
|
{
|
2013-03-28 01:27:27 +00:00
|
|
|
// Keep track of how often this happens.
|
|
|
|
Telemetry::Accumulate(Telemetry::COMPONENTS_SHIM_ACCESSED_BY_CONTENT, true);
|
|
|
|
|
2013-03-28 01:27:26 +00:00
|
|
|
// Create a fake Components object.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> components(cx, JS_NewObject(cx, nullptr, nullptr, global));
|
2013-03-28 01:27:26 +00:00
|
|
|
NS_ENSURE_TRUE(components, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
bool ok = JS_DefineProperty(cx, global, "Components", JS::ObjectValue(*components),
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
|
|
|
|
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
// Create a fake interfaces object.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> interfaces(cx, JS_NewObject(cx, nullptr, nullptr, global));
|
2013-03-28 01:27:26 +00:00
|
|
|
NS_ENSURE_TRUE(interfaces, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
ok = JS_DefineProperty(cx, components, "interfaces", JS::ObjectValue(*interfaces),
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
|
|
|
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
|
|
|
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
// Define a bunch of shims from the Ci.nsIDOMFoo to window.Foo for DOM
|
|
|
|
// interfaces with constants.
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(kInterfaceShimMap); ++i) {
|
|
|
|
|
|
|
|
// Grab the names from the table.
|
|
|
|
const char *geckoName = kInterfaceShimMap[i].geckoName;
|
|
|
|
const char *domName = kInterfaceShimMap[i].domName;
|
|
|
|
|
|
|
|
// Look up the appopriate interface object on the global.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx, JS::UndefinedValue());
|
|
|
|
ok = JS_GetProperty(cx, global, domName, v.address());
|
2013-03-28 01:27:26 +00:00
|
|
|
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
if (!v.isObject()) {
|
|
|
|
NS_WARNING("Unable to find interface object on global");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Define the shim on the interfaces object.
|
|
|
|
ok = JS_DefineProperty(cx, interfaces, geckoName, v,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
|
|
|
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
|
|
|
|
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IMETHODIMP
|
2010-09-17 21:54:40 +00:00
|
|
|
nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj_, jsid id_, uint32_t flags,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject **objp, bool *_retval)
|
2010-08-07 00:15:55 +00:00
|
|
|
{
|
2013-03-06 16:41:43 +00:00
|
|
|
JS::RootedObject obj(cx, obj_);
|
|
|
|
JS::RootedId id(cx, id_);
|
2012-05-19 22:03:45 +00:00
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
if (!JSID_IS_STRING(id)) {
|
2005-03-10 00:39:28 +00:00
|
|
|
return NS_OK;
|
2005-05-26 19:39:49 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-03-28 01:27:26 +00:00
|
|
|
MOZ_ASSERT(*_retval == true); // guaranteed by XPC_WN_Helper_NewResolve
|
|
|
|
if (id == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_COMPONENTS)) {
|
|
|
|
*objp = obj;
|
|
|
|
return DefineComponentsShim(cx, obj);
|
|
|
|
}
|
|
|
|
|
2013-01-17 17:30:37 +00:00
|
|
|
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
|
|
|
|
MOZ_ASSERT(win->IsInnerWindow());
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
nsIScriptContext *my_context = win->GetContextInternal();
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-04-24 22:21:26 +00:00
|
|
|
// Don't resolve standard classes on XrayWrappers, only resolve them if we're
|
|
|
|
// resolving on the real global object.
|
|
|
|
if (!xpc::WrapperFactory::IsXrayWrapper(obj)) {
|
2012-08-09 07:19:53 +00:00
|
|
|
JSBool did_resolve = JS_FALSE;
|
|
|
|
JSBool ok = JS_TRUE;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> exn(cx, JSVAL_VOID);
|
2010-09-23 00:34:20 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
{
|
2013-04-24 22:21:26 +00:00
|
|
|
// Resolve standard classes on my_context's JSContext (or on cx,
|
|
|
|
// if we don't have a my_context yet), in case the two contexts
|
|
|
|
// have different origins. We want lazy standard class
|
|
|
|
// initialization to behave as if it were done eagerly, on each
|
|
|
|
// window's own context (not on some other window-caller's
|
|
|
|
// context).
|
|
|
|
AutoPushJSContext my_cx(my_context ? my_context->GetNativeContext() : cx);
|
|
|
|
JSAutoCompartment ac(my_cx, obj);
|
2008-03-18 20:42:19 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
|
2010-08-10 22:00:26 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
if (!ok) {
|
|
|
|
// Trust the JS engine (or the script security manager) to set
|
|
|
|
// the exception in the JS engine.
|
2010-08-10 22:00:26 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_GetPendingException(my_cx, exn.address())) {
|
2012-08-09 07:19:53 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2010-08-10 22:00:26 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
// Return NS_OK to avoid stomping over the exception that was passed
|
|
|
|
// down from the ResolveStandardClass call.
|
|
|
|
// Note that the order of the JS_ClearPendingException and
|
|
|
|
// JS_SetPendingException is important in the case that my_cx == cx.
|
2010-08-10 22:00:26 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
JS_ClearPendingException(my_cx);
|
|
|
|
}
|
2008-08-14 19:07:08 +00:00
|
|
|
}
|
2006-01-21 02:59:22 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
if (!ok) {
|
|
|
|
JS_SetPendingException(cx, exn);
|
|
|
|
*_retval = JS_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-05-31 18:43:48 +00:00
|
|
|
|
2012-08-09 07:19:53 +00:00
|
|
|
if (did_resolve) {
|
|
|
|
*objp = obj;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-06-26 21:22:12 +00:00
|
|
|
}
|
2003-05-31 18:43:48 +00:00
|
|
|
|
2012-12-20 00:32:34 +00:00
|
|
|
// We want this code to be before the child frame lookup code
|
|
|
|
// below so that a child frame named 'constructor' doesn't
|
|
|
|
// shadow the window's constructor property.
|
|
|
|
if (sConstructor_id == id) {
|
|
|
|
return ResolveConstructor(cx, obj, objp);
|
2005-03-10 00:39:28 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2005-04-21 21:05:10 +00:00
|
|
|
if (!my_context || !my_context->IsContextInitialized()) {
|
|
|
|
// The context is not yet initialized so there's nothing we can do
|
|
|
|
// here yet.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-19 22:03:45 +00:00
|
|
|
if (sLocation_id == id) {
|
2011-06-22 08:00:43 +00:00
|
|
|
// This must be done even if we're just getting the value of
|
|
|
|
// window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
|
|
|
|
// here) since we must define window.location to prevent the
|
|
|
|
// getter from being overriden (for security reasons).
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMLocation> location;
|
2013-01-03 18:29:16 +00:00
|
|
|
nsresult rv = win->GetLocation(getter_AddRefs(location));
|
2011-06-22 08:00:43 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-11-04 08:00:06 +00:00
|
|
|
// Make sure we wrap the location object in the window's scope.
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> scope(cx, wrapper->GetJSObject());
|
2011-06-22 08:00:43 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), true,
|
2013-05-03 18:53:32 +00:00
|
|
|
v.address(), getter_AddRefs(holder));
|
2011-06-22 08:00:43 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JSBool ok = JS_WrapValue(cx, v.address()) &&
|
2013-03-21 15:20:42 +00:00
|
|
|
JS_DefinePropertyById(cx, obj, id, v, JS_PropertyStub,
|
2011-08-31 22:10:16 +00:00
|
|
|
LocationSetterUnwrapper,
|
2011-06-22 08:00:43 +00:00
|
|
|
JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
|
|
|
|
|
|
|
if (!ok) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*objp = obj;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-04-21 21:05:10 +00:00
|
|
|
|
2012-12-20 00:32:34 +00:00
|
|
|
if (sTop_id == id) {
|
2012-10-20 15:14:04 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> top;
|
2013-01-03 18:29:16 +00:00
|
|
|
nsresult rv = win->GetScriptableTop(getter_AddRefs(top));
|
2012-10-20 15:14:04 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2012-10-20 15:14:04 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
|
|
rv = WrapNative(cx, obj, top, &NS_GET_IID(nsIDOMWindow), true,
|
2013-05-03 18:53:32 +00:00
|
|
|
v.address(), getter_AddRefs(holder));
|
2012-10-20 15:14:04 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Hold on to the top window object as a global property so we
|
|
|
|
// don't need to worry about losing expando properties etc.
|
2013-03-21 15:20:42 +00:00
|
|
|
if (!JS_DefinePropertyById(cx, obj, id, v, JS_PropertyStub, JS_StrictPropertyStub,
|
2012-10-20 15:14:04 +00:00
|
|
|
JSPROP_READONLY | JSPROP_PERMANENT |
|
|
|
|
JSPROP_ENUMERATE)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
*objp = obj;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-03 18:29:16 +00:00
|
|
|
// Handle resolving if id refers to a name resolved by DOM worker code.
|
2013-03-06 16:41:43 +00:00
|
|
|
JS::RootedObject tmp(cx, NULL);
|
2013-01-03 18:29:16 +00:00
|
|
|
if (!ResolveWorkerClasses(cx, obj, id, flags, &tmp)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
if (tmp) {
|
|
|
|
*objp = tmp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-12-05 02:35:48 +00:00
|
|
|
|
2013-01-03 18:29:16 +00:00
|
|
|
// Check for names managed by the script namespace manager. Call
|
|
|
|
// GlobalResolve() after we call FindChildWithName() so that named child
|
|
|
|
// frames will override external properties which have been registered with
|
|
|
|
// the script namespace manager -- pages must be able to depend on frame
|
|
|
|
// names working no matter how Gecko's been configured.
|
|
|
|
bool did_resolve = false;
|
|
|
|
nsresult rv = GlobalResolve(win, cx, obj, id, &did_resolve);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2003-12-05 02:35:48 +00:00
|
|
|
|
2013-01-03 18:29:16 +00:00
|
|
|
if (did_resolve) {
|
|
|
|
*objp = obj;
|
|
|
|
return NS_OK;
|
2005-03-10 00:39:28 +00:00
|
|
|
}
|
2003-12-05 02:35:48 +00:00
|
|
|
|
2013-05-08 03:26:19 +00:00
|
|
|
// NB: By accident, we previously didn't support this over Xrays. This is a
|
|
|
|
// deprecated non-standard feature, so there's no reason to start doing so
|
|
|
|
// now.
|
|
|
|
if ((s_content_id == id) && !xpc::WrapperFactory::IsXrayWrapper(obj)) {
|
2012-08-11 16:12:54 +00:00
|
|
|
// Map window._content to window.content for backwards
|
|
|
|
// compatibility, this should spit out an message on the JS
|
|
|
|
// console.
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> funObj(cx);
|
2013-05-08 03:26:19 +00:00
|
|
|
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
|
|
|
|
obj, "_content");
|
|
|
|
if (!fun) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2012-08-11 16:12:54 +00:00
|
|
|
}
|
2013-05-08 03:26:19 +00:00
|
|
|
funObj = ::JS_GetFunctionObject(fun);
|
2012-08-11 16:12:54 +00:00
|
|
|
|
2013-05-04 07:51:53 +00:00
|
|
|
if (!JS_WrapObject(cx, funObj.address()) ||
|
2013-04-30 00:50:25 +00:00
|
|
|
!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
|
2013-05-04 07:51:53 +00:00
|
|
|
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj.get()),
|
2013-04-30 00:50:25 +00:00
|
|
|
JS_StrictPropertyStub,
|
|
|
|
JSPROP_ENUMERATE | JSPROP_GETTER |
|
|
|
|
JSPROP_SHARED)) {
|
2012-08-11 16:12:54 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*objp = obj;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-03-10 00:39:28 +00:00
|
|
|
if (flags & JSRESOLVE_ASSIGNING) {
|
2012-12-19 20:57:18 +00:00
|
|
|
if (IsReadonlyReplaceable(id)) {
|
|
|
|
// A readonly "replaceable" property is being set. Define the property
|
|
|
|
// on obj with the value undefined to override the predefined property.
|
|
|
|
// This isn't quite what WebIDL requires for [Replaceable] properties,
|
|
|
|
// but it'll do until we move Window over to the new DOM bindings.
|
2005-03-10 00:39:28 +00:00
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
|
2011-02-09 19:31:40 +00:00
|
|
|
JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
|
2002-05-22 00:34:01 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2001-05-10 09:45:46 +00:00
|
|
|
}
|
2002-05-22 00:34:01 +00:00
|
|
|
*objp = obj;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-03-10 00:39:28 +00:00
|
|
|
} else {
|
2012-05-19 22:03:45 +00:00
|
|
|
if (sDocument_id == id) {
|
2012-08-04 07:44:01 +00:00
|
|
|
nsCOMPtr<nsIDocument> document = win->GetDoc();
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> v(cx);
|
2005-09-07 02:56:15 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2012-08-04 07:44:01 +00:00
|
|
|
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), document, document,
|
2013-05-03 18:53:32 +00:00
|
|
|
&NS_GET_IID(nsIDOMDocument), v.address(), getter_AddRefs(holder),
|
2012-08-04 07:44:01 +00:00
|
|
|
false);
|
2005-03-10 00:39:28 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-04-27 00:03:47 +00:00
|
|
|
|
2005-08-12 04:11:00 +00:00
|
|
|
// The PostCreate hook for the document will handle defining the
|
2005-09-07 02:56:15 +00:00
|
|
|
// property
|
|
|
|
*objp = obj;
|
2002-04-27 00:03:47 +00:00
|
|
|
|
2011-02-17 04:29:14 +00:00
|
|
|
// NB: We need to do this for any Xray wrapper.
|
|
|
|
if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
|
2010-03-25 02:08:50 +00:00
|
|
|
// Unless our object is a native wrapper, in which case we have to
|
|
|
|
// define it ourselves.
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
*_retval = JS_WrapValue(cx, v.address()) &&
|
2013-03-21 15:20:42 +00:00
|
|
|
JS_DefineProperty(cx, obj, "document", v,
|
|
|
|
JS_PropertyStub, JS_StrictPropertyStub,
|
2010-03-25 02:08:50 +00:00
|
|
|
JSPROP_READONLY | JSPROP_ENUMERATE);
|
|
|
|
if (!*_retval) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-10 00:39:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 19:49:25 +00:00
|
|
|
rv = nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
|
|
|
|
_retval);
|
2008-03-04 01:52:34 +00:00
|
|
|
|
2013-01-03 18:29:16 +00:00
|
|
|
if (NS_FAILED(rv) || *objp) {
|
2008-03-04 01:52:34 +00:00
|
|
|
// Something went wrong, or the property got resolved. Return.
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-03-05 04:43:57 +00:00
|
|
|
// Make a fast expando if we're assigning to (not declaring or
|
|
|
|
// binding a name) a new undefined property that's not already
|
|
|
|
// defined on our prototype chain. This way we can access this
|
|
|
|
// expando w/o ever getting back into XPConnect.
|
2012-05-25 06:54:05 +00:00
|
|
|
if (flags & JSRESOLVE_ASSIGNING) {
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> realObj(cx, wrapper->GetJSObject());
|
2008-03-04 01:52:34 +00:00
|
|
|
|
|
|
|
if (obj == realObj) {
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
2013-05-05 07:03:14 +00:00
|
|
|
if (!js::GetObjectProto(cx, obj, &proto)) {
|
2012-09-03 23:42:10 +00:00
|
|
|
*_retval = JS_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-03-04 01:52:34 +00:00
|
|
|
if (proto) {
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> pobj(cx);
|
2013-05-29 20:16:04 +00:00
|
|
|
JS::Rooted<JS::Value> val(cx);
|
2008-03-04 01:52:34 +00:00
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
if (!::JS_LookupPropertyWithFlagsById(cx, proto, id, flags,
|
2013-05-29 20:16:04 +00:00
|
|
|
pobj.address(), val.address())) {
|
2008-03-04 01:52:34 +00:00
|
|
|
*_retval = JS_FALSE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-09-25 16:13:31 +00:00
|
|
|
if (pobj) {
|
|
|
|
// A property was found on the prototype chain.
|
|
|
|
*objp = pobj;
|
2008-03-04 01:52:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-19 21:49:30 +00:00
|
|
|
// Define a fast expando. The key here is to use JS_PropertyStub as the
|
|
|
|
// getter/setter, which makes us stay out of XPConnect when using this
|
|
|
|
// property.
|
2008-03-04 01:52:34 +00:00
|
|
|
//
|
2012-12-19 21:49:30 +00:00
|
|
|
// We're adding a new property here, so we don't need to worry about
|
|
|
|
// conflicting with any existing ones.
|
2009-04-15 14:09:58 +00:00
|
|
|
//
|
2012-12-19 21:49:30 +00:00
|
|
|
// Since we always create the undeclared property here, shortcutting the
|
|
|
|
// normal process, we go out of our way to tell the JS engine to report
|
|
|
|
// strict warnings/errors using js::ReportIfUndeclaredVarAssignment.
|
2013-03-06 16:41:43 +00:00
|
|
|
JS::Rooted<JSString*> str(cx, JSID_TO_STRING(id));
|
2012-12-19 21:49:30 +00:00
|
|
|
if (!js::ReportIfUndeclaredVarAssignment(cx, str) ||
|
2010-07-15 06:19:36 +00:00
|
|
|
!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
|
2011-02-09 19:31:40 +00:00
|
|
|
JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
|
2008-03-04 01:52:34 +00:00
|
|
|
*_retval = JS_FALSE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*objp = obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-30 01:18:43 +00:00
|
|
|
NS_IMETHODIMP
|
2012-03-19 14:34:55 +00:00
|
|
|
nsWindowSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp *fop,
|
2010-09-17 21:54:40 +00:00
|
|
|
JSObject *obj)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2005-03-10 00:39:28 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryWrappedNative(wrapper));
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2011-04-14 12:04:08 +00:00
|
|
|
sgo->OnFinalize(obj);
|
2004-02-09 22:48:53 +00:00
|
|
|
|
2007-02-24 06:57:20 +00:00
|
|
|
return NS_OK;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2005-07-30 20:57:07 +00:00
|
|
|
NS_IMETHODIMP
|
2010-09-17 21:54:40 +00:00
|
|
|
nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
|
|
|
JSObject * obj, JSObject * *_retval)
|
2005-07-30 20:57:07 +00:00
|
|
|
{
|
2008-03-01 00:17:38 +00:00
|
|
|
nsGlobalWindow *origWin = nsGlobalWindow::FromWrapper(wrapper);
|
|
|
|
nsGlobalWindow *win = origWin->GetOuterWindowInternal();
|
2005-08-12 04:11:00 +00:00
|
|
|
|
2005-10-08 00:28:45 +00:00
|
|
|
if (!win) {
|
2005-08-12 04:11:00 +00:00
|
|
|
// If we no longer have an outer window. No code should ever be
|
|
|
|
// running on a window w/o an outer, which means this hook should
|
|
|
|
// never be called when we have no outer. But just in case, return
|
|
|
|
// null to prevent leaking an inner window to code in a different
|
|
|
|
// window.
|
2012-07-30 14:20:58 +00:00
|
|
|
*_retval = nullptr;
|
2005-10-08 00:28:45 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2005-08-12 04:11:00 +00:00
|
|
|
}
|
2005-07-30 20:57:07 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> winObj(cx, win->FastGetGlobalJSObject());
|
2013-02-04 15:13:14 +00:00
|
|
|
MOZ_ASSERT(winObj);
|
2005-10-08 00:28:45 +00:00
|
|
|
|
2013-02-04 15:13:14 +00:00
|
|
|
// Note that while |wrapper| is same-compartment with cx, the outer window
|
|
|
|
// might not be. If we're running script in an inactive scope and evalute
|
|
|
|
// |this|, the outer window is actually a cross-compartment wrapper. So we
|
|
|
|
// need to wrap here.
|
2013-05-03 18:53:32 +00:00
|
|
|
if (!JS_WrapObject(cx, winObj.address())) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*_retval = nullptr;
|
2010-10-18 22:21:50 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2009-02-16 21:16:13 +00:00
|
|
|
*_retval = winObj;
|
|
|
|
return NS_OK;
|
2005-07-30 20:57:07 +00:00
|
|
|
}
|
|
|
|
|
2002-05-22 00:34:01 +00:00
|
|
|
// DOM Location helper
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLocationSH::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj, jsid id, uint32_t mode,
|
2011-09-29 06:19:26 +00:00
|
|
|
jsval *vp, bool *_retval)
|
2002-05-22 00:34:01 +00:00
|
|
|
{
|
|
|
|
if ((mode & JSACC_TYPEMASK) == JSACC_PROTO && (mode & JSACC_WRITE)) {
|
|
|
|
// No setting location.__proto__, ever!
|
|
|
|
|
|
|
|
// Let XPConnect know that the access was not granted.
|
2011-10-17 14:59:28 +00:00
|
|
|
*_retval = false;
|
2002-05-22 00:34:01 +00:00
|
|
|
|
|
|
|
return NS_ERROR_DOM_SECURITY_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsDOMGenericSH::CheckAccess(wrapper, cx, obj, id, mode, vp, _retval);
|
|
|
|
}
|
|
|
|
|
2005-08-23 01:42:49 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLocationSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
|
|
|
JSObject *globalObj, JSObject **parentObj)
|
|
|
|
{
|
|
|
|
// window.location can be held onto by both evil pages that want to track the
|
|
|
|
// user's progress on the web and bookmarklets that want to use the location
|
|
|
|
// object. Parent it to the outer window so that access checks do the Right
|
|
|
|
// Thing.
|
|
|
|
*parentObj = globalObj;
|
|
|
|
|
2005-12-19 20:29:54 +00:00
|
|
|
nsCOMPtr<nsIDOMLocation> safeLoc(do_QueryInterface(nativeObj));
|
|
|
|
if (!safeLoc) {
|
|
|
|
// Oops, this wasn't really a location object. This can happen if someone
|
|
|
|
// tries to use our scriptable helper as a real object and tries to wrap
|
|
|
|
// it, see bug 319296
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLocation *loc = (nsLocation *)safeLoc.get();
|
2005-08-23 01:42:49 +00:00
|
|
|
nsIDocShell *ds = loc->GetDocShell();
|
|
|
|
if (!ds) {
|
|
|
|
NS_WARNING("Refusing to create a location in the wrong scope");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
|
2010-10-25 19:13:36 +00:00
|
|
|
if (!sgo) {
|
|
|
|
NS_WARNING("Refusing to create a location in the wrong scope because the "
|
2010-10-29 19:49:32 +00:00
|
|
|
"docshell is being destroyed");
|
2010-10-25 19:13:36 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2005-08-23 01:42:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-25 19:13:36 +00:00
|
|
|
*parentObj = sgo->GetGlobalJSObject();
|
2012-04-27 08:38:14 +00:00
|
|
|
return *parentObj ? NS_OK : NS_ERROR_FAILURE;
|
2005-08-23 01:42:49 +00:00
|
|
|
}
|
2002-05-22 00:34:01 +00:00
|
|
|
|
2012-11-21 21:20:05 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLocationSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-22 02:59:17 +00:00
|
|
|
JSObject *obj, jsid aId, jsval *vp, bool *_retval)
|
2012-11-21 21:20:05 +00:00
|
|
|
{
|
|
|
|
// Shadowing protection. This will go away when nsLocation moves to the new
|
|
|
|
// bindings.
|
2013-05-22 02:59:17 +00:00
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2012-11-21 21:20:05 +00:00
|
|
|
if (wrapper->HasNativeMember(id)) {
|
|
|
|
JS_ReportError(cx, "Permission denied to shadow native property");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-14 11:04:43 +00:00
|
|
|
// EventTarget helper
|
|
|
|
|
2008-11-13 16:54:52 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aGlobalObj, JSObject **parentObj)
|
2008-11-13 16:54:52 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> globalObj(cx, aGlobalObj);
|
2012-02-08 02:53:33 +00:00
|
|
|
nsDOMEventTargetHelper *target =
|
|
|
|
nsDOMEventTargetHelper::FromSupports(nativeObj);
|
2008-11-13 16:54:52 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> native_parent;
|
|
|
|
target->GetParentObject(getter_AddRefs(native_parent));
|
|
|
|
|
|
|
|
*parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;
|
|
|
|
|
2012-04-27 08:38:14 +00:00
|
|
|
return *parentObj ? NS_OK : NS_ERROR_FAILURE;
|
2008-11-13 16:54:52 +00:00
|
|
|
}
|
|
|
|
|
2008-09-25 14:40:30 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject *obj, jsid id, jsval *vp, bool *_retval)
|
2008-09-25 14:40:30 +00:00
|
|
|
{
|
2009-11-29 08:32:39 +00:00
|
|
|
nsEventTargetSH::PreserveWrapper(GetNative(wrapper, obj));
|
2008-11-13 16:54:52 +00:00
|
|
|
|
2008-11-06 11:09:30 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-29 08:32:39 +00:00
|
|
|
void
|
|
|
|
nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
|
|
|
|
{
|
2012-02-08 02:53:33 +00:00
|
|
|
nsDOMEventTargetHelper *target =
|
|
|
|
nsDOMEventTargetHelper::FromSupports(aNative);
|
2013-06-23 07:15:42 +00:00
|
|
|
target->PreserveWrapper(aNative);
|
2009-11-29 08:32:39 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
// IDBEventTarget helper
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
|
|
|
|
JSObject *aGlobalObj, JSObject **aParentObj)
|
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> globalObj(aCx, aGlobalObj);
|
2012-01-24 10:03:37 +00:00
|
|
|
IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNativeObj);
|
|
|
|
JSObject *parent = target->GetParentObject();
|
2013-05-04 07:51:53 +00:00
|
|
|
*aParentObj = parent ? parent : globalObj;
|
2012-01-24 10:03:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-10-16 00:44:20 +00:00
|
|
|
// Generic array scriptable helper.
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2005-10-04 05:50:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, uint32_t flags,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject **objp, bool *_retval)
|
2005-10-04 05:50:42 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2008-09-06 01:10:35 +00:00
|
|
|
if (id == sLength_id) {
|
|
|
|
// Bail early; this isn't something we're interested in
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-02-08 20:25:37 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool is_number = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t n = GetArrayIndexFromId(cx, id, &is_number);
|
2005-10-04 05:50:42 +00:00
|
|
|
|
|
|
|
if (is_number && n >= 0) {
|
2005-10-06 19:58:26 +00:00
|
|
|
// XXX The following is a cheap optimization to avoid hitting xpconnect to
|
|
|
|
// get the length. We may want to consider asking our concrete
|
|
|
|
// implementation for the length, and falling back onto the GetProperty if
|
|
|
|
// it doesn't provide one.
|
2005-10-04 05:50:42 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length;
|
2008-10-22 14:31:14 +00:00
|
|
|
nsresult rv = GetLength(wrapper, cx, obj, &length);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-10-04 05:50:42 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index = uint32_t(n);
|
2011-08-05 02:39:12 +00:00
|
|
|
if (index < length) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID, nullptr, nullptr,
|
2005-10-12 19:07:42 +00:00
|
|
|
JSPROP_ENUMERATE | JSPROP_SHARED);
|
2005-10-04 05:50:42 +00:00
|
|
|
*objp = obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
nsresult
|
|
|
|
nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj, uint32_t *length)
|
2008-10-22 14:31:14 +00:00
|
|
|
{
|
|
|
|
*length = 0;
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> lenval(cx);
|
|
|
|
if (!JS_GetProperty(cx, obj, "length", lenval.address())) {
|
2008-10-22 14:31:14 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!JSVAL_IS_INT(lenval)) {
|
|
|
|
// This can apparently happen with some sparse array impls falling back
|
|
|
|
// onto this code.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t slen = JSVAL_TO_INT(lenval);
|
2008-10-22 14:31:14 +00:00
|
|
|
if (slen < 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
*length = (uint32_t)slen;
|
2008-10-22 14:31:14 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-09-19 08:43:14 +00:00
|
|
|
NS_IMETHODIMP
|
2003-10-16 00:44:20 +00:00
|
|
|
nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, bool *_retval)
|
2003-09-19 08:43:14 +00:00
|
|
|
{
|
|
|
|
// Recursion protection in case someone tries to be smart and call
|
|
|
|
// the enumerate hook from a user defined .length getter, or
|
|
|
|
// somesuch.
|
|
|
|
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool sCurrentlyEnumerating;
|
2003-09-19 08:43:14 +00:00
|
|
|
|
|
|
|
if (sCurrentlyEnumerating) {
|
|
|
|
// Don't recurse to death.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
sCurrentlyEnumerating = true;
|
2003-09-19 08:43:14 +00:00
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> len_val(cx);
|
|
|
|
JSBool ok = ::JS_GetProperty(cx, obj, "length", len_val.address());
|
2003-09-19 08:43:14 +00:00
|
|
|
|
|
|
|
if (ok && JSVAL_IS_INT(len_val)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t length = JSVAL_TO_INT(len_val);
|
2003-09-19 08:43:14 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; ok && i < length; ++i) {
|
2012-07-30 14:20:58 +00:00
|
|
|
ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nullptr, nullptr,
|
2008-10-08 13:12:50 +00:00
|
|
|
JSPROP_ENUMERATE | JSPROP_SHARED);
|
2003-09-19 08:43:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
sCurrentlyEnumerating = false;
|
2003-09-19 08:43:14 +00:00
|
|
|
|
|
|
|
return ok ? NS_OK : NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
// Array scriptable helper
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, jsval *vp, bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool is_number = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t n = GetArrayIndexFromId(cx, id, &is_number);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2005-07-29 15:11:08 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2001-06-28 04:26:29 +00:00
|
|
|
if (is_number) {
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
if (n < 0) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
// Make sure rv == NS_OK here, so GetItemAt implementations that never fail
|
|
|
|
// don't have to set rv.
|
|
|
|
rv = NS_OK;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsWrapperCache *cache = nullptr;
|
2010-05-09 19:33:00 +00:00
|
|
|
nsISupports* array_item =
|
|
|
|
GetItemAt(GetNative(wrapper, obj), n, &cache, &rv);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2001-10-16 01:24:16 +00:00
|
|
|
if (array_item) {
|
2010-09-25 01:00:58 +00:00
|
|
|
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), array_item, cache,
|
2011-10-17 14:59:28 +00:00
|
|
|
true, vp);
|
2001-10-16 01:24:16 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-09-28 13:44:31 +00:00
|
|
|
|
|
|
|
rv = NS_SUCCESS_I_DID_SOMETHING;
|
2001-10-16 01:24:16 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2005-07-29 15:11:08 +00:00
|
|
|
return rv;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-16 00:44:20 +00:00
|
|
|
// StringList scriptable helper
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsStringListSH::GetStringAt(nsISupports *aNative, int32_t aIndex,
|
2003-10-16 00:44:20 +00:00
|
|
|
nsAString& aResult)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
|
|
|
|
NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2011-05-30 11:35:52 +00:00
|
|
|
nsresult rv = list->Item(aIndex, aResult);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (DOMStringIsNull(aResult)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length = 0;
|
2011-05-30 11:35:52 +00:00
|
|
|
list->GetLength(&length);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_ASSERTION(uint32_t(aIndex) >= length, "Item should only return null for out-of-bounds access");
|
2011-05-30 11:35:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return rv;
|
2003-10-16 00:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-12 06:55:00 +00:00
|
|
|
// HTMLAllCollection
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-06-12 06:55:00 +00:00
|
|
|
JSClass sHTMLDocumentAllClass = {
|
2004-07-23 00:26:02 +00:00
|
|
|
"HTML document.all class",
|
2004-08-26 03:49:17 +00:00
|
|
|
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE |
|
2012-09-15 18:19:54 +00:00
|
|
|
JSCLASS_EMULATES_UNDEFINED | JSCLASS_HAS_RESERVED_SLOTS(1),
|
2012-05-07 19:44:08 +00:00
|
|
|
JS_PropertyStub, /* addProperty */
|
2013-04-06 04:22:55 +00:00
|
|
|
JS_DeletePropertyStub, /* delProperty */
|
2012-05-07 19:44:08 +00:00
|
|
|
nsHTMLDocumentSH::DocumentAllGetProperty, /* getProperty */
|
|
|
|
JS_StrictPropertyStub, /* setProperty */
|
|
|
|
JS_EnumerateStub,
|
|
|
|
(JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve,
|
|
|
|
JS_ConvertStub,
|
|
|
|
nsHTMLDocumentSH::ReleaseDocument,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, /* checkAccess */
|
2004-07-23 00:26:02 +00:00
|
|
|
nsHTMLDocumentSH::CallToGetPropMapper
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
// static
|
|
|
|
JSBool
|
2013-05-04 07:51:53 +00:00
|
|
|
nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> obj,
|
2010-05-10 16:43:20 +00:00
|
|
|
nsDocument *domdoc,
|
|
|
|
nsContentList **nodeList)
|
2004-08-24 01:31:19 +00:00
|
|
|
{
|
|
|
|
// The document.all object is a mix of the node list returned by
|
|
|
|
// document.getElementsByTagName("*") and a map of elements in the
|
|
|
|
// document exposed by their id and/or name. To make access to the
|
|
|
|
// node list part (i.e. access to elements by index) not walk the
|
|
|
|
// document each time, we create a nsContentList and hold on to it
|
|
|
|
// in a reserved slot (0) on the document.all JSObject.
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JS::Value> collection(cx, JS_GetReservedSlot(obj, 0));
|
2004-08-24 01:31:19 +00:00
|
|
|
|
|
|
|
if (!JSVAL_IS_PRIMITIVE(collection)) {
|
|
|
|
// We already have a node list in our reserved slot, use it.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(collection));
|
2012-09-05 20:49:53 +00:00
|
|
|
nsIHTMLCollection* htmlCollection;
|
|
|
|
rv = mozilla::dom::UnwrapObject<nsIHTMLCollection>(cx, obj, htmlCollection);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
NS_ADDREF(*nodeList = static_cast<nsContentList*>(htmlCollection));
|
2009-05-12 20:20:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-05-16 18:06:21 +00:00
|
|
|
nsISupports *native = nsDOMClassInfo::XPConnect()->GetNativeOfWrapper(cx, obj);
|
2011-08-02 13:16:05 +00:00
|
|
|
if (native) {
|
|
|
|
NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
|
2012-09-05 20:49:53 +00:00
|
|
|
rv = NS_OK;
|
2011-08-02 13:16:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
}
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// No node list for this document.all yet, create one...
|
|
|
|
|
2010-05-10 16:43:20 +00:00
|
|
|
nsRefPtr<nsContentList> list =
|
|
|
|
domdoc->GetElementsByTagName(NS_LITERAL_STRING("*"));
|
|
|
|
if (!list) {
|
2012-07-27 14:03:08 +00:00
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
2010-05-10 16:43:20 +00:00
|
|
|
}
|
2004-08-24 01:31:19 +00:00
|
|
|
|
2005-09-07 02:56:15 +00:00
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
2012-07-27 14:03:08 +00:00
|
|
|
nsresult tmp = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
|
|
|
|
static_cast<nsINodeList*>(list), list, false,
|
2013-05-03 18:53:32 +00:00
|
|
|
collection.address(), getter_AddRefs(holder));
|
2012-07-27 14:03:08 +00:00
|
|
|
if (NS_FAILED(tmp)) {
|
|
|
|
rv = tmp;
|
|
|
|
}
|
2004-08-24 01:31:19 +00:00
|
|
|
|
2010-05-10 16:43:20 +00:00
|
|
|
list.forget(nodeList);
|
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
// ... and store it in our reserved slot.
|
2012-02-05 20:07:23 +00:00
|
|
|
JS_SetReservedSlot(obj, 0, collection);
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-19 23:01:10 +00:00
|
|
|
xpc::Throw(cx, NS_ERROR_FAILURE);
|
2004-08-24 01:31:19 +00:00
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return *nodeList != nullptr;
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2008-09-06 22:21:43 +00:00
|
|
|
JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JS::Handle<JSObject*> obj_,
|
|
|
|
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp)
|
2004-07-23 00:26:02 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, obj_);
|
2012-05-19 22:03:45 +00:00
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
// document.all.item and .namedItem get their value in the
|
|
|
|
// newResolve hook, so nothing to do for those properties here. And
|
|
|
|
// we need to return early to prevent <div id="item"> from shadowing
|
|
|
|
// document.all.item(), etc.
|
2013-05-16 18:06:21 +00:00
|
|
|
if (nsDOMClassInfo::sItem_id == id || nsDOMClassInfo::sNamedItem_id == id) {
|
2004-08-24 01:31:19 +00:00
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-05 07:03:14 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
2011-10-04 14:06:54 +00:00
|
|
|
while (js::GetObjectJSClass(obj) != &sHTMLDocumentAllClass) {
|
2013-05-05 07:03:14 +00:00
|
|
|
if (!js::GetObjectProto(cx, obj, &proto)) {
|
2012-09-03 23:42:10 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
2009-05-18 23:45:29 +00:00
|
|
|
|
2013-05-05 07:03:14 +00:00
|
|
|
if (!proto) {
|
2009-05-18 23:45:29 +00:00
|
|
|
NS_ERROR("The JS engine lies!");
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
2013-05-05 07:03:14 +00:00
|
|
|
|
|
|
|
obj = proto;
|
2009-05-18 23:45:29 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 15:52:34 +00:00
|
|
|
nsHTMLDocument *doc = GetDocument(obj);
|
|
|
|
nsISupports *result;
|
|
|
|
nsWrapperCache *cache;
|
2004-08-24 01:31:19 +00:00
|
|
|
nsresult rv = NS_OK;
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
if (JSID_IS_STRING(id)) {
|
2013-05-16 18:06:21 +00:00
|
|
|
if (nsDOMClassInfo::sLength_id == id) {
|
2004-08-24 01:31:19 +00:00
|
|
|
// Map document.all.length to the length of the collection
|
|
|
|
// document.getElementsByTagName("*"), and make sure <div
|
|
|
|
// id="length"> doesn't shadow document.all.length.
|
|
|
|
|
2010-05-10 16:43:20 +00:00
|
|
|
nsRefPtr<nsContentList> nodeList;
|
|
|
|
if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
|
2004-08-24 01:31:19 +00:00
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length;
|
2004-08-24 01:31:19 +00:00
|
|
|
rv = nodeList->GetLength(&length);
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-19 23:01:10 +00:00
|
|
|
xpc::Throw(cx, rv);
|
2004-08-24 01:31:19 +00:00
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-30 11:19:09 +00:00
|
|
|
vp.set(INT_TO_JSVAL(length));
|
2008-08-25 23:48:37 +00:00
|
|
|
|
|
|
|
return JS_TRUE;
|
2013-06-01 06:53:12 +00:00
|
|
|
}
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2013-06-01 06:53:12 +00:00
|
|
|
// For all other strings, look for an element by id or name.
|
|
|
|
nsDependentJSString str(id);
|
|
|
|
result = doc->GetDocumentAllResult(str, &cache, &rv);
|
2004-08-24 01:31:19 +00:00
|
|
|
|
2013-06-01 06:53:12 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
xpc::Throw(cx, rv);
|
|
|
|
return JS_FALSE;
|
2010-05-10 16:43:20 +00:00
|
|
|
}
|
2010-07-15 06:19:36 +00:00
|
|
|
} else if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
|
2004-08-24 01:31:19 +00:00
|
|
|
// Map document.all[n] (where n is a number) to the n:th item in
|
|
|
|
// the document.all node list.
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2010-05-10 16:43:20 +00:00
|
|
|
nsRefPtr<nsContentList> nodeList;
|
|
|
|
if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
|
2004-08-24 01:31:19 +00:00
|
|
|
return JS_FALSE;
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 12:50:24 +00:00
|
|
|
nsIContent *node = nodeList->Item(JSID_TO_INT(id));
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
result = node;
|
2010-05-10 16:43:20 +00:00
|
|
|
cache = node;
|
2010-12-27 20:41:31 +00:00
|
|
|
} else {
|
2012-07-30 14:20:58 +00:00
|
|
|
result = nullptr;
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result) {
|
2012-07-30 11:19:09 +00:00
|
|
|
rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), result, cache, true, vp.address());
|
2004-08-24 01:31:19 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2012-06-19 23:01:10 +00:00
|
|
|
xpc::Throw(cx, rv);
|
2004-08-24 01:31:19 +00:00
|
|
|
|
|
|
|
return JS_FALSE;
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
2007-07-26 00:36:19 +00:00
|
|
|
} else {
|
2012-07-30 11:19:09 +00:00
|
|
|
vp.setUndefined();
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return JS_TRUE;
|
|
|
|
}
|
|
|
|
|
2008-09-06 22:21:43 +00:00
|
|
|
JSBool
|
2013-06-21 13:12:46 +00:00
|
|
|
nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JS::Handle<JSObject*> obj,
|
|
|
|
JS::Handle<jsid> id, unsigned flags,
|
|
|
|
JS::MutableHandle<JSObject*> objp)
|
2004-07-23 00:26:02 +00:00
|
|
|
{
|
2013-03-06 16:41:43 +00:00
|
|
|
JS::RootedValue v(cx);
|
2004-07-23 00:26:02 +00:00
|
|
|
|
2013-05-16 18:06:21 +00:00
|
|
|
if (nsDOMClassInfo::sItem_id == id || nsDOMClassInfo::sNamedItem_id == id) {
|
2004-08-24 01:31:19 +00:00
|
|
|
// Define the item() or namedItem() method.
|
|
|
|
|
2010-10-28 15:15:53 +00:00
|
|
|
JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
|
|
|
|
0, JSPROP_ENUMERATE);
|
2012-07-04 18:12:16 +00:00
|
|
|
objp.set(obj);
|
2004-08-24 01:31:19 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return fnc != nullptr;
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 18:06:21 +00:00
|
|
|
if (nsDOMClassInfo::sLength_id == id) {
|
2004-08-24 01:31:19 +00:00
|
|
|
// document.all.length. Any jsval other than undefined would do
|
|
|
|
// here, all we need is to get into the code below that defines
|
|
|
|
// this propery on obj, the rest happens in
|
|
|
|
// DocumentAllGetProperty().
|
|
|
|
|
|
|
|
v = JSVAL_ONE;
|
2004-07-23 00:26:02 +00:00
|
|
|
} else {
|
|
|
|
if (!DocumentAllGetProperty(cx, obj, id, &v)) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
JSBool ok = JS_TRUE;
|
|
|
|
|
2012-07-30 11:19:09 +00:00
|
|
|
if (v.get() != JSVAL_VOID) {
|
2012-07-30 14:20:58 +00:00
|
|
|
ok = ::JS_DefinePropertyById(cx, obj, id, v, nullptr, nullptr, 0);
|
2012-07-04 18:12:16 +00:00
|
|
|
objp.set(obj);
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 01:31:19 +00:00
|
|
|
return ok;
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
2008-09-06 22:21:43 +00:00
|
|
|
void
|
2012-03-19 14:34:55 +00:00
|
|
|
nsHTMLDocumentSH::ReleaseDocument(JSFreeOp *fop, JSObject *obj)
|
2004-07-23 00:26:02 +00:00
|
|
|
{
|
2013-06-12 06:55:00 +00:00
|
|
|
nsIHTMLDocument* doc = GetDocument(obj);
|
2012-05-18 22:00:19 +00:00
|
|
|
if (doc) {
|
2013-07-09 14:28:15 +00:00
|
|
|
nsContentUtils::DeferredFinalize(doc);
|
2012-05-18 22:00:19 +00:00
|
|
|
}
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
2008-09-06 22:21:43 +00:00
|
|
|
JSBool
|
2012-02-28 23:11:11 +00:00
|
|
|
nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
|
2004-07-23 00:26:02 +00:00
|
|
|
{
|
|
|
|
// Handle document.all("foo") style access to document.all.
|
|
|
|
|
|
|
|
if (argc != 1) {
|
|
|
|
// XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
|
|
|
|
// and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
|
|
|
|
// accepts nothing other than one arg.
|
2012-06-19 23:01:10 +00:00
|
|
|
xpc::Throw(cx, NS_ERROR_INVALID_ARG);
|
2004-07-23 00:26:02 +00:00
|
|
|
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert all types to string.
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSString*> str(cx, ::JS_ValueToString(cx, JS_ARGV(cx, vp)[0]));
|
2004-07-23 00:26:02 +00:00
|
|
|
if (!str) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-17 07:30:38 +00:00
|
|
|
// If we are called via document.all(id) instead of document.all.item(i) or
|
|
|
|
// another method, use the document.all callee object as self.
|
2004-08-24 01:31:19 +00:00
|
|
|
JSObject *self;
|
2012-05-11 15:46:26 +00:00
|
|
|
JS::Value callee = JS_CALLEE(cx, vp);
|
|
|
|
if (callee.isObject() &&
|
2012-06-14 23:03:55 +00:00
|
|
|
JS_GetClass(&callee.toObject()) == &sHTMLDocumentAllClass) {
|
2011-01-17 07:30:38 +00:00
|
|
|
self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
|
|
|
|
} else {
|
2010-08-16 19:35:04 +00:00
|
|
|
self = JS_THIS_OBJECT(cx, vp);
|
|
|
|
if (!self)
|
|
|
|
return JS_FALSE;
|
2004-08-24 01:31:19 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
size_t length;
|
2012-09-29 16:32:56 +00:00
|
|
|
JS::Anchor<JSString *> anchor(str);
|
2010-12-03 08:24:17 +00:00
|
|
|
const jschar *chars = ::JS_GetStringCharsAndLength(cx, str, &length);
|
|
|
|
if (!chars) {
|
|
|
|
return JS_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ::JS_GetUCProperty(cx, self, chars, length, vp);
|
2004-07-23 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// StringArray helper
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, jsval *vp,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool is_number = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t n = GetArrayIndexFromId(cx, id, &is_number);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2001-06-28 04:26:29 +00:00
|
|
|
if (!is_number) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2001-06-28 04:26:29 +00:00
|
|
|
nsAutoString val;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2009-05-12 20:20:42 +00:00
|
|
|
nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
|
2001-06-28 04:26:29 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2011-05-30 11:35:52 +00:00
|
|
|
if (DOMStringIsNull(val)) {
|
|
|
|
*vp = JSVAL_VOID;
|
2012-10-02 08:24:10 +00:00
|
|
|
return NS_SUCCESS_I_DID_SOMETHING;
|
2011-05-13 16:12:24 +00:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2012-10-02 08:24:10 +00:00
|
|
|
NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, vp),
|
|
|
|
NS_ERROR_OUT_OF_MEMORY);
|
2005-07-29 15:11:08 +00:00
|
|
|
return NS_SUCCESS_I_DID_SOMETHING;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// History helper
|
|
|
|
|
2010-10-29 19:49:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
|
|
|
JSObject *globalObj, JSObject **parentObj)
|
|
|
|
{
|
2011-03-01 07:08:56 +00:00
|
|
|
nsHistory *history = (nsHistory *)((nsIDOMHistory*)nativeObj);
|
2011-02-01 17:19:35 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> innerWindow;
|
|
|
|
history->GetWindow(getter_AddRefs(innerWindow));
|
|
|
|
if (!innerWindow) {
|
|
|
|
NS_WARNING("refusing to create history object in the wrong scope");
|
|
|
|
return NS_ERROR_FAILURE;
|
2010-10-29 19:49:32 +00:00
|
|
|
}
|
2012-04-27 08:38:14 +00:00
|
|
|
return SetParentToWindow(static_cast<nsGlobalWindow *>(innerWindow.get()),
|
|
|
|
parentObj);
|
2010-10-29 19:49:32 +00:00
|
|
|
}
|
|
|
|
|
2001-08-31 02:36:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHistorySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, jsval *vp, bool *_retval)
|
2001-08-31 02:36:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool is_number = false;
|
2001-08-31 02:36:45 +00:00
|
|
|
GetArrayIndexFromId(cx, id, &is_number);
|
|
|
|
|
|
|
|
if (!is_number) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsStringArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsHistorySH::GetStringAt(nsISupports *aNative, int32_t aIndex,
|
2002-03-24 00:16:18 +00:00
|
|
|
nsAString& aResult)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHistory> history(do_QueryInterface(aNative));
|
|
|
|
|
2011-05-30 11:35:52 +00:00
|
|
|
nsresult rv = history->Item(aIndex, aResult);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (DOMStringIsNull(aResult)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t length = 0;
|
2011-05-30 11:35:52 +00:00
|
|
|
history->GetLength(&length);
|
|
|
|
NS_ASSERTION(aIndex >= length, "Item should only return null for out-of-bounds access");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return rv;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MediaList helper
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsMediaListSH::GetStringAt(nsISupports *aNative, int32_t aIndex,
|
2002-03-24 00:16:18 +00:00
|
|
|
nsAString& aResult)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMMediaList> media_list(do_QueryInterface(aNative));
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult rv = media_list->Item(uint32_t(aIndex), aResult);
|
2011-05-30 11:35:52 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (DOMStringIsNull(aResult)) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length = 0;
|
2011-05-30 11:35:52 +00:00
|
|
|
media_list->GetLength(&length);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_ASSERTION(uint32_t(aIndex) >= length, "Item should only return null for out-of-bounds access");
|
2011-05-30 11:35:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return rv;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// StyleSheetList helper
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
nsISupports*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
2010-05-09 19:33:00 +00:00
|
|
|
nsWrapperCache **aCache, nsresult *rv)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
{
|
2008-10-22 14:31:14 +00:00
|
|
|
nsDOMStyleSheetList* list = nsDOMStyleSheetList::FromSupports(aNative);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
return list->GetItemAt(aIndex);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-13 22:16:45 +00:00
|
|
|
// CSSRuleList scriptable helper
|
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
nsISupports*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsCSSRuleListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
|
2010-05-09 19:33:00 +00:00
|
|
|
nsWrapperCache **aCache, nsresult *aResult)
|
2001-05-13 22:16:45 +00:00
|
|
|
{
|
2008-10-22 14:31:14 +00:00
|
|
|
nsICSSRuleList* list = static_cast<nsICSSRuleList*>(aNative);
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICSSRuleList> list_qi = do_QueryInterface(aNative);
|
2001-05-13 22:16:45 +00:00
|
|
|
|
2008-10-22 14:31:14 +00:00
|
|
|
// If this assertion fires the QI implementation for the object in
|
|
|
|
// question doesn't use the nsICSSRuleList pointer as the nsISupports
|
|
|
|
// pointer. That must be fixed, or we'll crash...
|
2011-04-07 22:44:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-05-13 22:16:45 +00:00
|
|
|
|
2013-07-24 07:27:17 +00:00
|
|
|
return list->Item(aIndex);
|
2001-05-13 22:16:45 +00:00
|
|
|
}
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
|
2009-03-18 23:43:45 +00:00
|
|
|
// Storage2SH
|
|
|
|
|
|
|
|
// One reason we need a newResolve hook is that in order for
|
|
|
|
// enumeration of storage object keys to work the keys we're
|
|
|
|
// enumerating need to exist on the storage object for the JS engine
|
|
|
|
// to find them.
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-11 02:39:45 +00:00
|
|
|
JSObject *obj, jsid aId, uint32_t flags,
|
2011-09-29 06:19:26 +00:00
|
|
|
JSObject **objp, bool *_retval)
|
2009-03-18 23:43:45 +00:00
|
|
|
{
|
2013-05-11 02:39:45 +00:00
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2011-02-17 04:29:14 +00:00
|
|
|
if (ObjectIsNativeWrapper(cx, obj)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-20 12:44:18 +00:00
|
|
|
JS::Rooted<JSObject*> realObj(cx, wrapper->GetJSObject());
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2012-08-22 01:42:53 +00:00
|
|
|
JSAutoCompartment ac(cx, realObj);
|
2011-02-17 04:29:14 +00:00
|
|
|
|
2009-03-18 23:43:45 +00:00
|
|
|
// First check to see if the property is defined on our prototype,
|
|
|
|
// after converting id to a string if it's an integer.
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSString*> jsstr(cx, IdToString(cx, id));
|
2009-03-18 23:43:45 +00:00
|
|
|
if (!jsstr) {
|
2012-07-27 13:59:29 +00:00
|
|
|
return NS_OK;
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
|
|
|
if (!::JS_GetPrototype(cx, realObj, proto.address())) {
|
2012-09-03 23:42:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2009-03-18 23:43:45 +00:00
|
|
|
JSBool hasProp;
|
|
|
|
|
|
|
|
if (proto &&
|
2010-07-15 06:19:36 +00:00
|
|
|
(::JS_HasPropertyById(cx, proto, id, &hasProp) &&
|
2009-03-18 23:43:45 +00:00
|
|
|
hasProp)) {
|
|
|
|
// We found the property we're resolving on the prototype,
|
|
|
|
// nothing left to do here then.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're resolving property that doesn't exist on the prototype,
|
|
|
|
// check if the key exists in the storage object.
|
|
|
|
|
2009-05-16 13:59:30 +00:00
|
|
|
nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString depStr;
|
|
|
|
NS_ENSURE_TRUE(depStr.init(cx, jsstr), NS_ERROR_UNEXPECTED);
|
|
|
|
|
2009-03-18 23:43:45 +00:00
|
|
|
// GetItem() will return null if the caller can't access the session
|
|
|
|
// storage item.
|
|
|
|
nsAutoString data;
|
2010-12-03 08:24:17 +00:00
|
|
|
nsresult rv = storage->GetItem(depStr, data);
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!DOMStringIsNull(data)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nullptr,
|
|
|
|
nullptr, JSPROP_ENUMERATE)) {
|
2009-03-18 23:43:45 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*objp = realObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, jsval *vp, bool *_retval)
|
2009-03-18 23:43:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2009-05-16 13:59:30 +00:00
|
|
|
nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2012-05-18 08:29:40 +00:00
|
|
|
JSString* key = IdToString(cx, id);
|
|
|
|
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2012-05-18 08:29:40 +00:00
|
|
|
nsDependentJSString keyStr;
|
|
|
|
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2012-05-18 08:29:40 +00:00
|
|
|
// For native wrappers, do not get random names on storage objects.
|
|
|
|
if (ObjectIsNativeWrapper(cx, obj)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
|
|
|
|
2012-05-18 08:29:40 +00:00
|
|
|
nsAutoString val;
|
|
|
|
nsresult rv = storage->GetItem(keyStr, val);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-03-18 23:43:45 +00:00
|
|
|
if (DOMStringIsNull(val)) {
|
2012-04-03 07:25:39 +00:00
|
|
|
// No such key.
|
|
|
|
*vp = JSVAL_VOID;
|
|
|
|
} else {
|
|
|
|
JSString* str =
|
|
|
|
JS_NewUCStringCopyN(cx, static_cast<const jschar *>(val.get()),
|
|
|
|
val.Length());
|
|
|
|
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2012-04-03 07:25:39 +00:00
|
|
|
*vp = STRING_TO_JSVAL(str);
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_SUCCESS_I_DID_SOMETHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSContext *cx, JSObject *obj, jsid aId,
|
2011-09-29 06:19:26 +00:00
|
|
|
jsval *vp, bool *_retval)
|
2009-03-18 23:43:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2009-05-16 13:59:30 +00:00
|
|
|
nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
JSString *key = IdToString(cx, id);
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString keyStr;
|
|
|
|
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
|
|
|
|
|
2009-03-18 23:43:45 +00:00
|
|
|
JSString *value = ::JS_ValueToString(cx, *vp);
|
|
|
|
NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString valueStr;
|
|
|
|
NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsresult rv = storage->SetItem(keyStr, valueStr);
|
2009-03-18 23:43:45 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = NS_SUCCESS_I_DID_SOMETHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStorage2SH::DelProperty(nsIXPConnectWrappedNative *wrapper,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSContext *cx, JSObject *obj, jsid aId,
|
2013-04-06 04:22:55 +00:00
|
|
|
bool *_retval)
|
2009-03-18 23:43:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2009-05-16 13:59:30 +00:00
|
|
|
nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-07-15 06:19:36 +00:00
|
|
|
JSString *key = IdToString(cx, id);
|
2009-03-18 23:43:45 +00:00
|
|
|
NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-12-03 08:24:17 +00:00
|
|
|
nsDependentJSString keyStr;
|
|
|
|
NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsresult rv = storage->RemoveItem(keyStr);
|
2013-04-06 04:22:55 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
|
|
|
|
2013-04-06 04:22:55 +00:00
|
|
|
*_retval = true;
|
|
|
|
return NS_SUCCESS_I_DID_SOMETHING;
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2012-08-22 15:56:38 +00:00
|
|
|
JSObject *obj, uint32_t enum_op, jsval *statep,
|
2011-09-29 06:19:26 +00:00
|
|
|
jsid *idp, bool *_retval)
|
2009-03-18 23:43:45 +00:00
|
|
|
{
|
2010-10-15 21:55:53 +00:00
|
|
|
if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
|
|
|
|
nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
// XXXndeakin need to free the keys afterwards
|
|
|
|
nsTArray<nsString> *keys = storage->GetKeys();
|
|
|
|
NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
*statep = PRIVATE_TO_JSVAL(keys);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
if (idp) {
|
|
|
|
*idp = INT_TO_JSID(keys->Length());
|
2009-03-18 23:43:45 +00:00
|
|
|
}
|
2010-10-15 21:55:53 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
nsTArray<nsString> *keys =
|
|
|
|
(nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
|
|
|
|
nsString& key = keys->ElementAt(0);
|
|
|
|
JSString *str =
|
|
|
|
JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
|
|
|
|
(key.get()),
|
|
|
|
key.Length());
|
|
|
|
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
keys->RemoveElementAt(0);
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
// destroy the keys array if we have no keys or if we're done
|
|
|
|
NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
|
|
|
|
(enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
|
|
|
|
"Bad call from the JS engine");
|
|
|
|
delete keys;
|
2009-03-18 23:43:45 +00:00
|
|
|
|
2010-10-15 21:55:53 +00:00
|
|
|
*statep = JSVAL_NULL;
|
2009-03-18 23:43:45 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// nsIDOMEventListener::HandleEvent() 'this' converter helper
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsEventListenerThisTranslator)
|
|
|
|
NS_IMPL_RELEASE(nsEventListenerThisTranslator)
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
|
|
|
|
nsISupports **_retval)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
|
|
|
|
NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2013-04-19 22:18:32 +00:00
|
|
|
nsCOMPtr<EventTarget> target = event->InternalDOMEvent()->GetCurrentTarget();
|
|
|
|
*_retval = target.forget().get();
|
2001-04-01 01:10:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-12-09 19:08:45 +00:00
|
|
|
|
2011-01-11 20:15:52 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aGlobalObj, JSObject **parentObj)
|
2011-01-11 20:15:52 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> globalObj(cx, aGlobalObj);
|
2011-01-11 20:15:52 +00:00
|
|
|
nsDOMConstructor *wrapped = static_cast<nsDOMConstructor *>(nativeObj);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
|
|
|
|
do_QueryInterface(nativeObj);
|
|
|
|
NS_ASSERTION(is_constructor, "How did we not get a constructor?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return wrapped->PreCreate(cx, globalObj, parentObj);
|
|
|
|
}
|
|
|
|
|
2011-09-22 02:16:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSObject *aObj, jsid aId, uint32_t flags,
|
2011-09-22 02:16:50 +00:00
|
|
|
JSObject **objp, bool *_retval)
|
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
|
|
|
JS::Rooted<jsid> id(cx, aId);
|
2011-09-22 02:16:50 +00:00
|
|
|
// For regular DOM constructors, we have our interface constants defined on
|
|
|
|
// us by nsWindowSH::GlobalResolve. However, XrayWrappers can't see these
|
|
|
|
// interface constants (as they look like expando properties) so we have to
|
|
|
|
// specially resolve those constants here, but only for Xray wrappers.
|
|
|
|
if (!ObjectIsNativeWrapper(cx, obj)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> nativePropsObj(cx, xpc::XrayUtils::GetNativePropertiesObject(cx, obj));
|
2011-09-22 02:16:50 +00:00
|
|
|
nsDOMConstructor *wrapped =
|
|
|
|
static_cast<nsDOMConstructor *>(wrapper->Native());
|
|
|
|
nsresult rv = wrapped->ResolveInterfaceConstants(cx, nativePropsObj);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Now re-lookup the ID to see if we should report back that we resolved the
|
|
|
|
// looked-for constant. Note that we don't have to worry about infinitely
|
|
|
|
// recurring back here because the Xray wrapper's holder object doesn't call
|
|
|
|
// NewResolve hooks.
|
|
|
|
JSBool found;
|
|
|
|
if (!JS_HasPropertyById(cx, nativePropsObj, id, &found)) {
|
2012-04-04 09:15:10 +00:00
|
|
|
*_retval = false;
|
2011-09-22 02:16:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found) {
|
|
|
|
*objp = obj;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructorSH::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JSObject *aObj, const JS::CallArgs &args, bool *_retval)
|
2007-05-09 12:04:59 +00:00
|
|
|
{
|
2013-05-03 18:53:32 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2013-04-26 06:48:40 +00:00
|
|
|
MOZ_ASSERT(obj);
|
|
|
|
|
2007-05-09 12:04:59 +00:00
|
|
|
nsDOMConstructor *wrapped =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsDOMConstructor *>(wrapper->Native());
|
2007-05-09 12:04:59 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
2007-11-12 06:43:14 +00:00
|
|
|
nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
|
|
|
|
do_QueryWrappedNative(wrapper);
|
2007-05-09 12:04:59 +00:00
|
|
|
NS_ASSERTION(is_constructor, "How did we not get a constructor?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-04 17:25:15 +00:00
|
|
|
return wrapped->Construct(wrapper, cx, obj, args, _retval);
|
2007-05-09 12:04:59 +00:00
|
|
|
}
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
2013-05-04 17:25:15 +00:00
|
|
|
JSObject *aObj, const JS::CallArgs &args, bool *_retval)
|
2005-12-09 19:08:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2013-04-26 06:48:40 +00:00
|
|
|
MOZ_ASSERT(obj);
|
|
|
|
|
2005-12-09 19:08:45 +00:00
|
|
|
nsDOMConstructor *wrapped =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsDOMConstructor *>(wrapper->Native());
|
2005-12-09 19:08:45 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
2007-11-12 06:52:07 +00:00
|
|
|
nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
|
2007-11-12 06:43:14 +00:00
|
|
|
do_QueryWrappedNative(wrapper);
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ASSERTION(is_constructor, "How did we not get a constructor?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-04 17:25:15 +00:00
|
|
|
return wrapped->Construct(wrapper, cx, obj, args, _retval);
|
2005-12-09 19:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
2013-05-04 07:51:53 +00:00
|
|
|
JSContext *cx, JSObject *aObj, const jsval &val,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *bp, bool *_retval)
|
2005-12-09 19:08:45 +00:00
|
|
|
{
|
2013-05-04 07:51:53 +00:00
|
|
|
JS::Rooted<JSObject*> obj(cx, aObj);
|
2005-12-09 19:08:45 +00:00
|
|
|
nsDOMConstructor *wrapped =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsDOMConstructor *>(wrapper->Native());
|
2005-12-09 19:08:45 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
2007-11-12 06:43:14 +00:00
|
|
|
nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
|
|
|
|
do_QueryWrappedNative(wrapper);
|
2005-12-09 19:08:45 +00:00
|
|
|
NS_ASSERTION(is_constructor, "How did we not get a constructor?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
|
|
|
|
}
|
2006-02-23 03:17:11 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNonDOMObjectSH::GetFlags(uint32_t *aFlags)
|
2006-02-23 03:17:11 +00:00
|
|
|
{
|
|
|
|
// This is NOT a DOM Object. Use this helper class for cases when you need
|
|
|
|
// to do something like implement nsISecurityCheckedComponent in a meaningful
|
|
|
|
// way.
|
2012-07-13 12:33:25 +00:00
|
|
|
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::SINGLETON_CLASSINFO;
|
2006-02-23 03:38:59 +00:00
|
|
|
return NS_OK;
|
2006-02-23 03:17:11 +00:00
|
|
|
}
|