From 693923a31fd8fb3a34177117eb34b24eb9ef186a Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Fri, 16 Jul 2004 17:03:10 +0000 Subject: [PATCH] Landing fix for bug 239202, patch by trev@gtchat.de. Making nsIScriptGlobalObjectOwner not scriptable. r+sr=jst@mozilla.org --- content/base/src/nsDocumentViewer.cpp | 1 - content/base/src/nsPrintEngine.cpp | 2 - .../html/document/src/nsHTMLContentSink.cpp | 2 +- content/xbl/src/nsBindingManager.cpp | 1 - content/xbl/src/nsXBLBinding.cpp | 1 - content/xbl/src/nsXBLDocumentInfo.cpp | 32 ++------- content/xbl/src/nsXBLDocumentInfo.h | 2 +- content/xbl/src/nsXBLProtoImpl.cpp | 4 +- content/xml/document/src/nsXMLDocument.cpp | 4 +- content/xul/content/src/nsXULElement.cpp | 10 ++- content/xul/document/src/nsXULContentSink.cpp | 1 - content/xul/document/src/nsXULDocument.cpp | 8 +-- .../document/src/nsXULPrototypeDocument.cpp | 40 ++--------- docshell/base/nsCDocShell.idl | 4 +- docshell/base/nsDocShell.cpp | 45 +++---------- docshell/base/nsDocShell.h | 3 +- dom/public/Makefile.in | 2 +- dom/public/nsIScriptGlobalObjectOwner.h | 66 +++++++++++++++++++ dom/public/nsIScriptGlobalObjectOwner.idl | 0 dom/src/base/nsJSEnvironment.cpp | 17 ++--- dom/src/jsurl/nsJSProtocolHandler.cpp | 7 +- layout/base/nsDocumentViewer.cpp | 1 - layout/printing/nsPrintEngine.cpp | 2 - xpfe/appshell/src/nsWebShellWindow.cpp | 3 +- xpinstall/src/nsInstallTrigger.cpp | 4 +- 25 files changed, 116 insertions(+), 146 deletions(-) create mode 100644 dom/public/nsIScriptGlobalObjectOwner.h delete mode 100644 dom/public/nsIScriptGlobalObjectOwner.idl diff --git a/content/base/src/nsDocumentViewer.cpp b/content/base/src/nsDocumentViewer.cpp index 401d55fa2ab..0267a39805d 100644 --- a/content/base/src/nsDocumentViewer.cpp +++ b/content/base/src/nsDocumentViewer.cpp @@ -57,7 +57,6 @@ #include "nsICSSStyleSheet.h" #include "nsIFrame.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" diff --git a/content/base/src/nsPrintEngine.cpp b/content/base/src/nsPrintEngine.cpp index 5709d379fbd..76dba175305 100644 --- a/content/base/src/nsPrintEngine.cpp +++ b/content/base/src/nsPrintEngine.cpp @@ -117,8 +117,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsISupportsUtils.h" #include "nsIFrame.h" #include "nsIScriptContext.h" -#include "nsIScriptGlobalObjectOwner.h" -#include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" #include "nsISelectionListener.h" diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 8d6c607bfdf..0b99103f65b 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -2027,7 +2027,7 @@ IsScriptEnabled(nsIDocument *aDoc, nsIDocShell *aContainer) nsCOMPtr owner = do_GetInterface(aContainer); NS_ENSURE_TRUE(owner, PR_TRUE); - owner->GetScriptGlobalObject(getter_AddRefs(globalObject)); + globalObject = owner->GetScriptGlobalObject(); NS_ENSURE_TRUE(globalObject, PR_TRUE); } diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index e8e93d95c1d..cd3b5d15090 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -82,7 +82,6 @@ #include "nsIDOMScriptObjectFactory.h" #include "nsIPrincipal.h" #include "nsIScriptGlobalObject.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptObjectPrincipal.h" #include "nsIConsoleService.h" #include "nsIScriptError.h" diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 7af41198977..e1dfceba937 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -70,7 +70,6 @@ #include "nsXBLService.h" #include "nsXBLInsertionPoint.h" #include "nsIXPConnect.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptContext.h" #include "nsCRT.h" diff --git a/content/xbl/src/nsXBLDocumentInfo.cpp b/content/xbl/src/nsXBLDocumentInfo.cpp index f4ab4e50fce..b237d951d54 100644 --- a/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/content/xbl/src/nsXBLDocumentInfo.cpp @@ -40,6 +40,7 @@ #include "nsIDocument.h" #include "nsXBLPrototypeBinding.h" #include "nsIScriptObjectPrincipal.h" +#include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" #include "nsIDOMScriptObjectFactory.h" #include "jsapi.h" @@ -424,38 +425,20 @@ nsXBLDocumentInfo::FlushSkinStylesheets() // nsIScriptGlobalObjectOwner methods // -NS_IMETHODIMP -nsXBLDocumentInfo::GetScriptGlobalObject(nsIScriptGlobalObject** _result) +nsIScriptGlobalObject* +nsXBLDocumentInfo::GetScriptGlobalObject() { if (!mGlobalObject) { mGlobalObject = new nsXBLDocGlobalObject(); - if (!mGlobalObject) { - *_result = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } - + if (!mGlobalObject) + return nsnull; + mGlobalObject->SetGlobalObjectOwner(this); // does not refcount } - *_result = mGlobalObject; - NS_ADDREF(*_result); - return NS_OK; -} - -NS_IMETHODIMP -nsXBLDocumentInfo::ReportScriptError(nsIScriptError *errorObject) -{ - if (errorObject == nsnull) - return NS_ERROR_NULL_POINTER; - - // Get the console service, where we're going to register the error. - nsCOMPtr consoleService (do_GetService("@mozilla.org/consoleservice;1")); - - if (!consoleService) - return NS_ERROR_NOT_AVAILABLE; - return consoleService->LogMessage(errorObject); + return mGlobalObject; } nsresult NS_NewXBLDocumentInfo(nsIDocument* aDocument, nsIXBLDocumentInfo** aResult) @@ -470,4 +453,3 @@ nsresult NS_NewXBLDocumentInfo(nsIDocument* aDocument, nsIXBLDocumentInfo** aRes NS_ADDREF(*aResult); return NS_OK; } - diff --git a/content/xbl/src/nsXBLDocumentInfo.h b/content/xbl/src/nsXBLDocumentInfo.h index a2052493b43..96377e993cc 100644 --- a/content/xbl/src/nsXBLDocumentInfo.h +++ b/content/xbl/src/nsXBLDocumentInfo.h @@ -64,7 +64,7 @@ public: NS_IMETHOD FlushSkinStylesheets(); // nsIScriptGlobalObjectOwner methods - NS_DECL_NSISCRIPTGLOBALOBJECTOWNER + virtual nsIScriptGlobalObject* GetScriptGlobalObject(); private: nsCOMPtr mDocument; diff --git a/content/xbl/src/nsXBLProtoImpl.cpp b/content/xbl/src/nsXBLProtoImpl.cpp index 420d322f351..e5d1d4e8b7e 100644 --- a/content/xbl/src/nsXBLProtoImpl.cpp +++ b/content/xbl/src/nsXBLProtoImpl.cpp @@ -145,8 +145,8 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding) // context. nsCOMPtr globalOwner( do_QueryInterface(aBinding->XBLDocumentInfo())); - nsCOMPtr globalObject; - globalOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = globalOwner->GetScriptGlobalObject(); + NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED); nsIScriptContext *context = globalObject->GetContext(); diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp index 89745c74a07..ad9a613f8f5 100644 --- a/content/xml/document/src/nsXMLDocument.cpp +++ b/content/xml/document/src/nsXMLDocument.cpp @@ -630,11 +630,11 @@ nsXMLDocument::EndLoad() nsEventStatus status = nsEventStatus_eIgnore; nsEvent event(NS_PAGE_LOAD); - nsCOMPtr sgo; + nsIScriptGlobalObject* sgo = nsnull; nsCOMPtr container = do_QueryReferent(mDocumentContainer); if (container) { - container->GetScriptGlobalObject(getter_AddRefs(sgo)); + sgo = container->GetScriptGlobalObject(); } nsCxPusher pusher(sgo); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 17849fd2759..0b692c85c4c 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1482,8 +1482,7 @@ nsXULElement::CompileEventHandler(nsIScriptContext* aContext, nsCOMPtr globalOwner = do_QueryInterface(protodoc); - nsCOMPtr global; - globalOwner->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject(); NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED); context = global->GetContext(); @@ -4656,10 +4655,9 @@ nsXULPrototypeScript::Compile(const PRUnichar* aText, nsIScriptContext *context = nsnull; { - nsCOMPtr globalOwner - = do_QueryInterface(aPrototypeDocument); - nsCOMPtr global; - globalOwner->GetScriptGlobalObject(getter_AddRefs(global)); + nsCOMPtr globalOwner = + do_QueryInterface(aPrototypeDocument); + nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject(); NS_ASSERTION(global != nsnull, "prototype doc has no script global"); if (! global) return NS_ERROR_UNEXPECTED; diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index de92a1ea104..d420067ea71 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -71,7 +71,6 @@ #include "nsIPresShell.h" #include "nsIScriptContext.h" #include "nsIScriptGlobalObject.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIServiceManager.h" #include "nsITextContent.h" #include "nsIURL.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index d8b236458e6..97d14138343 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3234,10 +3234,10 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader, // Ignore the return value, as we don't need to propagate // a failure to write to the FastLoad file, because this // method aborts that whole process on error. - nsCOMPtr globalOwner - = do_QueryInterface(mCurrentPrototype); - nsCOMPtr global; - globalOwner->GetScriptGlobalObject(getter_AddRefs(global)); + nsCOMPtr globalOwner = + do_QueryInterface(mCurrentPrototype); + nsIScriptGlobalObject* global = + globalOwner->GetScriptGlobalObject(); NS_ASSERTION(global != nsnull, "master prototype w/o global?!"); if (global) { diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp index 75d54e497b0..1ec6da928a5 100644 --- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -157,7 +157,7 @@ public: virtual nsNodeInfoManager *GetNodeInfoManager(); // nsIScriptGlobalObjectOwner methods - NS_DECL_NSISCRIPTGLOBALOBJECTOWNER + virtual nsIScriptGlobalObject* GetScriptGlobalObject(); NS_DEFINE_STATIC_CID_ACCESSOR(NS_XULPROTOTYPEDOCUMENT_CID); @@ -540,8 +540,8 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) } // Now serialize the document contents - nsCOMPtr globalObject; - rv |= GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = GetScriptGlobalObject(); + NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED); nsIScriptContext *scriptContext = globalObject->GetContext(); @@ -764,39 +764,13 @@ nsXULPrototypeDocument::NotifyLoadDone() // nsIScriptGlobalObjectOwner methods // -NS_IMETHODIMP -nsXULPrototypeDocument::GetScriptGlobalObject(nsIScriptGlobalObject** _result) +nsIScriptGlobalObject* +nsXULPrototypeDocument::GetScriptGlobalObject() { - nsresult rv = NS_OK; if (!mGlobalObject) - rv = NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); - *_result = mGlobalObject; - NS_IF_ADDREF(*_result); - return rv; -} + NewXULPDGlobalObject(getter_AddRefs(mGlobalObject)); -NS_IMETHODIMP -nsXULPrototypeDocument::ReportScriptError(nsIScriptError *errorObject) -{ - nsresult rv; - - if (errorObject == nsnull) - return NS_ERROR_NULL_POINTER; - - // Get the console service, where we're going to register the error. - nsCOMPtr consoleService - (do_GetService("@mozilla.org/consoleservice;1")); - - if (consoleService != nsnull) { - rv = consoleService->LogMessage(errorObject); - if (NS_SUCCEEDED(rv)) { - return NS_OK; - } else { - return rv; - } - } else { - return NS_ERROR_NOT_AVAILABLE; - } + return mGlobalObject; } //---------------------------------------------------------------------- diff --git a/docshell/base/nsCDocShell.idl b/docshell/base/nsCDocShell.idl index 38a048eb9bb..5b870c1d1ce 100644 --- a/docshell/base/nsCDocShell.idl +++ b/docshell/base/nsCDocShell.idl @@ -43,7 +43,6 @@ #include "nsIBaseWindow.idl" #include "nsIScrollable.idl" #include "nsITextScroll.idl" -#include "nsIScriptGlobalObjectOwner.idl" /* nsCHTMLDocShell implements: @@ -54,11 +53,10 @@ nsIDocShellTreeNode nsIBaseWindow nsIScrollable nsITextScroll -nsIScriptGlobalObjectOwner */ %{ C++ -// {F1EAC762-87E9-11d3-AF80-00A024FFC08C} - +// {F1EAC762-87E9-11d3-AF80-00A024FFC08C} - #define NS_DOCSHELL_CID \ { 0xf1eac762, 0x87e9, 0x11d3, { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } } #define NS_DOCSHELL_CONTRACTID \ diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 1b2201fc0f0..9231db46a9a 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3835,45 +3835,16 @@ nsDocShell::ScrollByPages(PRInt32 numPages) // nsDocShell::nsIScriptGlobalObjectOwner //***************************************************************************** -NS_IMETHODIMP -nsDocShell::GetScriptGlobalObject(nsIScriptGlobalObject ** aGlobal) +nsIScriptGlobalObject* +nsDocShell::GetScriptGlobalObject() { if (mIsBeingDestroyed) { - return NS_ERROR_NOT_AVAILABLE; + return nsnull; } - NS_ENSURE_ARG_POINTER(aGlobal); - NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nsnull); - *aGlobal = mScriptGlobal; - NS_IF_ADDREF(*aGlobal); - return NS_OK; -} - -NS_IMETHODIMP -nsDocShell::ReportScriptError(nsIScriptError * errorObject) -{ - nsresult rv; - - if (errorObject == nsnull) - return NS_ERROR_NULL_POINTER; - - // Get the console service, where we're going to register the error. - nsCOMPtr consoleService - (do_GetService("@mozilla.org/consoleservice;1")); - - if (consoleService != nsnull) { - rv = consoleService->LogMessage(errorObject); - if (NS_SUCCEEDED(rv)) { - return NS_OK; - } - else { - return rv; - } - } - else { - return NS_ERROR_NOT_AVAILABLE; - } + return mScriptGlobal; } //***************************************************************************** @@ -6957,9 +6928,9 @@ NS_IMETHODIMP nsDocShell::EnsureFind() // we promise that the nsIWebBrowserFind that we return has been set // up to point to the focussed, or content window, so we have to // set that up each time. - nsCOMPtr scriptGO; - rv = GetScriptGlobalObject(getter_AddRefs(scriptGO)); - if (NS_FAILED(rv)) return rv; + + nsIScriptGlobalObject* scriptGO = GetScriptGlobalObject(); + NS_ENSURE_TRUE(scriptGO, NS_ERROR_UNEXPECTED); // default to our window nsCOMPtr rootWindow = do_QueryInterface(scriptGO); diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index bbc23d1b6c4..54331ef10f1 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -214,7 +214,6 @@ public: NS_DECL_NSITEXTSCROLL NS_DECL_NSIDOCCHARSET NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSISCRIPTGLOBALOBJECTOWNER NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIREFRESHURI NS_DECL_NSICONTENTVIEWERCONTAINER @@ -226,6 +225,8 @@ public: nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType); PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType); + // nsIScriptGlobalObjectOwner methods + virtual nsIScriptGlobalObject* GetScriptGlobalObject(); protected: // Object Management virtual ~nsDocShell(); diff --git a/dom/public/Makefile.in b/dom/public/Makefile.in index a77083847bd..6afc416071f 100644 --- a/dom/public/Makefile.in +++ b/dom/public/Makefile.in @@ -48,7 +48,6 @@ GRE_MODULE = 1 DIRS = idl coreEvents base XPIDLSRCS = nsIScriptContextOwner.idl \ - nsIScriptGlobalObjectOwner.idl \ nsIEntropyCollector.idl \ $(NULL) @@ -57,6 +56,7 @@ EXPORTS=nsIScriptContext.h \ nsIScriptObjectOwner.h \ nsIScriptObjectPrincipal.h \ nsIScriptGlobalObject.h \ + nsIScriptGlobalObjectOwner.h \ nsIDOMScriptObjectFactory.h \ nsDOMCID.h \ nsIScriptExternalNameSet.h \ diff --git a/dom/public/nsIScriptGlobalObjectOwner.h b/dom/public/nsIScriptGlobalObjectOwner.h new file mode 100644 index 00000000000..9b6103b24e9 --- /dev/null +++ b/dom/public/nsIScriptGlobalObjectOwner.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Travis Bogard + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsIScriptGlobalObjectOwner_h__ +#define nsIScriptGlobalObjectOwner_h__ + +#include "nsISupports.h" + +class nsIScriptGlobalObject; + +#define NS_ISCRIPTGLOBALOBJECTOWNER_IID \ + {0xfd25ca8e, 0x6b63, 0x435f, \ + { 0xb8, 0xc6, 0xb8, 0x07, 0x68, 0xa4, 0x0a, 0xdc }} + +/** + * Implemented by any object capable of supplying a nsIScriptGlobalObject. + * The implentor may create the script global object on demand. + */ + +class nsIScriptGlobalObjectOwner : public nsISupports +{ +public: + NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECTOWNER_IID) + + /** + * Returns the script global object + */ + virtual nsIScriptGlobalObject* GetScriptGlobalObject() = 0; +}; + +#endif /* nsIScriptGlobalObjectOwner_h__ */ diff --git a/dom/public/nsIScriptGlobalObjectOwner.idl b/dom/public/nsIScriptGlobalObjectOwner.idl deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dom/src/base/nsJSEnvironment.cpp b/dom/src/base/nsJSEnvironment.cpp index fc5b8839c25..93b8796d95a 100644 --- a/dom/src/base/nsJSEnvironment.cpp +++ b/dom/src/base/nsJSEnvironment.cpp @@ -38,7 +38,6 @@ #include "nsJSEnvironment.h" #include "nsIScriptContextOwner.h" #include "nsIScriptGlobalObject.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptObjectPrincipal.h" #include "nsIDOMWindowInternal.h" #include "nsIDOMNode.h" @@ -238,18 +237,10 @@ NS_ScriptErrorReporter(JSContext *cx, } if (NS_SUCCEEDED(rv)) { - nsIScriptGlobalObjectOwner *owner = - globalObject->GetGlobalObjectOwner(); - if (owner) { - owner->ReportScriptError(errorObject); - } else { - // We lack an owner to report this error to, so let's just - // report it to the console service so as to not lose it. - nsCOMPtr consoleService = - do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - consoleService->LogMessage(errorObject); - } + nsCOMPtr consoleService = + do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv)) { + consoleService->LogMessage(errorObject); } } } diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp index 0387232518b..7cff0b23f56 100644 --- a/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -167,13 +167,12 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel) } // So far so good: get the script context from its owner. - nsCOMPtr global; - rv = globalOwner->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject(); - NS_ASSERTION(NS_SUCCEEDED(rv) && global, + NS_ASSERTION(global, "Unable to get an nsIScriptGlobalObject from the " "ScriptGlobalObjectOwner!"); - if (NS_FAILED(rv) || !global) { + if (!global) { return NS_ERROR_FAILURE; } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 401d55fa2ab..0267a39805d 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -57,7 +57,6 @@ #include "nsICSSStyleSheet.h" #include "nsIFrame.h" -#include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 5709d379fbd..76dba175305 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -117,8 +117,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsISupportsUtils.h" #include "nsIFrame.h" #include "nsIScriptContext.h" -#include "nsIScriptGlobalObjectOwner.h" -#include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" #include "nsISelectionListener.h" diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 49be29aa12b..7ad79afe51f 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1075,8 +1075,7 @@ nsWebShellWindow::ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindowIn nsCOMPtr globalObjectOwner(do_QueryInterface(aShell)); NS_ENSURE_TRUE(globalObjectOwner, NS_ERROR_FAILURE); - nsCOMPtr globalObject; - globalObjectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = globalObjectOwner->GetScriptGlobalObject(); NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE); nsCOMPtr newDOMWindow(do_QueryInterface(globalObject)); diff --git a/xpinstall/src/nsInstallTrigger.cpp b/xpinstall/src/nsInstallTrigger.cpp index 9d9cc8ae251..5215ae93b6a 100644 --- a/xpinstall/src/nsInstallTrigger.cpp +++ b/xpinstall/src/nsInstallTrigger.cpp @@ -196,12 +196,12 @@ nsInstallTrigger::HandleContent(const char * aContentType, // Get the global object of the target window for StartSoftwareUpdate - nsCOMPtr globalObject; + nsIScriptGlobalObject* globalObject = nsnull; nsCOMPtr globalObjectOwner = do_QueryInterface(aWindowContext); if ( globalObjectOwner ) { - globalObjectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); + globalObject = globalObjectOwner->GetScriptGlobalObject(); } if ( !globalObject ) return NS_ERROR_INVALID_ARG;