From eeddf02bde91df3360a94f58beaeb0d8fb1505d8 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 22 Oct 2003 06:09:48 +0000 Subject: [PATCH] deCOMtaminate nsIDocument by changing methods to use return value instead of out-params, eliminating unused nsresult return values, moving some members to nsIDocument and inlining the getters/setters. Bug 222134, r=bzbarsky, sr=jst. git-svn-id: svn://10.0.0.236/trunk@148257 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/base/nsAccessibilityService.cpp | 3 +- mozilla/accessible/src/base/nsAccessible.cpp | 4 +- .../src/base/nsAccessibleTreeWalker.cpp | 2 +- .../accessible/src/base/nsCaretAccessible.cpp | 2 +- .../accessible/src/base/nsDocAccessible.cpp | 46 +- .../src/base/nsOuterDocAccessible.cpp | 3 +- .../accessible/src/base/nsRootAccessible.cpp | 3 +- mozilla/chrome/src/nsChromeRegistry.cpp | 15 +- mozilla/content/base/public/nsIDocument.h | 255 ++++---- .../base/src/nsContentAreaDragDrop.cpp | 5 +- mozilla/content/base/src/nsContentList.cpp | 3 +- mozilla/content/base/src/nsContentSink.cpp | 49 +- mozilla/content/base/src/nsContentUtils.cpp | 22 +- mozilla/content/base/src/nsCopySupport.cpp | 8 +- mozilla/content/base/src/nsDocument.cpp | 553 ++++-------------- mozilla/content/base/src/nsDocument.h | 231 +++----- .../content/base/src/nsDocumentFragment.cpp | 4 +- mozilla/content/base/src/nsDocumentViewer.cpp | 56 +- mozilla/content/base/src/nsFrameLoader.cpp | 15 +- .../content/base/src/nsGenericDOMDataNode.cpp | 22 +- mozilla/content/base/src/nsGenericElement.cpp | 32 +- .../base/src/nsHTMLContentSerializer.cpp | 19 +- .../base/src/nsImageLoadingContent.cpp | 23 +- .../content/base/src/nsNodeInfoManager.cpp | 18 +- mozilla/content/base/src/nsPrintEngine.cpp | 36 +- mozilla/content/base/src/nsRange.cpp | 5 +- mozilla/content/base/src/nsScriptLoader.cpp | 33 +- mozilla/content/base/src/nsSelection.cpp | 2 +- mozilla/content/base/src/nsStyleSet.cpp | 6 +- .../content/base/src/nsSyncLoadService.cpp | 4 +- .../events/src/nsEventListenerManager.cpp | 18 +- .../events/src/nsEventStateManager.cpp | 134 ++--- .../html/content/src/nsAttributeContent.cpp | 5 +- .../html/content/src/nsFormSubmission.cpp | 5 +- .../html/content/src/nsGenericHTMLElement.cpp | 60 +- .../html/content/src/nsHTMLAnchorElement.cpp | 7 +- .../html/content/src/nsHTMLBodyElement.cpp | 3 +- .../html/content/src/nsHTMLButtonElement.cpp | 4 +- .../html/content/src/nsHTMLFormElement.cpp | 7 +- .../html/content/src/nsHTMLFrameElement.cpp | 9 +- .../html/content/src/nsHTMLImageElement.cpp | 3 +- .../html/content/src/nsHTMLInputElement.cpp | 18 +- .../html/content/src/nsHTMLObjectElement.cpp | 3 +- .../html/content/src/nsHTMLOptionElement.cpp | 3 +- .../html/content/src/nsHTMLScriptElement.cpp | 5 +- .../html/content/src/nsHTMLSelectElement.cpp | 5 +- .../content/src/nsHTMLSharedObjectElement.cpp | 3 +- .../content/src/nsHTMLTextAreaElement.cpp | 5 +- .../html/content/src/nsHTMLUnknownElement.cpp | 4 +- .../html/document/src/nsHTMLContentSink.cpp | 49 +- .../html/document/src/nsHTMLDocument.cpp | 136 ++--- .../html/document/src/nsHTMLDocument.h | 58 +- .../src/nsHTMLFragmentContentSink.cpp | 2 +- .../html/document/src/nsImageDocument.cpp | 15 +- .../html/document/src/nsPluginDocument.cpp | 7 +- .../content/html/style/src/nsCSSLoader.cpp | 29 +- .../html/style/src/nsCSSStyleSheet.cpp | 52 +- mozilla/content/xbl/src/nsBindingManager.cpp | 22 +- mozilla/content/xbl/src/nsXBLBinding.cpp | 9 +- mozilla/content/xbl/src/nsXBLContentSink.cpp | 7 +- mozilla/content/xbl/src/nsXBLDocumentInfo.cpp | 16 +- mozilla/content/xbl/src/nsXBLProtoImpl.cpp | 3 +- .../content/xbl/src/nsXBLPrototypeBinding.cpp | 5 +- .../content/xbl/src/nsXBLPrototypeHandler.cpp | 6 +- .../content/xbl/src/nsXBLResourceLoader.cpp | 3 +- mozilla/content/xbl/src/nsXBLService.cpp | 53 +- .../xml/content/src/nsXMLStylesheetPI.cpp | 9 +- .../xml/document/src/nsXMLContentSink.cpp | 36 +- .../xml/document/src/nsXMLDocument.cpp | 51 +- .../content/xml/document/src/nsXMLDocument.h | 12 +- .../xml/document/src/nsXMLPrettyPrinter.cpp | 12 +- .../content/xul/content/src/nsXULElement.cpp | 60 +- .../xul/content/src/nsXULPopupListener.cpp | 3 +- .../document/public/nsIXULPrototypeDocument.h | 2 +- .../document/src/nsXULCommandDispatcher.cpp | 4 +- .../xul/document/src/nsXULContentSink.cpp | 5 +- .../xul/document/src/nsXULDocument.cpp | 89 ++- .../content/xul/document/src/nsXULDocument.h | 38 +- .../xul/document/src/nsXULPrototypeCache.cpp | 9 +- .../document/src/nsXULPrototypeDocument.cpp | 37 +- .../xul/templates/src/nsXULContentBuilder.cpp | 6 +- .../xul/templates/src/nsXULContentUtils.cpp | 13 +- .../templates/src/nsXULTemplateBuilder.cpp | 17 +- .../xul/templates/src/nsXULTreeBuilder.cpp | 9 +- mozilla/docshell/base/nsDocShell.cpp | 48 +- mozilla/docshell/base/nsWebShell.cpp | 3 +- mozilla/dom/src/base/nsDOMClassInfo.cpp | 8 +- mozilla/dom/src/base/nsFocusController.cpp | 11 +- mozilla/dom/src/base/nsGlobalWindow.cpp | 55 +- mozilla/dom/src/base/nsLocation.cpp | 9 +- .../src/nsComposerDocumentCommands.cpp | 4 +- .../editor/composer/src/nsEditingSession.cpp | 3 +- mozilla/editor/libeditor/base/nsEditor.cpp | 15 +- .../editor/libeditor/base/nsEditorUtils.cpp | 5 +- .../editor/libeditor/html/nsHTMLEditor.cpp | 19 +- .../libeditor/html/nsHTMLObjectResizer.cpp | 12 +- .../browser/activex/src/common/Makefile.in | 1 + .../activex/src/plugin/LegacyPlugin.cpp | 3 +- .../activex/src/plugin/XPCDocument.cpp | 6 +- .../browser/webBrowser/nsContextMenuInfo.cpp | 3 +- .../components/commandhandler/src/Makefile.in | 1 + .../components/find/src/nsWebBrowserFind.cpp | 7 +- .../src/nsWebBrowserPersist.cpp | 15 +- .../windowwatcher/src/nsWindowWatcher.cpp | 14 +- mozilla/extensions/cookie/nsImgManager.cpp | 5 +- .../inspector/base/src/inCSSValueSearch.cpp | 7 +- .../inspector/base/src/inDOMUtils.cpp | 3 +- .../inspector/base/src/inLayoutUtils.cpp | 10 +- .../transformiix/source/base/txURIUtils.cpp | 14 +- .../source/xml/parser/txXMLParser.cpp | 6 +- .../transformiix/source/xpath/Makefile.in | 1 + .../xslt/txMozillaStylesheetCompiler.cpp | 3 +- .../source/xslt/txMozillaTextOutput.cpp | 18 +- .../source/xslt/txMozillaXMLOutput.cpp | 14 +- .../typeaheadfind/src/nsTypeAheadFind.cpp | 21 +- .../extensions/wallet/src/nsWalletService.cpp | 3 +- mozilla/extensions/wallet/src/wallet.cpp | 9 +- .../soap/src/nsHTTPSOAPTransport.cpp | 4 +- .../xmlextras/base/src/nsDOMParser.cpp | 2 +- .../xmlextras/base/src/nsDOMSerializer.cpp | 7 +- .../xmlextras/base/src/nsXMLHttpRequest.cpp | 8 +- .../xmlextras/tests/TestXMLExtras.cpp | 4 +- mozilla/gfx/src/gtk/Makefile.in | 1 + mozilla/intl/build/Makefile.in | 1 + mozilla/intl/chardet/src/Makefile.in | 1 + mozilla/layout/base/nsCSSFrameConstructor.cpp | 69 +-- mozilla/layout/base/nsCSSRendering.cpp | 3 +- mozilla/layout/base/nsChildIterator.cpp | 3 +- mozilla/layout/base/nsDocumentViewer.cpp | 56 +- mozilla/layout/base/nsFrameManager.cpp | 6 +- mozilla/layout/base/nsImageLoader.cpp | 10 +- mozilla/layout/base/nsPresContext.cpp | 22 +- mozilla/layout/base/nsPresShell.cpp | 84 +-- mozilla/layout/base/src/nsCopySupport.cpp | 8 +- mozilla/layout/base/src/nsImageLoader.cpp | 10 +- mozilla/layout/base/src/nsPresContext.cpp | 22 +- mozilla/layout/build/nsContentDLF.cpp | 13 +- .../layout/forms/nsComboboxControlFrame.cpp | 5 +- mozilla/layout/forms/nsFileControlFrame.cpp | 13 +- mozilla/layout/forms/nsIsIndexFrame.cpp | 25 +- mozilla/layout/forms/nsTextControlFrame.cpp | 13 +- mozilla/layout/generic/nsBulletFrame.cpp | 10 +- mozilla/layout/generic/nsContainerFrame.cpp | 8 +- mozilla/layout/generic/nsGfxScrollFrame.cpp | 4 +- mozilla/layout/generic/nsImageFrame.cpp | 28 +- mozilla/layout/generic/nsImageMap.cpp | 3 +- mozilla/layout/generic/nsObjectFrame.cpp | 27 +- mozilla/layout/generic/nsSelection.cpp | 2 +- mozilla/layout/generic/nsTextFrame.cpp | 40 +- .../layout/html/base/src/nsBulletFrame.cpp | 10 +- .../layout/html/base/src/nsContainerFrame.cpp | 8 +- .../layout/html/base/src/nsFrameManager.cpp | 6 +- .../layout/html/base/src/nsGfxScrollFrame.cpp | 4 +- mozilla/layout/html/base/src/nsImageFrame.cpp | 28 +- mozilla/layout/html/base/src/nsImageMap.cpp | 3 +- .../layout/html/base/src/nsObjectFrame.cpp | 27 +- mozilla/layout/html/base/src/nsPresShell.cpp | 84 +-- mozilla/layout/html/base/src/nsTextFrame.cpp | 40 +- .../html/forms/src/nsComboboxControlFrame.cpp | 5 +- .../html/forms/src/nsFileControlFrame.cpp | 13 +- .../layout/html/forms/src/nsIsIndexFrame.cpp | 25 +- .../html/forms/src/nsTextControlFrame.cpp | 13 +- .../html/style/src/nsCSSFrameConstructor.cpp | 69 +-- .../layout/html/style/src/nsCSSRendering.cpp | 3 +- .../layout/html/style/src/nsChildIterator.cpp | 3 +- mozilla/layout/printing/nsPrintEngine.cpp | 36 +- mozilla/layout/style/nsCSSLoader.cpp | 29 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 52 +- mozilla/layout/style/nsStyleSet.cpp | 6 +- mozilla/layout/xul/base/src/nsBoxFrame.cpp | 3 +- mozilla/layout/xul/base/src/nsBoxObject.cpp | 12 +- .../xul/base/src/nsDocElementBoxFrame.cpp | 3 +- .../layout/xul/base/src/nsImageBoxFrame.cpp | 6 +- .../layout/xul/base/src/nsListBoxObject.cpp | 5 +- .../layout/xul/base/src/nsMenuBarFrame.cpp | 3 +- .../layout/xul/base/src/nsMenuPopupFrame.cpp | 4 +- .../layout/xul/base/src/nsResizerFrame.cpp | 3 +- .../layout/xul/base/src/nsTitleBarFrame.cpp | 4 +- .../xul/base/src/nsXULTooltipListener.cpp | 5 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 10 +- mozilla/mailnews/compose/src/nsMsgSend.cpp | 3 +- .../modules/plugin/base/src/ns4xPlugin.cpp | 4 +- .../plugin/base/src/nsPluginHostImpl.cpp | 52 +- .../plugin/base/src/nsPluginInstancePeer.cpp | 6 +- mozilla/rdf/chrome/src/nsChromeRegistry.cpp | 15 +- .../boot/src/nsSecureBrowserUIImpl.cpp | 9 +- .../passwordmgr/base/nsPasswordManager.cpp | 20 +- .../satchel/src/nsFormFillController.cpp | 16 +- .../webshell/tests/viewer/nsBrowserWindow.cpp | 4 +- mozilla/webshell/tests/viewer/nsViewerApp.cpp | 4 +- .../webshell/tests/viewer/nsWebCrawler.cpp | 7 +- .../webshell/tests/viewer/nsXPBaseWindow.cpp | 2 +- .../xpfe/appshell/src/nsWebShellWindow.cpp | 3 +- 193 files changed, 1493 insertions(+), 2706 deletions(-) diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 29f4385d1a3..5e12e8b93a6 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -298,8 +298,7 @@ nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell, nsCOMPtr rootNode(do_QueryInterface(aDocument)); NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE); - nsCOMPtr parentDoc; - aDocument->GetParentDocument(getter_AddRefs(parentDoc)); + nsIDocument *parentDoc = aDocument->GetParentDocument(); nsIPresShell *presShell = aShell; if (!presShell) { diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index c6ae3ca677c..cecf3b4d8b5 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -508,9 +508,7 @@ nsresult nsAccessible::GetFocusedNode(nsIDOMNode *aCurrentNode, nsIDOMNode **aFo if (!document) document = do_QueryInterface(aCurrentNode); if (document) { - nsCOMPtr ourGlobal; - document->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow(do_QueryInterface(ourGlobal)); + nsCOMPtr ourWindow(do_QueryInterface(document->GetScriptGlobalObject())); if (ourWindow) ourWindow->GetRootFocusController(getter_AddRefs(focusController)); } diff --git a/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp b/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp index 99d9f0c35a7..9f50d4105e7 100755 --- a/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp +++ b/mozilla/accessible/src/base/nsAccessibleTreeWalker.cpp @@ -58,7 +58,7 @@ nsAccessibleTreeWalker::nsAccessibleTreeWalker(nsIWeakReference* aPresShell, nsI if (presShell) { nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); - doc->GetBindingManager(getter_AddRefs(mBindingManager)); + mBindingManager = doc->GetBindingManager(); } } MOZ_COUNT_CTOR(nsAccessibleTreeWalker); diff --git a/mozilla/accessible/src/base/nsCaretAccessible.cpp b/mozilla/accessible/src/base/nsCaretAccessible.cpp index 816c809ff26..c575733e63e 100644 --- a/mozilla/accessible/src/base/nsCaretAccessible.cpp +++ b/mozilla/accessible/src/base/nsCaretAccessible.cpp @@ -101,7 +101,7 @@ NS_IMETHODIMP nsCaretAccessible::AttachNewSelectionListener(nsIDOMNode *aCurrent doc = do_QueryInterface(aCurrentNode); nsCOMPtr content(do_QueryInterface(aCurrentNode)); if (!content) - doc->GetRootContent(getter_AddRefs(content)); // If node is not content, use root content + content = doc->GetRootContent(); // If node is not content, use root content nsIFrame *frame = nsnull; presShell->GetPrimaryFrameFor(content, &frame); diff --git a/mozilla/accessible/src/base/nsDocAccessible.cpp b/mozilla/accessible/src/base/nsDocAccessible.cpp index 330b383eed3..fe58bdf0566 100644 --- a/mozilla/accessible/src/base/nsDocAccessible.cpp +++ b/mozilla/accessible/src/base/nsDocAccessible.cpp @@ -174,8 +174,7 @@ NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL) if (!mDocument) { return NS_ERROR_FAILURE; // Document has been shut down } - nsCOMPtr container; - mDocument->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mDocument->GetContainer(); nsCOMPtr webNav(do_GetInterface(container)); nsCAutoString theURL; if (webNav) { @@ -192,7 +191,12 @@ NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL) NS_IMETHODIMP nsDocAccessible::GetTitle(nsAString& aTitle) { - return mDocument? mDocument->GetDocumentTitle(aTitle): NS_ERROR_FAILURE; + if (mDocument) { + aTitle = mDocument->GetDocumentTitle(); + return NS_OK; + } + + return NS_ERROR_FAILURE; } NS_IMETHODIMP nsDocAccessible::GetMimeType(nsAString& aMimeType) @@ -253,9 +257,7 @@ NS_IMETHODIMP nsDocAccessible::GetWindow(nsIDOMWindow **aDOMWin) if (!mDocument) { return NS_ERROR_FAILURE; // Accessible is Shutdown() } - nsCOMPtr ourGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr domWindow(do_QueryInterface(ourGlobal)); + nsCOMPtr domWindow(do_QueryInterface(mDocument->GetScriptGlobalObject())); if (!domWindow) return NS_ERROR_FAILURE; // No DOM Window @@ -283,14 +285,11 @@ void nsDocAccessible::CheckForEditor() if (!mDocument) { return; // No document -- we've been shut down } - nsCOMPtr ourGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr domWindow(do_QueryInterface(ourGlobal)); + nsCOMPtr domWindow(do_QueryInterface(mDocument->GetScriptGlobalObject())); if (!domWindow) return; // No DOM Window - nsCOMPtr container; - mDocument->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mDocument->GetContainer(); nsCOMPtr editingSession(do_GetInterface(container)); if (!editingSession) return; // No editing session interface @@ -327,12 +326,9 @@ NS_IMETHODIMP nsDocAccessible::Init() { // Hook up our new accessible with our parent if (!mParent) { - nsCOMPtr parentDoc; - mDocument->GetParentDocument(getter_AddRefs(parentDoc)); + nsIDocument *parentDoc = mDocument->GetParentDocument(); if (parentDoc) { - nsCOMPtr ownerContent; - parentDoc->FindContentForSubDocument(mDocument, - getter_AddRefs(ownerContent)); + nsIContent *ownerContent = parentDoc->FindContentForSubDocument(mDocument); nsCOMPtr ownerNode(do_QueryInterface(ownerContent)); if (ownerNode) { nsCOMPtr accService = @@ -415,8 +411,8 @@ void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame) { *aRelativeFrame = GetFrame(); - nsCOMPtr document(mDocument); - nsCOMPtr parentDoc; + nsIDocument *document = mDocument; + nsIDocument *parentDoc = nsnull; while (document) { nsIPresShell *presShell = document->GetShellAt(0); @@ -452,8 +448,7 @@ void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame) aBounds = viewBounds; } - document->GetParentDocument(getter_AddRefs(parentDoc)); - document = parentDoc; + document = parentDoc = document->GetParentDocument(); } } @@ -471,9 +466,7 @@ nsresult nsDocAccessible::AddEventListeners() nsCOMPtr presShell(GetPresShell()); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsCOMPtr container; - mDocument->GetContainer(getter_AddRefs(container)); - + nsCOMPtr container = mDocument->GetContainer(); nsCOMPtr docShellTreeItem(do_QueryInterface(container)); NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE); @@ -491,7 +484,7 @@ nsresult nsDocAccessible::AddEventListeners() if (!mEditor) { // We're not an editor yet, but we might become one - nsCOMPtr commandManager = do_GetInterface(container); + nsCOMPtr commandManager = do_GetInterface(docShellTreeItem); if (commandManager) { commandManager->AddCommandObserver(this, "obs_documentCreated"); } @@ -595,15 +588,14 @@ nsresult nsDocAccessible::RemoveEventListeners() mDocLoadTimer = nsnull; } - nsCOMPtr container; - mDocument->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mDocument->GetContainer(); nsCOMPtr docShellTreeItem(do_QueryInterface(container)); NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE); PRInt32 itemType; docShellTreeItem->GetItemType(&itemType); if (itemType == nsIDocShellTreeItem::typeContent) { - nsCOMPtr commandManager = do_GetInterface(container); + nsCOMPtr commandManager = do_GetInterface(docShellTreeItem); if (commandManager) { commandManager->RemoveCommandObserver(this, "obs_documentCreated"); } diff --git a/mozilla/accessible/src/base/nsOuterDocAccessible.cpp b/mozilla/accessible/src/base/nsOuterDocAccessible.cpp index 66642c1cfb0..283a4563206 100644 --- a/mozilla/accessible/src/base/nsOuterDocAccessible.cpp +++ b/mozilla/accessible/src/base/nsOuterDocAccessible.cpp @@ -109,8 +109,7 @@ NS_IMETHODIMP nsOuterDocAccessible::Init() nsCOMPtr outerDoc = content->GetDocument(); NS_ENSURE_TRUE(outerDoc, NS_ERROR_FAILURE); - nsCOMPtr innerDoc; - outerDoc->GetSubDocumentFor(content, getter_AddRefs(innerDoc)); + nsIDocument *innerDoc = outerDoc->GetSubDocumentFor(content); nsCOMPtr innerNode(do_QueryInterface(innerDoc)); NS_ENSURE_TRUE(innerNode, NS_ERROR_FAILURE); diff --git a/mozilla/accessible/src/base/nsRootAccessible.cpp b/mozilla/accessible/src/base/nsRootAccessible.cpp index 02649324564..eb01332e806 100644 --- a/mozilla/accessible/src/base/nsRootAccessible.cpp +++ b/mozilla/accessible/src/base/nsRootAccessible.cpp @@ -125,8 +125,7 @@ NS_IMETHODIMP nsRootAccessible::GetRole(PRUint32 *aRole) *aRole = ROLE_PANE; // If it's a , use ROLE_DIALOG instead - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { nsCOMPtr rootElement(do_QueryInterface(rootContent)); if (rootElement) { diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 48f34fdd5d8..f3cb2add435 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -1431,9 +1431,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) return; // Annihilate all XBL bindings. - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->FlushSkinBindings(); + document->GetBindingManager()->FlushSkinBindings(); } NS_IMETHODIMP nsChromeRegistry::RefreshSkins() @@ -1587,15 +1585,13 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) nsCOMArray oldSheets; nsCOMArray newSheets; - PRInt32 count = 0; - document->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = document->GetNumberOfStyleSheets(PR_FALSE); // Iterate over the style sheets. PRInt32 i; for (i = 0; i < count; i++) { // Get the style sheet - nsCOMPtr styleSheet; - document->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(styleSheet)); + nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i, PR_FALSE); if (!oldSheets.AppendObject(styleSheet)) { return NS_ERROR_OUT_OF_MEMORY; @@ -3110,10 +3106,9 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes while (token) { nsCOMPtr content(do_QueryInterface(elt)); nsCOMPtr doc = content->GetDocument(); - nsCOMPtr docURL; - doc->GetDocumentURL(getter_AddRefs(docURL)); nsCOMPtr url; - rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), nsnull, docURL); + rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), + nsnull, doc->GetDocumentURL()); nsCOMPtr sheet; // The CSSLoader handles all the prototype cache stuff for diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index b098d57ac48..21aafcfa910 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -45,6 +45,14 @@ #include "nsCOMArray.h" #include "nsIDocumentObserver.h" #include "nsCOMPtr.h" +#include "nsIURI.h" +#include "nsIBindingManager.h" +#include "nsINodeInfo.h" +#include "nsWeakPtr.h" +#include "nsIWeakReferenceUtils.h" +#include "nsILoadGroup.h" +#include "nsReadableUtils.h" +#include "nsCRT.h" class nsIAtom; class nsIContent; @@ -56,8 +64,6 @@ class nsIStreamObserver; class nsIStyleSet; class nsIStyleSheet; class nsIStyleRule; -class nsIURI; -class nsILoadGroup; class nsIViewManager; class nsIScriptGlobalObject; class nsIDOMEvent; @@ -70,10 +76,8 @@ class nsIWordBreaker; class nsISelection; class nsIChannel; class nsIPrincipal; -class nsINodeInfoManager; class nsIDOMDocument; class nsIDOMDocumentType; -class nsIBindingManager; class nsIObserver; class nsISupportsArray; class nsIScriptLoader; @@ -102,6 +106,13 @@ class nsIScriptEventManager; class nsIDocument : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID) + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + + nsIDocument() + : mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")), + mNextContentID(NS_CONTENT_ID_COUNTER_BASE) { } + + virtual ~nsIDocument() { } NS_IMETHOD StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, @@ -116,18 +127,18 @@ public: /** * Return the title of the document. May return null. */ - NS_IMETHOD GetDocumentTitle(nsAString& aTitle) const = 0; + const nsAString& GetDocumentTitle() const { return mDocumentTitle; } /** * Return the URL for the document. May return null. */ - NS_IMETHOD GetDocumentURL(nsIURI** aURL) const = 0; - NS_IMETHOD SetDocumentURL(nsIURI* aURL) = 0; + nsIURI* GetDocumentURL() const { return mDocumentURL; } + void SetDocumentURL(nsIURI* aURL) { mDocumentURL = aURL; } /** * Return the principal responsible for this document. */ - NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal) = 0; + virtual nsIPrincipal* GetPrincipal() = 0; /** * Set the principal responsible for this document. @@ -137,32 +148,38 @@ public: /** * Return the LoadGroup for the document. May return null. */ - NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0; + already_AddRefed GetDocumentLoadGroup() const { + nsILoadGroup *group = nsnull; + if (mDocumentLoadGroup) + CallQueryReferent(mDocumentLoadGroup.get(), &group); + return group; + } /** * Return the base URL for relative URLs in the document (the document url * unless it's overridden by SetBaseURL, HTML tags, etc.). The * returned URL could be null if there is no document URL. */ - NS_IMETHOD GetBaseURL(nsIURI** aURL) const = 0; + nsIURI* GetBaseURL() const { return mDocumentBaseURL ? mDocumentBaseURL : mDocumentURL; } NS_IMETHOD SetBaseURL(nsIURI* aURL) = 0; /** * Get/Set the base target of a link in a document. */ - NS_IMETHOD GetBaseTarget(nsAString &aBaseTarget)=0; - NS_IMETHOD SetBaseTarget(const nsAString &aBaseTarget)=0; + virtual void GetBaseTarget(nsAString &aBaseTarget) const = 0; + virtual void SetBaseTarget(const nsAString &aBaseTarget) = 0; /** * Return a standard name for the document's character set. This * will trigger a startDocumentLoad if necessary to answer the * question. */ - NS_IMETHOD GetDocumentCharacterSet(nsACString& oCharSetID) = 0; - NS_IMETHOD SetDocumentCharacterSet(const nsACString& aCharSetID) = 0; + const nsACString& GetDocumentCharacterSet() const { return mCharacterSet; } + virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0; + + PRInt32 GetDocumentCharacterSetSource() const { return mCharacterSetSource; } + void SetDocumentCharacterSetSource(PRInt32 aCharsetSource) { mCharacterSetSource = aCharsetSource; } - NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource) = 0; - NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource) = 0; /** * Add an observer that gets notified whenever the charset changes. */ @@ -175,18 +192,22 @@ public: /** * Get the Content-Type of this document. + * (This will always return NS_OK, but has this signature to be compatible + * with nsIDOMNSDocument::GetContentType()) */ NS_IMETHOD GetContentType(nsAString& aContentType) = 0; /** * Set the Content-Type of this document. */ - NS_IMETHOD SetContentType(const nsAString& aContentType) = 0; + virtual void SetContentType(const nsAString& aContentType) = 0; /** * Return the language of this document. */ - NS_IMETHOD GetContentLanguage(nsAString& aContentLanguage) const = 0; + void GetContentLanguage(nsAString& aContentLanguage) const { + CopyASCIItoUCS2(mContentLanguage, aContentLanguage); + } // The state BidiEnabled should persist across multiple views // (screen, print) of the same document. @@ -195,7 +216,7 @@ public: * Check if the document contains bidi data. * If so, we have to apply the Unicode Bidi Algorithm. */ - NS_IMETHOD GetBidiEnabled(PRBool* aBidiEnabled) const = 0; + PRBool GetBidiEnabled() const { return mBidiEnabled; } /** * Indicate the document contains bidi data. @@ -203,27 +224,27 @@ public: * it affects a frame model irreversibly, and plays even though * the document no longer contains bidi data. */ - NS_IMETHOD SetBidiEnabled(PRBool aBidiEnabled) = 0; + void SetBidiEnabled(PRBool aBidiEnabled) { mBidiEnabled = aBidiEnabled; } /** * Return the Line Breaker for the document */ - NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) = 0; - NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) = 0; - NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) = 0; - NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0; + virtual nsILineBreaker* GetLineBreaker() = 0; + virtual void SetLineBreaker(nsILineBreaker* aLineBreaker) = 0; + virtual nsIWordBreaker* GetWordBreaker() = 0; + virtual void SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0; /** * Access HTTP header data (this may also get set from other * sources, like HTML META tags). */ - NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0; - NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0; + virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0; + virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0; /** - * Create a new presentation shell that will use aContext for it's - * presentation context (presentation context's must not be - * shared among multiple presentation shell's). + * Create a new presentation shell that will use aContext for its + * presentation context (presentation contexts must not be + * shared among multiple presentation shells). */ NS_IMETHOD CreateShell(nsIPresContext* aContext, nsIViewManager* aViewManager, @@ -238,12 +259,12 @@ public: * unless this document is within a compound document and has a * parent. Note that this parent chain may cross chrome boundaries. */ - NS_IMETHOD GetParentDocument(nsIDocument** aParent) = 0; + nsIDocument* GetParentDocument() const { return mParentDocument; } /** * Set the parent document of this document. */ - NS_IMETHOD SetParentDocument(nsIDocument* aParent) = 0; + void SetParentDocument(nsIDocument* aParent) { mParentDocument = aParent; } /** * Set the sub document for aContent to aSubDoc. @@ -253,20 +274,18 @@ public: /** * Get the sub document for aContent */ - NS_IMETHOD GetSubDocumentFor(nsIContent *aContent, - nsIDocument** aSubDoc) = 0; + virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const = 0; /** * Find the content node for which aDocument is a sub document. */ - NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument, - nsIContent **aContent) = 0; + virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const = 0; /** * Return the root content object for this document. */ - NS_IMETHOD GetRootContent(nsIContent** aRoot) = 0; - NS_IMETHOD SetRootContent(nsIContent* aRoot) = 0; + nsIContent* GetRootContent() const { return mRootContent; } + virtual void SetRootContent(nsIContent* aRoot) = 0; /** * Get the direct children of the document - content in @@ -291,8 +310,7 @@ public: * @return the number of stylesheets * @throws no exceptions */ - NS_IMETHOD GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets, - PRInt32* aCount) = 0; + virtual PRInt32 GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets) const = 0; /** * Get a particular stylesheet @@ -302,8 +320,8 @@ public: * @return the stylesheet at aIndex. Null if aIndex is out of range. * @throws no exceptions */ - NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets, - nsIStyleSheet** aSheet) = 0; + virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex, + PRBool aIncludeSpecialSheets) const = 0; /** * Insert a sheet at a particular spot in the stylesheet list (zero-based) @@ -321,7 +339,7 @@ public: * @param aSheet the sheet to get the index of * @return aIndex the index of the sheet in the full list */ - NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex) = 0; + virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const = 0; /** * Replace the stylesheets in aOldSheets with the stylesheets in @@ -331,8 +349,8 @@ public: * may be null; if so the corresponding sheets in the first list * will simply be removed. */ - NS_IMETHOD UpdateStyleSheets(nsCOMArray& aOldSheets, - nsCOMArray& aNewSheets) = 0; + virtual void UpdateStyleSheets(nsCOMArray& aOldSheets, + nsCOMArray& aNewSheets) = 0; /** * Add a stylesheet to the document @@ -356,13 +374,13 @@ public: * This is the context within which all scripts (during document * creation and during event handling) will run. */ - NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject) = 0; - NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; + virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0; + virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0; /** * Get the script loader for this document */ - NS_IMETHOD GetScriptLoader(nsIScriptLoader** aScriptLoader) = 0; + virtual nsIScriptLoader* GetScriptLoader() = 0; //---------------------------------------------------------------------- @@ -385,46 +403,46 @@ public: // BeginUpdate must be called before any batch of modifications of the // content model or of style data, EndUpdate must be called afterward. // To make this easy and painless, use the mozAutoDocUpdate helper class. - NS_IMETHOD BeginUpdate(nsUpdateType aUpdateType) = 0; - NS_IMETHOD EndUpdate(nsUpdateType aUpdateType) = 0; - NS_IMETHOD BeginLoad() = 0; - NS_IMETHOD EndLoad() = 0; - NS_IMETHOD ContentChanged(nsIContent* aContent, - nsISupports* aSubContent) = 0; + virtual void BeginUpdate(nsUpdateType aUpdateType) = 0; + virtual void EndUpdate(nsUpdateType aUpdateType) = 0; + virtual void BeginLoad() = 0; + virtual void EndLoad() = 0; + virtual void ContentChanged(nsIContent* aContent, + nsISupports* aSubContent) = 0; // notify that one or two content nodes changed state // either may be nsnull, but not both - NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, - nsIContent* aContent2, - PRInt32 aStateMask) = 0; - NS_IMETHOD AttributeWillChange(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute) = 0; - NS_IMETHOD AttributeChanged(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType) = 0; - NS_IMETHOD ContentAppended(nsIContent* aContainer, - PRInt32 aNewIndexInContainer) = 0; - NS_IMETHOD ContentInserted(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer) = 0; - NS_IMETHOD ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) = 0; - NS_IMETHOD ContentRemoved(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer) = 0; + virtual void ContentStatesChanged(nsIContent* aContent1, + nsIContent* aContent2, + PRInt32 aStateMask) = 0; + virtual void AttributeWillChange(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute) = 0; + virtual void AttributeChanged(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) = 0; + virtual void ContentAppended(nsIContent* aContainer, + PRInt32 aNewIndexInContainer) = 0; + virtual void ContentInserted(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) = 0; + virtual void ContentReplaced(nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer) = 0; + virtual void ContentRemoved(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) = 0; // Observation hooks for style data to propagate notifications // to document observers - NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet, - nsIStyleRule* aOldStyleRule, - nsIStyleRule* aNewStyleRule) = 0; - NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet, - nsIStyleRule* aStyleRule) = 0; - NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet, + virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet, + nsIStyleRule* aOldStyleRule, + nsIStyleRule* aNewStyleRule) = 0; + virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) = 0; + virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet, + nsIStyleRule* aStyleRule) = 0; NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, @@ -432,47 +450,86 @@ public: PRUint32 aFlags, nsEventStatus* aEventStatus) = 0; - NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE, - PRBool aUpdateViews=PR_FALSE) = 0; + virtual void FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE, + PRBool aUpdateViews=PR_FALSE) = 0; - NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0; + PRInt32 GetAndIncrementContentID() { return mNextContentID++; } - NS_IMETHOD GetBindingManager(nsIBindingManager** aResult) = 0; + nsIBindingManager* GetBindingManager() const { return mBindingManager; } - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) = 0; + nsINodeInfoManager* GetNodeInfoManager() const { return mNodeInfoManager; } - NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0; - NS_IMETHOD ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup) = 0; + virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0; + virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup) = 0; - NS_IMETHOD AddReference(void *aKey, nsISupports *aReference) = 0; - NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference) = 0; + virtual void AddReference(void *aKey, nsISupports *aReference) = 0; + virtual already_AddRefed RemoveReference(void *aKey) = 0; /** * Set the container (docshell) for this document. */ - NS_IMETHOD SetContainer(nsISupports *aContainer) = 0; + void SetContainer(nsISupports *aContainer) { + mDocumentContainer = do_GetWeakReference(aContainer); + } /** * Get the container (docshell) for this document. */ - NS_IMETHOD GetContainer(nsISupports **aContainer) = 0; + already_AddRefed GetContainer() const { + nsISupports* container = nsnull; + if (mDocumentContainer) + CallQueryReferent(mDocumentContainer.get(), &container); + return container; + } - NS_IMETHOD GetScriptEventManager(nsIScriptEventManager **aResult) = 0; + virtual nsIScriptEventManager* GetScriptEventManager() = 0; /** * Set and get XML declaration. Notice that if version is empty, * there can be no XML declaration (it is a required part). */ - NS_IMETHOD SetXMLDeclaration(const nsAString& aVersion, - const nsAString& aEncoding, - const nsAString& Standalone) = 0; - NS_IMETHOD GetXMLDeclaration(nsAString& aVersion, - nsAString& aEncoding, - nsAString& Standalone) = 0; + virtual void SetXMLDeclaration(const nsAString& aVersion, + const nsAString& aEncoding, + const nsAString& Standalone) = 0; + virtual void GetXMLDeclaration(nsAString& aVersion, + nsAString& aEncoding, + nsAString& Standalone) = 0; NS_IMETHOD_(PRBool) IsCaseSensitive() = 0; NS_IMETHOD_(PRBool) IsScriptEnabled() = 0; + +protected: + nsString mDocumentTitle; + nsCOMPtr mDocumentURL; + nsCOMPtr mDocumentBaseURL; + + nsWeakPtr mDocumentLoadGroup; + + nsWeakPtr mDocumentContainer; + + nsCString mCharacterSet; + PRInt32 mCharacterSetSource; + + // This is just a weak pointer; the parent document owns its children. + nsIDocument* mParentDocument; + + // A weak reference to the only child element, or null if no + // such element exists. + nsIContent* mRootContent; + + // A content ID counter used to give a monotonically increasing ID + // to the content objects in the document's content model + PRInt32 mNextContentID; + + nsCOMPtr mBindingManager; + nsCOMPtr mNodeInfoManager; + + // True if BIDI is enabled. + PRBool mBidiEnabled; + + nsXPIDLCString mContentLanguage; + nsCString mContentType; }; diff --git a/mozilla/content/base/src/nsContentAreaDragDrop.cpp b/mozilla/content/base/src/nsContentAreaDragDrop.cpp index 748eb70afb0..36263d3637c 100644 --- a/mozilla/content/base/src/nsContentAreaDragDrop.cpp +++ b/mozilla/content/base/src/nsContentAreaDragDrop.cpp @@ -561,9 +561,8 @@ nsContentAreaDragDrop::GetHookEnumeratorFromEvent(nsIDOMEvent* inEvent, nsCOMPtr doc = do_QueryInterface(domdoc); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - nsCOMPtr isupp; - doc->GetContainer(getter_AddRefs(isupp)); - nsCOMPtr docShell = do_QueryInterface(isupp); + nsCOMPtr container = doc->GetContainer(); + nsCOMPtr docShell = do_QueryInterface(container); NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE); nsCOMPtr hookList = do_GetInterface(docShell); diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index a03e0f8dc51..9e1bf08af81 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -860,8 +860,7 @@ nsContentList::PopulateSelf(PRUint32 aNeededLength) "Something is awry in PopulateWith!"); } else if (mDocument) { - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); + nsIContent *root = mDocument->GetRootContent(); if (root) { PopulateWith(root, PR_TRUE, elementsToAppend); NS_ASSERTION(elementsToAppend + mElements.Count() == invariant, diff --git a/mozilla/content/base/src/nsContentSink.cpp b/mozilla/content/base/src/nsContentSink.cpp index cb85ca6c43c..5f48bf40e13 100644 --- a/mozilla/content/base/src/nsContentSink.cpp +++ b/mozilla/content/base/src/nsContentSink.cpp @@ -171,10 +171,9 @@ nsContentSink::Init(nsIDocument* aDoc, new nsScriptLoaderObserverProxy(this); NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr loader; - nsresult rv = mDocument->GetScriptLoader(getter_AddRefs(loader)); - NS_ENSURE_SUCCESS(rv, rv); - rv = loader->AddObserver(proxy); + nsIScriptLoader *loader = mDocument->GetScriptLoader(); + NS_ENSURE_TRUE(loader, NS_ERROR_FAILURE); + nsresult rv = loader->AddObserver(proxy); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr htmlContainer(do_QueryInterface(aDoc)); @@ -186,7 +185,8 @@ nsContentSink::Init(nsIDocument* aDoc, // XXX if it isn't we need to set it here... ProcessHTTPHeaders(aChannel); - return aDoc->GetNodeInfoManager(getter_AddRefs(mNodeInfoManager)); + mNodeInfoManager = aDoc->GetNodeInfoManager(); + return mNodeInfoManager ? NS_OK : NS_ERROR_NOT_INITIALIZED; } @@ -349,10 +349,9 @@ nsContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue, // We use the original codebase in case the codebase was changed // by SetDomain - nsCOMPtr docPrincipal; - rv = mDocument->GetPrincipal(getter_AddRefs(docPrincipal)); - if (NS_FAILED(rv) || !docPrincipal) { - return rv; + nsIPrincipal *docPrincipal = mDocument->GetPrincipal(); + if (!docPrincipal) { + return NS_ERROR_FAILURE; } nsCOMPtr systemPrincipal; @@ -369,14 +368,10 @@ nsContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue, rv = docPrincipal->GetURI(getter_AddRefs(codebaseURI)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr globalObj; nsCOMPtr prompt; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); - if (globalObj) { - nsCOMPtr window (do_QueryInterface(globalObj)); - if (window) { - window->GetPrompter(getter_AddRefs(prompt)); - } + nsCOMPtr window (do_QueryInterface(mDocument->GetScriptGlobalObject())); + if (window) { + window->GetPrompter(getter_AddRefs(prompt)); } nsCOMPtr channel; @@ -749,11 +744,10 @@ nsContentSink::PrefetchHref(const nsAString &aHref, PRBool aExplicit) nsCOMPtr prefetchService(do_GetService(NS_PREFETCHSERVICE_CONTRACTID)); if (prefetchService) { // construct URI using document charset - nsCAutoString charset; - mDocument->GetDocumentCharacterSet(charset); + const nsACString &charset = mDocument->GetDocumentCharacterSet(); nsCOMPtr uri; NS_NewURI(getter_AddRefs(uri), aHref, - charset.IsEmpty() ? nsnull : charset.get(), + charset.IsEmpty() ? nsnull : PromiseFlatCString(charset).get(), mDocumentBaseURL); if (uri) { prefetchService->PrefetchURI(uri, mDocumentURL, aExplicit); @@ -764,7 +758,8 @@ nsContentSink::PrefetchHref(const nsAString &aHref, PRBool aExplicit) // Convert the ref from document charset to unicode. static nsresult -CharsetConvRef(const nsCString& aDocCharset, const nsCString& aRefInDocCharset, +CharsetConvRef(const nsACString& aDocCharset, + const nsCString& aRefInDocCharset, nsString& aRefInUnicode) { nsresult rv; @@ -778,7 +773,8 @@ CharsetConvRef(const nsCString& aDocCharset, const nsCString& aRefInDocCharset, } nsCOMPtr decoder; - rv = ccm->GetUnicodeDecoder(aDocCharset.get(), getter_AddRefs(decoder)); + rv = ccm->GetUnicodeDecoder(PromiseFlatCString(aDocCharset).get(), + getter_AddRefs(decoder)); if (NS_FAILED(rv)) { return rv; } @@ -851,15 +847,12 @@ nsContentSink::ScrollToRef(PRBool aReallyScroll) // document's charset. if (NS_FAILED(rv)) { - nsCAutoString docCharset; - rv = mDocument->GetDocumentCharacterSet(docCharset); + const nsACString &docCharset = mDocument->GetDocumentCharacterSet(); - if (NS_SUCCEEDED(rv)) { - rv = CharsetConvRef(docCharset, unescapedRef, ref); + rv = CharsetConvRef(docCharset, unescapedRef, ref); - if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) - rv = shell->GoToAnchor(ref, aReallyScroll); - } + if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) + rv = shell->GoToAnchor(ref, aReallyScroll); } if (NS_SUCCEEDED(rv)) { didScroll = PR_TRUE; diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 81378f43707..0b15d0de282 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -481,7 +481,7 @@ nsContentUtils::GetDocumentAndPrincipal(nsIDOMNode* aNode, } if (!*aPrincipal) { - (*aDocument)->GetPrincipal(aPrincipal); + NS_IF_ADDREF(*aPrincipal = (*aDocument)->GetPrincipal()); } return NS_OK; @@ -585,7 +585,7 @@ nsContentUtils::CheckSameOrigin(nsIDOMNode *aTrustedNode, } if (!trustedPrincipal) { - trustedDoc->GetPrincipal(getter_AddRefs(trustedPrincipal)); + trustedPrincipal = trustedDoc->GetPrincipal(); if (!trustedPrincipal) { // If the trusted node doesn't have a principal we can't check @@ -715,9 +715,7 @@ nsContentUtils::doReparentContentWrapper(nsIContent *aChild, } if (aOldDocument) { - nsCOMPtr old_ref; - - aOldDocument->RemoveReference(aChild, getter_AddRefs(old_ref)); + nsCOMPtr old_ref = aOldDocument->RemoveReference(aChild); if (old_ref) { // Transfer the reference from aOldDocument to aNewDocument @@ -748,8 +746,7 @@ nsresult GetContextFromDocument(nsIDocument *aDocument, JSContext **cx) { *cx = nsnull; - nsCOMPtr sgo; - aDocument->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = aDocument->GetScriptGlobalObject(); if (!sgo) { // No script global, no context. @@ -804,10 +801,7 @@ nsContentUtils::ReparentContentWrapper(nsIContent *aContent, nsCOMPtr new_parent; if (!aNewParent) { - nsCOMPtr root; - old_doc->GetRootContent(getter_AddRefs(root)); - - if (root.get() == aContent) { + if (old_doc->GetRootContent() == aContent) { new_parent = old_doc; } } else { @@ -1532,8 +1526,8 @@ nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult, nsIURI* aBaseURI) { nsCAutoString originCharset; - if (aDocument && NS_FAILED(aDocument->GetDocumentCharacterSet(originCharset))) - originCharset.Truncate(); + if (aDocument) + originCharset = aDocument->GetDocumentCharacterSet(); return NS_NewURI(aResult, NS_ConvertUCS2toUTF8(aSpec), originCharset.get(), aBaseURI, sIOService); @@ -1635,7 +1629,7 @@ nsCxPusher::Push(nsISupports *aCurrentTarget) } if (document) { - document->GetScriptGlobalObject(getter_AddRefs(sgo)); + sgo = document->GetScriptGlobalObject(); } if (!document && !sgo) { diff --git a/mozilla/content/base/src/nsCopySupport.cpp b/mozilla/content/base/src/nsCopySupport.cpp index 2ad96f33181..37d2cf14ac0 100644 --- a/mozilla/content/base/src/nsCopySupport.cpp +++ b/mozilla/content/base/src/nsCopySupport.cpp @@ -289,10 +289,8 @@ nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans, *aDoPutOnClipboard = PR_TRUE; - nsCOMPtr isupp; - nsresult rv = aDoc->GetContainer(getter_AddRefs(isupp)); - nsCOMPtr docShell = do_QueryInterface(isupp); - nsCOMPtr hookObj = do_GetInterface(docShell); + nsCOMPtr container = aDoc->GetContainer(); + nsCOMPtr hookObj = do_GetInterface(container); if (!hookObj) return NS_ERROR_FAILURE; nsCOMPtr enumerator; @@ -303,7 +301,9 @@ nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans, // nsIClipboardDragDropHooks.h nsCOMPtr override; + nsCOMPtr isupp; PRBool hasMoreHooks = PR_FALSE; + nsresult rv = NS_OK; while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks) { diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index b858261c578..21b1dbc9571 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -193,13 +193,12 @@ nsDOMStyleSheetList::GetLength(PRUint32* aLength) // observer notification to figure out if new ones have // been added or removed. if (-1 == mLength) { - mDocument->GetNumberOfStyleSheets(PR_FALSE, &mLength); + mLength = mDocument->GetNumberOfStyleSheets(PR_FALSE); #ifdef DEBUG PRInt32 i; for (i = 0; i < mLength; i++) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i, PR_FALSE); nsCOMPtr domss(do_QueryInterface(sheet)); NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet"); } @@ -219,11 +218,9 @@ nsDOMStyleSheetList::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) { *aReturn = nsnull; if (mDocument) { - PRInt32 count = 0; - mDocument->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); if (aIndex < (PRUint32)count) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(aIndex, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex, PR_FALSE); NS_ASSERTION(sheet, "Must have a sheet"); return CallQueryInterface(sheet, aReturn); } @@ -480,11 +477,9 @@ NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument) // bother initializing members to 0. nsDocument::nsDocument() - : mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")), - mNextContentID(NS_CONTENT_ID_COUNTER_BASE) { - // NOTE! nsDocument::operator new() zeroes out all members, so don't + // NOTE! nsIDocument::operator new() zeroes out all members, so don't // bother initializing members to 0. // Force initialization. @@ -642,7 +637,7 @@ nsDocument::Init() return mNodeInfoManager->Init(this); } -NS_IMETHODIMP +void nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) { nsCOMPtr uri; @@ -658,7 +653,7 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) aChannel->GetURI(getter_AddRefs(uri)); } - nsresult rv = ResetToURI(uri, aLoadGroup); + ResetToURI(uri, aLoadGroup); if (aChannel) { nsCOMPtr owner; @@ -666,11 +661,9 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) mPrincipal = do_QueryInterface(owner); } - - return rv; } -NS_IMETHODIMP +void nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) { mDocumentTitle.Truncate(); @@ -736,16 +729,6 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) mContentLanguage.Truncate(); mXMLDeclarationBits = 0; - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::SetDocumentURL(nsIURI* aURI) -{ - mDocumentURL = aURI; - - return NS_OK; } NS_IMETHODIMP @@ -755,9 +738,8 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, nsIStreamListener **aDocListener, PRBool aReset, nsIContentSink* aSink) { - nsresult rv = NS_OK; if (aReset) { - rv = Reset(aChannel, aLoadGroup); + Reset(aChannel, aLoadGroup); } nsCAutoString contentType; @@ -773,7 +755,7 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, RetrieveRelevantHeaders(aChannel); - return rv; + return NS_OK; } NS_IMETHODIMP @@ -782,23 +764,6 @@ nsDocument::StopDocumentLoad() return NS_OK; } -NS_IMETHODIMP -nsDocument::GetDocumentTitle(nsAString& aTitle) const -{ - aTitle = mDocumentTitle; - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetDocumentURL(nsIURI** aURI) const -{ - *aURI = mDocumentURL; - NS_IF_ADDREF(*aURI); - - return NS_OK; -} - NS_IMETHODIMP nsDocument::GetLastModified(nsAString& aLastModified) { @@ -813,30 +778,33 @@ nsDocument::GetLastModified(nsAString& aLastModified) return NS_OK; } -NS_IMETHODIMP -nsDocument::GetPrincipal(nsIPrincipal **aPrincipal) +nsIPrincipal* +nsDocument::GetPrincipal() { - *aPrincipal = nsnull; - if (!mPrincipal) { nsresult rv; nsCOMPtr securityManager = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) - return rv; + return nsnull; NS_WARN_IF_FALSE(mDocumentURL, "no URL!"); rv = securityManager->GetCodebasePrincipal(mDocumentURL, getter_AddRefs(mPrincipal)); if (NS_FAILED(rv)) { - return rv; + return nsnull; } } - *aPrincipal = mPrincipal; - NS_ADDREF(*aPrincipal); + return mPrincipal; +} - return NS_OK; +// nsIScriptObjectPrincipal version of GetPrincipal() +NS_IMETHODIMP +nsDocument::GetPrincipal(nsIPrincipal **aPrincipal) +{ + NS_IF_ADDREF(*aPrincipal = GetPrincipal()); + return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -855,7 +823,7 @@ nsDocument::GetContentType(nsAString& aContentType) return NS_OK; } -NS_IMETHODIMP +void nsDocument::SetContentType(const nsAString& aContentType) { NS_ASSERTION(mContentType.IsEmpty() || @@ -863,41 +831,6 @@ nsDocument::SetContentType(const nsAString& aContentType) "Do you really want to change the content-type?"); CopyUTF16toUTF8(aContentType, mContentType); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetContentLanguage(nsAString& aContentLanguage) const -{ - CopyASCIItoUCS2(mContentLanguage, aContentLanguage); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetDocumentLoadGroup(nsILoadGroup **aGroup) const -{ - nsCOMPtr group(do_QueryReferent(mDocumentLoadGroup)); - - *aGroup = group; - NS_IF_ADDREF(*aGroup); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetBaseURL(nsIURI** aURL) const -{ - *aURL = mDocumentBaseURL; - - if (!*aURL) { - *aURL = mDocumentURL; - } - - NS_IF_ADDREF(*aURL); - - return NS_OK; } NS_IMETHODIMP @@ -922,29 +855,18 @@ nsDocument::SetBaseURL(nsIURI* aURL) return rv; } -NS_IMETHODIMP -nsDocument::GetBaseTarget(nsAString &aBaseTarget) +void +nsDocument::GetBaseTarget(nsAString &aBaseTarget) const { aBaseTarget.Truncate(); - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::SetBaseTarget(const nsAString &aBaseTarget) { - return NS_OK; } -NS_IMETHODIMP -nsDocument::GetDocumentCharacterSet(nsACString& aCharSetID) -{ - aCharSetID = mCharacterSet; - - return NS_OK; -} - -NS_IMETHODIMP +void nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID) { if (!mCharacterSet.Equals(aCharSetID)) { @@ -960,24 +882,6 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID) NS_ConvertASCIItoUCS2(aCharSetID).get()); } } - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetDocumentCharacterSetSource(PRInt32* aCharsetSource) -{ - *aCharsetSource = mCharacterSetSource; - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::SetDocumentCharacterSetSource(PRInt32 aCharsetSource) -{ - mCharacterSetSource = aCharsetSource; - - return NS_OK; } NS_IMETHODIMP @@ -1000,63 +904,53 @@ nsDocument::RemoveCharSetObserver(nsIObserver* aObserver) return NS_OK; } -NS_IMETHODIMP -nsDocument::GetLineBreaker(nsILineBreaker** aResult) +nsILineBreaker* +nsDocument::GetLineBreaker() { if (!mLineBreaker) { // no line breaker, find a default one nsresult rv; nsCOMPtr lbf = do_GetService(NS_LWBRK_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, nsnull); lbf->GetBreaker(nsString(), getter_AddRefs(mLineBreaker)); - NS_ENSURE_TRUE(mLineBreaker, NS_ERROR_UNEXPECTED); + NS_ENSURE_TRUE(mLineBreaker, nsnull); } - *aResult = mLineBreaker; - NS_ADDREF(*aResult); - - return NS_OK; + return mLineBreaker; } -NS_IMETHODIMP +void nsDocument::SetLineBreaker(nsILineBreaker* aLineBreaker) { mLineBreaker = aLineBreaker; - - return NS_OK; } -NS_IMETHODIMP -nsDocument::GetWordBreaker(nsIWordBreaker** aResult) +nsIWordBreaker* +nsDocument::GetWordBreaker() { if (!mWordBreaker) { // no word breaker, find a default one nsresult rv; nsCOMPtr wbf = do_GetService(NS_LWBRK_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, nsnull); wbf->GetBreaker(nsString(), getter_AddRefs(mWordBreaker)); - NS_ENSURE_TRUE(wbf, NS_ERROR_UNEXPECTED); + NS_ENSURE_TRUE(wbf, nsnull); } - *aResult = mWordBreaker; - NS_ADDREF(*aResult); - - return NS_OK; + return mWordBreaker; } -NS_IMETHODIMP +void nsDocument::SetWordBreaker(nsIWordBreaker* aWordBreaker) { mWordBreaker = aWordBreaker; - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const { aData.Truncate(); @@ -1069,14 +963,15 @@ nsDocument::GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const } data = data->mNext; } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData) { - NS_ENSURE_ARG_POINTER(aHeaderField); + if (!aHeaderField) { + NS_ERROR("null headerField"); + return; + } if (!mHeaderData) { if (!aData.IsEmpty()) { // don't bother storing empty string @@ -1135,8 +1030,6 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData) } } } - - return NS_OK; } NS_IMETHODIMP @@ -1192,25 +1085,6 @@ nsDocument::GetShellAt(PRUint32 aIndex) const return (nsIPresShell*)mPresShells.SafeElementAt(aIndex); } -NS_IMETHODIMP -nsDocument::GetParentDocument(nsIDocument** aParent) -{ - *aParent = mParentDocument; - NS_IF_ADDREF(*aParent); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::SetParentDocument(nsIDocument* aParent) -{ - // Note that we do *not* AddRef our parent because that would create - // a circular reference. - mParentDocument = aParent; - - return NS_OK; -} - PR_STATIC_CALLBACK(void) SubDocClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry) { @@ -1305,11 +1179,9 @@ nsDocument::SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc) return NS_OK; } -NS_IMETHODIMP -nsDocument::GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc) +nsIDocument* +nsDocument::GetSubDocumentFor(nsIContent *aContent) const { - *aSubDoc = nsnull; - if (mSubDocuments) { SubDocMapEntry *entry = NS_STATIC_CAST(SubDocMapEntry*, @@ -1317,12 +1189,11 @@ nsDocument::GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc) PL_DHASH_LOOKUP)); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { - *aSubDoc = entry->mSubDocument; - NS_ADDREF(*aSubDoc); + return entry->mSubDocument; } } - return NS_OK; + return nsnull; } PR_STATIC_CALLBACK(PLDHashOperator) @@ -1341,37 +1212,22 @@ FindContentEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr, return PL_DHASH_NEXT; } -NS_IMETHODIMP -nsDocument::FindContentForSubDocument(nsIDocument *aDocument, - nsIContent **aContent) +nsIContent* +nsDocument::FindContentForSubDocument(nsIDocument *aDocument) const { - NS_ENSURE_ARG_POINTER(aDocument); + NS_ENSURE_TRUE(aDocument, nsnull); if (!mSubDocuments) { - *aContent = nsnull; - return NS_OK; + return nsnull; } FindContentData data(aDocument); PL_DHashTableEnumerate(mSubDocuments, FindContentEnumerator, &data); - *aContent = data.mResult; - NS_IF_ADDREF(*aContent); - - return NS_OK; + return data.mResult; } -NS_IMETHODIMP -nsDocument::GetRootContent(nsIContent** aRoot) -{ - *aRoot = mRootContent; - - NS_IF_ADDREF(*aRoot); - - return NS_OK; -} - -NS_IMETHODIMP +void nsDocument::SetRootContent(nsIContent* aRoot) { if (mRootContent) { @@ -1386,7 +1242,6 @@ nsDocument::SetRootContent(nsIContent* aRoot) } mRootContent = aRoot; - return NS_OK; } NS_IMETHODIMP_(nsIContent *) @@ -1412,61 +1267,47 @@ nsDocument::GetChildCount() const } PRInt32 -nsDocument::InternalGetNumberOfStyleSheets() +nsDocument::InternalGetNumberOfStyleSheets() const { return mStyleSheets.Count(); } -NS_IMETHODIMP -nsDocument::GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets, - PRInt32* aCount) +PRInt32 +nsDocument::GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets) const { if (aIncludeSpecialSheets) { - *aCount = mStyleSheets.Count(); - } else { - *aCount = InternalGetNumberOfStyleSheets(); + return mStyleSheets.Count(); } - return NS_OK; + + return InternalGetNumberOfStyleSheets(); } -already_AddRefed -nsDocument::InternalGetStyleSheetAt(PRInt32 aIndex) +nsIStyleSheet* +nsDocument::InternalGetStyleSheetAt(PRInt32 aIndex) const { - if (aIndex < 0 || aIndex >= mStyleSheets.Count()) { - NS_ERROR("Index out of range"); - return nsnull; - } - - nsIStyleSheet* sheet = mStyleSheets[aIndex]; - NS_ADDREF(sheet); - - return sheet; + NS_ASSERTION(aIndex >= 0 && aIndex < mStyleSheets.Count(), "Invalid index"); + return mStyleSheets[aIndex]; } -NS_IMETHODIMP -nsDocument::GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets, - nsIStyleSheet** aSheet) +nsIStyleSheet* +nsDocument::GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets) const { if (aIncludeSpecialSheets) { - if (aIndex >= 0 && aIndex < mStyleSheets.Count()) { - *aSheet = mStyleSheets[aIndex]; - NS_ADDREF(*aSheet); - } else { + if (aIndex < 0 || aIndex >= mStyleSheets.Count()) { NS_ERROR("Index out of range"); - *aSheet = nsnull; + return nsnull; } - } else { - *aSheet = InternalGetStyleSheetAt(aIndex).get(); + + return mStyleSheets[aIndex]; } - return NS_OK; + return InternalGetStyleSheetAt(aIndex); } -NS_IMETHODIMP -nsDocument::GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex) +PRInt32 +nsDocument::GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const { - *aIndex = mStyleSheets.IndexOf(aSheet); - return NS_OK; + return mStyleSheets.IndexOf(aSheet); } // subclass hooks for sheet ordering @@ -1564,7 +1405,7 @@ nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet) aSheet->SetOwningDocument(nsnull); } -NS_IMETHODIMP +void nsDocument::UpdateStyleSheets(nsCOMArray& aOldSheets, nsCOMArray& aNewSheets) { @@ -1619,8 +1460,6 @@ nsDocument::UpdateStyleSheets(nsCOMArray& aOldSheets, observer->EndUpdate(this, UPDATE_STYLE); } - - return NS_OK; } @@ -1687,11 +1526,9 @@ nsDocument::SetStyleSheetApplicableState(nsIStyleSheet* aSheet, } } -NS_IMETHODIMP -nsDocument::GetScriptGlobalObject(nsIScriptGlobalObject** aScriptGlobalObject) +nsIScriptGlobalObject* +nsDocument::GetScriptGlobalObject() const { - NS_ENSURE_ARG_POINTER(aScriptGlobalObject); - // If we're going away, we've already released the reference to our // ScriptGlobalObject. We can, however, try to obtain it for the // caller through our docshell. @@ -1699,17 +1536,16 @@ nsDocument::GetScriptGlobalObject(nsIScriptGlobalObject** aScriptGlobalObject) if (mIsGoingAway) { nsCOMPtr requestor = do_QueryReferent(mDocumentContainer); - if (requestor) - return CallGetInterface(requestor.get(), aScriptGlobalObject); + if (requestor) { + nsCOMPtr globalObject = do_GetInterface(requestor); + return globalObject; + } } - *aScriptGlobalObject = mScriptGlobalObject; - NS_IF_ADDREF(*aScriptGlobalObject); - - return NS_OK; + return mScriptGlobalObject; } -NS_IMETHODIMP +void nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) { // XXX HACK ALERT! If the script context owner is null, the document @@ -1751,26 +1587,20 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) } mScriptGlobalObject = aScriptGlobalObject; - - return NS_OK; } -NS_IMETHODIMP -nsDocument::GetScriptLoader(nsIScriptLoader** aScriptLoader) +nsIScriptLoader* +nsDocument::GetScriptLoader() { - NS_ENSURE_ARG_POINTER(aScriptLoader); - if (!mScriptLoader) { mScriptLoader = new nsScriptLoader(); if (!mScriptLoader) { - return NS_ERROR_OUT_OF_MEMORY; + return nsnull; } mScriptLoader->Init(this); } - NS_ADDREF(*aScriptLoader = mScriptLoader); - - return NS_OK; + return mScriptLoader; } // Note: We don't hold a reference to the document observer; we assume @@ -1798,7 +1628,7 @@ nsDocument::RemoveObserver(nsIDocumentObserver* aObserver) return (mObservers.IndexOf(aObserver) != -1); } -NS_IMETHODIMP +void nsDocument::BeginUpdate(nsUpdateType aUpdateType) { PRInt32 i; @@ -1806,11 +1636,9 @@ nsDocument::BeginUpdate(nsUpdateType aUpdateType) nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i]; observer->BeginUpdate(this, aUpdateType); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::EndUpdate(nsUpdateType aUpdateType) { PRInt32 i; @@ -1818,11 +1646,9 @@ nsDocument::EndUpdate(nsUpdateType aUpdateType) nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i]; observer->EndUpdate(this, aUpdateType); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::BeginLoad() { PRInt32 i; @@ -1830,8 +1656,6 @@ nsDocument::BeginLoad() nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i]; observer->BeginLoad(this); } - - return NS_OK; } static void @@ -1852,7 +1676,7 @@ GetDocumentFromDocShellTreeItem(nsIDocShellTreeItem *aDocShell, } } -NS_IMETHODIMP +void nsDocument::EndLoad() { PRInt32 i; @@ -1901,12 +1725,7 @@ nsDocument::EndLoad() getter_AddRefs(parent_doc)); if (parent_doc) { - nsCOMPtr target_content; - - parent_doc->FindContentForSubDocument(this, - getter_AddRefs(target_content)); - - target_frame = do_QueryInterface(target_content); + target_frame = do_QueryInterface(parent_doc->FindContentForSubDocument(this)); } } } @@ -1976,11 +1795,9 @@ nsDocument::EndLoad() tmp->GetSameTypeParent(getter_AddRefs(docShellParent)); } } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentChanged(nsIContent* aContent, nsISupports* aSubContent) { NS_ABORT_IF_FALSE(aContent, "Null content!"); @@ -1992,11 +1809,9 @@ nsDocument::ContentChanged(nsIContent* aContent, nsISupports* aSubContent) observer->ContentChanged(this, aContent, aSubContent); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2, PRInt32 aStateMask) { @@ -2007,12 +1822,10 @@ nsDocument::ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2, observer->ContentStatesChanged(this, aContent1, aContent2, aStateMask); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer) { @@ -2035,11 +1848,9 @@ nsDocument::ContentAppended(nsIContent* aContainer, i--; } } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentInserted(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) { @@ -2061,11 +1872,9 @@ nsDocument::ContentInserted(nsIContent* aContainer, nsIContent* aChild, i--; } } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, nsIContent* aNewChild, PRInt32 aIndexInContainer) { @@ -2080,11 +1889,9 @@ nsDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, observer->ContentReplaced(this, aContainer, aOldChild, aNewChild, aIndexInContainer); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) { @@ -2099,42 +1906,33 @@ nsDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aChild, observer->ContentRemoved(this, aContainer, aChild, aIndexInContainer); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::AttributeWillChange(nsIContent* aChild, PRInt32 aNameSpaceID, nsIAtom* aAttribute) { NS_ASSERTION(aChild, "Null child!"); - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::AttributeChanged(nsIContent* aChild, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { NS_ABORT_IF_FALSE(aChild, "Null child!"); PRInt32 i; - nsresult rv = NS_OK; for (i = mObservers.Count() - 1; i >= 0; --i) { nsIDocumentObserver *observer = NS_STATIC_CAST(nsIDocumentObserver *, mObservers.ElementAt(i)); - nsresult rv2 = observer->AttributeChanged(this, aChild, aNameSpaceID, - aAttribute, aModType); - if (NS_FAILED(rv2) && NS_SUCCEEDED(rv)) - rv = rv2; + observer->AttributeChanged(this, aChild, aNameSpaceID, + aAttribute, aModType); } - - return rv; } -NS_IMETHODIMP +void nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, nsIStyleRule* aOldStyleRule, nsIStyleRule* aNewStyleRule) @@ -2148,11 +1946,9 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet, observer->StyleRuleChanged(this, aStyleSheet, aOldStyleRule, aNewStyleRule); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) { @@ -2165,11 +1961,9 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet, observer->StyleRuleAdded(this, aStyleSheet, aStyleRule); } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule) { @@ -2182,8 +1976,6 @@ nsDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, observer->StyleRuleRemoved(this, aStyleSheet, aStyleRule); } - - return NS_OK; } @@ -2495,11 +2287,8 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets) NS_IMETHODIMP nsDocument::GetCharacterSet(nsAString& aCharacterSet) { - nsCAutoString charset; - nsresult rv = GetDocumentCharacterSet(charset); - if (NS_SUCCEEDED(rv)) - CopyASCIItoUCS2(charset, aCharacterSet); - return rv; + CopyASCIItoUCS2(GetDocumentCharacterSet(), aCharacterSet); + return NS_OK; } NS_IMETHODIMP @@ -2526,13 +2315,11 @@ nsDocument::AddBinding(nsIDOMElement* aContent, const nsAString& aURL) return rv; } - nsCOMPtr bm; - GetBindingManager(getter_AddRefs(bm)); nsCOMPtr content(do_QueryInterface(aContent)); nsCOMPtr uri; NS_NewURI(getter_AddRefs(uri), aURL); - return bm->AddLayeredBinding(content, uri); + return mBindingManager->AddLayeredBinding(content, uri); } NS_IMETHODIMP @@ -3945,12 +3732,12 @@ nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult) return NS_OK; } -NS_IMETHODIMP +void nsDocument::FlushPendingNotifications(PRBool aFlushReflows, PRBool aUpdateViews) { if (!aFlushReflows || !mScriptGlobalObject) { - return NS_OK; + return; } // We should be able to replace all this nsIDocShell* code with code @@ -3993,39 +3780,9 @@ nsDocument::FlushPendingNotifications(PRBool aFlushReflows, shell->FlushPendingNotifications(aUpdateViews); } } - - return NS_OK; } -NS_IMETHODIMP -nsDocument::GetAndIncrementContentID(PRInt32* aID) -{ - *aID = mNextContentID++; - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetBindingManager(nsIBindingManager** aResult) -{ - *aResult = mBindingManager; - NS_IF_ADDREF(*aResult); - - return NS_OK; -} - - -NS_IMETHODIMP -nsDocument::GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) -{ - NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_NOT_INITIALIZED); - - NS_ADDREF(*aNodeInfoManager = mNodeInfoManager); - - return NS_OK; -} - -NS_IMETHODIMP +void nsDocument::AddReference(void *aKey, nsISupports *aReference) { nsVoidKey key(aKey); @@ -4033,61 +3790,37 @@ nsDocument::AddReference(void *aKey, nsISupports *aReference) if (mScriptGlobalObject) { mContentWrapperHash.Put(&key, aReference); } - - return NS_OK; } -NS_IMETHODIMP -nsDocument::RemoveReference(void *aKey, nsISupports **aOldReference) +already_AddRefed +nsDocument::RemoveReference(void *aKey) { nsVoidKey key(aKey); - mContentWrapperHash.Remove(&key, aOldReference); - - return NS_OK; + nsISupports* oldReference; + mContentWrapperHash.Remove(&key, &oldReference); + return oldReference; } -NS_IMETHODIMP -nsDocument::SetContainer(nsISupports *aContainer) -{ - mDocumentContainer = do_GetWeakReference(aContainer); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetContainer(nsISupports **aContainer) -{ - nsCOMPtr container = do_QueryReferent(mDocumentContainer); - - *aContainer = container; - NS_IF_ADDREF(*aContainer); - - return NS_OK; -} - -NS_IMETHODIMP -nsDocument::GetScriptEventManager(nsIScriptEventManager **aResult) +nsIScriptEventManager* +nsDocument::GetScriptEventManager() { if (!mScriptEventManager) { mScriptEventManager = new nsScriptEventManager(this); // automatically AddRefs } - *aResult = mScriptEventManager; - NS_IF_ADDREF(*aResult); - - return NS_OK; + return mScriptEventManager; } -NS_IMETHODIMP +void nsDocument::SetXMLDeclaration(const nsAString& aVersion, const nsAString& aEncoding, const nsAString& aStandalone) { if (aVersion.IsEmpty()) { mXMLDeclarationBits = 0; - return NS_OK; + return; } mXMLDeclarationBits = XML_DECLARATION_BITS_DECLARATION_EXISTS; @@ -4102,11 +3835,9 @@ nsDocument::SetXMLDeclaration(const nsAString& aVersion, } else if (aStandalone.Equals(NS_LITERAL_STRING("no"))) { mXMLDeclarationBits |= XML_DECLARATION_BITS_STANDALONE_EXISTS; } - - return NS_OK; } -NS_IMETHODIMP +void nsDocument::GetXMLDeclaration(nsAString& aVersion, nsAString& aEncoding, nsAString& aStandalone) { @@ -4115,7 +3846,7 @@ nsDocument::GetXMLDeclaration(nsAString& aVersion, nsAString& aEncoding, aStandalone.Truncate(); if (!(mXMLDeclarationBits & XML_DECLARATION_BITS_DECLARATION_EXISTS)) { - return NS_OK; + return; } // always until we start supporting 1.1 etc. @@ -4134,8 +3865,6 @@ nsDocument::GetXMLDeclaration(nsAString& aVersion, nsAString& aEncoding, aStandalone.Assign(NS_LITERAL_STRING("no")); } } - - return NS_OK; } NS_IMETHODIMP_(PRBool) @@ -4150,12 +3879,10 @@ nsDocument::IsScriptEnabled() nsCOMPtr sm(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID)); NS_ENSURE_TRUE(sm, PR_TRUE); - nsCOMPtr principal; - GetPrincipal(getter_AddRefs(principal)); + nsIPrincipal* principal = GetPrincipal(); NS_ENSURE_TRUE(principal, PR_TRUE); - nsCOMPtr globalObject; - GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = GetScriptGlobalObject(); NS_ENSURE_TRUE(globalObject, PR_TRUE); nsCOMPtr scriptContext; @@ -4269,34 +3996,6 @@ nsDocument::WalkRadioGroup(const nsAString& aName, return NS_OK; } -/** - * Check if bidi enabled (set depending on the presence of RTL - * characters). If enabled, we should apply the Unicode Bidi Algorithm - * - * @lina 07/12/2000 - */ -NS_IMETHODIMP -nsDocument::GetBidiEnabled(PRBool* aBidiEnabled) const -{ - NS_ENSURE_ARG_POINTER(aBidiEnabled); - *aBidiEnabled = mBidiEnabled; - - return NS_OK; -} - -/** - * Indicate the document contains RTL characters. - * - * @lina 07/12/2000 - */ -NS_IMETHODIMP -nsDocument::SetBidiEnabled(PRBool aBidiEnabled) -{ - mBidiEnabled = aBidiEnabled; - - return NS_OK; -} - void nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel) { diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 1e6325c592c..d9d0ffd3ecf 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -245,10 +245,8 @@ class nsDocument : public nsIDocument, public: NS_DECL_ISUPPORTS - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); - NS_IMETHOD ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup); + virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup); + virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup); NS_IMETHOD StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, @@ -260,20 +258,10 @@ public: NS_IMETHOD StopDocumentLoad(); - /** - * Return the title of the document. May return null. - */ - NS_IMETHOD GetDocumentTitle(nsAString& aTitle) const; - - /** - * Return the URL for the document. May return null. - */ - NS_IMETHOD GetDocumentURL(nsIURI** aURI) const; - /** * Return the principal responsible for this document. */ - NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal); + virtual nsIPrincipal* GetPrincipal(); /** * Set the principal responsible for this document. @@ -289,39 +277,24 @@ public: /** * Set the Content-Type of this document. */ - NS_IMETHOD SetContentType(const nsAString& aContentType); - - /** - * Return the content language of this document. - */ - NS_IMETHOD GetContentLanguage(nsAString& aContentLanguage) const; - - /** - * Return the LoadGroup for the document. May return null. - */ - NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const; + virtual void SetContentType(const nsAString& aContentType); /** * Return the base URL for relative URLs in the document. May return null (or the document URL). */ - NS_IMETHOD GetBaseURL(nsIURI** aURL) const; NS_IMETHOD SetBaseURL(nsIURI* aURL); /** * Get/Set the base target of a link in a document. */ - NS_IMETHOD GetBaseTarget(nsAString &aBaseTarget); - NS_IMETHOD SetBaseTarget(const nsAString &aBaseTarget); + virtual void GetBaseTarget(nsAString &aBaseTarget) const; + virtual void SetBaseTarget(const nsAString &aBaseTarget); /** * Return a standard name for the document's character set. This will * trigger a startDocumentLoad if necessary to answer the question. */ - NS_IMETHOD GetDocumentCharacterSet(nsACString& oCharsetID); - NS_IMETHOD SetDocumentCharacterSet(const nsACString& aCharSetID); - - NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource); - NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource); + virtual void SetDocumentCharacterSet(const nsACString& aCharSetID); /** * Add an observer that gets notified whenever the charset changes. @@ -333,32 +306,21 @@ public: */ NS_IMETHOD RemoveCharSetObserver(nsIObserver* aObserver); - /** - * Check if the document contains bidi data. - * If so, we have to apply the Unicode Bidi Algorithm. - */ - NS_IMETHOD GetBidiEnabled(PRBool* aBidiEnabled) const; - /** - * Indicate the document contains RTL characters. - */ - NS_IMETHOD SetBidiEnabled(PRBool aBidiEnabled); - /** * Return the Line Breaker for the document */ - NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ; - NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ; - NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) ; - NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) ; + virtual nsILineBreaker* GetLineBreaker(); + virtual void SetLineBreaker(nsILineBreaker* aLineBreaker); + virtual nsIWordBreaker* GetWordBreaker(); + virtual void SetWordBreaker(nsIWordBreaker* aWordBreaker); /** * Access HTTP header data (this may also get set from other sources, like * HTML META tags). */ - NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, - nsAString& aData) const; - NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, - const nsAString& aData); + virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const; + virtual void SetHeaderData(nsIAtom* aheaderField, + const nsAString& aData); /** * Create a new presentation shell that will use aContext for @@ -373,23 +335,11 @@ public: NS_IMETHOD_(PRUint32) GetNumberOfShells() const; NS_IMETHOD_(nsIPresShell *) GetShellAt(PRUint32 aIndex) const; - /** - * Return the parent document of this document. Will return null - * unless this document is within a compound document and has a parent. - */ - NS_IMETHOD GetParentDocument(nsIDocument** aParent); - NS_IMETHOD SetParentDocument(nsIDocument* aParent); - NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc); - NS_IMETHOD GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc); - NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument, - nsIContent **aContent); + virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const; + virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const; - /** - * Return the root content object for this document. - */ - NS_IMETHOD GetRootContent(nsIContent** aRoot); - NS_IMETHOD SetRootContent(nsIContent* aRoot); + virtual void SetRootContent(nsIContent* aRoot); /** * Get the direct children of the document - content in @@ -403,16 +353,15 @@ public: * Get the style sheets owned by this document. * These are ordered, highest priority last */ - NS_IMETHOD GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets, - PRInt32* aCount); - NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets, - nsIStyleSheet** aSheet); - NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex); + virtual PRInt32 GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets) const; + virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex, + PRBool aIncludeSpecialSheets) const; + virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const; virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags); virtual void RemoveStyleSheet(nsIStyleSheet* aSheet); - NS_IMETHOD UpdateStyleSheets(nsCOMArray& aOldSheets, - nsCOMArray& aNewSheets); + virtual void UpdateStyleSheets(nsCOMArray& aOldSheets, + nsCOMArray& aNewSheets); virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet); virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet); @@ -425,13 +374,13 @@ public: * This is the context within which all scripts (during document * creation and during event handling) will run. */ - NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject); - NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject); + virtual nsIScriptGlobalObject* GetScriptGlobalObject() const; + virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject); /** * Get the script loader for this document */ - NS_IMETHOD GetScriptLoader(nsIScriptLoader** aScriptLoader); + virtual nsIScriptLoader* GetScriptLoader(); /** * Add a new observer of document change notifications. Whenever @@ -448,60 +397,55 @@ public: // Observation hooks used to propagate notifications to document // observers. - NS_IMETHOD BeginUpdate(nsUpdateType aUpdateType); - NS_IMETHOD EndUpdate(nsUpdateType aUpdateType); - NS_IMETHOD BeginLoad(); - NS_IMETHOD EndLoad(); - NS_IMETHOD ContentChanged(nsIContent* aContent, - nsISupports* aSubContent); - NS_IMETHOD ContentStatesChanged(nsIContent* aContent1, - nsIContent* aContent2, - PRInt32 aStateMask); + virtual void BeginUpdate(nsUpdateType aUpdateType); + virtual void EndUpdate(nsUpdateType aUpdateType); + virtual void BeginLoad(); + virtual void EndLoad(); + virtual void ContentChanged(nsIContent* aContent, + nsISupports* aSubContent); + virtual void ContentStatesChanged(nsIContent* aContent1, + nsIContent* aContent2, + PRInt32 aStateMask); - NS_IMETHOD AttributeWillChange(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute); - NS_IMETHOD AttributeChanged(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); - NS_IMETHOD ContentAppended(nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - NS_IMETHOD ContentInserted(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - NS_IMETHOD ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); - NS_IMETHOD ContentRemoved(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); + virtual void AttributeWillChange(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute); + virtual void AttributeChanged(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + virtual void ContentAppended(nsIContent* aContainer, + PRInt32 aNewIndexInContainer); + virtual void ContentInserted(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + virtual void ContentReplaced(nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer); + virtual void ContentRemoved(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); - NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet, - nsIStyleRule* aOldStyleRule, - nsIStyleRule* aNewStyleRule); - NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet, - nsIStyleRule* aStyleRule); - NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet, + virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet, + nsIStyleRule* aOldStyleRule, + nsIStyleRule* aNewStyleRule); + virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule); + virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet, + nsIStyleRule* aStyleRule); - NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE, - PRBool aUpdateViews = PR_FALSE); - NS_IMETHOD GetAndIncrementContentID(PRInt32* aID); - NS_IMETHOD GetBindingManager(nsIBindingManager** aResult); - NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager); - NS_IMETHOD AddReference(void *aKey, nsISupports *aReference); - NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference); - NS_IMETHOD SetContainer(nsISupports *aContainer); - NS_IMETHOD GetContainer(nsISupports **aContainer); - NS_IMETHOD GetScriptEventManager(nsIScriptEventManager **aResult); - NS_IMETHOD SetXMLDeclaration(const nsAString& aVersion, + virtual void FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE, + PRBool aUpdateViews = PR_FALSE); + virtual void AddReference(void *aKey, nsISupports *aReference); + virtual already_AddRefed RemoveReference(void *aKey); + virtual nsIScriptEventManager* GetScriptEventManager(); + virtual void SetXMLDeclaration(const nsAString& aVersion, const nsAString& aEncoding, const nsAString& Standalone); - NS_IMETHOD GetXMLDeclaration(nsAString& aVersion, - nsAString& aEncoding, - nsAString& Standalone); + virtual void GetXMLDeclaration(nsAString& aVersion, + nsAString& aEncoding, + nsAString& Standalone); NS_IMETHOD_(PRBool) IsCaseSensitive(); NS_IMETHOD_(PRBool) IsScriptEnabled(); @@ -575,12 +519,13 @@ public: // nsIDOM3EventTarget NS_DECL_NSIDOM3EVENTTARGET + // nsIScriptObjectPrincipal + NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal); + NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, nsIDOMEvent** aDOMEvent, PRUint32 aFlags, nsEventStatus* aEventStatus); - NS_IMETHOD SetDocumentURL(nsIURI* aURI); - virtual nsresult Init(); protected: @@ -589,8 +534,8 @@ protected: PRUint32 aFlags); virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex); - virtual already_AddRefed InternalGetStyleSheetAt(PRInt32 aIndex); - virtual PRInt32 InternalGetNumberOfStyleSheets(); + virtual nsIStyleSheet* InternalGetStyleSheetAt(PRInt32 aIndex) const; + virtual PRInt32 InternalGetNumberOfStyleSheets() const; virtual void RetrieveRelevantHeaders(nsIChannel *aChannel); @@ -602,21 +547,10 @@ protected: nsDocument(); virtual ~nsDocument(); - nsString mDocumentTitle; nsCString mLastModified; - nsCOMPtr mDocumentURL; - nsCOMPtr mDocumentBaseURL; nsCOMPtr mPrincipal; - nsWeakPtr mDocumentLoadGroup; - - nsWeakPtr mDocumentContainer; - - nsCString mCharacterSet; - PRInt32 mCharacterSetSource; - nsVoidArray mCharSetObservers; - nsIDocument* mParentDocument; PLDHashTable *mSubDocuments; @@ -625,10 +559,6 @@ protected: // Array of owning references to all children nsCOMArray mChildren; - // A weak reference to the only element in mChildren, or null if no - // such element exists. - nsIContent* mRootContent; - nsCOMArray mStyleSheets; // Basically always has at least 1 entry @@ -643,21 +573,11 @@ protected: nsRefPtr mChildNodes; - // A content ID counter used to give a monotonically increasing ID - // to the content objects in the document's content model - PRInt32 mNextContentID; - nsHashtable mRadioGroups; - nsCOMPtr mBindingManager; - nsCOMPtr mNodeInfoManager; - // True if the document is being destroyed. PRPackedBool mIsGoingAway; - // True if BIDI is enabled. - PRPackedBool mBidiEnabled; - // True if the document is being destroyed. PRPackedBool mInDestructor; @@ -669,9 +589,6 @@ protected: nsCOMPtr mCSSLoader; - nsXPIDLCString mContentLanguage; - nsCString mContentType; - nsCOMPtr mScriptEventManager; private: diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index e6be775f8a0..b140bd2f98f 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -183,11 +183,11 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult, nsresult rv; if (aOwnerDocument) { - rv = aOwnerDocument->GetNodeInfoManager(getter_AddRefs(nimgr)); + nimgr = aOwnerDocument->GetNodeInfoManager(); } else { rv = nsNodeInfoManager::GetAnonymousManager(getter_AddRefs(nimgr)); + NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, rv); rv = nimgr->GetNodeInfo(NS_LITERAL_STRING("#document-fragment"), nsnull, kNameSpaceID_None, diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index d363389d92b..07c90ec0baf 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -704,10 +704,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) nsCOMPtr sc = do_QueryInterface(mContainer); if (sc) { - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); - - nsCOMPtr frameset(do_QueryInterface(root)); + nsCOMPtr frameset(do_QueryInterface(mDocument->GetRootContent())); if (frameset) { // If this is a frameset (i.e. not a frame) then we never want @@ -899,10 +896,8 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus) nsresult rv = NS_OK; NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); - nsCOMPtr global; - // First, get the script global object from the document... - rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = mDocument->GetScriptGlobalObject(); // Fail if no ScriptGlobalObject is available... NS_ENSURE_TRUE(global, NS_ERROR_NULL_POINTER); @@ -979,9 +974,8 @@ DocumentViewerImpl::Unload() } // First, get the script global object from the document... - nsCOMPtr global; + nsCOMPtr global = mDocument->GetScriptGlobalObject(); - nsresult rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global)); if (!global) { // Fail if no ScriptGlobalObject is available... NS_ASSERTION(0, "nsIScriptGlobalObject not set for document!"); @@ -994,10 +988,8 @@ DocumentViewerImpl::Unload() event.eventStructType = NS_EVENT; event.message = NS_PAGE_UNLOAD; - rv = global->HandleDOMEvent(mPresContext, &event, nsnull, - NS_EVENT_FLAG_INIT, &status); - - return rv; + return global->HandleDOMEvent(mPresContext, &event, nsnull, + NS_EVENT_FLAG_INIT, &status); } NS_IMETHODIMP @@ -1025,8 +1017,7 @@ DocumentViewerImpl::Close() // Break global object circular reference on the document created // in the DocViewer Init - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = mDocument->GetScriptGlobalObject(); if (globalObject) { globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE); @@ -1622,12 +1613,10 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, rv = CallCreateInstance(kStyleSetCID, aStyleSet); if (NS_OK == rv) { - PRInt32 index = 0; - aDocument->GetNumberOfStyleSheets(PR_TRUE, &index); + PRInt32 index = aDocument->GetNumberOfStyleSheets(PR_TRUE); while (0 < index--) { - nsCOMPtr sheet; - aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = aDocument->GetStyleSheetAt(index, PR_TRUE); /* * GetStyleSheetAt will return all style sheets in the document but @@ -1731,9 +1720,8 @@ DocumentViewerImpl::GetPresShellAndRootContent(nsIWebShell * aWebShell, if (!doc) return; - doc->GetRootContent(aContent); // this addrefs - *aPresShell = presShell; - NS_ADDREF(*aPresShell); + NS_IF_ADDREF(*aContent = doc->GetRootContent()); + NS_ADDREF(*aPresShell = presShell); } //--------------------------------------------------------------------- @@ -2014,9 +2002,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } else if (mDocument) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - bodyNode = do_QueryInterface(rootContent); + bodyNode = do_QueryInterface(mDocument->GetRootContent()); } if (!bodyNode) return NS_ERROR_FAILURE; @@ -2759,31 +2745,22 @@ DocumentViewerImpl::GetPopupNode(nsIDOMNode** aNode) NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(document, NS_ERROR_FAILURE); - // get the script global object - nsCOMPtr global; - rv = document->GetScriptGlobalObject(getter_AddRefs(global)); - NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(global, NS_ERROR_FAILURE); // get the internal dom window - nsCOMPtr internalWin(do_QueryInterface(global, &rv)); + nsCOMPtr internalWin(do_QueryInterface(document->GetScriptGlobalObject(), &rv)); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(internalWin, NS_ERROR_FAILURE); // get the private dom window nsCOMPtr privateWin(do_QueryInterface(internalWin, &rv)); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(privateWin, NS_ERROR_FAILURE); // get the focus controller nsCOMPtr focusController; - rv = privateWin->GetRootFocusController(getter_AddRefs(focusController)); - NS_ENSURE_SUCCESS(rv, rv); + privateWin->GetRootFocusController(getter_AddRefs(focusController)); NS_ENSURE_TRUE(focusController, NS_ERROR_FAILURE); // get the popup node - rv = focusController->GetPopupNode(aNode); // addref happens here - NS_ENSURE_SUCCESS(rv, rv); + focusController->GetPopupNode(aNode); // addref happens here return rv; } @@ -2953,10 +2930,7 @@ NS_IMETHODIMP nsDocViewerSelectionListener::NotifySelectionChanged(nsIDOMDocumen mDocViewer->GetDocument(getter_AddRefs(theDoc)); if (!theDoc) return NS_ERROR_FAILURE; - nsCOMPtr scriptGlobalObject; - theDoc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - - nsCOMPtr domWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWindow = do_QueryInterface(theDoc->GetScriptGlobalObject()); if (!domWindow) return NS_ERROR_FAILURE; domWindow->UpdateCommands(NS_LITERAL_STRING("select")); diff --git a/mozilla/content/base/src/nsFrameLoader.cpp b/mozilla/content/base/src/nsFrameLoader.cpp index 59465c0e7d5..8c80feb45ef 100644 --- a/mozilla/content/base/src/nsFrameLoader.cpp +++ b/mozilla/content/base/src/nsFrameLoader.cpp @@ -172,16 +172,14 @@ nsFrameLoader::LoadFrame() } // Make an absolute URI - nsCOMPtr base_uri; - doc->GetBaseURL(getter_AddRefs(base_uri)); + nsIURI *base_uri = doc->GetBaseURL(); - nsCAutoString doc_charset; - doc->GetDocumentCharacterSet(doc_charset); + const nsACString &doc_charset = doc->GetDocumentCharacterSet(); nsCOMPtr uri; rv = NS_NewURI(getter_AddRefs(uri), src, doc_charset.IsEmpty() ? nsnull : - doc_charset.get(), base_uri); + PromiseFlatCString(doc_charset).get(), base_uri); NS_ENSURE_SUCCESS(rv, rv); // Check for security @@ -376,7 +374,7 @@ nsFrameLoader::GetPresContext(nsIPresContext **aPresContext) { *aPresContext = nsnull; - nsCOMPtr doc = mOwnerContent->GetDocument(); + nsIDocument* doc = mOwnerContent->GetDocument(); while (doc) { nsIPresShell *presShell = doc->GetShellAt(0); @@ -387,10 +385,7 @@ nsFrameLoader::GetPresContext(nsIPresContext **aPresContext) return NS_OK; } - nsCOMPtr parent; - doc->GetParentDocument(getter_AddRefs(parent)); - - doc = parent; + doc = doc->GetParentDocument(); } return NS_OK; diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 3f753bbc96f..9cae2b5871f 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -449,10 +449,10 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData) if (NS_SUCCEEDED(rv)) { tccd->SetData(nsITextContentChangeData::Append, length, aData.Length()); - rv = mDocument->ContentChanged(this, tccd); + mDocument->ContentChanged(this, tccd); NS_RELEASE(tccd); } else { - rv = mDocument->ContentChanged(this, nsnull); + mDocument->ContentChanged(this, nsnull); } } @@ -1067,10 +1067,11 @@ nsGenericDOMDataNode::GetBaseURL(nsIURI** aURI) const } if (mDocument) { - return mDocument->GetBaseURL(aURI); + NS_IF_ADDREF(*aURI = mDocument->GetBaseURL()); + } else { + *aURI = nsnull; } - *aURI = nsnull; return NS_OK; } @@ -1397,16 +1398,9 @@ nsGenericDOMDataNode::LookupRangeList() const void nsGenericDOMDataNode::SetBidiStatus() { - if (mDocument) { - PRBool isBidiDocument = PR_FALSE; - - mDocument->GetBidiEnabled(&isBidiDocument); - - if (isBidiDocument) { - // OK, we already know it's Bidi, so we won't test again - - return; - } + if (mDocument && mDocument->GetBidiEnabled()) { + // OK, we already know it's Bidi, so we won't test again + return; } mText.SetBidiFlag(); diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 02ca0245a11..ec6cbe35f6f 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1701,8 +1701,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, if (mDocument && aDeep) { // Notify XBL- & nsIAnonymousContentCreator-generated // anonymous content that the document is changing. - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager* bindingManager = mDocument->GetBindingManager(); NS_ASSERTION(bindingManager, "No binding manager."); if (bindingManager) { bindingManager->ChangeDocumentFor(this, mDocument, aDocument); @@ -1726,8 +1725,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, nsCOMPtr prefix = mNodeInfo->GetPrefixAtom(); PRInt32 nameSpaceID = mNodeInfo->GetNamespaceID(); - nsCOMPtr nodeInfoManager; - aDocument->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nsINodeInfoManager* nodeInfoManager = aDocument->GetNodeInfoManager(); if (nodeInfoManager) { nsCOMPtr newNodeInfo; nodeInfoManager->GetNodeInfo(name, prefix, nameSpaceID, @@ -1856,8 +1854,7 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext, // determine the parent: nsCOMPtr parent; if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager* bindingManager = mDocument->GetBindingManager(); if (bindingManager) { // we have a binding manager -- do we have an anonymous parent? bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); @@ -2203,7 +2200,7 @@ nsGenericElement::GetBaseURL(nsIURI** aBaseURL) const } else if (doc) { // No parent, so just use the document (we must be the root or not in the // tree). - doc->GetBaseURL(getter_AddRefs(parentBase)); + parentBase = doc->GetBaseURL(); } // Now check for an xml:base attr @@ -2217,7 +2214,7 @@ nsGenericElement::GetBaseURL(nsIURI** aBaseURL) const nsCAutoString charset; if (doc) { - doc->GetDocumentCharacterSet(charset); + charset = doc->GetDocumentCharacterSet(); } nsCOMPtr ourBase; @@ -3008,8 +3005,7 @@ nsresult nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr) { if (mDocument) { - nsCOMPtr manager; - mDocument->GetBindingManager(getter_AddRefs(manager)); + nsIBindingManager* manager = mDocument->GetBindingManager(); if (manager) return manager->GetBindingImplementation(this, aIID, aInstancePtr); } @@ -3074,7 +3070,7 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute, // Try to get context from doc if (mDocument) { - if (NS_SUCCEEDED(mDocument->GetScriptGlobalObject(getter_AddRefs(global))) && global) { + if ((global = mDocument->GetScriptGlobalObject())) { NS_ENSURE_SUCCESS(global->GetContext(getter_AddRefs(context)), NS_ERROR_FAILURE); } } @@ -3326,8 +3322,7 @@ PRBool nsGenericElement::HasMutationListeners(nsIContent* aContent, if (!doc) return PR_FALSE; - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (!global) return PR_FALSE; @@ -3437,10 +3432,8 @@ nsGenericContainerElement::SetAttr(nsINodeInfo* aNodeInfo, } if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(name, nameSpaceID, PR_FALSE, aNotify); @@ -3627,10 +3620,8 @@ nsGenericContainerElement::UnsetAttr(PRInt32 aNameSpaceID, delete attr; if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); @@ -3734,8 +3725,7 @@ nsGenericContainerElement::List(FILE* out, PRInt32 aIndent) const fputs(">\n", out); if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager* bindingManager = mDocument->GetBindingManager(); if (bindingManager) { nsCOMPtr anonymousChildren; bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsGenericContainerElement*, this)), diff --git a/mozilla/content/base/src/nsHTMLContentSerializer.cpp b/mozilla/content/base/src/nsHTMLContentSerializer.cpp index 7a07d1f4686..325ccfb1075 100644 --- a/mozilla/content/base/src/nsHTMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsHTMLContentSerializer.cpp @@ -165,7 +165,7 @@ nsHTMLContentSerializer::AppendText(nsIDOMText* aText, aText->GetOwnerDocument(getter_AddRefs(domDoc)); nsCOMPtr document = do_QueryInterface(domDoc); if (document) { - document->GetLineBreaker(getter_AddRefs(mLineBreaker)); + mLineBreaker = document->GetLineBreaker(); } if (!mLineBreaker) { @@ -623,16 +623,13 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent, // but that gets more complicated since we have to // search the tag list for CODEBASE as well. // For now, just leave them relative. - nsIDocument* document = aContent->GetDocument(); - if (document) { - nsCOMPtr uri; - document->GetBaseURL(getter_AddRefs(uri)); - if (uri) { - nsAutoString absURI; - rv = NS_MakeAbsoluteURI(absURI, valueStr, uri); - if (NS_SUCCEEDED(rv)) { - valueStr = absURI; - } + nsCOMPtr uri; + aContent->GetBaseURL(getter_AddRefs(uri)); + if (uri) { + nsAutoString absURI; + rv = NS_MakeAbsoluteURI(absURI, valueStr, uri); + if (NS_SUCCEEDED(rv)) { + valueStr = absURI; } } } diff --git a/mozilla/content/base/src/nsImageLoadingContent.cpp b/mozilla/content/base/src/nsImageLoadingContent.cpp index 2b60270fc6f..49a456dfae5 100644 --- a/mozilla/content/base/src/nsImageLoadingContent.cpp +++ b/mozilla/content/base/src/nsImageLoadingContent.cpp @@ -419,12 +419,10 @@ nsImageLoadingContent::ImageURIChanged(const nsACString& aNewURI) return NS_OK; } - nsCOMPtr loadGroup; - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); NS_WARN_IF_FALSE(loadGroup, "Could not get loadgroup; onload may fire too early"); - nsCOMPtr documentURI; - doc->GetDocumentURL(getter_AddRefs(documentURI)); + nsIURI *documentURI = doc->GetDocumentURL(); nsCOMPtr & req = mCurrentRequest ? mPendingRequest : mCurrentRequest; @@ -524,9 +522,8 @@ nsImageLoadingContent::CanLoadImage(nsIURI* aURI, nsIDocument* aDocument) // Check with the content-policy things to make sure this load is permitted. - nsCOMPtr globalScript; - nsresult rv = aDocument->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (NS_FAILED(rv)) { + nsIScriptGlobalObject *globalScript = aDocument->GetScriptGlobalObject(); + if (!globalScript) { // just let it load. Documents loaded as data should take care to // prevent image loading themselves. return NS_OK; @@ -535,8 +532,8 @@ nsImageLoadingContent::CanLoadImage(nsIURI* aURI, nsIDocument* aDocument) nsCOMPtr domWin(do_QueryInterface(globalScript)); PRBool shouldLoad = PR_TRUE; - rv = NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE, aURI, this, - domWin, &shouldLoad); + nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE, aURI, this, + domWin, &shouldLoad); if (NS_SUCCEEDED(rv) && !shouldLoad) { return NS_ERROR_IMAGE_BLOCKED; } @@ -582,13 +579,12 @@ nsImageLoadingContent::StringToURI(const nsACString& aSpec, NS_ENSURE_SUCCESS(rv, rv); // (2) Get the charset - nsCAutoString charset; - aDocument->GetDocumentCharacterSet(charset); + const nsACString &charset = aDocument->GetDocumentCharacterSet(); // (3) Construct the silly thing return NS_NewURI(aURI, aSpec, - charset.IsEmpty() ? nsnull : charset.get(), + charset.IsEmpty() ? nsnull : PromiseFlatCString(charset).get(), baseURL, sIOService); } @@ -682,8 +678,7 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType) getter_AddRefs(eventQ)); NS_ENSURE_TRUE(eventQ, rv); - nsCOMPtr loadGroup; - document->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = document->GetDocumentLoadGroup(); nsIPresShell *shell = document->GetShellAt(0); NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); diff --git a/mozilla/content/base/src/nsNodeInfoManager.cpp b/mozilla/content/base/src/nsNodeInfoManager.cpp index 70fb115b424..9d32c54e117 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.cpp +++ b/mozilla/content/base/src/nsNodeInfoManager.cpp @@ -173,10 +173,8 @@ nsNodeInfoManager::DropDocumentReference() // that we're creating a principal without having a uri. // This happens in a few cases where a document is created and then // immediately dropped without ever getting a URI. - nsCOMPtr docUri; - mDocument->GetDocumentURL(getter_AddRefs(docUri)); - if (docUri) { - mDocument->GetPrincipal(getter_AddRefs(mPrincipal)); + if (mDocument->GetDocumentURL()) { + mPrincipal = mDocument->GetPrincipal(); } } mDocument = nsnull; @@ -338,13 +336,17 @@ nsNodeInfoManager::GetDocumentPrincipal(nsIPrincipal** aPrincipal) if (mDocument) { // If the document has a uri we'll ask for it's principal. Otherwise we'll // consider this document 'anonymous' - nsCOMPtr docUri; - mDocument->GetDocumentURL(getter_AddRefs(docUri)); - if (!docUri) { + if (!mDocument->GetDocumentURL()) { *aPrincipal = nsnull; return NS_OK; } - return mDocument->GetPrincipal(aPrincipal); + + *aPrincipal = mDocument->GetPrincipal(); + if (!*aPrincipal) + return NS_ERROR_FAILURE; + + NS_ADDREF(*aPrincipal); + return NS_OK; } *aPrincipal = mPrincipal; NS_IF_ADDREF(*aPrincipal); diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index c97a251d1b6..8c8dfeb7495 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -753,10 +753,7 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings, if (!printSilently) { nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); if (printPromptService) { - nsCOMPtr scriptGlobalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); - nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWin = do_QueryInterface(mDocument->GetScriptGlobalObject()); NS_ENSURE_TRUE(domWin, NS_ERROR_FAILURE); // Platforms not implementing a given dialog for the service may @@ -1685,10 +1682,7 @@ nsPrintEngine::ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify) if (mPrt->mShowProgressDialog) { nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); if (printPromptService) { - nsCOMPtr scriptGlobalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - if (!scriptGlobalObject) return; - nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWin = do_QueryInterface(mDocument->GetScriptGlobalObject()); if (!domWin) return; nsCOMPtr wbp(do_QueryInterface(mDocViewerPrint)); @@ -1778,8 +1772,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (rootContent) { if (NS_SUCCEEDED(mDocViewerPrint->FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) { isFrameSet = PR_TRUE; @@ -1857,14 +1850,12 @@ nsPrintEngine::GetWebShellTitleAndURL(nsIWebShell* aWebShell, *aTitle = nsnull; *aURLStr = nsnull; - nsAutoString docTitle; - aDoc->GetDocumentTitle(docTitle); + const nsAString &docTitle = aDoc->GetDocumentTitle(); if (!docTitle.IsEmpty()) { *aTitle = ToNewUnicode(docTitle); } - nsCOMPtr url; - aDoc->GetDocumentURL(getter_AddRefs(url)); + nsIURI* url = aDoc->GetDocumentURL(); if (!url) return; nsCAutoString urlCStr; @@ -1966,15 +1957,12 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aRootObject, return; } - nsCOMPtr subDoc; - doc->GetSubDocumentFor(aContent, getter_AddRefs(subDoc)); + nsIDocument* subDoc = doc->GetSubDocumentFor(aContent); if (subDoc) { - nsCOMPtr container; - subDoc->GetContainer(getter_AddRefs(container)); - nsIPresShell *presShell = subDoc->GetShellAt(0); + nsCOMPtr container = subDoc->GetContainer(); nsCOMPtr webShell(do_QueryInterface(container)); if (presShell && webShell) { @@ -3957,13 +3945,12 @@ nsPrintEngine::FindFocusedDOMWindowInternal() { nsCOMPtr theDOMWin; nsCOMPtr theDoc; - nsCOMPtr theSGO; nsCOMPtr focusController; nsIDOMWindowInternal * domWin = nsnull; mDocViewer->GetDocument(getter_AddRefs(theDoc)); if(theDoc){ - theDoc->GetScriptGlobalObject(getter_AddRefs(theSGO)); + nsIScriptGlobalObject* theSGO = theDoc->GetScriptGlobalObject(); if(theSGO){ nsCOMPtr theDOMWindow = do_QueryInterface(theSGO); if(theDOMWindow){ @@ -4448,11 +4435,10 @@ nsPrintEngine::TurnScriptingOn(PRBool aDoTurnOn) NS_ASSERTION(mDocument, "We MUST have a document."); // get the script global object - nsCOMPtr scriptGlobalObj; - nsresult rv = mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObj)); - NS_ASSERTION(NS_SUCCEEDED(rv) && scriptGlobalObj, "Can't get nsIScriptGlobalObject"); + nsIScriptGlobalObject *scriptGlobalObj = mDocument->GetScriptGlobalObject(); + NS_ASSERTION(scriptGlobalObj, "Can't get nsIScriptGlobalObject"); nsCOMPtr scx; - rv = scriptGlobalObj->GetContext(getter_AddRefs(scx)); + nsresult rv = scriptGlobalObj->GetContext(getter_AddRefs(scx)); NS_ASSERTION(NS_SUCCEEDED(rv) && scx, "Can't get nsIScriptContext"); scx->SetScriptsEnabled(aDoTurnOn, PR_TRUE); } diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp index 8357c83a71f..a638f7bb622 100644 --- a/mozilla/content/base/src/nsRange.cpp +++ b/mozilla/content/base/src/nsRange.cpp @@ -2585,11 +2585,10 @@ nsRange::CreateContextualFragment(const nsAString& aFragment, // (just in case...null subject principal will probably never happen) if (NS_SUCCEEDED(result) && (!subjectPrin || sysPrin.get() == subjectPrin.get())) { - nsCOMPtr globalObj; - result = document->GetScriptGlobalObject(getter_AddRefs(globalObj)); + nsIScriptGlobalObject *globalObj = document->GetScriptGlobalObject(); nsCOMPtr scriptContext; - if (NS_SUCCEEDED(result) && globalObj) { + if (globalObj) { result = globalObj->GetContext(getter_AddRefs(scriptContext)); } diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 9444a6c6504..31e2729ed0b 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -362,8 +362,7 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, // Script evaluation can also be disabled in the current script // context even though it's enabled in the document. - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject *globalObject = mDocument->GetScriptGlobalObject(); if (globalObject) { nsCOMPtr context; @@ -444,8 +443,7 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, } // Check that the containing page is allowed to load this URI. - nsCOMPtr docURI; - mDocument->GetDocumentURL(getter_AddRefs(docURI)); + nsIURI *docURI = mDocument->GetDocumentURL(); if (!docURI) { return FireErrorNotification(NS_ERROR_UNEXPECTED, aElement, aObserver); } @@ -475,11 +473,9 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, // Add the request to our pending requests list mPendingRequests.AppendObject(request); - nsCOMPtr loadGroup; + nsCOMPtr loadGroup = mDocument->GetDocumentLoadGroup(); nsCOMPtr loader; - (void) mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - nsCOMPtr docshell; rv = globalObject->GetDocShell(getter_AddRefs(docshell)); if (NS_FAILED(rv)) { @@ -487,10 +483,6 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, return FireErrorNotification(rv, aElement, aObserver); } - // Get the referrer url from the document - nsCOMPtr documentURI; - mDocument->GetDocumentURL(getter_AddRefs(documentURI)); - nsCOMPtr prompter(do_QueryInterface(docshell)); nsCOMPtr channel; @@ -504,7 +496,7 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), NS_LITERAL_CSTRING("*/*"), PR_FALSE); - httpChannel->SetReferrer(documentURI); + httpChannel->SetReferrer(mDocument->GetDocumentURL()); } rv = NS_NewStreamLoader(getter_AddRefs(loader), channel, this, request); } @@ -516,7 +508,7 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, } else { request->mLoading = PR_FALSE; request->mIsInline = PR_TRUE; - mDocument->GetDocumentURL(getter_AddRefs(request->mURI)); + request->mURI = mDocument->GetDocumentURL(); nsCOMPtr scriptElement(do_QueryInterface(aElement)); if (scriptElement) { @@ -641,8 +633,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, return NS_ERROR_FAILURE; } - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject *globalObject = mDocument->GetScriptGlobalObject(); NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE); nsCOMPtr context; @@ -651,8 +642,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, return NS_ERROR_FAILURE; } - nsCOMPtr principal; - mDocument->GetPrincipal(getter_AddRefs(principal)); + nsIPrincipal *principal = mDocument->GetPrincipal(); // We can survive without a principal, but we really should // have one. NS_ASSERTION(principal, "principal required for document"); @@ -834,11 +824,9 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader, if (characterSet.IsEmpty()) { // charset from document default - rv = mDocument->GetDocumentCharacterSet(characterSet); + characterSet = mDocument->GetDocumentCharacterSet(); } - NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get document charset!"); - if (characterSet.IsEmpty()) { // fall back to ISO-8851-1, see bug 118404 characterSet = NS_LITERAL_CSTRING("ISO-8859-1"); @@ -906,9 +894,8 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader, nsCOMPtr principal = do_QueryInterface(owner); if (principal) { - nsCOMPtr docPrincipal; - rv = mDocument->GetPrincipal(getter_AddRefs(docPrincipal)); - if (NS_SUCCEEDED(rv)) { + nsIPrincipal *docPrincipal = mDocument->GetPrincipal(); + if (docPrincipal) { nsCOMPtr newPrincipal = IntersectPrincipalCerts(docPrincipal, principal); diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 5a15c3deb30..0b3c58f6e1f 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -3219,7 +3219,7 @@ NS_IMETHODIMP nsSelection::SelectAll() return rv; if (!doc) return NS_ERROR_FAILURE; - doc->GetRootContent(getter_AddRefs(rootContent)); + rootContent = doc->GetRootContent(); if (!rootContent) return NS_ERROR_FAILURE; } diff --git a/mozilla/content/base/src/nsStyleSet.cpp b/mozilla/content/base/src/nsStyleSet.cpp index 6ee28039168..4f4f287bade 100644 --- a/mozilla/content/base/src/nsStyleSet.cpp +++ b/mozilla/content/base/src/nsStyleSet.cpp @@ -648,16 +648,14 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen if (EnsureArray(mDocSheets)) { mDocSheets->RemoveElement(aSheet); // lowest index last - PRInt32 newDocIndex = 0; - aDocument->GetIndexOfStyleSheet(aSheet, &newDocIndex); + PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet); PRUint32 count; nsresult rv = mDocSheets->Count(&count); if (NS_FAILED(rv)) return; // XXX error? PRUint32 index; for (index = 0; index < count; index++) { nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index); - PRInt32 sheetDocIndex = 0; - aDocument->GetIndexOfStyleSheet(sheet, &sheetDocIndex); + PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet); if (sheetDocIndex < newDocIndex) { mDocSheets->InsertElementAt(aSheet, index); index = count; // break loop diff --git a/mozilla/content/base/src/nsSyncLoadService.cpp b/mozilla/content/base/src/nsSyncLoadService.cpp index fbf702b14a8..2309b95e785 100644 --- a/mozilla/content/base/src/nsSyncLoadService.cpp +++ b/mozilla/content/base/src/nsSyncLoadService.cpp @@ -388,9 +388,7 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel, NS_ENSURE_TRUE(mLoadSuccess, NS_ERROR_FAILURE); - nsCOMPtr rootContent; - document->GetRootContent(getter_AddRefs(rootContent)); - NS_ENSURE_TRUE(rootContent, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(document->GetRootContent(), NS_ERROR_FAILURE); return CallQueryInterface(document, aResult); } diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index df4804200ef..c0cb0c5786f 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -659,7 +659,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, document = content->GetDocument(); else document = do_QueryInterface(mTarget); if (document) - document->GetScriptGlobalObject(getter_AddRefs(global)); + global = document->GetScriptGlobalObject(); else global = do_QueryInterface(mTarget); if (global) { nsCOMPtr window(do_QueryInterface(global)); @@ -2001,16 +2001,12 @@ nsEventListenerManager::FixContextMenuEvent(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(shell)); shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr scriptObj; - doc->GetScriptGlobalObject(getter_AddRefs(scriptObj)); - if (scriptObj) { - nsCOMPtr privWindow = do_QueryInterface(scriptObj); - if (privWindow) { - nsCOMPtr focusController; - privWindow->GetRootFocusController(getter_AddRefs(focusController)); - if (focusController) - focusController->GetFocusedElement(getter_AddRefs(currentFocus)); - } + nsCOMPtr privWindow = do_QueryInterface(doc->GetScriptGlobalObject()); + if (privWindow) { + nsCOMPtr focusController; + privWindow->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) + focusController->GetFocusedElement(getter_AddRefs(currentFocus)); } } } diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 7ddb870d30e..b3413b40c30 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -434,9 +434,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (mDocument) { if (gLastFocusedDocument && gLastFocusedPresContext) { - nsCOMPtr ourGlobal; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject()); // If the focus controller is already suppressed, it means that we // are in the middle of an activate sequence. In this case, we do @@ -520,8 +518,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, focusevent.eventStructType = NS_EVENT; focusevent.message = NS_FOCUS_CONTENT; - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsCOMPtr globalObject = mDocument->GetScriptGlobalObject(); if (globalObject) { // We don't want there to be a focused content node while we're // dispatching the focus event. @@ -551,25 +548,15 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, // Try to keep the focus controllers and the globals in synch if (gLastFocusedDocument && gLastFocusedDocument != mDocument) { - nsCOMPtr lastGlobal; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(lastGlobal)); nsCOMPtr lastController; - if (lastGlobal) { - nsCOMPtr lastWindow; - lastWindow = do_QueryInterface(lastGlobal); + nsCOMPtr lastWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject()); + if (lastWindow) + lastWindow->GetRootFocusController(getter_AddRefs(lastController)); - if (lastWindow) - lastWindow->GetRootFocusController(getter_AddRefs(lastController)); - } - - nsCOMPtr nextGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(nextGlobal)); nsCOMPtr nextController; - if (nextGlobal) { - nsCOMPtr nextWindow = do_QueryInterface(nextGlobal); - if (nextWindow) - nextWindow->GetRootFocusController(getter_AddRefs(nextController)); - } + nsCOMPtr nextWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); + if (nextWindow) + nextWindow->GetRootFocusController(getter_AddRefs(nextController)); if (lastController != nextController && lastController && nextController) lastController->SetActive(PR_FALSE); @@ -616,14 +603,14 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (gLastFocusedContent) { nsIDocument* doc = gLastFocusedContent->GetDocument(); if (doc) - doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + ourGlobal = doc->GetScriptGlobalObject(); else { - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + ourGlobal = mDocument->GetScriptGlobalObject(); NS_RELEASE(gLastFocusedContent); } } else - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + ourGlobal = mDocument->GetScriptGlobalObject(); // Now fire blurs. We fire a blur on the focused document, element, // and window. @@ -661,8 +648,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, // get the window here, in case the event causes // gLastFocusedDocument to change. - nsCOMPtr globalObject; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsCOMPtr globalObject = gLastFocusedDocument->GetScriptGlobalObject(); gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, @@ -692,9 +678,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, EnsureDocument(aPresContext); - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); - nsCOMPtr win(do_QueryInterface(globalObj)); + nsCOMPtr win(do_QueryInterface(mDocument->GetScriptGlobalObject())); if (!win) { NS_ERROR("win is null. this happens [often on xlib builds]. see bug #79213"); @@ -716,11 +700,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, focusController->SetActive(PR_TRUE); } - if (!focusedWindow) { - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - focusedWindow = do_QueryInterface(globalObject); - } + if (!focusedWindow) + focusedWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); NS_WARN_IF_FALSE(focusedWindow,"check why focusedWindow is null!!!"); @@ -780,8 +761,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, { EnsureDocument(aPresContext); - nsCOMPtr ourGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + nsCOMPtr ourGlobal = mDocument->GetScriptGlobalObject(); // Suppress the focus controller for the duration of the // de-activation. This will cause it to remember the last @@ -1507,11 +1487,7 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) { if(!gLastFocusedDocument) return NS_ERROR_FAILURE; - nsCOMPtr ourGlobal; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - if(!ourGlobal) return NS_ERROR_FAILURE; - - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject()); if(!ourWindow) return NS_ERROR_FAILURE; nsCOMPtr rootWindow; @@ -1640,7 +1616,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext, else { // If there is no focused content, get the document content EnsureDocument(presShell); - mDocument->GetRootContent(getter_AddRefs(focusContent)); + focusContent = mDocument->GetRootContent(); if (!focusContent) return NS_ERROR_FAILURE; } @@ -1767,8 +1743,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent, NS_ASSERTION(doc, "No document in prescontext!"); - nsCOMPtr parentDoc; - doc->GetParentDocument(getter_AddRefs(parentDoc)); + nsIDocument *parentDoc = doc->GetParentDocument(); if (!parentDoc) { return NS_OK; @@ -1779,9 +1754,8 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent, /* now find the content node in our parent docshell's document that corresponds to our docshell */ - nsCOMPtr frameContent; - parentDoc->FindContentForSubDocument(doc, getter_AddRefs(frameContent)); + nsIContent *frameContent = parentDoc->FindContentForSubDocument(doc); NS_ENSURE_TRUE(frameContent, NS_ERROR_FAILURE); /* @@ -2539,14 +2513,12 @@ nsEventStateManager::MaybeDispatchMouseEventToIframe( // (mouseover / mouseout) to the IFRAME element above us. This will result // in over-out-over combo to the IFRAME but as long as IFRAMEs are native // windows this will serve as a workaround to maintain IFRAME mouseover state. - nsCOMPtr parentDoc; // If this is the first event in this window then mDocument might not be set // yet. Call EnsureDocument to set it. EnsureDocument(aPresContext); - mDocument->GetParentDocument(getter_AddRefs(parentDoc)); + nsIDocument *parentDoc = mDocument->GetParentDocument(); if (parentDoc) { - nsCOMPtr docContent; - parentDoc->FindContentForSubDocument(mDocument, getter_AddRefs(docContent)); + nsIContent *docContent = parentDoc->FindContentForSubDocument(mDocument); if (docContent) { nsCOMPtr tag; docContent->GetTag(getter_AddRefs(tag)); @@ -3019,9 +2991,7 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel) nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); - nsCOMPtr sgo; - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); - nsCOMPtr domwin(do_QueryInterface(sgo)); + nsCOMPtr domwin(do_QueryInterface(doc->GetScriptGlobalObject)); nsCOMPtr widget; nsIViewManager* vm = presShell->GetViewManager(); @@ -3071,8 +3041,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) EnsureDocument(mPresContext); NS_ASSERTION(mDocument, "no document"); - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsCOMPtr rootContent = mDocument->GetRootContent(); nsCOMPtr pcContainer; mPresContext->GetContainer(getter_AddRefs(pcContainer)); @@ -3175,13 +3144,10 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) nsCOMPtr doc = nextFocus->GetDocument(); if (doc) { - nsCOMPtr sub_doc; - doc->GetSubDocumentFor(nextFocus, getter_AddRefs(sub_doc)); + nsIDocument *sub_doc = doc->GetSubDocumentFor(nextFocus); if (sub_doc) { - nsCOMPtr container; - sub_doc->GetContainer(getter_AddRefs(container)); - + nsCOMPtr container = sub_doc->GetContainer(); sub_shell = do_QueryInterface(container); } } @@ -3290,13 +3256,10 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) nsCOMPtr parentShell; parentDS->GetPresShell(getter_AddRefs(parentShell)); - nsCOMPtr docContent; nsCOMPtr parent_doc; - parentShell->GetDocument(getter_AddRefs(parent_doc)); - parent_doc->FindContentForSubDocument(mDocument, - getter_AddRefs(docContent)); + nsIContent *docContent = parent_doc->FindContentForSubDocument(mDocument); nsCOMPtr parentPC; parentShell->GetPresContext(getter_AddRefs(parentPC)); @@ -3616,11 +3579,9 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, if (child) { nsCOMPtr doc = child->GetDocument(); if (doc) { - nsCOMPtr subDoc; - doc->GetSubDocumentFor(child, getter_AddRefs(subDoc)); + nsIDocument *subDoc = doc->GetSubDocumentFor(child); if (subDoc) { - nsCOMPtr container; - subDoc->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = subDoc->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { nsCOMPtr contentViewer; @@ -4166,14 +4127,8 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo if(gLastFocusedDocument && mDocument) { nsCOMPtr newFocusController; nsCOMPtr oldFocusController; - nsCOMPtr oldPIDOMWindow; - nsCOMPtr newPIDOMWindow; - nsCOMPtr oldGlobal; - nsCOMPtr newGlobal; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(oldGlobal)); - mDocument->GetScriptGlobalObject(getter_AddRefs(newGlobal)); - nsCOMPtr newWindow = do_QueryInterface(newGlobal); - nsCOMPtr oldWindow = do_QueryInterface(oldGlobal); + nsCOMPtr newWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); + nsCOMPtr oldWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject()); if(newWindow) newWindow->GetRootFocusController(getter_AddRefs(newFocusController)); if(oldWindow) @@ -4213,7 +4168,7 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo nsCOMPtr globalObject; if(gLastFocusedDocument) - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + globalObject = gLastFocusedDocument->GetScriptGlobalObject(); EnsureDocument(presShell); @@ -4227,14 +4182,8 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo if (mDocument) { nsCOMPtr newFocusController; nsCOMPtr oldFocusController; - nsCOMPtr oldPIDOMWindow; - nsCOMPtr newPIDOMWindow; - nsCOMPtr oldGlobal; - nsCOMPtr newGlobal; - gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(oldGlobal)); - mDocument->GetScriptGlobalObject(getter_AddRefs(newGlobal)); - nsCOMPtr newWindow = do_QueryInterface(newGlobal); - nsCOMPtr oldWindow = do_QueryInterface(oldGlobal); + nsCOMPtr newWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); + nsCOMPtr oldWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject()); if (newWindow) newWindow->GetRootFocusController(getter_AddRefs(newFocusController)); @@ -4669,8 +4618,7 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, domNode->GetNodeType(&nodeType); if (nodeType == nsIDOMNode::TEXT_NODE) { - nsCOMPtr origStartContent(startContent), rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsCOMPtr origStartContent(startContent); nsAutoString nodeValue; domNode->GetNodeValue(nodeValue); @@ -4678,7 +4626,7 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, startContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL); if (nodeValue.Length() == *aStartOffset && !isFormControl && - startContent != rootContent) { + startContent != mDocument->GetRootContent()) { // Yes, indeed we were at the end of the last node nsCOMPtr frameTraversal; @@ -5112,8 +5060,7 @@ nsEventStateManager::IsFrameSetDoc(nsIDocShell* aDocShell) presShell->GetDocument(getter_AddRefs(doc)); nsCOMPtr htmlDoc = do_QueryInterface(doc); if (htmlDoc) { - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (rootContent) { PRUint32 childCount = rootContent->GetChildCount(); for (PRUint32 i = 0; i < childCount; ++i) { @@ -5169,9 +5116,7 @@ nsEventStateManager::IsIFrameDoc(nsIDocShell* aDocShell) nsCOMPtr doc(do_QueryInterface(domDoc)); NS_ASSERTION(doc, "DOM document not implementing nsIDocument"); - nsCOMPtr docContent; - - parentDoc->FindContentForSubDocument(doc, getter_AddRefs(docContent)); + nsIContent *docContent = parentDoc->FindContentForSubDocument(doc); if (!docContent) return PR_FALSE; @@ -5427,8 +5372,7 @@ nsEventStateManager::ShiftFocusByDoc(PRBool aForward) already_AddRefed nsEventStateManager::GetFocusControllerForDocument(nsIDocument* aDocument) { - nsCOMPtr container; - aDocument->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aDocument->GetContainer(); nsCOMPtr windowPrivate = do_GetInterface(container); nsIFocusController* fc; if (windowPrivate) diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index 68d7e9b9cc1..ebe7097144e 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -388,10 +388,11 @@ nsAttributeContent::GetBaseURL(nsIURI** aURI) const } if (mDocument) { - return mDocument->GetBaseURL(aURI); + NS_IF_ADDREF(*aURI = mDocument->GetBaseURL()); + } else { + *aURI = nsnull; } - *aURI = nsnull; return NS_OK; } diff --git a/mozilla/content/html/content/src/nsFormSubmission.cpp b/mozilla/content/html/content/src/nsFormSubmission.cpp index 89b0952614d..88289e62824 100644 --- a/mozilla/content/html/content/src/nsFormSubmission.cpp +++ b/mozilla/content/html/content/src/nsFormSubmission.cpp @@ -1074,8 +1074,7 @@ SendJSWarning(nsIHTMLContent* aContent, { nsIDocument* document = aContent->GetDocument(); if (document) { - nsCOMPtr documentURL; - document->GetDocumentURL(getter_AddRefs(documentURL)); + nsIURI *documentURL = document->GetDocumentURL(); NS_ENSURE_TRUE(documentURL, NS_ERROR_UNEXPECTED); documentURL->GetPath(documentURLSpec); } @@ -1274,7 +1273,7 @@ nsFormSubmission::GetSubmitCharset(nsIHTMLContent* aForm, // Get the charset from document nsIDocument* doc = aForm->GetDocument(); if (doc) { - rv = doc->GetDocumentCharacterSet(oCharset); + oCharset = doc->GetDocumentCharacterSet(); } if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 86916b9bdbc..8ba16a1fec9 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -360,9 +360,11 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent, nsIDocument *doc = mNodeInfo->GetDocument(); - PRInt32 id = PR_INT32_MAX; + PRInt32 id; if (doc) { - doc->GetAndIncrementContentID(&id); + id = doc->GetAndIncrementContentID(); + } else { + id = PR_INT32_MAX; } aDst->SetContentID(id); @@ -598,8 +600,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, } while (next); - nsCOMPtr docElement; - mDocument->GetRootContent(getter_AddRefs(docElement)); + nsIContent *docElement = mDocument->GetRootContent(); // Find the frame parent whose content's tagName either matches // the tagName passed in or is the document element. @@ -907,9 +908,7 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML) PRBool scripts_enabled = PR_FALSE; if (doc) { - nsCOMPtr sgo; - - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); if (sgo) { sgo->GetContext(getter_AddRefs(scx)); @@ -1463,9 +1462,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext, // window to the front. We update the focus controller, but do // nothing else. nsCOMPtr focusController; - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); - nsCOMPtr win(do_QueryInterface(globalObj)); + nsCOMPtr win(do_QueryInterface(mDocument->GetScriptGlobalObject())); win->GetRootFocusController(getter_AddRefs(focusController)); PRBool isActive = PR_FALSE; focusController->GetActive(&isActive); @@ -1714,10 +1711,8 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, result = mAttributes->SetAttributeFor(aAttribute, aValue, mapped, this, sheet); if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aAttribute, aNameSpaceID, PR_FALSE, aNotify); @@ -1806,10 +1801,8 @@ nsGenericHTMLElement::SetAttr(nsINodeInfo* aNodeInfo, NS_ENSURE_SUCCESS(rv, rv); if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(localName, namespaceID, PR_FALSE, aNotify); @@ -1963,10 +1956,8 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute, } } - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aAttribute, kNameSpaceID_None, PR_TRUE, aNotify); @@ -2084,10 +2075,8 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, } if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(this, getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(this, getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aAttribute, aNameSpaceID, PR_TRUE, aNotify); @@ -2349,10 +2338,11 @@ nsGenericHTMLElement::GetBaseURL(nsIURI** aBaseURL) const // base class -- our base URL is determined solely by the document base. if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (doc) { - return doc->GetBaseURL(aBaseURL); + NS_IF_ADDREF(*aBaseURL = doc->GetBaseURL()); + } else { + *aBaseURL = nsnull; } - *aBaseURL = nsnull; return NS_OK; } @@ -2366,10 +2356,12 @@ nsGenericHTMLElement::GetBaseURL(const nsHTMLValue& aBaseHref, { nsresult result = NS_OK; - nsCOMPtr docBaseURL; + nsIURI* docBaseURL; if (aDocument) { - result = aDocument->GetBaseURL(getter_AddRefs(docBaseURL)); + docBaseURL = aDocument->GetBaseURL(); + } else { + docBaseURL = nsnull; } if (eHTMLUnit_String == aBaseHref.GetUnit()) { @@ -2400,7 +2392,7 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const } } if (nsnull != mDocument) { - result = mDocument->GetBaseTarget(aBaseTarget); + mDocument->GetBaseTarget(aBaseTarget); } else { aBaseTarget.Truncate(); @@ -2676,8 +2668,7 @@ nsGenericHTMLElement::GetLayoutHistoryAndKey(nsIHTMLContent* aContent, // Get the history (don't bother with the key if the history is not there) // nsresult rv; - nsCOMPtr container; - doc->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = doc->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { rv = docShell->GetLayoutHistoryState(aHistory); @@ -4607,14 +4598,11 @@ nsGenericHTMLElement::GetProtocolFromHrefString(const nsAString& aHref, } else { // set the protocol to the protocol of the base URI. - nsCOMPtr uri; - if (aDocument) { - aDocument->GetBaseURL(getter_AddRefs(uri)); - } - - if (uri) { - uri->GetScheme(protocol); + nsIURI *uri = aDocument->GetBaseURL(); + if (uri) { + uri->GetScheme(protocol); + } } if (protocol.IsEmpty()) { diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index 8ffdcd6bf51..5cbb48c1384 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -313,9 +313,7 @@ nsHTMLAnchorElement::RemoveFocus(nsIPresContext* aPresContext) if (!mDocument) return NS_ERROR_NULL_POINTER; - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - rv = esm->SetContentState(rootContent, NS_EVENT_STATE_FOCUS); + rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS); } return rv; @@ -361,8 +359,7 @@ nsHTMLAnchorElement::GetTarget(nsAString& aValue) nsresult rv; rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::target, aValue); if (rv == NS_CONTENT_ATTR_NOT_THERE && mDocument) { - rv = mDocument->GetBaseTarget(aValue); - NS_ENSURE_SUCCESS(rv, rv); + mDocument->GetBaseTarget(aValue); } return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 6d5a490f947..ba4b273dae0 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -432,8 +432,7 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor) // XXX This should just use nsGenericHTMLElement::GetPrimaryFrame() if (mDocument) { // Make sure the presentation is up-to-date - rv = mDocument->FlushPendingNotifications(); - NS_ENSURE_SUCCESS(rv, rv); + mDocument->FlushPendingNotifications(); } nsCOMPtr context; diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index ace47f0bed9..4560b16d5f6 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -362,9 +362,7 @@ nsHTMLButtonElement::RemoveFocus(nsIPresContext* aPresContext) if (!mDocument) return NS_ERROR_NULL_POINTER; - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - rv = esm->SetContentState(rootContent, NS_EVENT_STATE_FOCUS); + rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS); } return rv; diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index a8566baacd7..5005ee62439 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -998,9 +998,7 @@ nsHTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL, nsCOMPtr inst; *aCancelSubmit = PR_FALSE; - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr window = do_QueryInterface(globalObject); + nsCOMPtr window = do_QueryInterface(mDocument->GetScriptGlobalObject()); PRBool loop = PR_TRUE; while (NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) { @@ -1274,8 +1272,7 @@ nsHTMLFormElement::GetActionURL(nsIURI** aActionURL) } // Get base URL - nsCOMPtr docURL; - mDocument->GetDocumentURL(getter_AddRefs(docURL)); + nsIURI *docURL = mDocument->GetDocumentURL(); NS_ENSURE_TRUE(docURL, NS_ERROR_UNEXPECTED); // If an action is not specified and we are inside diff --git a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp index 3716f0823ad..af3fdef4eea 100644 --- a/mozilla/content/html/content/src/nsHTMLFrameElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFrameElement.cpp @@ -191,9 +191,7 @@ nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) return NS_OK; } - nsCOMPtr content_document; - - mDocument->GetSubDocumentFor(this, getter_AddRefs(content_document)); + nsIDocument* content_document = mDocument->GetSubDocumentFor(this); if (!content_document) { return NS_OK; @@ -219,10 +217,7 @@ nsHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow) return NS_OK; } - nsCOMPtr globalObj; - doc->GetScriptGlobalObject(getter_AddRefs(globalObj)); - - nsCOMPtr window (do_QueryInterface(globalObj)); + nsCOMPtr window (do_QueryInterface(doc->GetScriptGlobalObject())); *aContentWindow = window; NS_IF_ADDREF(*aContentWindow); diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index bba85eb9a6a..ef65c6bd830 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -171,8 +171,7 @@ NS_NewHTMLImageElement(nsIHTMLContent** aInstancePtrResult, nsCOMPtr doc(do_QueryInterface(dom_doc)); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - nsCOMPtr nodeInfoManager; - doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_UNEXPECTED); rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::img, nsnull, diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 5ef69540763..97bdb62054c 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -1054,14 +1054,12 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext) // window to the front. We update the focus controller, but do // nothing else. nsCOMPtr focusController; - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); - nsCOMPtr win(do_QueryInterface(globalObj)); + nsCOMPtr win(do_QueryInterface(mDocument->GetScriptGlobalObject())); win->GetRootFocusController(getter_AddRefs(focusController)); PRBool isActive = PR_FALSE; focusController->GetActive(&isActive); if (!isActive) { - nsCOMPtr domWin(do_QueryInterface(globalObj)); + nsCOMPtr domWin(do_QueryInterface(win)); focusController->SetFocusedWindow(domWin); focusController->SetFocusedElement(this); return NS_OK; @@ -1108,11 +1106,7 @@ nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext) if (!mDocument) return NS_ERROR_NULL_POINTER; - nsCOMPtr rootContent; - - mDocument->GetRootContent(getter_AddRefs(rootContent)); - - rv = esm->SetContentState(rootContent, NS_EVENT_STATE_FOCUS); + rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS); } return rv; @@ -1142,15 +1136,13 @@ nsHTMLInputElement::Select() // If the window is not active, do not allow the select to bring the // window to the front. We update the focus controller, but do // nothing else. - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); - nsCOMPtr win(do_QueryInterface(globalObj)); + nsCOMPtr win(do_QueryInterface(mDocument->GetScriptGlobalObject())); nsCOMPtr focusController; win->GetRootFocusController(getter_AddRefs(focusController)); PRBool isActive = PR_FALSE; focusController->GetActive(&isActive); if (!isActive) { - nsCOMPtr domWin(do_QueryInterface(globalObj)); + nsCOMPtr domWin(do_QueryInterface(win)); focusController->SetFocusedWindow(domWin); focusController->SetFocusedElement(this); SelectAll(presContext); diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index 0f1433651bd..fd6f516171c 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -229,8 +229,7 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument) return NS_OK; } - nsCOMPtr sub_doc; - mDocument->GetSubDocumentFor(this, getter_AddRefs(sub_doc)); + nsIDocument *sub_doc = mDocument->GetSubDocumentFor(this); if (!sub_doc) { return NS_OK; diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 4a7b1b47a36..d0fc597dd08 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -169,8 +169,7 @@ NS_NewHTMLOptionElement(nsIHTMLContent** aInstancePtrResult, nsCOMPtr doc(do_QueryInterface(dom_doc)); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - nsCOMPtr nodeInfoManager; - doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_UNEXPECTED); rv = nodeInfoManager->GetNodeInfo(nsHTMLAtoms::option, nsnull, diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index a55e201d88d..d47ae0da735 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -214,7 +214,7 @@ nsHTMLScriptEventHandler::Invoke(nsISupports *aTargetObject, nsCOMPtr doc(do_QueryInterface(domdoc)); if (doc) { - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + sgo = doc->GetScriptGlobalObject(); if (sgo) { sgo->GetContext(getter_AddRefs(scriptContext)); } @@ -652,8 +652,7 @@ nsHTMLScriptElement::MaybeProcessScript() // We'll always call this to make sure that // ScriptAvailable/ScriptEvaluated gets called. See bug 153600 nsresult rv = NS_OK; - nsCOMPtr loader; - mDocument->GetScriptLoader(getter_AddRefs(loader)); + nsCOMPtr loader = mDocument->GetScriptLoader(); if (loader) { mEvaluating = PR_TRUE; rv = loader->ProcessScriptElement(this, this); diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index bddcf59602a..6c638157c78 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -1727,10 +1727,7 @@ nsHTMLSelectElement::RemoveFocus(nsIPresContext* aPresContext) return NS_ERROR_NULL_POINTER; } - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - - rv = esm->SetContentState(rootContent, NS_EVENT_STATE_FOCUS); + rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS); } return rv; diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp index 0f1433651bd..fd6f516171c 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -229,8 +229,7 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument) return NS_OK; } - nsCOMPtr sub_doc; - mDocument->GetSubDocumentFor(this, getter_AddRefs(sub_doc)); + nsIDocument *sub_doc = mDocument->GetSubDocumentFor(this); if (!sub_doc) { return NS_OK; diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index bdae782102c..d6f93d82200 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -327,10 +327,7 @@ nsHTMLTextAreaElement::RemoveFocus(nsIPresContext* aPresContext) if (!mDocument) return NS_ERROR_NULL_POINTER; - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - - rv = esm->SetContentState(rootContent, NS_EVENT_STATE_FOCUS); + rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS); } return rv; diff --git a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp index 01d57064ebe..381e9cd33a4 100644 --- a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp @@ -216,8 +216,8 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID, } if (aNotify && mDocument) { - result = mDocument->AttributeChanged(this, aNameSpaceID, aAttribute, - nsIDOMMutationEvent::MODIFICATION); + mDocument->AttributeChanged(this, aNameSpaceID, aAttribute, + nsIDOMMutationEvent::MODIFICATION); } return result; diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index e5aa098c9e3..b3dbb98dcaa 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -956,9 +956,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode, mSkippedContent.Truncate(); } - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - (*aResult)->SetContentID(id); + (*aResult)->SetContentID(mDocument->GetAndIncrementContentID()); return rv; } @@ -2094,12 +2092,10 @@ IsScriptEnabled(nsIDocument *aDoc, nsIDocShell *aContainer) do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID); NS_ENSURE_TRUE(securityManager, PR_TRUE); - nsCOMPtr principal; - aDoc->GetPrincipal(getter_AddRefs(principal)); + nsIPrincipal *principal = aDoc->GetPrincipal(); NS_ENSURE_TRUE(principal, PR_TRUE); - nsCOMPtr globalObject; - aDoc->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsCOMPtr globalObject = aDoc->GetScriptGlobalObject(); // Getting context is tricky if the document hasn't had it's // GlobalObject set yet @@ -2246,8 +2242,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, NS_ENSURE_SUCCESS(rv, rv); // Make root part - nsCOMPtr doc_root; - mDocument->GetRootContent(getter_AddRefs(doc_root)); + nsIContent *doc_root = mDocument->GetRootContent(); if (doc_root) { // If the document already has a root we'll use it. This will @@ -2412,8 +2407,7 @@ HTMLContentSink::DidBuildModel(void) } } - nsCOMPtr loader; - mDocument->GetScriptLoader(getter_AddRefs(loader)); + nsIScriptLoader *loader = mDocument->GetScriptLoader(); if (loader) { loader->RemoveObserver(this); } @@ -3940,7 +3934,7 @@ HTMLContentSink::ProcessBaseHref(const nsAString& aBaseHref) rv = mDocument->SetBaseURL(baseHrefURI); if (NS_SUCCEEDED(rv)) { - mDocument->GetBaseURL(getter_AddRefs(mDocumentBaseURL)); + mDocumentBaseURL = mDocument->GetBaseURL(); } } else { // NAV compatibility quirk @@ -4040,9 +4034,7 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) result = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); NS_ENSURE_SUCCESS(result, result); - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - element->SetContentID(id); + element->SetContentID(mDocument->GetAndIncrementContentID()); // Add in the attributes and add the style content object to the // head container. @@ -4098,9 +4090,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) result = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); NS_ENSURE_SUCCESS(result, result); - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - element->SetContentID(id); + element->SetContentID(mDocument->GetAndIncrementContentID()); nsCOMPtr ssle(do_QueryInterface(element)); @@ -4431,9 +4421,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) return rv; } - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - element->SetContentID(id); + element->SetContentID(mDocument->GetAndIncrementContentID()); // Add in the attributes and add the style content object to the // head container. @@ -4476,7 +4464,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) // Fix bug 82498 // We don't want to evaluate scripts in a frameset document. if (mDocument) { - mDocument->GetScriptLoader(getter_AddRefs(loader)); + loader = mDocument->GetScriptLoader(); if (loader) { loader->SetEnabled(PR_FALSE); } @@ -4548,9 +4536,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) rv = NS_CreateHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - element->SetContentID(id); + element->SetContentID(mDocument->GetAndIncrementContentID()); nsCOMPtr ssle = do_QueryInterface(element); @@ -4663,7 +4649,7 @@ HTMLContentSink::SetDocumentCharset(nsACString& aCharset) } if (mDocument) { - return mDocument->SetDocumentCharacterSet(aCharset); + mDocument->SetDocumentCharacterSet(aCharset); } return NS_OK; @@ -4685,8 +4671,7 @@ HTMLContentSink::DumpContentModel() FILE* out = ::fopen("rtest_html.txt", "a"); if (out) { if (mDocument) { - nsIContent* root = nsnull; - mDocument->GetRootContent(&root); + nsIContent* root = mDocument->GetRootContent(); if (root) { if (mDocumentURL) { nsCAutoString buf; @@ -4697,7 +4682,6 @@ HTMLContentSink::DumpContentModel() fputs(";", out); result = root->DumpContent(out, 0, PR_FALSE); fputs(";\n", out); - NS_RELEASE(root); } } @@ -4727,10 +4711,7 @@ HTMLContentSink::AddDummyParserRequest(void) nsCOMPtr loadGroup; if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) { - return rv; - } + loadGroup = mDocument->GetDocumentLoadGroup(); } if (loadGroup) { @@ -4752,7 +4733,7 @@ HTMLContentSink::RemoveDummyParserRequest(void) nsCOMPtr loadGroup; if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + loadGroup = mDocument->GetDocumentLoadGroup(); } if (loadGroup && mDummyParserRequest) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index af8ce9085d5..aee838e6fac 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -375,31 +375,27 @@ nsHTMLDocument::Init() } -NS_IMETHODIMP +void nsHTMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) { - nsresult rv = nsDocument::Reset(aChannel, aLoadGroup); + nsDocument::Reset(aChannel, aLoadGroup); - if (NS_SUCCEEDED(rv) && aChannel) { + if (aChannel) { aChannel->GetLoadFlags(&mLoadFlags); } - - return rv; } -NS_IMETHODIMP +void nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup) { mLoadFlags = nsIRequest::LOAD_NORMAL; - nsresult rv = nsDocument::ResetToURI(aURI, aLoadGroup); - NS_ENSURE_SUCCESS(rv, rv); - - return BaseResetToURI(aURI); + nsDocument::ResetToURI(aURI, aLoadGroup); + BaseResetToURI(aURI); } -nsresult +void nsHTMLDocument::BaseResetToURI(nsIURI *aURL) { nsresult rv = NS_OK; @@ -454,8 +450,6 @@ nsHTMLDocument::BaseResetToURI(nsIURI *aURL) // document, after all. Once we start getting data, this may be // changed. mContentType = "text/html"; - - return rv; } @@ -1062,7 +1056,7 @@ nsHTMLDocument::DocumentWriteTerminationFunc(nsISupports *aRef) htmldoc->EndLoad(); } -NS_IMETHODIMP +void nsHTMLDocument::EndLoad() { if (mParser) { @@ -1096,14 +1090,14 @@ nsHTMLDocument::EndLoad() scx->SetTerminationFunction(DocumentWriteTerminationFunc, NS_STATIC_CAST(nsIDocument *, this)); - return NS_OK; + return; } } } } mParser = nsnull; - return nsDocument::EndLoad(); + nsDocument::EndLoad(); } NS_IMETHODIMP @@ -1263,14 +1257,12 @@ nsHTMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, mStyleSheets.InsertObjectAt(aSheet, aIndex + 1); } -already_AddRefed -nsHTMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) +nsIStyleSheet* +nsHTMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) const { PRInt32 count = InternalGetNumberOfStyleSheets(); if (aIndex >= 0 && aIndex < count) { - nsIStyleSheet* sheet = mStyleSheets[aIndex + 1]; - NS_ADDREF(sheet); - return sheet; + return mStyleSheets[aIndex + 1]; } else { NS_ERROR("Index out of range"); return nsnull; @@ -1278,7 +1270,7 @@ nsHTMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) } PRInt32 -nsHTMLDocument::InternalGetNumberOfStyleSheets() +nsHTMLDocument::InternalGetNumberOfStyleSheets() const { PRInt32 count = mStyleSheets.Count(); if (count != 0 && mStyleAttrStyleSheet == mStyleSheets[count - 1]) @@ -1288,20 +1280,16 @@ nsHTMLDocument::InternalGetNumberOfStyleSheets() return count; } -NS_IMETHODIMP -nsHTMLDocument::GetBaseTarget(nsAString& aTarget) +void +nsHTMLDocument::GetBaseTarget(nsAString& aTarget) const { aTarget.Assign(mBaseTarget); - - return NS_OK; } -NS_IMETHODIMP +void nsHTMLDocument::SetBaseTarget(const nsAString& aTarget) { mBaseTarget = aTarget; - - return NS_OK; } NS_IMETHODIMP @@ -1359,7 +1347,7 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode) return NS_OK; } -NS_IMETHODIMP +void nsHTMLDocument::ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer) { @@ -1373,10 +1361,10 @@ nsHTMLDocument::ContentAppended(nsIContent* aContainer, RegisterNamedItems(aContainer->GetChildAt(i)); } - return nsDocument::ContentAppended(aContainer, aNewIndexInContainer); + nsDocument::ContentAppended(aContainer, aNewIndexInContainer); } -NS_IMETHODIMP +void nsHTMLDocument::ContentInserted(nsIContent* aContainer, nsIContent* aContent, PRInt32 aIndexInContainer) { @@ -1385,13 +1373,13 @@ nsHTMLDocument::ContentInserted(nsIContent* aContainer, nsIContent* aContent, nsresult rv = RegisterNamedItems(aContent); if (NS_FAILED(rv)) { - return rv; + return; } - return nsDocument::ContentInserted(aContainer, aContent, aIndexInContainer); + nsDocument::ContentInserted(aContainer, aContent, aIndexInContainer); } -NS_IMETHODIMP +void nsHTMLDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, nsIContent* aNewChild, PRInt32 aIndexInContainer) @@ -1401,20 +1389,20 @@ nsHTMLDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, nsresult rv = UnregisterNamedItems(aOldChild); if (NS_FAILED(rv)) { - return rv; + return; } rv = RegisterNamedItems(aNewChild); if (NS_FAILED(rv)) { - return rv; + return; } - return nsDocument::ContentReplaced(aContainer, aOldChild, - aNewChild, aIndexInContainer); + nsDocument::ContentReplaced(aContainer, aOldChild, + aNewChild, aIndexInContainer); } -NS_IMETHODIMP +void nsHTMLDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aContent, PRInt32 aIndexInContainer) { @@ -1423,13 +1411,13 @@ nsHTMLDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aContent, nsresult rv = UnregisterNamedItems(aContent); if (NS_FAILED(rv)) { - return rv; + return; } - return nsDocument::ContentRemoved(aContainer, aContent, aIndexInContainer); + nsDocument::ContentRemoved(aContainer, aContent, aIndexInContainer); } -NS_IMETHODIMP +void nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute) { @@ -1447,7 +1435,7 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, nsresult rv = RemoveFromNameTable(value, aContent); if (NS_FAILED(rv)) { - return rv; + return; } } } else if (aAttribute == aContent->GetIDAttributeName() && @@ -1455,14 +1443,14 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, nsresult rv = RemoveFromIdTable(aContent); if (NS_FAILED(rv)) { - return rv; + return; } } - return nsDocument::AttributeWillChange(aContent, aNameSpaceID, aAttribute); + nsDocument::AttributeWillChange(aContent, aNameSpaceID, aAttribute); } -NS_IMETHODIMP +void nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { @@ -1480,7 +1468,7 @@ nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsresult rv = UpdateNameTableEntry(value, aContent); if (NS_FAILED(rv)) { - return rv; + return; } } } else if (aAttribute == aContent->GetIDAttributeName() && @@ -1495,16 +1483,15 @@ nsHTMLDocument::AttributeChanged(nsIContent* aContent, PRInt32 aNameSpaceID, nsresult rv = AddToIdTable(value, aContent); if (NS_FAILED(rv)) { - return rv; + return; } } } - return nsDocument::AttributeChanged(aContent, aNameSpaceID, aAttribute, - aModType); + nsDocument::AttributeChanged(aContent, aNameSpaceID, aAttribute, aModType); } -NS_IMETHODIMP +void nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows, PRBool aUpdateViews) { @@ -1531,11 +1518,12 @@ nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows, sink = mParser->GetContentSink(); if (sink) { nsresult rv = sink->FlushPendingNotifications(); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; } } - return nsDocument::FlushPendingNotifications(aFlushReflows, aUpdateViews); + nsDocument::FlushPendingNotifications(aFlushReflows, aUpdateViews); } NS_IMETHODIMP_(PRBool) @@ -2270,14 +2258,10 @@ nsHTMLDocument::SetCookie(const nsAString& aCookie) nsresult rv = NS_OK; nsCOMPtr service = do_GetService(kCookieServiceCID, &rv); if (service && mDocumentURL) { - nsCOMPtr globalObj; nsCOMPtr prompt; - this->GetScriptGlobalObject(getter_AddRefs(globalObj)); - if (globalObj) { - nsCOMPtr window (do_QueryInterface(globalObj)); - if (window) { - window->GetPrompter(getter_AddRefs(prompt)); - } + nsCOMPtr window (do_QueryInterface(GetScriptGlobalObject())); + if (window) { + window->GetPrompter(getter_AddRefs(prompt)); } nsCOMPtr codebaseURI; @@ -2320,7 +2304,7 @@ nsHTMLDocument::GetSourceDocumentURL(nsIURI** sourceURL) return NS_OK; // No document in the window } - doc->GetDocumentURL(sourceURL); + NS_IF_ADDREF(*sourceURL = doc->GetDocumentURL()); return sourceURL ? NS_OK : NS_ERROR_FAILURE; } @@ -2416,10 +2400,7 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL) // the anonymous content (i.e. scrollbar elements) is set to // null. - rv = Reset(channel, group); - if (NS_FAILED(rv)) { - return rv; - } + Reset(channel, group); if (root) { // Tear down the frames for the root element. @@ -2871,8 +2852,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, { *aWidth = *aHeight = 0; - nsresult rv = FlushPendingNotifications(); - NS_ENSURE_SUCCESS(rv, rv); + FlushPendingNotifications(); // Find the element: this is what we'll want to use for the // document's width and height values. @@ -2884,7 +2864,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, // Now grab its frame nsIFrame* frame; - rv = aShell->GetPrimaryFrameFor(body, &frame); + nsresult rv = aShell->GetPrimaryFrameFor(body, &frame); if (NS_SUCCEEDED(rv) && frame) { nsSize size; nsCOMPtr presContext; @@ -3746,18 +3726,14 @@ nsHTMLDocument::ResolveName(const nsAString& aName, PRBool nsHTMLDocument::GetBodyContent() { - nsCOMPtr root; - - GetRootContent(getter_AddRefs(root)); - - if (!root) { + if (!mRootContent) { return PR_FALSE; } - PRUint32 i, child_count = root->GetChildCount(); + PRUint32 i, child_count = mRootContent->GetChildCount(); for (i = 0; i < child_count; ++i) { - nsIContent *child = root->GetChildAt(i); + nsIContent *child = mRootContent->GetChildAt(i); NS_ENSURE_TRUE(child, NS_ERROR_UNEXPECTED); if (child->IsContentOfType(nsIContent::eHTML) && @@ -3833,9 +3809,7 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void) channel->SetLoadFlags(mLoadFlags); } - nsCOMPtr loadGroup; - rv = GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr loadGroup = GetDocumentLoadGroup(); // Use the Parent document's loadgroup to trigger load notifications if (loadGroup && channel) { @@ -3861,9 +3835,7 @@ nsHTMLDocument::RemoveWyciwygChannel(void) { nsresult rv = NS_OK; - nsCOMPtr loadGroup; - rv = GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr loadGroup = GetDocumentLoadGroup(); // note there can be a write request without a load group if // this is a synchronously constructed about:blank document diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 05478a4aaa4..aaa909b03be 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -86,8 +86,8 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(void); NS_IMETHOD_(nsrefcnt) Release(void); - NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); - NS_IMETHOD ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup); + virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); + virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup); NS_IMETHOD CreateShell(nsIPresContext* aContext, nsIViewManager* aViewManager, @@ -104,7 +104,7 @@ public: NS_IMETHOD StopDocumentLoad(); - NS_IMETHOD EndLoad(); + virtual void EndLoad(); NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap); @@ -117,8 +117,8 @@ public: NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aStyleSheet); NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader); - NS_IMETHOD GetBaseTarget(nsAString& aTarget); - NS_IMETHOD SetBaseTarget(const nsAString& aTarget); + virtual void GetBaseTarget(nsAString& aTarget) const; + virtual void SetBaseTarget(const nsAString& aTarget); NS_IMETHOD SetReferrer(const nsAString& aReferrer); @@ -130,28 +130,28 @@ public: return mWriteLevel != PRUint32(0); } - NS_IMETHOD ContentAppended(nsIContent* aContainer, - PRInt32 aNewIndexInContainer); - NS_IMETHOD ContentInserted(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - NS_IMETHOD ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); - NS_IMETHOD ContentRemoved(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); - NS_IMETHOD AttributeChanged(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute, - PRInt32 aModType); - NS_IMETHOD AttributeWillChange(nsIContent* aChild, - PRInt32 aNameSpaceID, - nsIAtom* aAttribute); + virtual void ContentAppended(nsIContent* aContainer, + PRInt32 aNewIndexInContainer); + virtual void ContentInserted(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + virtual void ContentReplaced(nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer); + virtual void ContentRemoved(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + virtual void AttributeChanged(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + virtual void AttributeWillChange(nsIContent* aChild, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute); - NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE, - PRBool aUpdateViews = PR_FALSE); + virtual void FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE, + PRBool aUpdateViews = PR_FALSE); NS_IMETHOD_(PRBool) IsCaseSensitive(); @@ -230,8 +230,8 @@ protected: PRUint32 aFlags); virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex); - virtual already_AddRefed InternalGetStyleSheetAt(PRInt32 aIndex); - virtual PRInt32 InternalGetNumberOfStyleSheets(); + virtual nsIStyleSheet* InternalGetStyleSheetAt(PRInt32 aIndex) const; + virtual PRInt32 InternalGetNumberOfStyleSheets() const; static PRBool MatchLinks(nsIContent *aContent, nsString* aData); static PRBool MatchAnchors(nsIContent *aContent, nsString* aData); @@ -256,7 +256,7 @@ protected: nsresult CreateAndAddWyciwygChannel(void); nsresult RemoveWyciwygChannel(void); - nsresult BaseResetToURI(nsIURI* aURI); + void BaseResetToURI(nsIURI* aURI); virtual void RetrieveRelevantHeaders(nsIChannel *aChannel); diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index 2b60800eb38..acd36a654f9 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -726,7 +726,7 @@ NS_IMETHODIMP nsHTMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument) { if (aTargetDocument) { - aTargetDocument->GetNodeInfoManager(getter_AddRefs(mNodeInfoManager)); + mNodeInfoManager = aTargetDocument->GetNodeInfoManager(); } if (mNodeInfoManager) { diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 893f64e9626..aace7f245cd 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -95,7 +95,7 @@ public: PRBool aReset = PR_TRUE, nsIContentSink* aSink = nsnull); - NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject); + virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject); NS_DECL_NSIIMAGEDOCUMENT @@ -253,7 +253,7 @@ nsImageDocument::StartDocumentLoad(const char* aCommand, return NS_OK; } -NS_IMETHODIMP +void nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) { if (!aScriptGlobalObject) { @@ -273,16 +273,13 @@ nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObjec // Set the script global object on the superclass before doing // anything that might require it.... - nsresult rv = nsHTMLDocument::SetScriptGlobalObject(aScriptGlobalObject); - if (NS_FAILED(rv)) { - return rv; - } + nsHTMLDocument::SetScriptGlobalObject(aScriptGlobalObject); if (aScriptGlobalObject) { // Create synthetic document - rv = CreateSyntheticDocument(); + nsresult rv = CreateSyntheticDocument(); if (NS_FAILED(rv)) { - return rv; + return; } if (mImageResizingEnabled) { @@ -294,8 +291,6 @@ nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObjec target->AddEventListener(NS_LITERAL_STRING("keypress"), this, PR_FALSE); } } - - return NS_OK; } diff --git a/mozilla/content/html/document/src/nsPluginDocument.cpp b/mozilla/content/html/document/src/nsPluginDocument.cpp index 0de5ab98503..4f66f6b7c02 100644 --- a/mozilla/content/html/document/src/nsPluginDocument.cpp +++ b/mozilla/content/html/document/src/nsPluginDocument.cpp @@ -61,7 +61,7 @@ public: PRBool aReset = PR_TRUE, nsIContentSink* aSink = nsnull); - NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject); + virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject); protected: nsresult CreateSyntheticPluginDocument(); @@ -91,13 +91,14 @@ NS_INTERFACE_MAP_BEGIN(nsPluginDocument) NS_INTERFACE_MAP_END_INHERITING(nsMediaDocument) -NS_IMETHODIMP nsPluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) +void +nsPluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject) { if (!aScriptGlobalObject) { mStreamListener = nsnull; } - return nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject); + nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject); } diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp index 351640e5733..e69de9f1b70 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.cpp +++ b/mozilla/content/html/style/src/nsCSSLoader.cpp @@ -613,7 +613,7 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader, if (aCharset.IsEmpty() && mLoader->mDocument) { // no useful data on charset. Try the document charset. // That needs no resolution, since it's already fully resolved - mLoader->mDocument->GetDocumentCharacterSet(aCharset); + aCharset = mLoader->mDocument->GetDocumentCharacterSet(); #ifdef DEBUG_bzbarsky fprintf(stderr, "Set from document: %s\n", PromiseFlatCString(aCharset).get()); @@ -926,11 +926,10 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI, return NS_OK; } - nsCOMPtr globalObject; - rv = mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - if (NS_FAILED(rv) || !globalObject) { + nsIScriptGlobalObject *globalObject = mDocument->GetScriptGlobalObject(); + if (!globalObject) { LOG((" No script global object")); - return rv; + return NS_OK; } nsCOMPtr domWin(do_QueryInterface(globalObject)); @@ -1111,8 +1110,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, // XXX Need to cancel pending sheet loads for this element, if any - PRInt32 sheetCount; - aDocument->GetNumberOfStyleSheets(PR_FALSE, &sheetCount); + PRInt32 sheetCount = aDocument->GetNumberOfStyleSheets(PR_FALSE); /* * Start the walk at the _end_ of the list, since in the typical @@ -1124,9 +1122,8 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, */ PRInt32 insertionPoint; for (insertionPoint = sheetCount - 1; insertionPoint >= 0; --insertionPoint) { - nsCOMPtr curSheet; - aDocument->GetStyleSheetAt(insertionPoint, PR_FALSE, - getter_AddRefs(curSheet)); + nsIStyleSheet *curSheet = aDocument->GetStyleSheetAt(insertionPoint, + PR_FALSE); NS_ASSERTION(curSheet, "There must be a sheet here!"); nsCOMPtr domSheet = do_QueryInterface(curSheet); NS_ASSERTION(domSheet, "All the \"normal\" sheets implement nsIDOMStyleSheet"); @@ -1330,7 +1327,7 @@ CSSLoaderImpl::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) #endif nsCOMPtr loadGroup; if (mDocument) { - mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + loadGroup = mDocument->GetDocumentLoadGroup(); NS_ASSERTION(loadGroup, "No loadgroup for stylesheet; onload will fire early"); } @@ -1358,8 +1355,7 @@ CSSLoaderImpl::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) NS_LITERAL_CSTRING("text/css,*/*;q=0.1"), PR_FALSE); if (mDocument) { - nsCOMPtr documentURI; - mDocument->GetDocumentURL(getter_AddRefs(documentURI)); + nsIURI *documentURI = mDocument->GetDocumentURL(); NS_ASSERTION(documentURI, "Null document uri is bad!"); if (documentURI) { httpChannel->SetReferrer(documentURI); @@ -1645,10 +1641,9 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_INITIALIZED); // Check whether we should even load - nsCOMPtr docURI; - nsresult rv = mDocument->GetDocumentURL(getter_AddRefs(docURI)); - if (NS_FAILED(rv) || !docURI) return NS_ERROR_FAILURE; - rv = CheckLoadAllowed(docURI, aURL, aElement); + nsIURI *docURI = mDocument->GetDocumentURL(); + if (!docURI) return NS_ERROR_FAILURE; + nsresult rv = CheckLoadAllowed(docURI, aURL, aElement); if (NS_FAILED(rv)) return rv; LOG((" Passed load check")); diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index 5ee740147f3..f148eeb6e8a 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -1224,8 +1224,7 @@ DOMMediaListImpl::GetMediaText(nsAString& aMediaText) } \ /* XXXldb Pass something meaningful? */ \ if (doc) { \ - rv = doc->StyleRuleChanged(sheet, nsnull, nsnull); \ - NS_ENSURE_SUCCESS(rv, rv); \ + doc->StyleRuleChanged(sheet, nsnull, nsnull); \ } @@ -2780,8 +2779,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, } } if (mDocument && notify) { - result = mDocument->StyleRuleAdded(this, cssRule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleAdded(this, cssRule); } } @@ -2824,8 +2822,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) DidDirty(); if (mDocument) { - result = mDocument->StyleRuleRemoved(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleRemoved(this, rule); } } } @@ -2865,8 +2862,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) DidDirty(); if (mDocument) { - result = mDocument->StyleRuleRemoved(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleRemoved(this, rule); } return NS_OK; @@ -2940,8 +2936,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* rule = dont_AddRef((nsICSSRule*)rules->ElementAt(counter)); if (mDocument) { - result = mDocument->StyleRuleAdded(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleAdded(this, rule); } } @@ -2999,8 +2994,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) // they do)! nsCOMPtr styleRule(do_QueryInterface(ownerRule)); - nsresult rv = mDocument->StyleRuleAdded(this, styleRule); - NS_ENSURE_SUCCESS(rv, rv); + mDocument->StyleRuleAdded(this, styleRule); } return NS_OK; @@ -3567,24 +3561,24 @@ static PRBool SelectorMatches(RuleProcessorData &data, // The content language can be a comma-separated list of // language codes. nsAutoString language; - if (NS_SUCCEEDED(doc->GetContentLanguage(language))) { - nsDependentString langString(pseudoClass->mString); - language.StripWhitespace(); - PRInt32 begin = 0; - PRInt32 len = language.Length(); - while (begin < len) { - PRInt32 end = language.FindChar(PRUnichar(','), begin); - if (end == kNotFound) { - end = len; - } - if (DashMatchCompare(Substring(language, begin, end-begin), - langString, - PR_FALSE)) { - result = localTrue; - break; - } - begin = end + 1; + doc->GetContentLanguage(language); + + nsDependentString langString(pseudoClass->mString); + language.StripWhitespace(); + PRInt32 begin = 0; + PRInt32 len = language.Length(); + while (begin < len) { + PRInt32 end = language.FindChar(PRUnichar(','), begin); + if (end == kNotFound) { + end = len; } + if (DashMatchCompare(Substring(language, begin, end-begin), + langString, + PR_FALSE)) { + result = localTrue; + break; + } + begin = end + 1; } } } diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index c1f919dd65a..d2061e7d10d 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -573,11 +573,8 @@ nsBindingManager::ChangeDocumentFor(nsIContent* aContent, nsIDocument* aOldDocum if (binding) { binding->ChangeDocument(aOldDocument, aNewDocument); SetBinding(aContent, nsnull); - if (aNewDocument) { - nsCOMPtr otherManager; - aNewDocument->GetBindingManager(getter_AddRefs(otherManager)); - otherManager->SetBinding(aContent, binding); - } + if (aNewDocument) + aNewDocument->GetBindingManager()->SetBinding(aContent, binding); } // Clear out insertion parents and content lists. @@ -894,10 +891,8 @@ nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, if (!ioService) return NS_ERROR_FAILURE; ioService->ExtractScheme(url, otherScheme); - nsCOMPtr docURL; - aBoundDoc->GetDocumentURL(getter_AddRefs(docURL)); nsCAutoString scheme; - docURL->GetScheme(scheme); + aBoundDoc->GetDocumentURL()->GetScheme(scheme); // First we need to load our binding. *aResult = nsnull; @@ -988,10 +983,8 @@ nsBindingManager::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) nsCOMPtr doc; aDocumentInfo->GetDocument(getter_AddRefs(doc)); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); nsCAutoString str; - uri->GetSpec(str); + doc->GetDocumentURL()->GetSpec(str); StringToObjectEntry* entry = mDocumentTable.AddEntry(str); if (!entry) return NS_ERROR_OUT_OF_MEMORY; @@ -1009,10 +1002,8 @@ nsBindingManager::RemoveXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) nsCOMPtr doc; aDocumentInfo->GetDocument(getter_AddRefs(doc)); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); nsCAutoString str; - uri->GetSpec(str); + doc->GetDocumentURL()->GetSpec(str); mDocumentTable.Remove(str); return NS_OK; @@ -1181,8 +1172,7 @@ nsBindingManager::GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, if (!doc) return NS_NOINTERFACE; - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (!global) return NS_NOINTERFACE; diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index a5562ddf505..328ad908565 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -536,8 +536,7 @@ nsXBLBinding::GenerateAnonymousContent() if (! doc) return NS_OK; - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); nsCOMPtr children; bindingManager->GetContentListFor(mBoundElement, getter_AddRefs(children)); @@ -949,8 +948,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen GetImmediateChild(nsXBLAtoms::implementation, getter_AddRefs(interfaceElement)); if (interfaceElement) { - nsCOMPtr global; - aOldDocument->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = aOldDocument->GetScriptGlobalObject(); if (global) { nsCOMPtr context; global->GetContext(getter_AddRefs(context)); @@ -1296,8 +1294,7 @@ nsXBLBinding::AddScriptEventListener(nsIContent* aElement, nsIAtom* aName, if (!receiver) return NS_OK; - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = document->GetScriptGlobalObject(); // This can happen normally as part of teardown code. if (!global) diff --git a/mozilla/content/xbl/src/nsXBLContentSink.cpp b/mozilla/content/xbl/src/nsXBLContentSink.cpp index 5ba19c60d10..962ebe2f5b3 100644 --- a/mozilla/content/xbl/src/nsXBLContentSink.cpp +++ b/mozilla/content/xbl/src/nsXBLContentSink.cpp @@ -339,12 +339,9 @@ nsXBLContentSink::OnOpenContainer(const PRUnichar **aAtts, if (!mDocInfo) return NS_ERROR_FAILURE; - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->PutXBLDocumentInfo(mDocInfo); + mDocument->GetBindingManager()->PutXBLDocumentInfo(mDocInfo); - nsCOMPtr url; - mDocument->GetDocumentURL(getter_AddRefs(url)); + nsIURI *url = mDocument->GetDocumentURL(); PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; diff --git a/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp b/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp index d45591cd682..db5c907a685 100644 --- a/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/mozilla/content/xbl/src/nsXBLDocumentInfo.cpp @@ -48,6 +48,7 @@ #include "nsIConsoleService.h" #include "nsIScriptError.h" #include "nsIChromeRegistry.h" +#include "nsIPrincipal.h" static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); @@ -338,7 +339,12 @@ nsXBLDocGlobalObject::GetPrincipal(nsIPrincipal** aPrincipal) rv = docInfo->GetDocument(getter_AddRefs(document)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - return document->GetPrincipal(aPrincipal); + *aPrincipal = document->GetPrincipal(); + if (!*aPrincipal) + return NS_ERROR_FAILURE; + + NS_ADDREF(*aPrincipal); + return NS_OK; } static PRBool IsChromeOrResourceURI(nsIURI* aURI) @@ -362,8 +368,7 @@ nsXBLDocumentInfo::nsXBLDocumentInfo(const char* aDocURI, nsIDocument* aDocument mScriptAccess = PR_TRUE; mBindingTable = nsnull; - nsCOMPtr uri; - mDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = mDocument->GetDocumentURL(); if (IsChromeOrResourceURI(uri)) { // Cache whether or not this chrome XBL can execute scripts. nsCOMPtr reg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID)); @@ -478,11 +483,8 @@ nsXBLDocumentInfo::ReportScriptError(nsIScriptError *errorObject) nsresult NS_NewXBLDocumentInfo(nsIDocument* aDocument, nsIXBLDocumentInfo** aResult) { - nsCOMPtr url; - aDocument->GetDocumentURL(getter_AddRefs(url)); - nsCAutoString str; - url->GetSpec(str); + aDocument->GetDocumentURL()->GetSpec(str); *aResult = new nsXBLDocumentInfo(str.get(), aDocument); diff --git a/mozilla/content/xbl/src/nsXBLProtoImpl.cpp b/mozilla/content/xbl/src/nsXBLProtoImpl.cpp index e19ed8a30fe..f116a33a653 100644 --- a/mozilla/content/xbl/src/nsXBLProtoImpl.cpp +++ b/mozilla/content/xbl/src/nsXBLProtoImpl.cpp @@ -59,8 +59,7 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aBinding, nsIConten nsIDocument* document = aBoundElement->GetDocument(); if (!document) return NS_OK; - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = document->GetScriptGlobalObject(); if (!global) return NS_OK; nsCOMPtr context; diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index 2ef6ae21009..b888758ced1 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -793,10 +793,9 @@ nsXBLPrototypeBinding::LocateInstance(nsIContent* aBoundElement, // First we have to locate this insertion point and use its index and its // count to detemine our precise position within the template. nsIDocument* doc = aBoundElement->GetDocument(); - nsCOMPtr bm; - doc->GetBindingManager(getter_AddRefs(bm)); nsCOMPtr binding; - bm->GetBinding(aBoundElement, getter_AddRefs(binding)); + doc->GetBindingManager()->GetBinding(aBoundElement, + getter_AddRefs(binding)); nsCOMPtr currBinding = binding; nsCOMPtr anonContent; diff --git a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp index c3913cedfa7..c17a8e61c50 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -280,9 +280,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - privateWindow = do_QueryInterface(globalObject); + privateWindow = do_QueryInterface(doc->GetScriptGlobalObject()); } privateWindow->GetRootFocusController(getter_AddRefs(focusController)); @@ -389,7 +387,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, return NS_OK; } - boundDocument->GetScriptGlobalObject(getter_AddRefs(boundGlobal)); + boundGlobal = boundDocument->GetScriptGlobalObject(); } // If we still don't have a 'boundGlobal', we're doomed. bug 95465. diff --git a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp index 3085125514b..28c78fa4c8f 100644 --- a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp +++ b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp @@ -105,8 +105,7 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult) nsCOMPtr doc; info->GetDocument(getter_AddRefs(doc)); - nsCOMPtr docURL; - doc->GetDocumentURL(getter_AddRefs(docURL)); + nsIURI *docURL = doc->GetDocumentURL(); nsCOMPtr url; diff --git a/mozilla/content/xbl/src/nsXBLService.cpp b/mozilla/content/xbl/src/nsXBLService.cpp index b5f44fd3d97..f01f85839e1 100644 --- a/mozilla/content/xbl/src/nsXBLService.cpp +++ b/mozilla/content/xbl/src/nsXBLService.cpp @@ -390,25 +390,20 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent) } // Remove ourselves from the set of pending docs. - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); - nsCOMPtr uri; - mBindingDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); + nsIURI *uri = mBindingDocument->GetDocumentURL(); nsCAutoString str; uri->GetSpec(str); bindingManager->RemoveLoadingDocListener(str); - nsCOMPtr root; - mBindingDocument->GetRootContent(getter_AddRefs(root)); - if (!root) { + if (!mBindingDocument->GetRootContent()) { NS_ERROR("*** XBL doc with no root element! Something went horribly wrong! ***"); return NS_ERROR_FAILURE; } // Put our doc info in the doc table. nsCOMPtr info; - nsCOMPtr xblDocBindingManager; - mBindingDocument->GetBindingManager(getter_AddRefs(xblDocBindingManager)); + nsIBindingManager *xblDocBindingManager = mBindingDocument->GetBindingManager(); xblDocBindingManager->GetXBLDocumentInfo(str, getter_AddRefs(info)); xblDocBindingManager->RemoveXBLDocumentInfo(info); // Break the self-imposed cycle. if (!info) { @@ -542,8 +537,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl if (!document) return NS_OK; - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = document->GetBindingManager(); nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); @@ -574,9 +568,7 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL, PRBool aAugmentFl } // Security check - remote pages can't load local bindings, except from chrome - nsCOMPtr docURI; - rv = document->GetDocumentURL(getter_AddRefs(docURI)); - NS_ENSURE_SUCCESS(rv, rv); //XXX can a document have no URI here? + nsIURI *docURI = document->GetDocumentURL(); PRBool isChrome = PR_FALSE; rv = docURI->SchemeIs("chrome", &isChrome); @@ -666,8 +658,7 @@ nsXBLService::FlushStyleBindings(nsIContent* aContent) if (! document) return NS_OK; - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = document->GetBindingManager(); nsCOMPtr binding; bindingManager->GetBinding(aContent, getter_AddRefs(binding)); @@ -695,8 +686,7 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** { nsIDocument* document = aContent->GetDocument(); if (document) { - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = document->GetBindingManager(); if (bindingManager) return bindingManager->ResolveTag(aContent, aNameSpaceID, aResult); @@ -726,11 +716,8 @@ nsXBLService::GetXBLDocumentInfo(const nsCString& aURLStr, nsIContent* aBoundEle if (!*aResult) { // The second line of defense is the binding manager's document table. nsIDocument* boundDocument = aBoundElement->GetDocument(); - if (boundDocument) { - nsCOMPtr bindingManager; - boundDocument->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->GetXBLDocumentInfo(aURLStr, aResult); - } + if (boundDocument) + boundDocument->GetBindingManager()->GetXBLDocumentInfo(aURLStr, aResult); } return NS_OK; } @@ -994,10 +981,8 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement, // Look up the prefix. // We have a base class binding. Load it right now. NS_ConvertUCS2toUTF8 urlCString(value); - nsCOMPtr docURI; - doc->GetDocumentURL(getter_AddRefs(docURI)); nsCAutoString urlStr; - docURI->Resolve(urlCString, urlStr); + doc->GetDocumentURL()->Resolve(urlCString, urlStr); if (NS_FAILED(GetBindingInternal(aBoundElement, urlStr, aPeekOnly, aIsReady, getter_AddRefs(baseBinding)))) return NS_ERROR_FAILURE; // Binding not yet ready or an error occurred. if (!aPeekOnly) { @@ -1047,10 +1032,10 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, nsIDocument* aB if (!info) { // The second line of defense is the binding manager's document table. - nsCOMPtr bindingManager; + nsIBindingManager *bindingManager = nsnull; if (aBoundDocument) { - aBoundDocument->GetBindingManager(getter_AddRefs(bindingManager)); + bindingManager = aBoundDocument->GetBindingManager(); bindingManager->GetXBLDocumentInfo(aURLStr, getter_AddRefs(info)); } @@ -1100,8 +1085,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement, nsIDocument* aB FetchBindingDocument(aBoundElement, aBoundDocument, uri, aRef, aForceSyncLoad, getter_AddRefs(document)); if (document) { - nsCOMPtr xblDocBindingManager; - document->GetBindingManager(getter_AddRefs(xblDocBindingManager)); + nsIBindingManager *xblDocBindingManager = document->GetBindingManager(); xblDocBindingManager->GetXBLDocumentInfo(aURLStr, getter_AddRefs(info)); if (!info) { NS_ERROR("An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?"); @@ -1147,7 +1131,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun // Create an XML content sink and a parser. nsCOMPtr loadGroup; if (aBoundDocument) - aBoundDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + loadGroup = aBoundDocument->GetDocumentLoadGroup(); nsCOMPtr tagName; if (aBoundElement) @@ -1192,9 +1176,12 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun rec->AddEventListener(NS_LITERAL_STRING("load"), (nsIDOMLoadListener*)xblListener, PR_FALSE); // Add ourselves to the list of loading docs. - nsCOMPtr bindingManager; + nsIBindingManager *bindingManager; if (aBoundDocument) - aBoundDocument->GetBindingManager(getter_AddRefs(bindingManager)); + bindingManager = aBoundDocument->GetBindingManager(); + else + bindingManager = nsnull; + nsCAutoString uri; aURI->GetSpec(uri); if (bindingManager) diff --git a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp index 54948131c60..087be1007e8 100644 --- a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp +++ b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp @@ -168,12 +168,15 @@ nsXMLStylesheetPI::GetStyleSheetURL(PRBool* aIsInline, return; } - nsCOMPtr url, baseURL; + nsIURI *baseURL; nsCAutoString charset; if (mDocument) { - mDocument->GetBaseURL(getter_AddRefs(baseURL)); - mDocument->GetDocumentCharacterSet(charset); + baseURL = mDocument->GetBaseURL(); + charset = mDocument->GetDocumentCharacterSet(); + } else { + baseURL = nsnull; } + NS_NewURI(aURI, href, charset.get(), baseURL); } diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 4b3032fc97b..7739ec5f485 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -256,8 +256,7 @@ nsXMLContentSink::DidBuildModel() } else { // Kick off layout for non-XSLT transformed documents. - nsCOMPtr loader; - mDocument->GetScriptLoader(getter_AddRefs(loader)); + nsIScriptLoader *loader = mDocument->GetScriptLoader(); if (loader) { loader->RemoveObserver(this); } @@ -352,8 +351,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, mDocument = do_QueryInterface(aResultDocument); } - nsCOMPtr loader; - originalDocument->GetScriptLoader(getter_AddRefs(loader)); + nsIScriptLoader *loader = originalDocument->GetScriptLoader(); if (loader) { loader->RemoveObserver(this); } @@ -362,8 +360,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, // into the document. // XXX do we need to notify for things like PIs? Or just the // documentElement? - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { NS_ASSERTION(mDocument->IndexOf(rootContent) != -1, "rootContent not in doc?"); @@ -619,11 +616,10 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl) mXSLTProcessor->SetTransformObserver(this); - nsCOMPtr loadGroup; - nsresult rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) { + nsCOMPtr loadGroup = mDocument->GetDocumentLoadGroup(); + if (!loadGroup) { mXSLTProcessor = nsnull; - return rv; + return NS_ERROR_FAILURE; } return mXSLTProcessor->LoadStyleSheet(aUrl, loadGroup, mDocumentURL); @@ -711,7 +707,7 @@ nsXMLContentSink::ProcessBASETag(nsIContent* aContent) if (NS_SUCCEEDED(rv)) { rv = mDocument->SetBaseURL(baseURI); // The document checks if it is legal to set this base if (NS_SUCCEEDED(rv)) { - mDocument->GetBaseURL(getter_AddRefs(mDocumentBaseURL)); + mDocumentBaseURL = mDocument->GetBaseURL(); } } } @@ -747,7 +743,7 @@ NS_IMETHODIMP nsXMLContentSink::SetDocumentCharset(nsACString& aCharset) { if (mDocument) { - return mDocument->SetDocumentCharacterSet(aCharset); + mDocument->SetDocumentCharacterSet(aCharset); } return NS_OK; @@ -1070,11 +1066,9 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo, htmlContainer->GetCSSLoader(*getter_AddRefs(cssLoader)); if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) { PRBool alreadyLoaded = PR_FALSE; - PRInt32 i = 0, sheetCount = 0; - doc->GetNumberOfStyleSheets(PR_TRUE, &sheetCount); - for (; i < sheetCount; i++) { - nsCOMPtr sheet; - doc->GetStyleSheetAt(i, PR_TRUE, getter_AddRefs(sheet)); + PRInt32 sheetCount = doc->GetNumberOfStyleSheets(PR_TRUE); + for (PRInt32 i = 0; i < sheetCount; i++) { + nsIStyleSheet* sheet = doc->GetStyleSheetAt(i, PR_TRUE); NS_ASSERTION(sheet, "unexpected null stylesheet in the document"); if (sheet) { nsCOMPtr uri; @@ -1163,10 +1157,7 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName, getter_AddRefs(content), &appendContent); NS_ENSURE_SUCCESS(result, result); - PRInt32 id; - mDocument->GetAndIncrementContentID(&id); - content->SetContentID(id); - + content->SetContentID(mDocument->GetAndIncrementContentID()); content->SetDocument(mDocument, PR_FALSE, PR_TRUE); // Set the attributes on the new content element @@ -1441,7 +1432,8 @@ nsXMLContentSink::HandleXMLDeclaration(const PRUnichar *aData, nsParserUtils::GetQuotedAttributeValue(data, NS_LITERAL_STRING("encoding"), encoding); nsParserUtils::GetQuotedAttributeValue(data, NS_LITERAL_STRING("standalone"), standalone); - return mDocument->SetXMLDeclaration(version, encoding, standalone); + mDocument->SetXMLDeclaration(version, encoding, standalone); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index dd3819a3478..70fdbf9b6de 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -235,17 +235,15 @@ nsXMLDocument::Init() return rv; } -NS_IMETHODIMP +void nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) { - nsresult result = nsDocument::Reset(aChannel, aLoadGroup); - if (NS_FAILED(result)) - return result; + nsDocument::Reset(aChannel, aLoadGroup); nsCOMPtr url; if (aChannel) { - result = aChannel->GetURI(getter_AddRefs(url)); + nsresult result = aChannel->GetURI(getter_AddRefs(url)); if (NS_FAILED(result)) - return result; + return; } if (mAttrStyleSheet) { @@ -255,13 +253,11 @@ nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) mInlineStyleSheet->SetOwningDocument(nsnull); } - result = SetDefaultStylesheets(url); + SetDefaultStylesheets(url); mBaseTarget.Truncate(); mScriptContext = nsnull; - - return result; } ///////////////////////////////////////////////////// @@ -387,7 +383,7 @@ nsXMLDocument::GetLoadGroup(nsILoadGroup **aLoadGroup) window->GetDocument(getter_AddRefs(domdoc)); nsCOMPtr doc = do_QueryInterface(domdoc); if (doc) { - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } } } @@ -432,7 +428,7 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) } } - nsCOMPtr baseURI(mDocumentURL); + nsIURI *baseURI = mDocumentURL; nsCAutoString charset; if (callingContext) { @@ -447,8 +443,8 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) nsCOMPtr doc(do_QueryInterface(dom_doc)); if (doc) { - doc->GetBaseURL(getter_AddRefs(baseURI)); - doc->GetDocumentCharacterSet(charset); + baseURI = doc->GetBaseURL(); + charset = doc->GetDocumentCharacterSet(); } } } @@ -600,17 +596,14 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, // who puts the document on display to worry about enabling. // scripts - nsCOMPtr loader; - nsresult rv = GetScriptLoader(getter_AddRefs(loader)); - if (NS_FAILED(rv)) - return rv; + nsIScriptLoader *loader = GetScriptLoader(); if (loader) { loader->SetEnabled(PR_FALSE); // Do not load/process scripts when loading as data } // styles nsCOMPtr cssLoader; - rv = GetCSSLoader(*getter_AddRefs(cssLoader)); + nsresult rv = GetCSSLoader(*getter_AddRefs(cssLoader)); if (NS_FAILED(rv)) return rv; if (cssLoader) { @@ -687,7 +680,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, return NS_OK; } -NS_IMETHODIMP +void nsXMLDocument::EndLoad() { mLoopingForSyncLoad = PR_FALSE; @@ -711,7 +704,7 @@ nsXMLDocument::EndLoad() HandleDOMEvent(nsnull, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } - return nsDocument::EndLoad(); + nsDocument::EndLoad(); } NS_IMETHODIMP @@ -792,15 +785,13 @@ nsXMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex) mStyleSheets.InsertObjectAt(aSheet, aIndex + mCatalogSheetCount + 1); } -already_AddRefed -nsXMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) +nsIStyleSheet* +nsXMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) const { PRInt32 count = InternalGetNumberOfStyleSheets(); if (aIndex >= 0 && aIndex < count) { - nsIStyleSheet* sheet = mStyleSheets[aIndex + mCatalogSheetCount + 1]; - NS_ADDREF(sheet); - return sheet; + return mStyleSheets[aIndex + mCatalogSheetCount + 1]; } else { NS_ERROR("Index out of range"); return nsnull; @@ -808,7 +799,7 @@ nsXMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex) } PRInt32 -nsXMLDocument::InternalGetNumberOfStyleSheets() +nsXMLDocument::InternalGetNumberOfStyleSheets() const { PRInt32 count = mStyleSheets.Count(); @@ -1112,18 +1103,16 @@ nsXMLDocument::SetDefaultStylesheets(nsIURI* aUrl) return rv; } -NS_IMETHODIMP +void nsXMLDocument::SetBaseTarget(const nsAString &aBaseTarget) { mBaseTarget.Assign(aBaseTarget); - return NS_OK; } -NS_IMETHODIMP -nsXMLDocument::GetBaseTarget(nsAString &aBaseTarget) +void +nsXMLDocument::GetBaseTarget(nsAString &aBaseTarget) const { aBaseTarget.Assign(mBaseTarget); - return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/xml/document/src/nsXMLDocument.h b/mozilla/content/xml/document/src/nsXMLDocument.h index 63a4c3f0507..a205a7b0247 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.h +++ b/mozilla/content/xml/document/src/nsXMLDocument.h @@ -69,7 +69,7 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(void); NS_IMETHOD_(nsrefcnt) Release(void); - NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); + virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); NS_IMETHOD StartDocumentLoad(const char* aCommand, nsIChannel* channel, nsILoadGroup* aLoadGroup, @@ -78,10 +78,10 @@ public: PRBool aReset = PR_TRUE, nsIContentSink* aSink = nsnull); - NS_IMETHOD EndLoad(); + virtual void EndLoad(); - NS_IMETHOD GetBaseTarget(nsAString &aBaseTarget); - NS_IMETHOD SetBaseTarget(const nsAString &aBaseTarget); + virtual void GetBaseTarget(nsAString &aBaseTarget) const; + virtual void SetBaseTarget(const nsAString &aBaseTarget); // nsIDOMNode interface NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn); @@ -127,8 +127,8 @@ protected: // subclass hooks for sheet ordering virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags); virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex); - virtual already_AddRefed InternalGetStyleSheetAt(PRInt32 aIndex); - virtual PRInt32 InternalGetNumberOfStyleSheets(); + virtual nsIStyleSheet* InternalGetStyleSheetAt(PRInt32 aIndex) const; + virtual PRInt32 InternalGetNumberOfStyleSheets() const; nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult); diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp index 6817ba7fdf3..ac2cc53eaa1 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -78,9 +79,7 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument) } // check if we're in an invisible iframe - nsCOMPtr sgo; - aDocument->GetScriptGlobalObject(getter_AddRefs(sgo)); - nsCOMPtr internalWin = do_QueryInterface(sgo); + nsCOMPtr internalWin = do_QueryInterface(aDocument->GetScriptGlobalObject()); nsCOMPtr frameElem; if (internalWin) { internalWin->GetFrameElement(getter_AddRefs(frameElem)); @@ -178,13 +177,12 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument) NS_ENSURE_SUCCESS(rv, rv); // Hand the result document to the binding - nsCOMPtr manager; - aDocument->GetBindingManager(getter_AddRefs(manager)); nsCOMPtr binding; nsCOMPtr rootCont = do_QueryInterface(rootElem); NS_ASSERTION(rootCont, "Element doesn't implement nsIContent"); - manager->GetBindingImplementation(rootCont, NS_GET_IID(nsIObserver), - (void**)getter_AddRefs(binding)); + aDocument->GetBindingManager()->GetBindingImplementation(rootCont, + NS_GET_IID(nsIObserver), + (void**)getter_AddRefs(binding)); NS_ASSERTION(binding, "Prettyprint binding doesn't implement nsIObserver"); NS_ENSURE_TRUE(binding, NS_ERROR_UNEXPECTED); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 8d2a9b4011f..eb9a68a5e7d 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -340,8 +340,7 @@ static PRBool HasMutationListeners(nsIContent* aContent, PRUint32 aType) if (!doc) return PR_FALSE; - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (!global) return PR_FALSE; @@ -631,9 +630,7 @@ nsXULElement::QueryInterface(REFNSIID iid, void** result) return NS_OK; } else if (mDocument) { - nsCOMPtr manager; - mDocument->GetBindingManager(getter_AddRefs(manager)); - return manager->GetBindingImplementation(this, iid, result); + return mDocument->GetBindingManager()->GetBindingImplementation(this, iid, result); } else { *result = nsnull; return NS_NOINTERFACE; @@ -688,12 +685,10 @@ nsXULElement::GetParentNode(nsIDOMNode** aParentNode) if (mDocument) { // XXX This is a mess because of our fun multiple inheritance heirarchy - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); nsCOMPtr thisIContent; QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(thisIContent)); - if (root == thisIContent) { + if (mDocument->GetRootContent() == thisIContent) { // If we don't have a parent, and we're the root content // of the document, DOM says that our parent is the // document. @@ -1576,22 +1571,18 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName, nsresult rv; nsCOMPtr context; - nsCOMPtr global; - { - mDocument->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = mDocument->GetScriptGlobalObject(); - // This can happen normally as part of teardown code. - if (! global) - return NS_OK; + // This can happen normally as part of teardown code. + if (! global) + return NS_OK; - rv = global->GetContext(getter_AddRefs(context)); - if (NS_FAILED(rv)) return rv; + rv = global->GetContext(getter_AddRefs(context)); + if (NS_FAILED(rv)) return rv; - if (!context) return NS_OK; - } + if (!context) return NS_OK; - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); + nsIContent *root = mDocument->GetRootContent(); nsCOMPtr content(do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this))); if ((!root || root == content) && !NodeInfo()->Equals(nsXULAtoms::overlay)) { nsCOMPtr receiver = do_QueryInterface(global); @@ -1782,8 +1773,7 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileE if (mDocument) { // Notify XBL- & nsIAnonymousContentCreator-generated // anonymous content that the document is changing. - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); NS_ASSERTION(bindingManager, "no binding manager"); if (bindingManager) { bindingManager->ChangeDocumentFor(NS_STATIC_CAST(nsIStyledContent*, this), mDocument, aDocument); @@ -2402,10 +2392,8 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo, UnregisterAccessKey(oldValue); if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(binding)); if (binding) binding->AttributeChanged(attrName, attrns, PR_FALSE, aNotify); @@ -2711,10 +2699,8 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, // Notify document if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr binding; - bindingManager->GetBinding(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(binding)); + mDocument->GetBindingManager()->GetBinding(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(binding)); if (binding) binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); @@ -2921,8 +2907,7 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const fputs(">\n", out); if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); if (bindingManager) { nsCOMPtr anonymousChildren; bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)), @@ -3105,8 +3090,7 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext, // determine the parent: nsCOMPtr parent; if (mDocument) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager* bindingManager = mDocument->GetBindingManager(); if (bindingManager) { // we have a binding manager -- do we have an anonymous parent? bindingManager->GetInsertionParent(this, getter_AddRefs(parent)); @@ -3260,10 +3244,11 @@ nsXULElement::GetBaseURL(nsIURI **aURI) const { // XXX TODO, should share the impl with nsGenericElement if (mDocument) { - return mDocument->GetBaseURL(aURI); + NS_IF_ADDREF(*aURI = mDocument->GetBaseURL()); + } else { + *aURI = nsnull; } - *aURI = nsnull; return NS_OK; } @@ -5134,10 +5119,9 @@ nsXULPrototypeScript::Compile(const PRUnichar* aText, // Use the enclosing document's principal // XXX is this right? or should we use the protodoc's? - nsCOMPtr principal; - rv = aDocument->GetPrincipal(getter_AddRefs(principal)); - if (NS_FAILED(rv)) - return rv; + nsIPrincipal *principal = aDocument->GetPrincipal(); + if (!principal) + return NS_ERROR_FAILURE; nsCAutoString urlspec; aURI->GetSpec(urlspec); diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index 7ff2316d793..74058edf5c0 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -559,8 +559,7 @@ XULPopupListenerImpl::LaunchPopup(PRInt32 aClientX, PRInt32 aClientY) // We have some popup content. Obtain our window. nsCOMPtr context; - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsCOMPtr global = document->GetScriptGlobalObject(); if (global) { if ((NS_OK == global->GetContext(getter_AddRefs(context))) && context) { // Get the DOM window diff --git a/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h b/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h index a63bbbc9cbf..ed31055b453 100644 --- a/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h +++ b/mozilla/content/xul/document/public/nsIXULPrototypeDocument.h @@ -90,7 +90,7 @@ public: NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const = 0; NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData) = 0; - NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aResult) = 0; + virtual nsIPrincipal* GetDocumentPrincipal() = 0; NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal) = 0; NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager** aNodeInfoManager) = 0; diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp index 6ccf9b9bc8e..1095f4ea6a7 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -124,9 +124,7 @@ void nsXULCommandDispatcher::EnsureFocusController() { if (!mFocusController) { - nsCOMPtr global; - mDocument->GetScriptGlobalObject(getter_AddRefs(global)); - nsCOMPtr win(do_QueryInterface(global)); + nsCOMPtr win(do_QueryInterface(mDocument->GetScriptGlobalObject())); // An inelegant way to retrieve this to be sure, but we are // guaranteed that the focus controller outlives us, so it diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 20e78d5d3f3..dd3bb2b4fc7 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -561,7 +561,7 @@ XULContentSinkImpl::SetDocumentCharset(nsACString& aCharset) { nsCOMPtr doc = do_QueryReferent(mDocument); if (doc) { - return doc->SetDocumentCharacterSet(aCharset); + doc->SetDocumentCharacterSet(aCharset); } return NS_OK; @@ -1438,8 +1438,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, // where it's already there. nsCOMPtr doc(do_QueryReferent(mDocument)); if (doc) { - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = doc->GetScriptGlobalObject(); if (globalObject) { nsCOMPtr scriptContext; globalObject->GetContext(getter_AddRefs(scriptContext)); diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 35a629b9b6c..1a20c217fb3 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -494,18 +494,16 @@ NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument) // nsIDocument interface // -NS_IMETHODIMP +void nsXULDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) { NS_NOTREACHED("Reset"); - return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP +void nsXULDocument::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup) { NS_NOTREACHED("ResetToURI"); - return NS_ERROR_NOT_IMPLEMENTED; } // Override the nsDocument.cpp method to keep from returning the @@ -518,14 +516,13 @@ nsXULDocument::GetContentType(nsAString& aContentType) return NS_OK; } -NS_IMETHODIMP +void nsXULDocument::SetContentType(const nsAString& aContentType) { NS_ASSERTION(aContentType.Equals(NS_LITERAL_STRING("application/vnd.mozilla.xul+xml")), "xul-documents always has content-type application/vnd.mozilla.xul+xml"); // Don't do anything, xul always has the mimetype // application/vnd.mozilla.xul+xml - return NS_OK; } NS_IMETHODIMP @@ -673,14 +670,13 @@ nsXULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel, return NS_OK; } -NS_IMETHODIMP -nsXULDocument::GetPrincipal(nsIPrincipal **aPrincipal) +nsIPrincipal* +nsXULDocument::GetPrincipal() { - *aPrincipal = nsnull; NS_ASSERTION(mMasterPrototype, "Missing master prototype. See bug 169036"); - NS_ENSURE_TRUE(mMasterPrototype, NS_ERROR_UNEXPECTED); + NS_ENSURE_TRUE(mMasterPrototype, nsnull); - return mMasterPrototype->GetDocumentPrincipal(aPrincipal); + return mMasterPrototype->GetDocumentPrincipal(); } NS_IMETHODIMP @@ -690,7 +686,7 @@ nsXULDocument::SetPrincipal(nsIPrincipal *aPrincipal) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP +void nsXULDocument::EndLoad() { nsresult rv; @@ -700,7 +696,7 @@ nsXULDocument::EndLoad() nsCOMPtr uri; rv = mCurrentPrototype->GetURI(getter_AddRefs(uri)); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; // Remember if the XUL cache is on PRBool useXULCache; @@ -716,7 +712,7 @@ nsXULDocument::EndLoad() nsCOMPtr reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; nsCOMPtr sheets; reg->GetStyleSheets(uri, getter_AddRefs(sheets)); @@ -746,14 +742,14 @@ nsXULDocument::EndLoad() // documents that raced to load the prototype, and awaited // its load completion via proto->AwaitLoadDone(). rv = mCurrentPrototype->NotifyLoadDone(); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; } // Now walk the prototype to build content. rv = PrepareToWalk(); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; - return ResumeWalk(); + ResumeWalk(); } // Called back from nsXULPrototypeDocument::NotifyLoadDone for each XUL @@ -1086,7 +1082,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, return NS_OK; } -NS_IMETHODIMP +void nsXULDocument::AttributeChanged(nsIContent* aElement, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { @@ -1096,12 +1092,12 @@ nsXULDocument::AttributeChanged(nsIContent* aElement, PRInt32 aNameSpaceID, if ((aAttribute == nsXULAtoms::id) || (aAttribute == nsXULAtoms::ref)) { rv = mElementMap.Enumerate(RemoveElementsFromMapByContent, aElement); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; // That'll have removed _both_ the 'ref' and 'id' entries from // the map. So add 'em back now. rv = AddElementToMap(aElement); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; } // Synchronize broadcast listeners @@ -1155,23 +1151,21 @@ nsXULDocument::AttributeChanged(nsIContent* aElement, PRInt32 aNameSpaceID, // XXX Namespace handling broken :-( nsAutoString persist; rv = aElement->GetAttr(kNameSpaceID_None, nsXULAtoms::persist, persist); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; if (rv == NS_CONTENT_ATTR_HAS_VALUE) { nsAutoString attr; rv = aAttribute->ToString(attr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; if (persist.Find(attr) >= 0) { rv = Persist(aElement, kNameSpaceID_None, aAttribute); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return; } } - - return NS_OK; } -NS_IMETHODIMP +void nsXULDocument::ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer) { @@ -1181,26 +1175,26 @@ nsXULDocument::ContentAppended(nsIContent* aContainer, for (PRUint32 i = aNewIndexInContainer; i < count; ++i) { nsresult rv = AddSubtreeToDocument(aContainer->GetChildAt(i)); if (NS_FAILED(rv)) - return rv; + return; } - return nsXMLDocument::ContentAppended(aContainer, aNewIndexInContainer); + nsXMLDocument::ContentAppended(aContainer, aNewIndexInContainer); } -NS_IMETHODIMP +void nsXULDocument::ContentInserted(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) { nsresult rv = AddSubtreeToDocument(aChild); if (NS_FAILED(rv)) - return rv; + return; - return nsXMLDocument::ContentInserted(aContainer, aChild, - aIndexInContainer); + nsXMLDocument::ContentInserted(aContainer, aChild, + aIndexInContainer); } -NS_IMETHODIMP +void nsXULDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, nsIContent* aNewChild, @@ -1209,17 +1203,17 @@ nsXULDocument::ContentReplaced(nsIContent* aContainer, nsresult rv; rv = RemoveSubtreeFromDocument(aOldChild); if (NS_FAILED(rv)) - return rv; + return; rv = AddSubtreeToDocument(aNewChild); if (NS_FAILED(rv)) - return rv; + return; - return nsXMLDocument::ContentReplaced(aContainer, aOldChild, aNewChild, - aIndexInContainer); + nsXMLDocument::ContentReplaced(aContainer, aOldChild, aNewChild, + aIndexInContainer); } -NS_IMETHODIMP +void nsXULDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) @@ -1227,10 +1221,10 @@ nsXULDocument::ContentRemoved(nsIContent* aContainer, nsresult rv; rv = RemoveSubtreeFromDocument(aChild); if (NS_FAILED(rv)) - return rv; + return; - return nsXMLDocument::ContentRemoved(aContainer, aChild, - aIndexInContainer); + nsXMLDocument::ContentRemoved(aContainer, aChild, + aIndexInContainer); } NS_IMETHODIMP @@ -1497,10 +1491,7 @@ nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute, NS_ENSURE_TRUE(elements, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(elements); - nsCOMPtr root; - GetRootContent(getter_AddRefs(root)); - - nsCOMPtr domRoot = do_QueryInterface(root); + nsCOMPtr domRoot = do_QueryInterface(mRootContent); NS_ASSERTION(domRoot, "no doc root"); if (domRoot) { @@ -1666,10 +1657,7 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, nsSize size; nsIFrame* frame; - result = FlushPendingNotifications(); - if (NS_FAILED(result)) { - return result; - } + FlushPendingNotifications(); result = aShell->GetPrimaryFrameFor(mRootContent, &frame); if (NS_SUCCEEDED(result) && frame) { @@ -3692,6 +3680,9 @@ nsXULDocument::AddPrototypeSheets() if (! uri) return NS_ERROR_UNEXPECTED; + nsCAutoString spec; + uri->GetAsciiSpec(spec); + if (!IsChromeURI(uri)) { // These don't get to be in the prototype cache anyway... // and we can't load non-chrome sheets synchronously diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 8ab5b292483..d3461a90029 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -92,8 +92,8 @@ public: NS_DECL_NSISTREAMLOADEROBSERVER // nsIDocument interface - NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); - NS_IMETHOD ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup); + virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); + virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup); NS_IMETHOD StartDocumentLoad(const char* aCommand, nsIChannel *channel, @@ -103,32 +103,32 @@ public: PRBool aReset = PR_TRUE, nsIContentSink* aSink = nsnull); - NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal); + virtual nsIPrincipal* GetPrincipal(); NS_IMETHOD SetPrincipal(nsIPrincipal *aPrincipal); - NS_IMETHOD SetContentType(const nsAString& aContentType); + virtual void SetContentType(const nsAString& aContentType); - NS_IMETHOD EndLoad(); + virtual void EndLoad(); - NS_IMETHOD ContentAppended(nsIContent* aContainer, - PRInt32 aNewIndexInContainer); + virtual void ContentAppended(nsIContent* aContainer, + PRInt32 aNewIndexInContainer); - NS_IMETHOD ContentInserted(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); + virtual void ContentInserted(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); - NS_IMETHOD ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); + virtual void ContentReplaced(nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer); - NS_IMETHOD ContentRemoved(nsIContent* aContainer, - nsIContent* aChild, - PRInt32 aIndexInContainer); + virtual void ContentRemoved(nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); - NS_IMETHOD AttributeChanged(nsIContent* aElement, PRInt32 aNameSpaceID, - nsIAtom* aAttribute, PRInt32 aModType); + virtual void AttributeChanged(nsIContent* aElement, PRInt32 aNameSpaceID, + nsIAtom* aAttribute, PRInt32 aModType); NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, diff --git a/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp b/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp index 7267f887133..f258c3c7703 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp @@ -377,11 +377,8 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo) nsCOMPtr doc; aDocumentInfo->GetDocument(getter_AddRefs(doc)); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - nsCAutoString str; - uri->GetSpec(str); + doc->GetDocumentURL()->GetSpec(str); nsCOMPtr info; mXBLDocTable.Get(str, getter_AddRefs(info)); @@ -404,10 +401,8 @@ FlushSkinXBL(const nsACString& key, nsCOMPtr& aDocInfo, void { nsCOMPtr doc; aDocInfo->GetDocument(getter_AddRefs(doc)); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); nsCAutoString str; - uri->GetPath(str); + doc->GetDocumentURL()->GetPath(str); PLDHashOperator ret = PL_DHASH_NEXT; diff --git a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp index fb07657045e..0777ffe788f 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -146,7 +146,7 @@ public: NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const; NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData); - NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aResult); + virtual nsIPrincipal* GetDocumentPrincipal(); NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal); NS_IMETHOD AwaitLoadDone(nsIXULDocument* aDocument, PRBool* aResult); @@ -319,10 +319,9 @@ NS_NewXULPrototypeDocument(nsISupports* aOuter, REFNSIID aIID, void** aResult) nsresult nsXULPrototypeDocument::NewXULPDGlobalObject(nsIScriptGlobalObject** aResult) { - nsCOMPtr principal; - nsresult rv = GetDocumentPrincipal(getter_AddRefs(principal)); - if (NS_FAILED(rv)) - return rv; + nsIPrincipal *principal = GetDocumentPrincipal(); + if (!principal) + return NS_ERROR_FAILURE; // Now that GetDocumentPrincipal has succeeded, we can safely compare its // result to gSystemPrincipal, in order to create gSystemGlobal if the two @@ -389,7 +388,9 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream) nsCOMPtr principal; rv |= NS_ReadOptionalObject(aStream, PR_TRUE, getter_AddRefs(principal)); if (! principal) { - rv |= GetDocumentPrincipal(getter_AddRefs(principal)); + principal = GetDocumentPrincipal(); + if (!principal) + rv |= NS_ERROR_FAILURE; } else { mNodeInfoManager->SetDocumentPrincipal(principal); mDocumentPrincipal = principal; @@ -536,8 +537,7 @@ nsXULPrototypeDocument::SetURI(nsIURI* aURI) if (!mDocumentPrincipal) { // If the document doesn't have a principal yet we'll force the creation of one // so that mNodeInfoManager properly gets one. - nsCOMPtr principal; - GetDocumentPrincipal(getter_AddRefs(principal)); + GetDocumentPrincipal(); } return NS_OK; } @@ -620,8 +620,8 @@ nsXULPrototypeDocument::SetHeaderData(nsIAtom* aField, const nsAString& aData) -NS_IMETHODIMP -nsXULPrototypeDocument::GetDocumentPrincipal(nsIPrincipal** aResult) +nsIPrincipal* +nsXULPrototypeDocument::GetDocumentPrincipal() { NS_PRECONDITION(mNodeInfoManager, "missing nodeInfoManager"); if (!mDocumentPrincipal) { @@ -630,7 +630,7 @@ nsXULPrototypeDocument::GetDocumentPrincipal(nsIPrincipal** aResult) do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; + return nsnull; // XXX This should be handled by the security manager, see bug 160042 PRBool isChrome = PR_FALSE; @@ -648,14 +648,12 @@ nsXULPrototypeDocument::GetDocumentPrincipal(nsIPrincipal** aResult) } if (NS_FAILED(rv)) - return NS_ERROR_FAILURE; + return nsnull; mNodeInfoManager->SetDocumentPrincipal(mDocumentPrincipal); } - *aResult = mDocumentPrincipal; - NS_ADDREF(*aResult); - return NS_OK; + return mDocumentPrincipal; } @@ -959,6 +957,13 @@ nsXULPDGlobalObject::GetPrincipal(nsIPrincipal** aPrincipal) } nsCOMPtr protoDoc = do_QueryInterface(mGlobalObjectOwner); - return protoDoc->GetDocumentPrincipal(aPrincipal); + + *aPrincipal = protoDoc->GetDocumentPrincipal(); + if (!*aPrincipal) { + return NS_ERROR_FAILURE; + } + + NS_ADDREF(*aPrincipal); + return NS_OK; } diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index 899dd3ab2a9..a87d3d4bf00 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1512,8 +1512,7 @@ nsXULContentBuilder::CreateElement(PRInt32 aNameSpaceID, nsresult rv; nsCOMPtr result; - nsCOMPtr nodeInfoManager; - doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_NOT_INITIALIZED); nsCOMPtr nodeInfo; @@ -1861,8 +1860,7 @@ nsXULContentBuilder::OpenContainer(nsIContent* aElement) if (! doc) return NS_ERROR_UNEXPECTED; - nsresult rv = doc->ContentAppended(container, newIndex); - if (NS_FAILED(rv)) return rv; + doc->ContentAppended(container, newIndex); } return NS_OK; diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp index b7e5814bbc9..3548dacee46 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp @@ -231,8 +231,7 @@ nsXULContentUtils::GetElementRefResource(nsIContent* aElement, nsIRDFResource** // We'll use rdf_MakeAbsolute() to translate this to a URL. nsCOMPtr doc = aElement->GetDocument(); - nsCOMPtr url; - doc->GetDocumentURL(getter_AddRefs(url)); + nsIURI *url = doc->GetDocumentURL(); NS_ASSERTION(url != nsnull, "element has no document"); if (! url) return NS_ERROR_UNEXPECTED; @@ -336,9 +335,7 @@ nsXULContentUtils::MakeElementURI(nsIDocument* aDocument, const nsAString& aElem else { nsresult rv; - nsCOMPtr docURL; - rv = aDocument->GetBaseURL(getter_AddRefs(docURL)); - if (NS_FAILED(rv)) return rv; + nsIURI *docURL = aDocument->GetBaseURL(); // XXX Urgh. This is so broken; I'd really just like to use // NS_MakeAbsolueURI(). Unfortunatly, doing that breaks @@ -395,12 +392,8 @@ nsXULContentUtils::MakeElementID(nsIDocument* aDocument, const nsAString& aURI, // DOM APIs. nsresult rv; - nsCOMPtr docURL; - rv = aDocument->GetBaseURL(getter_AddRefs(docURL)); - if (NS_FAILED(rv)) return rv; - nsCAutoString spec; - docURL->GetSpec(spec); + aDocument->GetBaseURL()->GetSpec(spec); // XXX FIX ME to not do a copy nsAutoString str(aURI); diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 87677f18856..c6ab2b70d5c 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -713,12 +713,12 @@ nsXULTemplateBuilder::LoadDataSources() return NS_ERROR_UNEXPECTED; // Grab the doc's principal... - nsCOMPtr docPrincipal; - rv = doc->GetPrincipal(getter_AddRefs(docPrincipal)); - if (NS_FAILED(rv)) return rv; + nsIPrincipal *docPrincipal = doc->GetPrincipal(); + if (!docPrincipal) + return NS_ERROR_FAILURE; PRBool isTrusted = PR_FALSE; - rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted); + rv = IsSystemPrincipal(docPrincipal, &isTrusted); if (NS_FAILED(rv)) return rv; if (isTrusted) { @@ -740,8 +740,7 @@ nsXULTemplateBuilder::LoadDataSources() // // rdf:bookmarks rdf:history http://foo.bar.com/blah.cgi?baz=9 // - nsCOMPtr docurl; - doc->GetDocumentURL(getter_AddRefs(docurl)); + nsIURI *docurl = doc->GetDocumentURL(); nsAutoString datasources; mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::datasources, datasources); @@ -854,8 +853,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot() if (! doc) return NS_ERROR_UNEXPECTED; - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (! global) return NS_ERROR_UNEXPECTED; @@ -1478,8 +1476,7 @@ nsXULTemplateBuilder::GetTemplateRoot(nsIContent** aResult) if (! doc) return NS_ERROR_FAILURE; - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); if (bindingManager) { nsCOMPtr kids; diff --git a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp index 8dc5eac19dc..34288d9fc7e 100644 --- a/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -819,13 +819,12 @@ nsXULTreeBuilder::SetTree(nsITreeBoxObject* tree) return NS_ERROR_UNEXPECTED; // Grab the doc's principal... - nsCOMPtr docPrincipal; - nsresult rv = doc->GetPrincipal(getter_AddRefs(docPrincipal)); - if (NS_FAILED(rv)) - return rv; + nsIPrincipal* docPrincipal = doc->GetPrincipal(); + if (!docPrincipal) + return NS_ERROR_FAILURE; PRBool isTrusted = PR_FALSE; - rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted); + nsresult rv = IsSystemPrincipal(docPrincipal, &isTrusted); if (NS_SUCCEEDED(rv) && isTrusted) { // Get the datasource we intend to use to remember open state. nsAutoString datasourceStr; diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index f0ffbfeecc5..af8f7d6d30c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -947,14 +947,13 @@ PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem* // Get target principal uri (including document.domain) nsCOMPtr targetDOMDocument(do_GetInterface(aTargetTreeItem)); - NS_ENSURE_TRUE(targetDOMDocument, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(targetDOMDocument, PR_TRUE); nsCOMPtr targetDocument(do_QueryInterface(targetDOMDocument)); - NS_ENSURE_TRUE(targetDocument, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(targetDocument, PR_TRUE); - nsCOMPtr targetPrincipal; - rv = targetDocument->GetPrincipal(getter_AddRefs(targetPrincipal)); - NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetPrincipal, rv); + nsIPrincipal *targetPrincipal = targetDocument->GetPrincipal(); + NS_ENSURE_TRUE(targetPrincipal, NS_ERROR_FAILURE); nsCOMPtr targetPrincipalURI; rv = targetPrincipal->GetURI(getter_AddRefs(targetPrincipalURI)); @@ -1337,9 +1336,7 @@ nsDocShell::GetCharset(char** aCharset) NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); presShell->GetDocument(getter_AddRefs(doc)); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - nsCAutoString charset; - NS_ENSURE_SUCCESS(doc->GetDocumentCharacterSet(charset), NS_ERROR_FAILURE); - *aCharset = ToNewCString(charset); + *aCharset = ToNewCString(doc->GetDocumentCharacterSet()); if (!*aCharset) { return NS_ERROR_OUT_OF_MEMORY; } @@ -2081,10 +2078,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild) res = docv->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(res) || (!doc)) return NS_OK; - nsCAutoString parentCS; - res = doc->GetDocumentCharacterSet(parentCS); - if (NS_FAILED(res)) - return NS_OK; + const nsACString &parentCS = doc->GetDocumentCharacterSet(); // set the child's parentCharset nsCOMPtr parentCSAtom(do_GetAtom(parentCS)); @@ -2092,10 +2086,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild) if (NS_FAILED(res)) return NS_OK; - PRInt32 charsetSource; - res = doc->GetDocumentCharacterSetSource(&charsetSource); - if (NS_FAILED(res)) - return NS_OK; + PRInt32 charsetSource = doc->GetDocumentCharacterSetSource(); // set the child's parentCharset res = dcInfo->SetParentCharsetSource(charsetSource); @@ -3266,9 +3257,7 @@ nsDocShell::GetVisibility(PRBool * aVisibility) nsCOMPtr pDoc; pPresShell->GetDocument(getter_AddRefs(pDoc)); - nsCOMPtr shellContent; - nsCOMPtr shellISupports = do_QueryInterface(treeItem); - pDoc->FindContentForSubDocument(doc, getter_AddRefs(shellContent)); + nsIContent *shellContent = pDoc->FindContentForSubDocument(doc); NS_ASSERTION(shellContent, "subshell not in the map"); nsIFrame* frame; @@ -4459,9 +4448,7 @@ nsDocShell::CreateAboutBlankContentViewer() Embed(viewer, "", 0); viewer->SetDOMDocument(domdoc); - nsCOMPtr documentURI; - blankDoc->GetDocumentURL(getter_AddRefs(documentURI)); // about:blank, duh - SetCurrentURI(documentURI); + SetCurrentURI(blankDoc->GetDocumentURL()); rv = NS_OK; } } @@ -5276,12 +5263,10 @@ nsDocShell::GetCurrentDocumentOwner(nsISupports ** aOwner) } //-- Get the document's principal - nsCOMPtr principal; - rv = document->GetPrincipal(getter_AddRefs(principal)); - if (NS_FAILED(rv) || !principal) + nsIPrincipal *principal = document->GetPrincipal(); + if (!principal) return NS_ERROR_FAILURE; - rv = principal->QueryInterface(NS_GET_IID(nsISupports), (void **) aOwner); - return rv; + return principal->QueryInterface(NS_GET_IID(nsISupports), (void **) aOwner); } nsresult @@ -5834,9 +5819,7 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor, nsCOMPtr doc; rv = docv->GetDocument(getter_AddRefs(doc)); NS_ENSURE_SUCCESS(rv, rv); - nsCAutoString aCharset; - rv = doc->GetDocumentCharacterSet(aCharset); - NS_ENSURE_SUCCESS(rv, rv); + const nsACString &aCharset = doc->GetDocumentCharacterSet(); nsCOMPtr textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); @@ -5845,7 +5828,7 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor, // Unescape and convert to unicode nsXPIDLString uStr; - rv = textToSubURI->UnEscapeAndConvert(aCharset.get(), + rv = textToSubURI->UnEscapeAndConvert(PromiseFlatCString(aCharset).get(), PromiseFlatCString(sNewRef).get(), getter_Copies(uStr)); NS_ENSURE_SUCCESS(rv, rv); @@ -6903,8 +6886,7 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus) presShell->GetDocument(getter_AddRefs(doc)); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (!rootContent) return NS_ERROR_FAILURE; nsIFrame* frame; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 5dfd259be12..6fe7b082341 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -641,8 +641,7 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent, nsCOMPtr refererDoc(do_QueryInterface(refererOwnerDoc)); NS_ENSURE_TRUE(refererDoc, NS_ERROR_UNEXPECTED); - nsCOMPtr referer; - refererDoc->GetDocumentURL(getter_AddRefs(referer)); + nsIURI *referer = refererDoc->GetDocumentURL(); // referer could be null here in some odd cases, but that's ok, // we'll just load the link w/o sending a referer in those cases. diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index fcd3cda4ecf..365acfc4128 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -2985,7 +2985,7 @@ nsDOMClassInfo::doCheckPropertyAccess(JSContext *cx, JSObject *obj, jsval id, nsCOMPtr doc(do_QueryInterface(native)); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + sgo = doc->GetScriptGlobalObject(); if (!sgo) { // There's no script global in the document. This means that @@ -4441,8 +4441,7 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, // Get the script global object from the document. - nsCOMPtr sgo; - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); if (!sgo) { // No global object reachable from this document, use the @@ -4690,8 +4689,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, // We must ensure that the XBL Binding is installed before we hand // back this object. - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); NS_ENSURE_TRUE(bindingManager, NS_ERROR_UNEXPECTED); nsCOMPtr binding; diff --git a/mozilla/dom/src/base/nsFocusController.cpp b/mozilla/dom/src/base/nsFocusController.cpp index 096e9c4cb93..f8ae3244201 100644 --- a/mozilla/dom/src/base/nsFocusController.cpp +++ b/mozilla/dom/src/base/nsFocusController.cpp @@ -171,10 +171,7 @@ nsFocusController::UpdateCommands(const nsAString& aEventName) if (domDoc) { nsCOMPtr doc(do_QueryInterface(domDoc)); - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); - - nsCOMPtr window(do_QueryInterface(global)); + nsCOMPtr window(do_QueryInterface(doc->GetScriptGlobalObject())); if (window) window->UpdateCommands(aEventName); } @@ -364,11 +361,7 @@ nsFocusController::GetParentWindowFromDocument(nsIDOMDocument* aDocument, nsIDOM nsCOMPtr objectOwner = do_QueryInterface(aDocument); if(!objectOwner) return NS_OK; - nsCOMPtr globalObject; - objectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); - if(!globalObject) return NS_OK; - - nsCOMPtr domWindow = do_QueryInterface(globalObject); + nsCOMPtr domWindow = do_QueryInterface(objectOwner->GetScriptGlobalObject()); *aWindow = domWindow; NS_IF_ADDREF(*aWindow); return NS_OK; diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 585d8f9865a..5961cbb100a 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -393,7 +393,7 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument, nsCOMPtr doc(do_QueryInterface(mDocument)); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - doc->GetPrincipal(getter_AddRefs(mDocumentPrincipal)); + mDocumentPrincipal = doc->GetPrincipal(); } // Always clear watchpoints, to deal with two cases: @@ -425,9 +425,9 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument, nsCOMPtr doc(do_QueryInterface(aDocument)); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - nsCOMPtr newPrincipal; - nsresult rv = doc->GetPrincipal(getter_AddRefs(newPrincipal)); - if (NS_SUCCEEDED(rv)) { + nsIPrincipal *newPrincipal = doc->GetPrincipal(); + nsresult rv = NS_ERROR_FAILURE; + if (newPrincipal) { rv = sSecMan->CheckSameOriginPrincipal(mDocumentPrincipal, newPrincipal); } @@ -500,7 +500,7 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument, if (mDocument) { nsCOMPtr doc(do_QueryInterface(mDocument)); - nsCOMPtr docURL; + nsIURI *docURL; // If we had a document in this window the document most likely // made our scope "unclear" @@ -508,7 +508,9 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument, mIsScopeClear = PR_FALSE; if (doc) { - doc->GetDocumentURL(getter_AddRefs(docURL)); + docURL = doc->GetDocumentURL(); + } else { + docURL = nsnull; } if (aRemoveEventListeners && mListenerManager) { @@ -808,8 +810,7 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext, // down. if (aEvent->message == NS_PAGE_UNLOAD && mDocument && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) { nsCOMPtr doc(do_QueryInterface(mDocument)); - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); if (bindingManager) bindingManager->ExecuteDetachedHandlers(); } @@ -969,7 +970,12 @@ GlobalWindowImpl::GetPrincipal(nsIPrincipal** result) nsCOMPtr doc(do_QueryInterface(mDocument)); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - return doc->GetPrincipal(result); + *result = doc->GetPrincipal(); + if (!*result) + return NS_ERROR_FAILURE; + + NS_ADDREF(*result); + return NS_OK; } if (mDocumentPrincipal) { @@ -2901,11 +2907,8 @@ PRBool IsPopupBlocked(nsIDOMDocument* aDoc) nsCOMPtr doc(do_QueryInterface(aDoc)); nsCOMPtr pm(do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID)); if (pm && doc) { - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - PRUint32 permission = nsIPopupWindowManager::ALLOW_POPUP; - pm->TestPermission(uri, &permission); + pm->TestPermission(doc->GetDocumentURL(), &permission); blocked = (permission == nsIPopupWindowManager::DENY_POPUP); } return blocked; @@ -3544,10 +3547,8 @@ GlobalWindowImpl::ConvertCharset(const nsAString& aStr, nsCOMPtr doc(do_QueryInterface(mDocument)); if (doc) - result = doc->GetDocumentCharacterSet(charset); + charset = doc->GetDocumentCharacterSet(); } - if (NS_FAILED(result)) - return result; // Get an encoder for the character set result = ccm->GetUnicodeEncoderRaw(charset.get(), @@ -3650,11 +3651,9 @@ GlobalWindowImpl::Unescape(const nsAString& aStr, if (mDocument) { nsCOMPtr doc(do_QueryInterface(mDocument)); - if (doc) { - rv = doc->GetDocumentCharacterSet(charset); - } + if (doc) + charset = doc->GetDocumentCharacterSet(); } - NS_ENSURE_SUCCESS(rv, rv); // Get a decoder for the character set nsCOMPtr decoder; @@ -4162,8 +4161,7 @@ GlobalWindowImpl::GetPrivateParent(nsPIDOMWindow ** aParent) if (!doc) return NS_OK; // This is ok, just means a null parent. - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject *globalObject = doc->GetScriptGlobalObject(); if (!globalObject) return NS_OK; // This is ok, just means a null parent. @@ -4201,10 +4199,7 @@ GlobalWindowImpl::GetPrivateRoot(nsIDOMWindowInternal ** aParent) if (chromeElement) { nsIDocument* doc = chromeElement->GetDocument(); if (doc) { - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - - parent = do_QueryInterface(globalObject); + parent = do_QueryInterface(doc->GetScriptGlobalObject()); nsCOMPtr tempParent; parent->GetTop(getter_AddRefs(tempParent)); CallQueryInterface(tempParent, aParent); @@ -4540,9 +4535,7 @@ GlobalWindowImpl::GetInterface(const nsIID & aIID, void **aSink) else if (aIID.Equals(NS_GET_IID(nsIScriptEventManager))) { nsCOMPtr doc(do_QueryInterface(mDocument)); if (doc) { - nsCOMPtr mgr; - - doc->GetScriptEventManager(getter_AddRefs(mgr)); + nsIScriptEventManager* mgr = doc->GetScriptEventManager(); if (mgr) { *aSink = mgr; } @@ -5479,7 +5472,7 @@ GlobalWindowImpl::SecurityCheckURL(const char *aURL) /* resolve the URI, which could be relative to the calling window (note the algorithm to get the base URI should match the one used to actually kick off the load in nsWindowWatcher.cpp). */ - nsCOMPtr baseURI; + nsIURI* baseURI = nsnull; nsCOMPtr uriToLoad; nsCOMPtr scriptcx; @@ -5494,7 +5487,7 @@ GlobalWindowImpl::SecurityCheckURL(const char *aURL) caller->GetDocument(getter_AddRefs(callerDOMdoc)); nsCOMPtr callerDoc(do_QueryInterface(callerDOMdoc)); if (callerDoc) - callerDoc->GetDocumentURL(getter_AddRefs(baseURI)); + baseURI = callerDoc->GetDocumentURL(); } } diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index 3440e10175d..f88187df64f 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -98,8 +98,8 @@ static nsresult GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString nsCOMPtr doc(do_QueryInterface(domDoc)); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - rv = doc->GetDocumentCharacterSet(aCharset); - return rv; + aCharset = doc->GetDocumentCharacterSet(); + return NS_OK; } LocationImpl::LocationImpl(nsIDocShell *aDocShell) @@ -929,7 +929,8 @@ LocationImpl::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL) nsCOMPtr doc; nsresult rv = GetSourceDocument(cx, getter_AddRefs(doc)); if (doc) { - return doc->GetBaseURL(sourceURL); + NS_IF_ADDREF(*sourceURL = doc->GetBaseURL()); + return NS_OK; } *sourceURL = nsnull; @@ -942,7 +943,7 @@ LocationImpl::GetSourceURL(JSContext* cx, nsIURI** sourceURL) nsCOMPtr doc; nsresult rv = GetSourceDocument(cx, getter_AddRefs(doc)); if (doc) { - doc->GetDocumentURL(sourceURL); + NS_IF_ADDREF(*sourceURL = doc->GetDocumentURL()); } else { *sourceURL = nsnull; } diff --git a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp index d683279aeec..5420985ab26 100644 --- a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp @@ -466,9 +466,7 @@ nsDocumentStateCommand::GetCommandStateParams(const char *aCommandName, nsCOMPtr doc = do_QueryInterface(domDoc); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr uri; - rv = doc->GetDocumentURL(getter_AddRefs(uri)); - NS_ENSURE_SUCCESS(rv, rv); + nsIURI *uri = doc->GetDocumentURL(); if (!uri) return NS_ERROR_FAILURE; return aParams->SetISupportsValue(STATE_DATA, (nsISupports*)uri); diff --git a/mozilla/editor/composer/src/nsEditingSession.cpp b/mozilla/editor/composer/src/nsEditingSession.cpp index de6d527550b..aabf81acafa 100644 --- a/mozilla/editor/composer/src/nsEditingSession.cpp +++ b/mozilla/editor/composer/src/nsEditingSession.cpp @@ -760,8 +760,7 @@ nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress, nsCOMPtr doc = do_QueryInterface(domDoc); if (!doc) return NS_ERROR_FAILURE; - rv = doc->SetDocumentURL(aURI); - if (NS_FAILED(rv)) return rv; + doc->SetDocumentURL(aURI); // Notify the location-changed observer that // the document URL has changed diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 7fb2cd5a392..62b007918c7 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -954,8 +954,10 @@ nsEditor::GetDocumentCharacterSet(nsACString &characterSet) { nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); - if (doc) - return doc->GetDocumentCharacterSet(characterSet); + if (doc) { + characterSet = doc->GetDocumentCharacterSet(); + return NS_OK; + } rv = NS_ERROR_NULL_POINTER; } @@ -973,7 +975,8 @@ nsEditor::SetDocumentCharacterSet(const nsACString& characterSet) nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); if (doc) { - return doc->SetDocumentCharacterSet(characterSet); + doc->SetDocumentCharacterSet(characterSet); + return NS_OK; } rv = NS_ERROR_NULL_POINTER; } @@ -5072,11 +5075,7 @@ nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent) nsCOMPtr doc = do_QueryInterface(tempDoc); - nsCOMPtr nodeInfoManager; - rv = doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); - if (NS_FAILED(rv)) - return rv; - + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.cpp b/mozilla/editor/libeditor/base/nsEditorUtils.cpp index e1c44c5a8f9..e30d55edad2 100644 --- a/mozilla/editor/libeditor/base/nsEditorUtils.cpp +++ b/mozilla/editor/libeditor/base/nsEditorUtils.cpp @@ -249,9 +249,8 @@ nsEditorHookUtils::GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc, nsCOMPtr doc = do_QueryInterface(aDoc); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr isupp; - doc->GetContainer(getter_AddRefs(isupp)); - nsCOMPtr docShell = do_QueryInterface(isupp); + nsCOMPtr container = doc->GetContainer(); + nsCOMPtr docShell = do_QueryInterface(container); nsCOMPtr hookObj = do_GetInterface(docShell); if (!hookObj) return NS_ERROR_FAILURE; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 8927ff6fd78..e5d942681fd 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -1264,11 +1264,8 @@ nsHTMLEditor::UpdateBaseURL() { nsCOMPtr doc = do_QueryInterface(domDoc); if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr uri; - rv = doc->GetDocumentURL(getter_AddRefs(uri)); - NS_ENSURE_SUCCESS(rv, rv); - return doc->SetBaseURL(uri); + return doc->SetBaseURL(doc->GetDocumentURL()); } return NS_OK; } @@ -3533,9 +3530,6 @@ nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList) if (!iter) return NS_ERROR_NULL_POINTER; if ((NS_SUCCEEDED(res))) { - // get the root content - nsCOMPtr rootContent; - nsCOMPtr domdoc; nsEditor::GetDocument(getter_AddRefs(domdoc)); if (!domdoc) @@ -3545,9 +3539,7 @@ nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList) if (!doc) return NS_ERROR_UNEXPECTED; - doc->GetRootContent(getter_AddRefs(rootContent)); - - iter->Init(rootContent); + iter->Init(doc->GetRootContent()); // loop through the content iterator for each content node while (NS_ENUMERATOR_FALSE == iter->IsDone()) @@ -3945,9 +3937,6 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList) if (!iter) return NS_ERROR_NULL_POINTER; if ((NS_SUCCEEDED(res))) { - // get the root content - nsCOMPtr rootContent; - nsCOMPtr domdoc; nsEditor::GetDocument(getter_AddRefs(domdoc)); if (!domdoc) @@ -3957,9 +3946,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList) if (!doc) return NS_ERROR_UNEXPECTED; - doc->GetRootContent(getter_AddRefs(rootContent)); - - iter->Init(rootContent); + iter->Init(doc->GetRootContent()); // loop through the content iterator for each content node while (NS_ENUMERATOR_FALSE == iter->IsDone()) diff --git a/mozilla/editor/libeditor/html/nsHTMLObjectResizer.cpp b/mozilla/editor/libeditor/html/nsHTMLObjectResizer.cpp index 9c37fb25491..a5514e3c725 100644 --- a/mozilla/editor/libeditor/html/nsHTMLObjectResizer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLObjectResizer.cpp @@ -402,9 +402,7 @@ nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement) nsCOMPtr doc = do_QueryInterface(domDoc); if (!doc) return NS_ERROR_NULL_POINTER; - nsCOMPtr global; - res = doc->GetScriptGlobalObject(getter_AddRefs(global)); - if (NS_FAILED(res)) return res; + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (!global) { return NS_ERROR_NULL_POINTER; } mResizeEventListenerP = new DocumentResizeEventListener(this); @@ -476,9 +474,7 @@ nsHTMLEditor::HideResizers(void) GetDocument(getter_AddRefs(domDoc)); nsCOMPtr doc = do_QueryInterface(domDoc); if (!doc) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr global; - res = doc->GetScriptGlobalObject(getter_AddRefs(global)); - if (NS_FAILED(res)) return res; + nsIScriptGlobalObject *global = doc->GetScriptGlobalObject(); if (!global) { return NS_ERROR_NULL_POINTER; } nsCOMPtr target = do_QueryInterface(global); @@ -686,9 +682,7 @@ nsHTMLEditor::SetResizingInfoPosition(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt3 return NS_ERROR_UNEXPECTED; // get the root content - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); - nsCOMPtr nsElement = do_QueryInterface(rootContent); + nsCOMPtr nsElement = do_QueryInterface(doc->GetRootContent()); if (!nsElement) {return NS_ERROR_NULL_POINTER; } // let's get the size of the document diff --git a/mozilla/embedding/browser/activex/src/common/Makefile.in b/mozilla/embedding/browser/activex/src/common/Makefile.in index 8bf87d7b5ef..c4a3e4b2e80 100644 --- a/mozilla/embedding/browser/activex/src/common/Makefile.in +++ b/mozilla/embedding/browser/activex/src/common/Makefile.in @@ -38,6 +38,7 @@ REQUIRES = \ gfx \ layout \ content \ + necko \ $(NULL) CPPSRCS = \ diff --git a/mozilla/embedding/browser/activex/src/plugin/LegacyPlugin.cpp b/mozilla/embedding/browser/activex/src/plugin/LegacyPlugin.cpp index df1142b4698..7057e27f766 100644 --- a/mozilla/embedding/browser/activex/src/plugin/LegacyPlugin.cpp +++ b/mozilla/embedding/browser/activex/src/plugin/LegacyPlugin.cpp @@ -855,8 +855,7 @@ NewControl(const char *pluginType, nsCOMPtr doc(do_QueryInterface(DOMdocument)); if (doc) { - nsCOMPtr baseURI; - doc->GetBaseURL(getter_AddRefs(baseURI)); + nsIURI *baseURI = doc->GetBaseURL(); if (baseURI) { nsCAutoString newURL; diff --git a/mozilla/embedding/browser/activex/src/plugin/XPCDocument.cpp b/mozilla/embedding/browser/activex/src/plugin/XPCDocument.cpp index 5765c6b6c93..d1bde20497f 100644 --- a/mozilla/embedding/browser/activex/src/plugin/XPCDocument.cpp +++ b/mozilla/embedding/browser/activex/src/plugin/XPCDocument.cpp @@ -828,8 +828,7 @@ END_COM_MAP() if (!doc) return E_UNEXPECTED; - nsCOMPtr principal; - doc->GetPrincipal(getter_AddRefs(principal)); + nsIPrincipal *principal = doc->GetPrincipal(); if (!principal) return E_UNEXPECTED; @@ -1900,8 +1899,7 @@ END_COM_MAP() nsCOMPtr doc(do_QueryInterface(mDOMDocument)); if (doc) { - nsCOMPtr baseURI; - doc->GetBaseURL(getter_AddRefs(baseURI)); + nsIURI *baseURI = doc->GetBaseURL(); nsCAutoString spec; if (baseURI && NS_SUCCEEDED(baseURI->GetSpec(spec))) diff --git a/mozilla/embedding/browser/webBrowser/nsContextMenuInfo.cpp b/mozilla/embedding/browser/webBrowser/nsContextMenuInfo.cpp index e6ffb21c685..a5399200701 100644 --- a/mozilla/embedding/browser/webBrowser/nsContextMenuInfo.cpp +++ b/mozilla/embedding/browser/webBrowser/nsContextMenuInfo.cpp @@ -289,8 +289,7 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode * aDOMNode, imgIRequest // nothing on the element or its parent style contexts, fall back to canvas frame for the whole page rv = NS_ERROR_FAILURE; - nsCOMPtr rootContent; - document->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = document->GetRootContent(); NS_ENSURE_TRUE(rootContent, NS_ERROR_FAILURE); presShell->GetPrimaryFrameFor(rootContent, &frame); diff --git a/mozilla/embedding/components/commandhandler/src/Makefile.in b/mozilla/embedding/components/commandhandler/src/Makefile.in index ce9d2fc50b7..8429c7b4922 100644 --- a/mozilla/embedding/components/commandhandler/src/Makefile.in +++ b/mozilla/embedding/components/commandhandler/src/Makefile.in @@ -30,6 +30,7 @@ REQUIRES = string \ dom \ widget \ content \ + necko \ xuldoc \ caps \ xpconnect \ diff --git a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp index 1861a8842fc..6703438080e 100644 --- a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp +++ b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp @@ -634,10 +634,9 @@ nsresult nsWebBrowserFind::SearchInFrame(nsIDOMWindow* aWindow, nsCOMPtr theDoc = do_QueryInterface(domDoc); if (!theDoc) return NS_ERROR_FAILURE; - nsCOMPtr docURI; - rv = theDoc->GetDocumentURL(getter_AddRefs(docURI)); - NS_ENSURE_SUCCESS(rv, rv); - + nsIURI *docURI = theDoc->GetDocumentURL(); + NS_ENSURE_TRUE(docURI, NS_ERROR_FAILURE); + // Get the security manager and do the same-origin check nsCOMPtr secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/mozilla/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp index c7615cb5c38..decce548feb 100644 --- a/mozilla/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp +++ b/mozilla/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp @@ -1404,14 +1404,14 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal( // Persist the main document nsCOMPtr doc(do_QueryInterface(aDocument)); - doc->GetDocumentURL(getter_AddRefs(mURI)); + mURI = doc->GetDocumentURL(); nsCOMPtr oldBaseURI = mCurrentBaseURI; nsCAutoString oldCharset(mCurrentCharset); // Store the base URI and the charset - doc->GetBaseURL(getter_AddRefs(mCurrentBaseURI)); - doc->GetDocumentCharacterSet(mCurrentCharset); + mCurrentBaseURI = doc->GetBaseURL(); + mCurrentCharset = doc->GetDocumentCharacterSet(); // Does the caller want to fixup the referenced URIs and save those too? if (aDataPath) @@ -3377,13 +3377,8 @@ nsWebBrowserPersist::SaveDocumentWithFixup( nsCAutoString charsetStr(aSaveCharset); if (charsetStr.IsEmpty()) - { - rv = aDocument->GetDocumentCharacterSet(charsetStr); - if(NS_FAILED(rv)) - { - charsetStr = NS_LITERAL_CSTRING("ISO-8859-1"); - } - } + charsetStr = aDocument->GetDocumentCharacterSet(); + rv = encoder->SetCharset(charsetStr); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index b3475aad63d..769cfbd03bb 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -701,10 +701,7 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, newDocShell->GetContentViewer(getter_AddRefs(newContentViewer)); nsCOMPtr newMarkupDocViewer(do_QueryInterface(newContentViewer)); if (doc && newMarkupDocViewer) { - nsCAutoString charset; - rv = doc->GetDocumentCharacterSet(charset); - if (NS_SUCCEEDED(rv)) - newMarkupDocViewer->SetDefaultCharacterSet(charset); + newMarkupDocViewer->SetDefaultCharacterSet(doc->GetDocumentCharacterSet()); } } } @@ -775,11 +772,8 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, nsCOMPtr doc(do_QueryInterface(document)); if (doc) { - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - // Set the referrer - loadInfo->SetReferrer(uri); + loadInfo->SetReferrer(doc->GetDocumentURL()); } } } @@ -1133,7 +1127,7 @@ nsWindowWatcher::URIfromURL(const char *aURL, // failing that, use the given URL unmodified. It had better not be relative. - nsCOMPtr baseURI; + nsIURI *baseURI = nsnull; // get baseWindow's document URI if (baseWindow) { @@ -1143,7 +1137,7 @@ nsWindowWatcher::URIfromURL(const char *aURL, nsCOMPtr doc; doc = do_QueryInterface(domDoc); if (doc) { - doc->GetBaseURL(getter_AddRefs(baseURI)); + baseURI = doc->GetBaseURL(); } } } diff --git a/mozilla/extensions/cookie/nsImgManager.cpp b/mozilla/extensions/cookie/nsImgManager.cpp index 432ac960f9b..16928360638 100644 --- a/mozilla/extensions/cookie/nsImgManager.cpp +++ b/mozilla/extensions/cookie/nsImgManager.cpp @@ -150,7 +150,6 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRInt32 aContentType, if (!needToCheck) return NS_OK; - nsCOMPtr baseURI; nsCOMPtr doc; nsCOMPtr content = do_QueryInterface(aContext); NS_ASSERTION(content, "no content available"); @@ -168,8 +167,8 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRInt32 aContentType, return NS_OK; } - rv = doc->GetBaseURL(getter_AddRefs(baseURI)); - if (NS_FAILED(rv) || !baseURI) + nsIURI *baseURI = doc->GetBaseURL(); + if (!baseURI) return rv; nsCOMPtr docshell; diff --git a/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp b/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp index 6c39e143195..b21bc9f9df2 100644 --- a/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp +++ b/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp @@ -106,13 +106,10 @@ inCSSValueSearch::SearchSync() nsCOMPtr doc = do_QueryInterface(mDocument); if (doc) { - PRInt32 count = 0; // we want all the sheets, including inline style and such - doc->GetNumberOfStyleSheets(PR_TRUE, &count); + PRInt32 count = doc->GetNumberOfStyleSheets(PR_TRUE); for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr sheet; - doc->GetStyleSheetAt(i, PR_TRUE, getter_AddRefs(sheet)); - SearchStyleSheet(sheet); + SearchStyleSheet(doc->GetStyleSheetAt(i, PR_TRUE)); } } diff --git a/mozilla/extensions/inspector/base/src/inDOMUtils.cpp b/mozilla/extensions/inspector/base/src/inDOMUtils.cpp index a71a5e0a4a8..aef493f9885 100644 --- a/mozilla/extensions/inspector/base/src/inDOMUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inDOMUtils.cpp @@ -219,8 +219,7 @@ inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsISimpleEnumerator **_retva if (!doc1) return NS_OK; nsCOMPtr doc = do_QueryInterface(doc1); - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = doc->GetBindingManager(); if (!bindingManager) return NS_OK; nsCOMPtr content = do_QueryInterface(aElement); diff --git a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp index 3a298dfa09a..fdc970761e3 100644 --- a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp @@ -236,10 +236,7 @@ inLayoutUtils::GetBindingManagerFor(nsIDOMNode* aNode) aNode->GetOwnerDocument(getter_AddRefs(domdoc)); if (domdoc) { nsCOMPtr doc = do_QueryInterface(domdoc); - nsCOMPtr bindingManager = do_QueryInterface(domdoc); - doc->GetBindingManager(getter_AddRefs(bindingManager)); - - return bindingManager; + return doc->GetBindingManager(); } return nsnull; @@ -252,10 +249,7 @@ inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode) if (content) { nsCOMPtr doc = content->GetDocument(); if (doc) { - nsCOMPtr sub_doc; - doc->GetSubDocumentFor(content, getter_AddRefs(sub_doc)); - - nsCOMPtr domdoc(do_QueryInterface(sub_doc)); + nsCOMPtr domdoc(do_QueryInterface(doc->GetSubDocumentFor(content))); return domdoc; } diff --git a/mozilla/extensions/transformiix/source/base/txURIUtils.cpp b/mozilla/extensions/transformiix/source/base/txURIUtils.cpp index e3c2569ad99..912215d3798 100644 --- a/mozilla/extensions/transformiix/source/base/txURIUtils.cpp +++ b/mozilla/extensions/transformiix/source/base/txURIUtils.cpp @@ -298,7 +298,7 @@ PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode) } if (!principal) { - doc->GetPrincipal(getter_AddRefs(principal)); + principal = doc->GetPrincipal(); } if (!principal) { @@ -336,22 +336,18 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode) return; } - nsCOMPtr loadGroup; nsCOMPtr channel; - sourceDoc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = sourceDoc->GetDocumentLoadGroup(); nsCOMPtr serv = do_GetService(NS_IOSERVICE_CONTRACTID); if (serv) { // Create a temporary channel to get nsIDocument->Reset to // do the right thing. We want the output document to get // much of the input document's characteristics. - nsCOMPtr docURL; - sourceDoc->GetDocumentURL(getter_AddRefs(docURL)); - serv->NewChannelFromURI(docURL, getter_AddRefs(channel)); + serv->NewChannelFromURI(sourceDoc->GetDocumentURL(), + getter_AddRefs(channel)); } aNewDoc->Reset(channel, loadGroup); - nsCOMPtr baseURL; - sourceDoc->GetBaseURL(getter_AddRefs(baseURL)); - aNewDoc->SetBaseURL(baseURL); + aNewDoc->SetBaseURL(sourceDoc->GetBaseURL()); } diff --git a/mozilla/extensions/transformiix/source/xml/parser/txXMLParser.cpp b/mozilla/extensions/transformiix/source/xml/parser/txXMLParser.cpp index b1d71bacb03..c14c80c005f 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/txXMLParser.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/txXMLParser.cpp @@ -81,10 +81,8 @@ txParseDocumentFromURI(const nsAString& aHref, const nsAString& aReferrer, nsCOMPtr theDocument; nsCOMPtr loaderDocument = do_QueryInterface(aLoader->getNSObj()); - nsCOMPtr loadGroup; - nsCOMPtr loaderUri; - loaderDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - loaderDocument->GetDocumentURL(getter_AddRefs(loaderUri)); + nsCOMPtr loadGroup = loaderDocument->GetDocumentLoadGroup(); + nsIURI *loaderUri = loaderDocument->GetDocumentURL(); NS_ENSURE_TRUE(loaderUri, NS_ERROR_FAILURE); nsCOMPtr channel; diff --git a/mozilla/extensions/transformiix/source/xpath/Makefile.in b/mozilla/extensions/transformiix/source/xpath/Makefile.in index 11ab87526ae..97e1f9741b9 100644 --- a/mozilla/extensions/transformiix/source/xpath/Makefile.in +++ b/mozilla/extensions/transformiix/source/xpath/Makefile.in @@ -34,6 +34,7 @@ REQUIRES = string \ ifndef TX_EXE REQUIRES += dom \ content \ + necko \ widget \ xpconnect \ js \ diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp index 1b71209a127..4014ae7d4bf 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaStylesheetCompiler.cpp @@ -756,8 +756,7 @@ TX_CompileStylesheet(nsIDOMNode* aNode, txStylesheet** aStylesheet) } nsCOMPtr doc = do_QueryInterface(document); - nsCOMPtr uri; - doc->GetBaseURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetBaseURL(); nsCAutoString baseURI; uri->GetSpec(baseURI); diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp index 1142f5c86da..8e3780aaa8c 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaTextOutput.cpp @@ -168,23 +168,19 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument, } // Reset and set up document - nsCOMPtr loadGroup; nsCOMPtr channel; nsCOMPtr sourceDoc = do_QueryInterface(aSourceDocument); - sourceDoc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = sourceDoc->GetDocumentLoadGroup(); nsCOMPtr serv = do_GetService(NS_IOSERVICE_CONTRACTID); if (serv) { // Create a temporary channel to get nsIDocument->Reset to // do the right thing. We want the output document to get // much of the input document's characteristics. - nsCOMPtr docURL; - sourceDoc->GetDocumentURL(getter_AddRefs(docURL)); - serv->NewChannelFromURI(docURL, getter_AddRefs(channel)); + serv->NewChannelFromURI(sourceDoc->GetDocumentURL(), + getter_AddRefs(channel)); } doc->Reset(channel, loadGroup); - nsCOMPtr baseURL; - sourceDoc->GetBaseURL(getter_AddRefs(baseURL)); - doc->SetBaseURL(baseURL); + doc->SetBaseURL(sourceDoc->GetBaseURL()); // Notify the contentsink that the document is created nsCOMPtr observer = do_QueryReferent(mObserver); @@ -236,11 +232,7 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument, return; } - rv = doc->SetRootContent(rootContent); - NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to set the root content"); - if (NS_FAILED(rv)) { - return; - } + doc->SetRootContent(rootContent); mDocument->CreateElementNS(XHTML_NSURI, NS_LITERAL_STRING("head"), diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp index c8a6b9a01ca..280e5ed1dc7 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXMLOutput.cpp @@ -208,16 +208,14 @@ void txMozillaXMLOutput::endDocument() if (!mRefreshString.IsEmpty()) { nsCOMPtr doc = do_QueryInterface(mDocument); - nsCOMPtr sgo; - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); if (sgo) { nsCOMPtr docShell; sgo->GetDocShell(getter_AddRefs(docShell)); nsCOMPtr refURI = do_QueryInterface(docShell); if (refURI) { - nsCOMPtr baseURI; - doc->GetBaseURL(getter_AddRefs(baseURI)); - refURI->SetupRefreshURIFromHeader(baseURI, mRefreshString); + refURI->SetupRefreshURIFromHeader(doc->GetBaseURL(), + mRefreshString); } } } @@ -739,8 +737,7 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, PRInt32 aNsID, } // Set up script loader of the result document. - nsCOMPtr loader; - doc->GetScriptLoader(getter_AddRefs(loader)); + nsIScriptLoader *loader = doc->GetScriptLoader(); if (loader) { if (mNotifier) { loader->AddObserver(mNotifier); @@ -904,9 +901,8 @@ txTransformNotifier::SignalTransformEnd() // XXX Need a better way to determine transform success/failure if (mDocument) { - nsCOMPtr loader; nsCOMPtr doc = do_QueryInterface(mDocument); - doc->GetScriptLoader(getter_AddRefs(loader)); + nsIScriptLoader *loader = doc->GetScriptLoader(); if (loader) { loader->RemoveObserver(this); } diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 16712d2ec82..69c0cc9ab42 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -1342,9 +1342,9 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, } mFocusedWeakShell = do_GetWeakReference(presShell); - nsCOMPtr docContent; - doc->GetRootContent(getter_AddRefs(docContent)); + nsIContent *docContent = doc->GetRootContent(); if (docContent) { + // XXXbryner Do we really want to focus the root content here? docContent->SetFocus(presContext); } // Get selection controller and selection for new frame/iframe @@ -1493,7 +1493,7 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer, rootContent = do_QueryInterface(bodyEl); } if (!rootContent) { - doc->GetRootContent(getter_AddRefs(rootContent)); + rootContent = doc->GetRootContent(); } nsCOMPtr rootNode(do_QueryInterface(rootContent)); @@ -1981,15 +1981,11 @@ nsTypeAheadFind::GetAutoStart(nsIDOMWindow *aDOMWin, PRBool *aIsAutoStartOn) } } - nsCOMPtr parentDoc; - doc->GetParentDocument(getter_AddRefs(parentDoc)); + nsIDocument *parentDoc = doc->GetParentDocument(); if (parentDoc) { - nsCOMPtr browserElContent; // get content for - parentDoc->FindContentForSubDocument(doc, - getter_AddRefs(browserElContent)); nsCOMPtr browserElement = - do_QueryInterface(browserElContent); + do_QueryInterface(parentDoc->FindContentForSubDocument(doc)); if (browserElement) { nsAutoString tagName, autoFind, test; @@ -2483,9 +2479,7 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, return NS_OK; } - nsCOMPtr ourGlobal; - doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr domWin(do_QueryInterface(ourGlobal)); + nsCOMPtr domWin(do_QueryInterface(doc->GetScriptGlobalObject())); nsCOMPtr topContentWin; GetStartWindow(domWin, getter_AddRefs(topContentWin)); @@ -3015,8 +3009,7 @@ nsTypeAheadController::EnsureContentWindow(nsIDOMWindowInternal *aFocusedWin, docShell->GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); NS_ENSURE_TRUE(rootContent, NS_ERROR_FAILURE); rootContent->SetFocus(presContext); } diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 00ab47daf7f..db427bb3002 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -391,8 +391,7 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, return NS_OK; } - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetDocumentURL(); if (!uri) { NS_ASSERTION(0, "no URI available"); return NS_OK; diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 9061037e948..2cd7c520c73 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -2707,8 +2707,7 @@ static void wallet_InitializeCurrentURL(nsIDocument * doc) { /* get url */ - nsCOMPtr url; - doc->GetDocumentURL(getter_AddRefs(url)); + nsIURI *url = doc->GetDocumentURL(); if (wallet_lastUrl == url) { return; } else { @@ -3436,8 +3435,7 @@ wallet_TraversalForPrefill if (NS_SUCCEEDED(result)) { nsCOMPtr doc = do_QueryInterface(domdoc); if (doc) { - nsCOMPtr url; - doc->GetDocumentURL(getter_AddRefs(url)); + nsIURI *url = doc->GetDocumentURL(); if (url) { wallet_GetHostFile(url, urlName); } @@ -3911,8 +3909,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) { if (!doc) { return; } - nsCOMPtr docURL; - doc->GetDocumentURL(getter_AddRefs(docURL)); + nsIURI *docURL = doc->GetDocumentURL(); if (!docURL) { return; } diff --git a/mozilla/extensions/webservices/soap/src/nsHTTPSOAPTransport.cpp b/mozilla/extensions/webservices/soap/src/nsHTTPSOAPTransport.cpp index 6668070e1a7..21e9b5eced5 100644 --- a/mozilla/extensions/webservices/soap/src/nsHTTPSOAPTransport.cpp +++ b/mozilla/extensions/webservices/soap/src/nsHTTPSOAPTransport.cpp @@ -112,9 +112,7 @@ nsresult ChangePrincipal(nsIDOMDocument* aDocument) nsCOMPtr targetDoc(do_QueryInterface(aDocument, &rv)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr targetURI; - targetDoc->GetDocumentURL(getter_AddRefs(targetURI)); - rv = secMgr->CheckSameOrigin(nsnull, targetURI); + rv = secMgr->CheckSameOrigin(nsnull, targetDoc->GetDocumentURL()); // change the principal only if the script security // manager has denied access. if (NS_FAILED(rv)) { diff --git a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp index d8614058803..a6082e21174 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp @@ -482,7 +482,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream, nsCOMPtr doc = do_QueryInterface(domdoc); if (doc) { - doc->GetBaseURL(getter_AddRefs(baseURI)); + baseURI = doc->GetBaseURL(); } } } diff --git a/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp b/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp index b34833b8364..e1952e9f29e 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp @@ -102,9 +102,7 @@ static nsresult SetUpEncoder(nsIDOMNode *aRoot, const char* aCharset, nsIDocumen if (aCharset) { charset = aCharset; } else { - rv = document->GetDocumentCharacterSet(charset); - if (NS_FAILED(rv)) - return rv; + charset = document->GetDocumentCharacterSet(); } rv = encoder->SetCharset(charset); if (NS_FAILED(rv)) @@ -150,10 +148,9 @@ nsresult CheckSameOrigin(nsIDOMNode *aRoot) nsCOMPtr doc(do_QueryInterface(owner_doc)); if (doc) { - nsCOMPtr principal; nsCOMPtr root_uri; - doc->GetPrincipal(getter_AddRefs(principal)); + nsIPrincipal *principal = doc->GetPrincipal(); if (principal) { principal->GetURI(getter_AddRefs(root_uri)); diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 2907d6646d9..29055c74efe 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -402,9 +402,7 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer) nsCAutoString dataCharset; nsCOMPtr document(do_QueryInterface(mDocument)); if (document) { - rv = document->GetDocumentCharacterSet(dataCharset); - if (NS_FAILED(rv)) - return rv; + dataCharset = document->GetDocumentCharacterSet(); } else { if (NS_FAILED(DetectCharset(dataCharset)) || dataCharset.IsEmpty()) { // MS documentation states UTF-8 is default for responseText @@ -609,7 +607,7 @@ nsXMLHttpRequest::GetLoadGroup(nsILoadGroup **aLoadGroup) nsCOMPtr doc = GetDocumentFromScriptContext(mScriptContext); if (doc) { - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } return NS_OK; @@ -630,7 +628,7 @@ nsXMLHttpRequest::GetBaseURI(nsIURI **aBaseURI) nsCOMPtr doc = GetDocumentFromScriptContext(mScriptContext); if (doc) { - doc->GetBaseURL(aBaseURI); + NS_IF_ADDREF(*aBaseURI = doc->GetBaseURL()); } return NS_OK; diff --git a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp index 494dbdeb719..b7f848f3a87 100644 --- a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp +++ b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp @@ -272,10 +272,8 @@ int main (int argc, char* argv[]) nsCRT::free(s); nsCOMPtr doc = do_QueryInterface(pDOMDocument); if (doc) { - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); nsCAutoString spec; - uri->GetSpec(spec); + doc->GetDocumentURL()->GetSpec(spec); printf("Document URI=\"%s\"\n",spec.get()); } } diff --git a/mozilla/gfx/src/gtk/Makefile.in b/mozilla/gfx/src/gtk/Makefile.in index 38a47208a7d..2461c959255 100644 --- a/mozilla/gfx/src/gtk/Makefile.in +++ b/mozilla/gfx/src/gtk/Makefile.in @@ -45,6 +45,7 @@ REQUIRES = xpcom \ locale \ necko \ content \ + dom \ layout \ imglib2 \ $(NULL) diff --git a/mozilla/intl/build/Makefile.in b/mozilla/intl/build/Makefile.in index 4042b8343d4..ab309f0a167 100644 --- a/mozilla/intl/build/Makefile.in +++ b/mozilla/intl/build/Makefile.in @@ -40,6 +40,7 @@ REQUIRES = xpcom \ locale \ htmlparser \ content \ + dom \ widget \ webshell \ necko \ diff --git a/mozilla/intl/chardet/src/Makefile.in b/mozilla/intl/chardet/src/Makefile.in index 83ff17ab208..519d8d9457b 100644 --- a/mozilla/intl/chardet/src/Makefile.in +++ b/mozilla/intl/chardet/src/Makefile.in @@ -40,6 +40,7 @@ REQUIRES = xpcom \ necko \ widget \ content \ + dom \ embedcomponents \ $(NULL) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index d313992a534..4838653f864 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -1377,9 +1377,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... - nsCOMPtr nimgr; - nsresult rv = aDocument->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + nsINodeInfoManager *nimgr = aDocument->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); // XXXldb We should not be creating an |image| element, because it // matches selectors! See bug 109216. @@ -1387,6 +1386,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); + nsresult rv; nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -3368,8 +3368,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, return NS_OK; // Binding will load asynchronously. if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -3578,8 +3577,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, */ // Set up our style rule observer. - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); if (bindingManager) { nsCOMPtr ruleSupplier(do_QueryInterface(bindingManager)); nsCOMPtr set; @@ -5725,9 +5723,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, if (processChildren || processAnonymousChildren) { nsFrameItems childItems; if (processChildren) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->ShouldBuildChildFrames(aContent, &processChildren); + mDocument->GetBindingManager()->ShouldBuildChildFrames(aContent, + &processChildren); if (processChildren) rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_FALSE, childItems, PR_FALSE); @@ -7154,8 +7151,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe aFrameItems, PR_TRUE); if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -7234,8 +7230,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe } if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -7268,8 +7263,7 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte aPresContext->GetShell(getter_AddRefs(shell)); if (mDocument && shell) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { // Before removing the frames associated with the content object, ask them to save their @@ -8135,8 +8129,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, #ifdef MOZ_XUL if (aContainer) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); nsCOMPtr tag; PRInt32 namespaceID; @@ -8169,7 +8162,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, PRBool hasInsertion = PR_FALSE; if (!multiple) { - nsCOMPtr bindingManager; + nsIBindingManager *bindingManager = nsnull; nsIDocument* document = nsnull; nsIContent *firstAppendedChild = aContainer->GetChildAt(aNewIndexInContainer); @@ -8177,7 +8170,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, document = firstAppendedChild->GetDocument(); } if (document) - document->GetBindingManager(getter_AddRefs(bindingManager)); + bindingManager = document->GetBindingManager(); if (bindingManager) { nsCOMPtr insParent; bindingManager->GetInsertionParent(firstAppendedChild, getter_AddRefs(insParent)); @@ -8393,9 +8386,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } // We built some new frames. Initialize any newly-constructed bindings. - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) { @@ -8710,9 +8701,6 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext, if (!aContainer) return PR_FALSE; - nsCOMPtr bindingManager; - aDocument->GetBindingManager(getter_AddRefs(bindingManager)); - nsCOMPtr tag; aChild->GetTag(getter_AddRefs(tag)); @@ -8751,7 +8739,8 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext, } PRInt32 namespaceID; - bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag)); + aDocument->GetBindingManager()->ResolveTag(aContainer, &namespaceID, + getter_AddRefs(tag)); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsXULAtoms::treechildren || @@ -8800,10 +8789,9 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // If we have a null parent, then this must be the document element // being inserted if (! aContainer) { - nsCOMPtr docElement; - mDocument->GetRootContent(getter_AddRefs(docElement)); + nsIContent *docElement = mDocument->GetRootContent(); - if (aChild == docElement.get()) { + if (aChild == docElement) { NS_PRECONDITION(nsnull == mInitialContainingBlock, "initial containing block already created"); if (!mDocElementContainingBlock) @@ -8849,9 +8837,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, #endif } - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // otherwise this is not a child of the root element, and we // won't let it have a frame. @@ -9039,9 +9025,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // Now that we've created frames, run the attach queue. //XXXwaterson should we do this after we've processed pseudos, too? - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) @@ -10243,12 +10227,10 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // content from being removed and re-inserted (which is what would // happen otherwise). if (!primaryFrame && !reframe) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); - PRInt32 namespaceID; nsCOMPtr tag; - bindingManager->ResolveTag(aContent, &namespaceID, getter_AddRefs(tag)); + mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID, + getter_AddRefs(tag)); if (tag && (tag.get() == nsXULAtoms::listitem || tag.get() == nsXULAtoms::listcell)) return NS_OK; @@ -11399,8 +11381,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell, if (!document) return NS_OK; - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = document->GetBindingManager(); if (!bindingManager) return NS_OK; @@ -12724,9 +12705,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, *aNewFrame = newFrame; if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // Notify the parent frame if (aIsAppend) diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index ca5ff2980af..ad32828e716 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -1553,7 +1553,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, nsIDocument *doc = nsnull; if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) { nsIContent *pContent; - if (NS_SUCCEEDED(doc->GetRootContent(&pContent)) && pContent) { + if ((pContent = doc->GetRootContent())) { // make sure that this is the HTML element nsCOMPtr tag; pContent->GetTag(getter_AddRefs(tag)); @@ -1581,7 +1581,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, } #endif }// if tag - NS_RELEASE(pContent); }// if content NS_RELEASE(doc); }// if doc diff --git a/mozilla/layout/base/nsChildIterator.cpp b/mozilla/layout/base/nsChildIterator.cpp index 7094a6c1b43..9ec5c19f432 100644 --- a/mozilla/layout/base/nsChildIterator.cpp +++ b/mozilla/layout/base/nsChildIterator.cpp @@ -58,8 +58,7 @@ ChildIterator::Init(nsIContent* aContent, if (! doc) return NS_ERROR_FAILURE; - nsCOMPtr mgr; - doc->GetBindingManager(getter_AddRefs(mgr)); + nsIBindingManager *mgr = doc->GetBindingManager(); if (! mgr) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index d363389d92b..07c90ec0baf 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -704,10 +704,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) nsCOMPtr sc = do_QueryInterface(mContainer); if (sc) { - nsCOMPtr root; - mDocument->GetRootContent(getter_AddRefs(root)); - - nsCOMPtr frameset(do_QueryInterface(root)); + nsCOMPtr frameset(do_QueryInterface(mDocument->GetRootContent())); if (frameset) { // If this is a frameset (i.e. not a frame) then we never want @@ -899,10 +896,8 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus) nsresult rv = NS_OK; NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); - nsCOMPtr global; - // First, get the script global object from the document... - rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = mDocument->GetScriptGlobalObject(); // Fail if no ScriptGlobalObject is available... NS_ENSURE_TRUE(global, NS_ERROR_NULL_POINTER); @@ -979,9 +974,8 @@ DocumentViewerImpl::Unload() } // First, get the script global object from the document... - nsCOMPtr global; + nsCOMPtr global = mDocument->GetScriptGlobalObject(); - nsresult rv = mDocument->GetScriptGlobalObject(getter_AddRefs(global)); if (!global) { // Fail if no ScriptGlobalObject is available... NS_ASSERTION(0, "nsIScriptGlobalObject not set for document!"); @@ -994,10 +988,8 @@ DocumentViewerImpl::Unload() event.eventStructType = NS_EVENT; event.message = NS_PAGE_UNLOAD; - rv = global->HandleDOMEvent(mPresContext, &event, nsnull, - NS_EVENT_FLAG_INIT, &status); - - return rv; + return global->HandleDOMEvent(mPresContext, &event, nsnull, + NS_EVENT_FLAG_INIT, &status); } NS_IMETHODIMP @@ -1025,8 +1017,7 @@ DocumentViewerImpl::Close() // Break global object circular reference on the document created // in the DocViewer Init - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); + nsIScriptGlobalObject* globalObject = mDocument->GetScriptGlobalObject(); if (globalObject) { globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE); @@ -1622,12 +1613,10 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, rv = CallCreateInstance(kStyleSetCID, aStyleSet); if (NS_OK == rv) { - PRInt32 index = 0; - aDocument->GetNumberOfStyleSheets(PR_TRUE, &index); + PRInt32 index = aDocument->GetNumberOfStyleSheets(PR_TRUE); while (0 < index--) { - nsCOMPtr sheet; - aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = aDocument->GetStyleSheetAt(index, PR_TRUE); /* * GetStyleSheetAt will return all style sheets in the document but @@ -1731,9 +1720,8 @@ DocumentViewerImpl::GetPresShellAndRootContent(nsIWebShell * aWebShell, if (!doc) return; - doc->GetRootContent(aContent); // this addrefs - *aPresShell = presShell; - NS_ADDREF(*aPresShell); + NS_IF_ADDREF(*aContent = doc->GetRootContent()); + NS_ADDREF(*aPresShell = presShell); } //--------------------------------------------------------------------- @@ -2014,9 +2002,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } else if (mDocument) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - bodyNode = do_QueryInterface(rootContent); + bodyNode = do_QueryInterface(mDocument->GetRootContent()); } if (!bodyNode) return NS_ERROR_FAILURE; @@ -2759,31 +2745,22 @@ DocumentViewerImpl::GetPopupNode(nsIDOMNode** aNode) NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(document, NS_ERROR_FAILURE); - // get the script global object - nsCOMPtr global; - rv = document->GetScriptGlobalObject(getter_AddRefs(global)); - NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(global, NS_ERROR_FAILURE); // get the internal dom window - nsCOMPtr internalWin(do_QueryInterface(global, &rv)); + nsCOMPtr internalWin(do_QueryInterface(document->GetScriptGlobalObject(), &rv)); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(internalWin, NS_ERROR_FAILURE); // get the private dom window nsCOMPtr privateWin(do_QueryInterface(internalWin, &rv)); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(privateWin, NS_ERROR_FAILURE); // get the focus controller nsCOMPtr focusController; - rv = privateWin->GetRootFocusController(getter_AddRefs(focusController)); - NS_ENSURE_SUCCESS(rv, rv); + privateWin->GetRootFocusController(getter_AddRefs(focusController)); NS_ENSURE_TRUE(focusController, NS_ERROR_FAILURE); // get the popup node - rv = focusController->GetPopupNode(aNode); // addref happens here - NS_ENSURE_SUCCESS(rv, rv); + focusController->GetPopupNode(aNode); // addref happens here return rv; } @@ -2953,10 +2930,7 @@ NS_IMETHODIMP nsDocViewerSelectionListener::NotifySelectionChanged(nsIDOMDocumen mDocViewer->GetDocument(getter_AddRefs(theDoc)); if (!theDoc) return NS_ERROR_FAILURE; - nsCOMPtr scriptGlobalObject; - theDoc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - - nsCOMPtr domWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWindow = do_QueryInterface(theDoc->GetScriptGlobalObject()); if (!domWindow) return NS_ERROR_FAILURE; domWindow->UpdateCommands(NS_LITERAL_STRING("select")); diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index fc190e59679..8d7b49392eb 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -1196,8 +1196,7 @@ nsresult CantRenderReplacedElementEvent::AddLoadGroupRequest(nsIPresShell* aPres if (NS_FAILED(rv)) return rv; if (!mDummyLayoutRequest) return NS_ERROR_FAILURE; - nsCOMPtr loadGroup; - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (!loadGroup) return NS_ERROR_FAILURE; rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); @@ -1224,8 +1223,7 @@ nsresult CantRenderReplacedElementEvent::RemoveLoadGroupRequest() presShell->GetDocument(getter_AddRefs(doc)); if (!doc) return NS_ERROR_FAILURE;; - nsCOMPtr loadGroup; - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (!loadGroup) return NS_ERROR_FAILURE; rv = loadGroup->RemoveRequest(request, nsnull, NS_OK); diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp index 5db7abc6d58..2bab305f34a 100644 --- a/mozilla/layout/base/nsImageLoader.cpp +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -90,8 +90,6 @@ nsImageLoader::Load(nsIURI *aURI) if (!aURI) return NS_ERROR_FAILURE; - nsCOMPtr loadGroup; - nsCOMPtr shell; nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); if ((NS_FAILED(rv)) || (!shell)) return NS_ERROR_FAILURE; @@ -101,11 +99,7 @@ nsImageLoader::Load(nsIURI *aURI) if (NS_FAILED(rv)) return rv; // Get the document's loadgroup - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - - // Get the document URI (for the referrer). - nsCOMPtr documentURI; - doc->GetDocumentURL(getter_AddRefs(documentURI)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (mRequest) { nsCOMPtr oldURI; @@ -124,7 +118,7 @@ nsImageLoader::Load(nsIURI *aURI) if (NS_FAILED(rv)) return rv; // XXX: initialDocumentURI is NULL! - return il->LoadImage(aURI, nsnull, documentURI, loadGroup, + return il->LoadImage(aURI, nsnull, doc->GetDocumentURL(), loadGroup, this, doc, nsIRequest::LOAD_BACKGROUND, nsnull, nsnull, getter_AddRefs(mRequest)); diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index c7e5f58da54..5d6090c8756 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -683,7 +683,7 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) { NS_ASSERTION(doc, "expect document here"); if (doc) { - doc->GetBaseURL(getter_AddRefs(mBaseURL)); + mBaseURL = doc->GetBaseURL(); if (mBaseURL) { PRBool isChrome = PR_FALSE; @@ -698,10 +698,8 @@ nsPresContext::SetShell(nsIPresShell* aShell) } if (mLangService) { - nsCAutoString charset; doc->AddCharSetObserver(this); - doc->GetDocumentCharacterSet(charset); - UpdateCharSet(charset.get()); + UpdateCharSet(PromiseFlatCString(doc->GetDocumentCharacterSet()).get()); } } } @@ -863,8 +861,7 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) if (mShell != nsnull) { mShell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (rootContent) { SetImgAnimations(rootContent, aMode); } @@ -1367,8 +1364,7 @@ nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags) (void) mShell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr loadGroup; - (void) doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (loadGroup) { loadGroup->GetLoadFlags(&aLoadFlags); @@ -1404,12 +1400,8 @@ nsPresContext::LoadImage(nsIURI* aURL, // XXXldb This really means the document is being destroyed, so // perhaps we're better off skipping the load entirely. if (document) { - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - - if (globalScript) { - nsCOMPtr domWin(do_QueryInterface(globalScript)); - + nsCOMPtr domWin(do_QueryInterface(document->GetScriptGlobalObject())); + if (domWin) { PRBool shouldLoad = PR_TRUE; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE, aURL, element, domWin, &shouldLoad); @@ -1564,7 +1556,7 @@ nsPresContext::GetBidiEnabled(PRBool* aBidiEnabled) const mShell->GetDocument(getter_AddRefs(doc) ); NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled"); if (doc) { - doc->GetBidiEnabled(aBidiEnabled); + *aBidiEnabled = doc->GetBidiEnabled(); } } return NS_OK; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 6052d1056a9..5e855f197ea 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1992,13 +1992,11 @@ NS_IMETHODIMP PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle) { if (mDocument && mStyleSet) { - PRInt32 count = 0; - mDocument->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); PRInt32 index; NS_NAMED_LITERAL_STRING(textHtml,"text/html"); for (index = 0; index < count; index++) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(index, PR_FALSE); PRBool complete; sheet->GetComplete(complete); if (complete) { @@ -2029,13 +2027,11 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList) { // XXX should this be returning incomplete sheets? Probably. if (mDocument) { - PRInt32 count = 0; - mDocument->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); PRInt32 index; NS_NAMED_LITERAL_STRING(textHtml,"text/html"); for (index = 0; index < count; index++) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(index, PR_FALSE); if (sheet) { nsAutoString type; sheet->GetType(type); @@ -2101,8 +2097,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) return NS_ERROR_NULL_POINTER; } - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + nsIScriptGlobalObject *globalObj = mDocument->GetScriptGlobalObject(); // If the document doesn't have a global object there's no need to // notify its presshell about changes to preferences since the @@ -2641,17 +2636,13 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, } while (curDoc) { - nsCOMPtr globalObject; - curDoc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr curWin = do_QueryInterface(globalObject); + nsCOMPtr curWin = do_QueryInterface(curDoc->GetScriptGlobalObject()); if (curWin == ourWin || !curWin) break; - nsCOMPtr parentDoc; - curDoc->GetParentDocument(getter_AddRefs(parentDoc)); - if (parentDoc == aDocument) + curDoc = curDoc->GetParentDocument(); + if (curDoc == aDocument) return; - curDoc = parentDoc; } if (!curDoc) { @@ -2747,14 +2738,12 @@ PresShell::GetDidInitialReflow(PRBool *aDidInitialReflow) NS_IMETHODIMP PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) { - nsCOMPtr root; mDidInitialReflow = PR_TRUE; #ifdef NS_DEBUG if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) { - nsCOMPtr uri; if (mDocument) { - mDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = mDocument->GetDocumentURL(); if (uri) { nsCAutoString url; uri->GetSpec(url); @@ -2776,9 +2765,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) mPresContext->SetVisibleArea(r); } - if (mDocument) { - mDocument->GetRootContent(getter_AddRefs(root)); - } + nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull; // Get the root frame from the frame manager nsIFrame* rootFrame; @@ -3084,8 +3071,7 @@ PresShell::FireResizeEvent() event.message = NS_RESIZE_EVENT; event.time = 0; - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + nsCOMPtr globalObj = mDocument->GetScriptGlobalObject(); if (globalObj) { globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -3759,8 +3745,7 @@ PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) aReflowCommand->List(stdout); if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) { printf("Current content model:\n"); - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { rootContent->List(stdout, 0); } @@ -4329,11 +4314,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame, if (content) { nsIDocument* document = content->GetDocument(); if (document){ - nsCOMPtr focusController; - nsCOMPtr ourGlobal; - document->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(document->GetScriptGlobalObject()); if(ourWindow) { + nsCOMPtr focusController; ourWindow->GetRootFocusController(getter_AddRefs(focusController)); if (focusController) { PRBool dontScroll; @@ -4670,9 +4653,7 @@ PresShell::DoCopy() return rv; // Now that we have copied, update the Paste menu item - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr domWindow = do_QueryInterface(globalObject); + nsCOMPtr domWindow = do_QueryInterface(doc->GetScriptGlobalObject()); if (domWindow) { domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard")); @@ -4892,9 +4873,7 @@ PresShell::IsPaintingSuppressed(PRBool* aResult) void PresShell::UnsuppressAndInvalidate() { - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr ourWindow = do_QueryInterface(globalObject); + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); nsCOMPtr focusController; if (ourWindow) ourWindow->GetRootFocusController(getter_AddRefs(focusController)); @@ -5391,14 +5370,8 @@ PresShell::ContentRemoved(nsIDocument *aDocument, // to be called again should a new root node be inserted for this // presShell. (Bug 167355) - if (mDocument) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - - if (!rootContent) { - mDidInitialReflow = PR_FALSE; - } - } + if (mDocument && !mDocument->GetRootContent()) + mDidInitialReflow = PR_FALSE; VERIFY_STYLE_TREE; DidCauseReflow(); @@ -5977,9 +5950,7 @@ PresShell::HandleEvent(nsIView *aView, // to redraw pre-edit (composed) string // If Mozilla does not have input focus and event is IME, // sends IME event to pre-focused element - nsCOMPtr ourGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); if (ourWindow) { nsCOMPtr focusController; ourWindow->GetRootFocusController(getter_AddRefs(focusController)); @@ -6001,7 +5972,7 @@ PresShell::HandleEvent(nsIView *aView, } #endif /* defined(MOZ_X11) */ if (!mCurrentEventContent) { - mDocument->GetRootContent(&mCurrentEventContent); + NS_IF_ADDREF(mCurrentEventContent = mDocument->GetRootContent()); } mCurrentEventFrame = nsnull; } @@ -6706,10 +6677,8 @@ PresShell::AddDummyLayoutRequest(void) if (NS_FAILED(rv)) return rv; nsCOMPtr loadGroup; - if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) return rv; - } + if (mDocument) + loadGroup = mDocument->GetDocumentLoadGroup(); if (loadGroup) { rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); @@ -6731,10 +6700,8 @@ PresShell::RemoveDummyLayoutRequest(void) if (gAsyncReflowDuringDocLoad) { nsCOMPtr loadGroup; - if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) return rv; - } + if (mDocument) + loadGroup = mDocument->GetDocumentLoadGroup(); if (loadGroup && mDummyLayoutRequest) { rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK); @@ -7414,8 +7381,7 @@ PresShell::DumpReflows() if (mReflowCountMgr) { nsCAutoString uriStr; if (mDocument) { - nsCOMPtr uri; - mDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = mDocument->GetDocumentURL(); if (uri) { uri->GetPath(uriStr); } diff --git a/mozilla/layout/base/src/nsCopySupport.cpp b/mozilla/layout/base/src/nsCopySupport.cpp index 2ad96f33181..37d2cf14ac0 100644 --- a/mozilla/layout/base/src/nsCopySupport.cpp +++ b/mozilla/layout/base/src/nsCopySupport.cpp @@ -289,10 +289,8 @@ nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans, *aDoPutOnClipboard = PR_TRUE; - nsCOMPtr isupp; - nsresult rv = aDoc->GetContainer(getter_AddRefs(isupp)); - nsCOMPtr docShell = do_QueryInterface(isupp); - nsCOMPtr hookObj = do_GetInterface(docShell); + nsCOMPtr container = aDoc->GetContainer(); + nsCOMPtr hookObj = do_GetInterface(container); if (!hookObj) return NS_ERROR_FAILURE; nsCOMPtr enumerator; @@ -303,7 +301,9 @@ nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans, // nsIClipboardDragDropHooks.h nsCOMPtr override; + nsCOMPtr isupp; PRBool hasMoreHooks = PR_FALSE; + nsresult rv = NS_OK; while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks) { diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp index 5db7abc6d58..2bab305f34a 100644 --- a/mozilla/layout/base/src/nsImageLoader.cpp +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -90,8 +90,6 @@ nsImageLoader::Load(nsIURI *aURI) if (!aURI) return NS_ERROR_FAILURE; - nsCOMPtr loadGroup; - nsCOMPtr shell; nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); if ((NS_FAILED(rv)) || (!shell)) return NS_ERROR_FAILURE; @@ -101,11 +99,7 @@ nsImageLoader::Load(nsIURI *aURI) if (NS_FAILED(rv)) return rv; // Get the document's loadgroup - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - - // Get the document URI (for the referrer). - nsCOMPtr documentURI; - doc->GetDocumentURL(getter_AddRefs(documentURI)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (mRequest) { nsCOMPtr oldURI; @@ -124,7 +118,7 @@ nsImageLoader::Load(nsIURI *aURI) if (NS_FAILED(rv)) return rv; // XXX: initialDocumentURI is NULL! - return il->LoadImage(aURI, nsnull, documentURI, loadGroup, + return il->LoadImage(aURI, nsnull, doc->GetDocumentURL(), loadGroup, this, doc, nsIRequest::LOAD_BACKGROUND, nsnull, nsnull, getter_AddRefs(mRequest)); diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index c7e5f58da54..5d6090c8756 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -683,7 +683,7 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) { NS_ASSERTION(doc, "expect document here"); if (doc) { - doc->GetBaseURL(getter_AddRefs(mBaseURL)); + mBaseURL = doc->GetBaseURL(); if (mBaseURL) { PRBool isChrome = PR_FALSE; @@ -698,10 +698,8 @@ nsPresContext::SetShell(nsIPresShell* aShell) } if (mLangService) { - nsCAutoString charset; doc->AddCharSetObserver(this); - doc->GetDocumentCharacterSet(charset); - UpdateCharSet(charset.get()); + UpdateCharSet(PromiseFlatCString(doc->GetDocumentCharacterSet()).get()); } } } @@ -863,8 +861,7 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) if (mShell != nsnull) { mShell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (rootContent) { SetImgAnimations(rootContent, aMode); } @@ -1367,8 +1364,7 @@ nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags) (void) mShell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr loadGroup; - (void) doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (loadGroup) { loadGroup->GetLoadFlags(&aLoadFlags); @@ -1404,12 +1400,8 @@ nsPresContext::LoadImage(nsIURI* aURL, // XXXldb This really means the document is being destroyed, so // perhaps we're better off skipping the load entirely. if (document) { - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - - if (globalScript) { - nsCOMPtr domWin(do_QueryInterface(globalScript)); - + nsCOMPtr domWin(do_QueryInterface(document->GetScriptGlobalObject())); + if (domWin) { PRBool shouldLoad = PR_TRUE; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE, aURL, element, domWin, &shouldLoad); @@ -1564,7 +1556,7 @@ nsPresContext::GetBidiEnabled(PRBool* aBidiEnabled) const mShell->GetDocument(getter_AddRefs(doc) ); NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled"); if (doc) { - doc->GetBidiEnabled(aBidiEnabled); + *aBidiEnabled = doc->GetBidiEnabled(); } } return NS_OK; diff --git a/mozilla/layout/build/nsContentDLF.cpp b/mozilla/layout/build/nsContentDLF.cpp index f66723c3125..547a8e10246 100644 --- a/mozilla/layout/build/nsContentDLF.cpp +++ b/mozilla/layout/build/nsContentDLF.cpp @@ -327,16 +327,17 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsIDocument **aDocum // initialize nsCOMPtr uri; NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank")); - if (uri) - rv = blankDoc->ResetToURI(uri, aLoadGroup); + if (uri) { + blankDoc->ResetToURI(uri, aLoadGroup); + rv = NS_OK; + } } // add some simple content structure if (NS_SUCCEEDED(rv)) { rv = NS_ERROR_FAILURE; - nsCOMPtr nim; - blankDoc->GetNodeInfoManager(getter_AddRefs(nim)); + nsINodeInfoManager *nim = blankDoc->GetNodeInfoManager(); if (nim) { nsCOMPtr htmlNodeInfo; @@ -366,9 +367,7 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, nsIDocument **aDocum htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE); - PRInt32 id; - blankDoc->GetAndIncrementContentID(&id); - bodyElement->SetContentID(id); + bodyElement->SetContentID(blankDoc->GetAndIncrementContentID()); htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE); rv = NS_OK; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 00a26ac252d..385003e6204 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -2126,9 +2126,8 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc = mContent->GetDocument(); // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); - nsCOMPtr nimgr; - result = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(result, result); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index e7a3225504a..59c958501fd 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -140,14 +140,14 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, { // Get the NodeInfoManager and tag necessary to create input elements nsCOMPtr doc = mContent->GetDocument(); - nsCOMPtr nimgr; - nsresult rv = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); + nsresult rv; nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -272,12 +272,7 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr scriptGlobalObject; - result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - if (!scriptGlobalObject) - return NS_FAILED(result) ? result : NS_ERROR_FAILURE; - - nsCOMPtr parentWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr parentWindow = do_QueryInterface(doc->GetScriptGlobalObject()); if (!parentWindow) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index 94999e33439..efaf6f0ecf6 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -228,9 +228,8 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the node info manager (used to create hr's and input's) nsCOMPtr doc = mContent->GetDocument(); - nsCOMPtr nimgr; - result = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(result, result); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&result)); NS_ENSURE_SUCCESS(result, result); @@ -420,10 +419,11 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 // Resolve url to an absolute url - nsCOMPtr docURL; - document->GetBaseURL(getter_AddRefs(docURL)); - NS_ASSERTION(docURL, "No Base URL found in Form Submit!\n"); - if (!docURL) return NS_OK; // No base URL -> exit early, see Bug 30721 + nsIURI *docURL = document->GetBaseURL(); + if (!docURL) { + NS_ERROR("No Base URL found in Form Submit!\n"); + return NS_OK; // No base URL -> exit early, see Bug 30721 + } // If an action is not specified and we are inside // a HTML document then reload the URL. This makes us @@ -463,10 +463,11 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) nsCOMPtr actionURL; nsXPIDLCString scheme; PRBool isJSURL = PR_FALSE; - nsCAutoString docCharset; - document->GetDocumentCharacterSet(docCharset); + const nsACString &docCharset = document->GetDocumentCharacterSet(); + const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); + if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, - docCharset.get(), + flatDocCharset.get(), docURL))) { result = actionURL->SchemeIs("javascript", &isJSURL); } @@ -483,7 +484,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) } nsCOMPtr uri; result = NS_NewURI(getter_AddRefs(uri), href, - docCharset.get(), docURL); + flatDocCharset.get(), docURL); if (NS_FAILED(result)) return result; // Now pass on absolute url to the click handler @@ -506,7 +507,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset) // Get the charset from document nsIDocument* doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentCharacterSet(oCharset); + oCharset = doc->GetDocumentCharacterSet(); } } diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 52c164f02c7..98baa4e6b0a 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -383,11 +383,7 @@ nsTextInputListener::UpdateTextInputCommands(const nsAString& commandsToUpdate) nsCOMPtr doc = content->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - nsCOMPtr scriptGlobalObject; - nsresult rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); - - nsCOMPtr domWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWindow = do_QueryInterface(doc->GetScriptGlobalObject()); NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE); return domWindow->UpdateCommands(commandsToUpdate); @@ -1675,12 +1671,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, if (!elementFactory) return NS_ERROR_FAILURE; - nsCOMPtr nodeInfoManager; - rv = doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); - - if (NS_FAILED(rv)) - return rv; - + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index d78847be840..d0ea772ea7f 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -134,12 +134,12 @@ nsBulletFrame::Init(nsIPresContext* aPresContext, GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); // Get the document URI for the referrer... - nsCOMPtr documentURI; + nsIURI *documentURI = nsnull; nsCOMPtr doc; if (mContent) { doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentURL(getter_AddRefs(documentURI)); + documentURI = doc->GetDocumentURL(); } } @@ -1630,12 +1630,12 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext, GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); // Get the document URI for the referrer... - nsCOMPtr documentURI; + nsIURI* documentURI = nsnull; nsCOMPtr doc; if (mContent) { doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentURL(getter_AddRefs(documentURI)); + documentURI = doc->GetDocumentURL(); } } @@ -1808,7 +1808,7 @@ nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGr if (!doc) return; - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 034df75ae2e..01f22d7acdc 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -596,11 +596,9 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr parentDoc; - doc->GetParentDocument(getter_AddRefs(parentDoc)); - nsCOMPtr rootElem; - doc->GetRootContent(getter_AddRefs(rootElem)); - if (!parentDoc && rootElem && rootElem->IsContentOfType(nsIContent::eXUL)) { + nsIContent *rootElem = doc->GetRootContent(); + if (!doc->GetParentDocument() && + rootElem && rootElem->IsContentOfType(nsIContent::eXUL)) { // we're XUL at the root of the document hierarchy. Try to make our // window translucent. // don't proceed unless this is the root view diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 97d4d366706..801d433fd1e 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -385,9 +385,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, if (!elementFactory) return NS_ERROR_FAILURE; - nsCOMPtr nodeInfoManager; + nsINodeInfoManager *nodeInfoManager = nsnull; if (document) - document->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nodeInfoManager = document->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 41e493525af..054c2a1cbcc 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -1505,7 +1505,6 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, aPresContext->GetLinkHandler(getter_AddRefs(handler)); if (nsnull != handler) { if (aClick) { - nsresult proceed = NS_OK; // Check that this page is allowed to load this URI. // Almost a copy of the similarly named method in nsGenericElement nsresult rv; @@ -1519,17 +1518,18 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, if (NS_SUCCEEDED(rv) && ps) rv = ps->GetDocument(getter_AddRefs(doc)); - nsCOMPtr baseURI; - if (NS_SUCCEEDED(rv) && doc) - doc->GetDocumentURL(getter_AddRefs(baseURI)); - - if (NS_SUCCEEDED(rv)) - proceed = securityManager->CheckLoadURI(baseURI, aURI, nsIScriptSecurityManager::STANDARD); + if (NS_SUCCEEDED(rv)) { + nsIURI *baseURI = doc ? doc->GetDocumentURL() : nsnull; - // Only pass off the click event if the script security manager - // says it's ok. - if (NS_SUCCEEDED(proceed)) - handler->OnLinkClick(mContent, eLinkVerb_Replace, aURI, aTargetSpec.get()); + rv = securityManager->CheckLoadURI(baseURI, aURI, + nsIScriptSecurityManager::STANDARD); + + // Only pass off the click event if the script security manager + // says it's ok. + if (NS_SUCCEEDED(rv)) + handler->OnLinkClick(mContent, eLinkVerb_Replace, aURI, + aTargetSpec.get()); + } } else { handler->OnOverLink(mContent, aURI, aTargetSpec.get()); @@ -1696,7 +1696,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext, nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString charset; if (doc) { - doc->GetDocumentCharacterSet(charset); + charset = doc->GetDocumentCharacterSet(); } nsCOMPtr uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), src, charset.get(), @@ -1884,7 +1884,7 @@ nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const if (mContent) { NS_ASSERTION(mContent->GetDocument(), "Frame still alive after content removed from document!"); - mContent->GetDocument()->GetDocumentCharacterSet(aCharset); + aCharset = mContent->GetDocument()->GetDocumentCharacterSet(); } } @@ -1922,7 +1922,7 @@ nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGro if (!doc) return; - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } nsresult nsImageFrame::LoadIcons(nsIPresContext *aPresContext) diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index 6f2cbd462dd..4ad1a56845c 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -455,8 +455,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString urlSpec; if (doc) { - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetDocumentURL(); if (uri) { uri->GetSpec(urlSpec); } diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 1fe6fdf9b6b..b8c6336d7ee 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -979,8 +979,8 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI, // get document charset nsCAutoString originCharset; - if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset))) - originCharset.Truncate(); + if (document) + originCharset = document->GetDocumentCharacterSet(); return NS_NewURI(aFullURI, aSrc, originCharset.get(), aBaseURI); } @@ -1301,11 +1301,7 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext, if (! document) return NS_ERROR_FAILURE; - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr domWin(do_QueryInterface(globalScript)); + nsCOMPtr domWin(do_QueryInterface(document->GetScriptGlobalObject(), &rv)); if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::OBJECT, @@ -1965,8 +1961,7 @@ nsObjectFrame::NotifyContentObjectWrapper() nsCOMPtr doc = mContent->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - nsCOMPtr sgo; - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED); nsCOMPtr scx; @@ -2335,7 +2330,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge if (NS_SUCCEEDED(rv) && doc) { // XXX should this really be the document base URL? Or the // content's base URL? - rv = doc->GetBaseURL(getter_AddRefs(baseURL)); // gets the document's url + baseURL = doc->GetBaseURL(); // gets the document's url } else { mOwner->GetFullURL(*getter_AddRefs(baseURL)); // gets the plugin's content url } @@ -2635,10 +2630,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); - nsCOMPtr docURL; - doc->GetBaseURL(getter_AddRefs(docURL)); // should return base + doc url - - rv = docURL->GetSpec(mDocumentBase); + rv = doc->GetBaseURL()->GetSpec(mDocumentBase); } if (rv == NS_OK) *result = ToNewCString(mDocumentBase); @@ -2714,10 +2706,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result) NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document"); if (NS_FAILED(rv)) return rv; - nsCAutoString charset; - rv = doc->GetDocumentCharacterSet(charset); - NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset"); - if (NS_FAILED(rv)) return rv; + const nsACString &charset = doc->GetDocumentCharacterSet(); if (charset.IsEmpty()) return NS_OK; @@ -2725,7 +2714,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result) if (charset == NS_LITERAL_CSTRING("us-acsii")) { *result = PL_strdup("US_ASCII"); } else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") || - !nsCRT::strncmp(charset.get(), "UTF", 3)) { + !nsCRT::strncmp(PromiseFlatCString(charset).get(), "UTF", 3)) { *result = ToNewCString(charset); } else { if (!gCharsetMap) { diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 5a15c3deb30..0b3c58f6e1f 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -3219,7 +3219,7 @@ NS_IMETHODIMP nsSelection::SelectAll() return rv; if (!doc) return NS_ERROR_FAILURE; - doc->GetRootContent(getter_AddRefs(rootContent)); + rootContent = doc->GetRootContent(); if (!rootContent) return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 9138f456d49..d1301cfed6e 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -2053,7 +2053,7 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte if (!doc) return NS_ERROR_FAILURE; - doc->GetLineBreaker(aLineBreaker); + NS_IF_ADDREF(*aLineBreaker = doc->GetLineBreaker()); aIsSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; @@ -2508,9 +2508,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, } // Transform text from content into renderable form - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PRInt32 textLength; PRInt32 numSpaces; @@ -3407,9 +3405,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, // Get the renderable form of the text nsCOMPtr doc(GetDocument(aCX)); - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aCX); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aCX); PRInt32 textLength; // no need to worry about justification, that's always on the slow path PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); @@ -3745,9 +3741,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, // Transform text from content into renderable form nsCOMPtr doc(GetDocument(aPresContext)); - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PRInt32 textLength; PRInt32 numSpaces; @@ -3956,10 +3950,7 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (!doc) { return NS_OK; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); if (textLength)//if no renderable length, you cant park here. @@ -3986,10 +3977,7 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (!doc) { return NS_OK; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); nsIFrame *frameUsed = nsnull; @@ -4131,12 +4119,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) return result; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsCOMPtr wb; - doc->GetWordBreaker(getter_AddRefs(wb)); - - nsTextTransformer tx(lb, wb, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), + doc->GetWordBreaker(), aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); nsIFrame *frameUsed = nsnull; @@ -4415,11 +4399,8 @@ nsTextFrame::CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRIn return rv; if (!doc) return NS_ERROR_FAILURE; - //get the linebreaker - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); //create texttransformer - nsTextTransformer tx(lb, nsnull, aContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aContext); //create the buffers nsAutoTextBuffer paintBuffer; nsAutoIndexBuffer indexBuffer; @@ -5313,12 +5294,11 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, NS_WARNING("Content has no document."); return NS_ERROR_FAILURE; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); PRBool forceArabicShaping = (ts.mSmallCaps || (0 != ts.mWordSpacing) || (0 != ts.mLetterSpacing) || ts.mJustifying); + nsILineBreaker *lb = doc->GetLineBreaker(); nsTextTransformer tx(lb, nsnull, aPresContext); // Keep the text in ascii if possible. Note that if we're measuring small // caps text then transform to Unicode because the helper function only diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp index d78847be840..d0ea772ea7f 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.cpp +++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp @@ -134,12 +134,12 @@ nsBulletFrame::Init(nsIPresContext* aPresContext, GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); // Get the document URI for the referrer... - nsCOMPtr documentURI; + nsIURI *documentURI = nsnull; nsCOMPtr doc; if (mContent) { doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentURL(getter_AddRefs(documentURI)); + documentURI = doc->GetDocumentURL(); } } @@ -1630,12 +1630,12 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext, GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); // Get the document URI for the referrer... - nsCOMPtr documentURI; + nsIURI* documentURI = nsnull; nsCOMPtr doc; if (mContent) { doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentURL(getter_AddRefs(documentURI)); + documentURI = doc->GetDocumentURL(); } } @@ -1808,7 +1808,7 @@ nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGr if (!doc) return; - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 034df75ae2e..01f22d7acdc 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -596,11 +596,9 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr parentDoc; - doc->GetParentDocument(getter_AddRefs(parentDoc)); - nsCOMPtr rootElem; - doc->GetRootContent(getter_AddRefs(rootElem)); - if (!parentDoc && rootElem && rootElem->IsContentOfType(nsIContent::eXUL)) { + nsIContent *rootElem = doc->GetRootContent(); + if (!doc->GetParentDocument() && + rootElem && rootElem->IsContentOfType(nsIContent::eXUL)) { // we're XUL at the root of the document hierarchy. Try to make our // window translucent. // don't proceed unless this is the root view diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index fc190e59679..8d7b49392eb 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -1196,8 +1196,7 @@ nsresult CantRenderReplacedElementEvent::AddLoadGroupRequest(nsIPresShell* aPres if (NS_FAILED(rv)) return rv; if (!mDummyLayoutRequest) return NS_ERROR_FAILURE; - nsCOMPtr loadGroup; - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (!loadGroup) return NS_ERROR_FAILURE; rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); @@ -1224,8 +1223,7 @@ nsresult CantRenderReplacedElementEvent::RemoveLoadGroupRequest() presShell->GetDocument(getter_AddRefs(doc)); if (!doc) return NS_ERROR_FAILURE;; - nsCOMPtr loadGroup; - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); if (!loadGroup) return NS_ERROR_FAILURE; rv = loadGroup->RemoveRequest(request, nsnull, NS_OK); diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index 97d4d366706..801d433fd1e 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -385,9 +385,9 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, if (!elementFactory) return NS_ERROR_FAILURE; - nsCOMPtr nodeInfoManager; + nsINodeInfoManager *nodeInfoManager = nsnull; if (document) - document->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nodeInfoManager = document->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 41e493525af..054c2a1cbcc 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -1505,7 +1505,6 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, aPresContext->GetLinkHandler(getter_AddRefs(handler)); if (nsnull != handler) { if (aClick) { - nsresult proceed = NS_OK; // Check that this page is allowed to load this URI. // Almost a copy of the similarly named method in nsGenericElement nsresult rv; @@ -1519,17 +1518,18 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, if (NS_SUCCEEDED(rv) && ps) rv = ps->GetDocument(getter_AddRefs(doc)); - nsCOMPtr baseURI; - if (NS_SUCCEEDED(rv) && doc) - doc->GetDocumentURL(getter_AddRefs(baseURI)); - - if (NS_SUCCEEDED(rv)) - proceed = securityManager->CheckLoadURI(baseURI, aURI, nsIScriptSecurityManager::STANDARD); + if (NS_SUCCEEDED(rv)) { + nsIURI *baseURI = doc ? doc->GetDocumentURL() : nsnull; - // Only pass off the click event if the script security manager - // says it's ok. - if (NS_SUCCEEDED(proceed)) - handler->OnLinkClick(mContent, eLinkVerb_Replace, aURI, aTargetSpec.get()); + rv = securityManager->CheckLoadURI(baseURI, aURI, + nsIScriptSecurityManager::STANDARD); + + // Only pass off the click event if the script security manager + // says it's ok. + if (NS_SUCCEEDED(rv)) + handler->OnLinkClick(mContent, eLinkVerb_Replace, aURI, + aTargetSpec.get()); + } } else { handler->OnOverLink(mContent, aURI, aTargetSpec.get()); @@ -1696,7 +1696,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext, nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString charset; if (doc) { - doc->GetDocumentCharacterSet(charset); + charset = doc->GetDocumentCharacterSet(); } nsCOMPtr uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), src, charset.get(), @@ -1884,7 +1884,7 @@ nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const if (mContent) { NS_ASSERTION(mContent->GetDocument(), "Frame still alive after content removed from document!"); - mContent->GetDocument()->GetDocumentCharacterSet(aCharset); + aCharset = mContent->GetDocument()->GetDocumentCharacterSet(); } } @@ -1922,7 +1922,7 @@ nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGro if (!doc) return; - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } nsresult nsImageFrame::LoadIcons(nsIPresContext *aPresContext) diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index 6f2cbd462dd..4ad1a56845c 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -455,8 +455,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString urlSpec; if (doc) { - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetDocumentURL(); if (uri) { uri->GetSpec(urlSpec); } diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 1fe6fdf9b6b..b8c6336d7ee 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -979,8 +979,8 @@ nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI, // get document charset nsCAutoString originCharset; - if (document && NS_FAILED(document->GetDocumentCharacterSet(originCharset))) - originCharset.Truncate(); + if (document) + originCharset = document->GetDocumentCharacterSet(); return NS_NewURI(aFullURI, aSrc, originCharset.get(), aBaseURI); } @@ -1301,11 +1301,7 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext, if (! document) return NS_ERROR_FAILURE; - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr domWin(do_QueryInterface(globalScript)); + nsCOMPtr domWin(do_QueryInterface(document->GetScriptGlobalObject(), &rv)); if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::OBJECT, @@ -1965,8 +1961,7 @@ nsObjectFrame::NotifyContentObjectWrapper() nsCOMPtr doc = mContent->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); - nsCOMPtr sgo; - doc->GetScriptGlobalObject(getter_AddRefs(sgo)); + nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED); nsCOMPtr scx; @@ -2335,7 +2330,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge if (NS_SUCCEEDED(rv) && doc) { // XXX should this really be the document base URL? Or the // content's base URL? - rv = doc->GetBaseURL(getter_AddRefs(baseURL)); // gets the document's url + baseURL = doc->GetBaseURL(); // gets the document's url } else { mOwner->GetFullURL(*getter_AddRefs(baseURL)); // gets the plugin's content url } @@ -2635,10 +2630,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); - nsCOMPtr docURL; - doc->GetBaseURL(getter_AddRefs(docURL)); // should return base + doc url - - rv = docURL->GetSpec(mDocumentBase); + rv = doc->GetBaseURL()->GetSpec(mDocumentBase); } if (rv == NS_OK) *result = ToNewCString(mDocumentBase); @@ -2714,10 +2706,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result) NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document"); if (NS_FAILED(rv)) return rv; - nsCAutoString charset; - rv = doc->GetDocumentCharacterSet(charset); - NS_ASSERTION(NS_SUCCEEDED(rv), "can't get charset"); - if (NS_FAILED(rv)) return rv; + const nsACString &charset = doc->GetDocumentCharacterSet(); if (charset.IsEmpty()) return NS_OK; @@ -2725,7 +2714,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result) if (charset == NS_LITERAL_CSTRING("us-acsii")) { *result = PL_strdup("US_ASCII"); } else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") || - !nsCRT::strncmp(charset.get(), "UTF", 3)) { + !nsCRT::strncmp(PromiseFlatCString(charset).get(), "UTF", 3)) { *result = ToNewCString(charset); } else { if (!gCharsetMap) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 6052d1056a9..5e855f197ea 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1992,13 +1992,11 @@ NS_IMETHODIMP PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle) { if (mDocument && mStyleSet) { - PRInt32 count = 0; - mDocument->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); PRInt32 index; NS_NAMED_LITERAL_STRING(textHtml,"text/html"); for (index = 0; index < count; index++) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(index, PR_FALSE); PRBool complete; sheet->GetComplete(complete); if (complete) { @@ -2029,13 +2027,11 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList) { // XXX should this be returning incomplete sheets? Probably. if (mDocument) { - PRInt32 count = 0; - mDocument->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); PRInt32 index; NS_NAMED_LITERAL_STRING(textHtml,"text/html"); for (index = 0; index < count; index++) { - nsCOMPtr sheet; - mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet)); + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(index, PR_FALSE); if (sheet) { nsAutoString type; sheet->GetType(type); @@ -2101,8 +2097,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) return NS_ERROR_NULL_POINTER; } - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + nsIScriptGlobalObject *globalObj = mDocument->GetScriptGlobalObject(); // If the document doesn't have a global object there's no need to // notify its presshell about changes to preferences since the @@ -2641,17 +2636,13 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, } while (curDoc) { - nsCOMPtr globalObject; - curDoc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr curWin = do_QueryInterface(globalObject); + nsCOMPtr curWin = do_QueryInterface(curDoc->GetScriptGlobalObject()); if (curWin == ourWin || !curWin) break; - nsCOMPtr parentDoc; - curDoc->GetParentDocument(getter_AddRefs(parentDoc)); - if (parentDoc == aDocument) + curDoc = curDoc->GetParentDocument(); + if (curDoc == aDocument) return; - curDoc = parentDoc; } if (!curDoc) { @@ -2747,14 +2738,12 @@ PresShell::GetDidInitialReflow(PRBool *aDidInitialReflow) NS_IMETHODIMP PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) { - nsCOMPtr root; mDidInitialReflow = PR_TRUE; #ifdef NS_DEBUG if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) { - nsCOMPtr uri; if (mDocument) { - mDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = mDocument->GetDocumentURL(); if (uri) { nsCAutoString url; uri->GetSpec(url); @@ -2776,9 +2765,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) mPresContext->SetVisibleArea(r); } - if (mDocument) { - mDocument->GetRootContent(getter_AddRefs(root)); - } + nsIContent *root = mDocument ? mDocument->GetRootContent() : nsnull; // Get the root frame from the frame manager nsIFrame* rootFrame; @@ -3084,8 +3071,7 @@ PresShell::FireResizeEvent() event.message = NS_RESIZE_EVENT; event.time = 0; - nsCOMPtr globalObj; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj)); + nsCOMPtr globalObj = mDocument->GetScriptGlobalObject(); if (globalObj) { globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -3759,8 +3745,7 @@ PresShell::AppendReflowCommand(nsHTMLReflowCommand* aReflowCommand) aReflowCommand->List(stdout); if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) { printf("Current content model:\n"); - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { rootContent->List(stdout, 0); } @@ -4329,11 +4314,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame, if (content) { nsIDocument* document = content->GetDocument(); if (document){ - nsCOMPtr focusController; - nsCOMPtr ourGlobal; - document->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(document->GetScriptGlobalObject()); if(ourWindow) { + nsCOMPtr focusController; ourWindow->GetRootFocusController(getter_AddRefs(focusController)); if (focusController) { PRBool dontScroll; @@ -4670,9 +4653,7 @@ PresShell::DoCopy() return rv; // Now that we have copied, update the Paste menu item - nsCOMPtr globalObject; - doc->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr domWindow = do_QueryInterface(globalObject); + nsCOMPtr domWindow = do_QueryInterface(doc->GetScriptGlobalObject()); if (domWindow) { domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard")); @@ -4892,9 +4873,7 @@ PresShell::IsPaintingSuppressed(PRBool* aResult) void PresShell::UnsuppressAndInvalidate() { - nsCOMPtr globalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr ourWindow = do_QueryInterface(globalObject); + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); nsCOMPtr focusController; if (ourWindow) ourWindow->GetRootFocusController(getter_AddRefs(focusController)); @@ -5391,14 +5370,8 @@ PresShell::ContentRemoved(nsIDocument *aDocument, // to be called again should a new root node be inserted for this // presShell. (Bug 167355) - if (mDocument) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); - - if (!rootContent) { - mDidInitialReflow = PR_FALSE; - } - } + if (mDocument && !mDocument->GetRootContent()) + mDidInitialReflow = PR_FALSE; VERIFY_STYLE_TREE; DidCauseReflow(); @@ -5977,9 +5950,7 @@ PresShell::HandleEvent(nsIView *aView, // to redraw pre-edit (composed) string // If Mozilla does not have input focus and event is IME, // sends IME event to pre-focused element - nsCOMPtr ourGlobal; - mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); + nsCOMPtr ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject()); if (ourWindow) { nsCOMPtr focusController; ourWindow->GetRootFocusController(getter_AddRefs(focusController)); @@ -6001,7 +5972,7 @@ PresShell::HandleEvent(nsIView *aView, } #endif /* defined(MOZ_X11) */ if (!mCurrentEventContent) { - mDocument->GetRootContent(&mCurrentEventContent); + NS_IF_ADDREF(mCurrentEventContent = mDocument->GetRootContent()); } mCurrentEventFrame = nsnull; } @@ -6706,10 +6677,8 @@ PresShell::AddDummyLayoutRequest(void) if (NS_FAILED(rv)) return rv; nsCOMPtr loadGroup; - if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) return rv; - } + if (mDocument) + loadGroup = mDocument->GetDocumentLoadGroup(); if (loadGroup) { rv = mDummyLayoutRequest->SetLoadGroup(loadGroup); @@ -6731,10 +6700,8 @@ PresShell::RemoveDummyLayoutRequest(void) if (gAsyncReflowDuringDocLoad) { nsCOMPtr loadGroup; - if (mDocument) { - rv = mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); - if (NS_FAILED(rv)) return rv; - } + if (mDocument) + loadGroup = mDocument->GetDocumentLoadGroup(); if (loadGroup && mDummyLayoutRequest) { rv = loadGroup->RemoveRequest(mDummyLayoutRequest, nsnull, NS_OK); @@ -7414,8 +7381,7 @@ PresShell::DumpReflows() if (mReflowCountMgr) { nsCAutoString uriStr; if (mDocument) { - nsCOMPtr uri; - mDocument->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = mDocument->GetDocumentURL(); if (uri) { uri->GetPath(uriStr); } diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 9138f456d49..d1301cfed6e 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -2053,7 +2053,7 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte if (!doc) return NS_ERROR_FAILURE; - doc->GetLineBreaker(aLineBreaker); + NS_IF_ADDREF(*aLineBreaker = doc->GetLineBreaker()); aIsSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; @@ -2508,9 +2508,7 @@ nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, } // Transform text from content into renderable form - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PRInt32 textLength; PRInt32 numSpaces; @@ -3407,9 +3405,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, // Get the renderable form of the text nsCOMPtr doc(GetDocument(aCX)); - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aCX); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aCX); PRInt32 textLength; // no need to worry about justification, that's always on the slow path PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); @@ -3745,9 +3741,7 @@ nsTextFrame::GetPointFromOffset(nsIPresContext* aPresContext, // Transform text from content into renderable form nsCOMPtr doc(GetDocument(aPresContext)); - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PRInt32 textLength; PRInt32 numSpaces; @@ -3956,10 +3950,7 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (!doc) { return NS_OK; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); if (textLength)//if no renderable length, you cant park here. @@ -3986,10 +3977,7 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) if (!doc) { return NS_OK; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - - nsTextTransformer tx(lb, nsnull, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); nsIFrame *frameUsed = nsnull; @@ -4131,12 +4119,8 @@ nsTextFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) return result; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); - nsCOMPtr wb; - doc->GetWordBreaker(getter_AddRefs(wb)); - - nsTextTransformer tx(lb, wb, aPresContext); + nsTextTransformer tx(doc->GetLineBreaker(), + doc->GetWordBreaker(), aPresContext); PrepareUnicodeText(tx, &indexBuffer, &paintBuffer, &textLength); nsIFrame *frameUsed = nsnull; @@ -4415,11 +4399,8 @@ nsTextFrame::CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRIn return rv; if (!doc) return NS_ERROR_FAILURE; - //get the linebreaker - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); //create texttransformer - nsTextTransformer tx(lb, nsnull, aContext); + nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aContext); //create the buffers nsAutoTextBuffer paintBuffer; nsAutoIndexBuffer indexBuffer; @@ -5313,12 +5294,11 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, NS_WARNING("Content has no document."); return NS_ERROR_FAILURE; } - nsCOMPtr lb; - doc->GetLineBreaker(getter_AddRefs(lb)); PRBool forceArabicShaping = (ts.mSmallCaps || (0 != ts.mWordSpacing) || (0 != ts.mLetterSpacing) || ts.mJustifying); + nsILineBreaker *lb = doc->GetLineBreaker(); nsTextTransformer tx(lb, nsnull, aPresContext); // Keep the text in ascii if possible. Note that if we're measuring small // caps text then transform to Unicode because the helper function only diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 00a26ac252d..385003e6204 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -2126,9 +2126,8 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc = mContent->GetDocument(); // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); - nsCOMPtr nimgr; - result = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(result, result); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index e7a3225504a..59c958501fd 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -140,14 +140,14 @@ nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, { // Get the NodeInfoManager and tag necessary to create input elements nsCOMPtr doc = mContent->GetDocument(); - nsCOMPtr nimgr; - nsresult rv = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); + nsresult rv; nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -272,12 +272,7 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (!doc) return NS_ERROR_FAILURE; - nsCOMPtr scriptGlobalObject; - result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - if (!scriptGlobalObject) - return NS_FAILED(result) ? result : NS_ERROR_FAILURE; - - nsCOMPtr parentWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr parentWindow = do_QueryInterface(doc->GetScriptGlobalObject()); if (!parentWindow) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index 94999e33439..efaf6f0ecf6 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -228,9 +228,8 @@ nsIsIndexFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the node info manager (used to create hr's and input's) nsCOMPtr doc = mContent->GetDocument(); - nsCOMPtr nimgr; - result = doc->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(result, result); + nsINodeInfoManager *nimgr = doc->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&result)); NS_ENSURE_SUCCESS(result, result); @@ -420,10 +419,11 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 // Resolve url to an absolute url - nsCOMPtr docURL; - document->GetBaseURL(getter_AddRefs(docURL)); - NS_ASSERTION(docURL, "No Base URL found in Form Submit!\n"); - if (!docURL) return NS_OK; // No base URL -> exit early, see Bug 30721 + nsIURI *docURL = document->GetBaseURL(); + if (!docURL) { + NS_ERROR("No Base URL found in Form Submit!\n"); + return NS_OK; // No base URL -> exit early, see Bug 30721 + } // If an action is not specified and we are inside // a HTML document then reload the URL. This makes us @@ -463,10 +463,11 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) nsCOMPtr actionURL; nsXPIDLCString scheme; PRBool isJSURL = PR_FALSE; - nsCAutoString docCharset; - document->GetDocumentCharacterSet(docCharset); + const nsACString &docCharset = document->GetDocumentCharacterSet(); + const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); + if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, - docCharset.get(), + flatDocCharset.get(), docURL))) { result = actionURL->SchemeIs("javascript", &isJSURL); } @@ -483,7 +484,7 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) } nsCOMPtr uri; result = NS_NewURI(getter_AddRefs(uri), href, - docCharset.get(), docURL); + flatDocCharset.get(), docURL); if (NS_FAILED(result)) return result; // Now pass on absolute url to the click handler @@ -506,7 +507,7 @@ void nsIsIndexFrame::GetSubmitCharset(nsCString& oCharset) // Get the charset from document nsIDocument* doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentCharacterSet(oCharset); + oCharset = doc->GetDocumentCharacterSet(); } } diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 52c164f02c7..98baa4e6b0a 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -383,11 +383,7 @@ nsTextInputListener::UpdateTextInputCommands(const nsAString& commandsToUpdate) nsCOMPtr doc = content->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); - nsCOMPtr scriptGlobalObject; - nsresult rv = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); - - nsCOMPtr domWindow = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWindow = do_QueryInterface(doc->GetScriptGlobalObject()); NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE); return domWindow->UpdateCommands(commandsToUpdate); @@ -1675,12 +1671,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, if (!elementFactory) return NS_ERROR_FAILURE; - nsCOMPtr nodeInfoManager; - rv = doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); - - if (NS_FAILED(rv)) - return rv; - + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); nsCOMPtr nodeInfo; diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index d313992a534..4838653f864 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1377,9 +1377,8 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create an HTML image content object, and set the SRC. // XXX Check if it's an image type we can handle... - nsCOMPtr nimgr; - nsresult rv = aDocument->GetNodeInfoManager(getter_AddRefs(nimgr)); - NS_ENSURE_SUCCESS(rv, rv); + nsINodeInfoManager *nimgr = aDocument->GetNodeInfoManager(); + NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE); // XXXldb We should not be creating an |image| element, because it // matches selectors! See bug 109216. @@ -1387,6 +1386,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex nimgr->GetNodeInfo(nsHTMLAtoms::img, nsnull, kNameSpaceID_None, getter_AddRefs(nodeInfo)); + nsresult rv; nsCOMPtr ef(do_GetService(kHTMLElementFactoryCID,&rv)); NS_ENSURE_SUCCESS(rv, rv); @@ -3368,8 +3368,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, return NS_OK; // Binding will load asynchronously. if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -3578,8 +3577,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, */ // Set up our style rule observer. - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); if (bindingManager) { nsCOMPtr ruleSupplier(do_QueryInterface(bindingManager)); nsCOMPtr set; @@ -5725,9 +5723,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, if (processChildren || processAnonymousChildren) { nsFrameItems childItems; if (processChildren) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->ShouldBuildChildFrames(aContent, &processChildren); + mDocument->GetBindingManager()->ShouldBuildChildFrames(aContent, + &processChildren); if (processChildren) rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_FALSE, childItems, PR_FALSE); @@ -7154,8 +7151,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe aFrameItems, PR_TRUE); if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -7234,8 +7230,7 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsIPresShell* aPresShe } if (binding) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); + nsIBindingManager *bm = mDocument->GetBindingManager(); if (bm) bm->AddToAttachedQueue(binding); } @@ -7268,8 +7263,7 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte aPresContext->GetShell(getter_AddRefs(shell)); if (mDocument && shell) { - nsCOMPtr rootContent; - mDocument->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = mDocument->GetRootContent(); if (rootContent) { // Before removing the frames associated with the content object, ask them to save their @@ -8135,8 +8129,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, #ifdef MOZ_XUL if (aContainer) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = mDocument->GetBindingManager(); nsCOMPtr tag; PRInt32 namespaceID; @@ -8169,7 +8162,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, PRBool hasInsertion = PR_FALSE; if (!multiple) { - nsCOMPtr bindingManager; + nsIBindingManager *bindingManager = nsnull; nsIDocument* document = nsnull; nsIContent *firstAppendedChild = aContainer->GetChildAt(aNewIndexInContainer); @@ -8177,7 +8170,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, document = firstAppendedChild->GetDocument(); } if (document) - document->GetBindingManager(getter_AddRefs(bindingManager)); + bindingManager = document->GetBindingManager(); if (bindingManager) { nsCOMPtr insParent; bindingManager->GetInsertionParent(firstAppendedChild, getter_AddRefs(insParent)); @@ -8393,9 +8386,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } // We built some new frames. Initialize any newly-constructed bindings. - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) { @@ -8710,9 +8701,6 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext, if (!aContainer) return PR_FALSE; - nsCOMPtr bindingManager; - aDocument->GetBindingManager(getter_AddRefs(bindingManager)); - nsCOMPtr tag; aChild->GetTag(getter_AddRefs(tag)); @@ -8751,7 +8739,8 @@ PRBool NotifyListBoxBody(nsIPresContext* aPresContext, } PRInt32 namespaceID; - bindingManager->ResolveTag(aContainer, &namespaceID, getter_AddRefs(tag)); + aDocument->GetBindingManager()->ResolveTag(aContainer, &namespaceID, + getter_AddRefs(tag)); // Just ignore tree tags, anyway we don't create any frames for them. if (tag == nsXULAtoms::treechildren || @@ -8800,10 +8789,9 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // If we have a null parent, then this must be the document element // being inserted if (! aContainer) { - nsCOMPtr docElement; - mDocument->GetRootContent(getter_AddRefs(docElement)); + nsIContent *docElement = mDocument->GetRootContent(); - if (aChild == docElement.get()) { + if (aChild == docElement) { NS_PRECONDITION(nsnull == mInitialContainingBlock, "initial containing block already created"); if (!mDocElementContainingBlock) @@ -8849,9 +8837,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, #endif } - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // otherwise this is not a child of the root element, and we // won't let it have a frame. @@ -9039,9 +9025,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, // Now that we've created frames, run the attach queue. //XXXwaterson should we do this after we've processed pseudos, too? - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // process the current pseudo frame state if (!state.mPseudoFrames.IsEmpty()) @@ -10243,12 +10227,10 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, // content from being removed and re-inserted (which is what would // happen otherwise). if (!primaryFrame && !reframe) { - nsCOMPtr bindingManager; - mDocument->GetBindingManager(getter_AddRefs(bindingManager)); - PRInt32 namespaceID; nsCOMPtr tag; - bindingManager->ResolveTag(aContent, &namespaceID, getter_AddRefs(tag)); + mDocument->GetBindingManager()->ResolveTag(aContent, &namespaceID, + getter_AddRefs(tag)); if (tag && (tag.get() == nsXULAtoms::listitem || tag.get() == nsXULAtoms::listcell)) return NS_OK; @@ -11399,8 +11381,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell, if (!document) return NS_OK; - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); + nsIBindingManager *bindingManager = document->GetBindingManager(); if (!bindingManager) return NS_OK; @@ -12724,9 +12705,7 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, *aNewFrame = newFrame; if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { - nsCOMPtr bm; - mDocument->GetBindingManager(getter_AddRefs(bm)); - bm->ProcessAttachedQueue(); + mDocument->GetBindingManager()->ProcessAttachedQueue(); // Notify the parent frame if (aIsAppend) diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index ca5ff2980af..ad32828e716 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -1553,7 +1553,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, nsIDocument *doc = nsnull; if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) { nsIContent *pContent; - if (NS_SUCCEEDED(doc->GetRootContent(&pContent)) && pContent) { + if ((pContent = doc->GetRootContent())) { // make sure that this is the HTML element nsCOMPtr tag; pContent->GetTag(getter_AddRefs(tag)); @@ -1581,7 +1581,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, } #endif }// if tag - NS_RELEASE(pContent); }// if content NS_RELEASE(doc); }// if doc diff --git a/mozilla/layout/html/style/src/nsChildIterator.cpp b/mozilla/layout/html/style/src/nsChildIterator.cpp index 7094a6c1b43..9ec5c19f432 100644 --- a/mozilla/layout/html/style/src/nsChildIterator.cpp +++ b/mozilla/layout/html/style/src/nsChildIterator.cpp @@ -58,8 +58,7 @@ ChildIterator::Init(nsIContent* aContent, if (! doc) return NS_ERROR_FAILURE; - nsCOMPtr mgr; - doc->GetBindingManager(getter_AddRefs(mgr)); + nsIBindingManager *mgr = doc->GetBindingManager(); if (! mgr) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index c97a251d1b6..8c8dfeb7495 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -753,10 +753,7 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings, if (!printSilently) { nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); if (printPromptService) { - nsCOMPtr scriptGlobalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); - nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWin = do_QueryInterface(mDocument->GetScriptGlobalObject()); NS_ENSURE_TRUE(domWin, NS_ERROR_FAILURE); // Platforms not implementing a given dialog for the service may @@ -1685,10 +1682,7 @@ nsPrintEngine::ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify) if (mPrt->mShowProgressDialog) { nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); if (printPromptService) { - nsCOMPtr scriptGlobalObject; - mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - if (!scriptGlobalObject) return; - nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + nsCOMPtr domWin = do_QueryInterface(mDocument->GetScriptGlobalObject()); if (!domWin) return; nsCOMPtr wbp(do_QueryInterface(mDocViewerPrint)); @@ -1778,8 +1772,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsIContent *rootContent = doc->GetRootContent(); if (rootContent) { if (NS_SUCCEEDED(mDocViewerPrint->FindFrameSetWithIID(rootContent, NS_GET_IID(nsIDOMHTMLFrameSetElement)))) { isFrameSet = PR_TRUE; @@ -1857,14 +1850,12 @@ nsPrintEngine::GetWebShellTitleAndURL(nsIWebShell* aWebShell, *aTitle = nsnull; *aURLStr = nsnull; - nsAutoString docTitle; - aDoc->GetDocumentTitle(docTitle); + const nsAString &docTitle = aDoc->GetDocumentTitle(); if (!docTitle.IsEmpty()) { *aTitle = ToNewUnicode(docTitle); } - nsCOMPtr url; - aDoc->GetDocumentURL(getter_AddRefs(url)); + nsIURI* url = aDoc->GetDocumentURL(); if (!url) return; nsCAutoString urlCStr; @@ -1966,15 +1957,12 @@ nsPrintEngine::MapContentForPO(nsPrintObject* aRootObject, return; } - nsCOMPtr subDoc; - doc->GetSubDocumentFor(aContent, getter_AddRefs(subDoc)); + nsIDocument* subDoc = doc->GetSubDocumentFor(aContent); if (subDoc) { - nsCOMPtr container; - subDoc->GetContainer(getter_AddRefs(container)); - nsIPresShell *presShell = subDoc->GetShellAt(0); + nsCOMPtr container = subDoc->GetContainer(); nsCOMPtr webShell(do_QueryInterface(container)); if (presShell && webShell) { @@ -3957,13 +3945,12 @@ nsPrintEngine::FindFocusedDOMWindowInternal() { nsCOMPtr theDOMWin; nsCOMPtr theDoc; - nsCOMPtr theSGO; nsCOMPtr focusController; nsIDOMWindowInternal * domWin = nsnull; mDocViewer->GetDocument(getter_AddRefs(theDoc)); if(theDoc){ - theDoc->GetScriptGlobalObject(getter_AddRefs(theSGO)); + nsIScriptGlobalObject* theSGO = theDoc->GetScriptGlobalObject(); if(theSGO){ nsCOMPtr theDOMWindow = do_QueryInterface(theSGO); if(theDOMWindow){ @@ -4448,11 +4435,10 @@ nsPrintEngine::TurnScriptingOn(PRBool aDoTurnOn) NS_ASSERTION(mDocument, "We MUST have a document."); // get the script global object - nsCOMPtr scriptGlobalObj; - nsresult rv = mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObj)); - NS_ASSERTION(NS_SUCCEEDED(rv) && scriptGlobalObj, "Can't get nsIScriptGlobalObject"); + nsIScriptGlobalObject *scriptGlobalObj = mDocument->GetScriptGlobalObject(); + NS_ASSERTION(scriptGlobalObj, "Can't get nsIScriptGlobalObject"); nsCOMPtr scx; - rv = scriptGlobalObj->GetContext(getter_AddRefs(scx)); + nsresult rv = scriptGlobalObj->GetContext(getter_AddRefs(scx)); NS_ASSERTION(NS_SUCCEEDED(rv) && scx, "Can't get nsIScriptContext"); scx->SetScriptsEnabled(aDoTurnOn, PR_TRUE); } diff --git a/mozilla/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp index 351640e5733..e69de9f1b70 100644 --- a/mozilla/layout/style/nsCSSLoader.cpp +++ b/mozilla/layout/style/nsCSSLoader.cpp @@ -613,7 +613,7 @@ SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader, if (aCharset.IsEmpty() && mLoader->mDocument) { // no useful data on charset. Try the document charset. // That needs no resolution, since it's already fully resolved - mLoader->mDocument->GetDocumentCharacterSet(aCharset); + aCharset = mLoader->mDocument->GetDocumentCharacterSet(); #ifdef DEBUG_bzbarsky fprintf(stderr, "Set from document: %s\n", PromiseFlatCString(aCharset).get()); @@ -926,11 +926,10 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI, return NS_OK; } - nsCOMPtr globalObject; - rv = mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject)); - if (NS_FAILED(rv) || !globalObject) { + nsIScriptGlobalObject *globalObject = mDocument->GetScriptGlobalObject(); + if (!globalObject) { LOG((" No script global object")); - return rv; + return NS_OK; } nsCOMPtr domWin(do_QueryInterface(globalObject)); @@ -1111,8 +1110,7 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, // XXX Need to cancel pending sheet loads for this element, if any - PRInt32 sheetCount; - aDocument->GetNumberOfStyleSheets(PR_FALSE, &sheetCount); + PRInt32 sheetCount = aDocument->GetNumberOfStyleSheets(PR_FALSE); /* * Start the walk at the _end_ of the list, since in the typical @@ -1124,9 +1122,8 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, */ PRInt32 insertionPoint; for (insertionPoint = sheetCount - 1; insertionPoint >= 0; --insertionPoint) { - nsCOMPtr curSheet; - aDocument->GetStyleSheetAt(insertionPoint, PR_FALSE, - getter_AddRefs(curSheet)); + nsIStyleSheet *curSheet = aDocument->GetStyleSheetAt(insertionPoint, + PR_FALSE); NS_ASSERTION(curSheet, "There must be a sheet here!"); nsCOMPtr domSheet = do_QueryInterface(curSheet); NS_ASSERTION(domSheet, "All the \"normal\" sheets implement nsIDOMStyleSheet"); @@ -1330,7 +1327,7 @@ CSSLoaderImpl::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) #endif nsCOMPtr loadGroup; if (mDocument) { - mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + loadGroup = mDocument->GetDocumentLoadGroup(); NS_ASSERTION(loadGroup, "No loadgroup for stylesheet; onload will fire early"); } @@ -1358,8 +1355,7 @@ CSSLoaderImpl::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) NS_LITERAL_CSTRING("text/css,*/*;q=0.1"), PR_FALSE); if (mDocument) { - nsCOMPtr documentURI; - mDocument->GetDocumentURL(getter_AddRefs(documentURI)); + nsIURI *documentURI = mDocument->GetDocumentURL(); NS_ASSERTION(documentURI, "Null document uri is bad!"); if (documentURI) { httpChannel->SetReferrer(documentURI); @@ -1645,10 +1641,9 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_INITIALIZED); // Check whether we should even load - nsCOMPtr docURI; - nsresult rv = mDocument->GetDocumentURL(getter_AddRefs(docURI)); - if (NS_FAILED(rv) || !docURI) return NS_ERROR_FAILURE; - rv = CheckLoadAllowed(docURI, aURL, aElement); + nsIURI *docURI = mDocument->GetDocumentURL(); + if (!docURI) return NS_ERROR_FAILURE; + nsresult rv = CheckLoadAllowed(docURI, aURL, aElement); if (NS_FAILED(rv)) return rv; LOG((" Passed load check")); diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index 5ee740147f3..f148eeb6e8a 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -1224,8 +1224,7 @@ DOMMediaListImpl::GetMediaText(nsAString& aMediaText) } \ /* XXXldb Pass something meaningful? */ \ if (doc) { \ - rv = doc->StyleRuleChanged(sheet, nsnull, nsnull); \ - NS_ENSURE_SUCCESS(rv, rv); \ + doc->StyleRuleChanged(sheet, nsnull, nsnull); \ } @@ -2780,8 +2779,7 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule, } } if (mDocument && notify) { - result = mDocument->StyleRuleAdded(this, cssRule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleAdded(this, cssRule); } } @@ -2824,8 +2822,7 @@ CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex) DidDirty(); if (mDocument) { - result = mDocument->StyleRuleRemoved(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleRemoved(this, rule); } } } @@ -2865,8 +2862,7 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex) DidDirty(); if (mDocument) { - result = mDocument->StyleRuleRemoved(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleRemoved(this, rule); } return NS_OK; @@ -2940,8 +2936,7 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* rule = dont_AddRef((nsICSSRule*)rules->ElementAt(counter)); if (mDocument) { - result = mDocument->StyleRuleAdded(this, rule); - NS_ENSURE_SUCCESS(result, result); + mDocument->StyleRuleAdded(this, rule); } } @@ -2999,8 +2994,7 @@ CSSStyleSheetImpl::StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify) // they do)! nsCOMPtr styleRule(do_QueryInterface(ownerRule)); - nsresult rv = mDocument->StyleRuleAdded(this, styleRule); - NS_ENSURE_SUCCESS(rv, rv); + mDocument->StyleRuleAdded(this, styleRule); } return NS_OK; @@ -3567,24 +3561,24 @@ static PRBool SelectorMatches(RuleProcessorData &data, // The content language can be a comma-separated list of // language codes. nsAutoString language; - if (NS_SUCCEEDED(doc->GetContentLanguage(language))) { - nsDependentString langString(pseudoClass->mString); - language.StripWhitespace(); - PRInt32 begin = 0; - PRInt32 len = language.Length(); - while (begin < len) { - PRInt32 end = language.FindChar(PRUnichar(','), begin); - if (end == kNotFound) { - end = len; - } - if (DashMatchCompare(Substring(language, begin, end-begin), - langString, - PR_FALSE)) { - result = localTrue; - break; - } - begin = end + 1; + doc->GetContentLanguage(language); + + nsDependentString langString(pseudoClass->mString); + language.StripWhitespace(); + PRInt32 begin = 0; + PRInt32 len = language.Length(); + while (begin < len) { + PRInt32 end = language.FindChar(PRUnichar(','), begin); + if (end == kNotFound) { + end = len; } + if (DashMatchCompare(Substring(language, begin, end-begin), + langString, + PR_FALSE)) { + result = localTrue; + break; + } + begin = end + 1; } } } diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index 6ee28039168..4f4f287bade 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -648,16 +648,14 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen if (EnsureArray(mDocSheets)) { mDocSheets->RemoveElement(aSheet); // lowest index last - PRInt32 newDocIndex = 0; - aDocument->GetIndexOfStyleSheet(aSheet, &newDocIndex); + PRInt32 newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet); PRUint32 count; nsresult rv = mDocSheets->Count(&count); if (NS_FAILED(rv)) return; // XXX error? PRUint32 index; for (index = 0; index < count; index++) { nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index); - PRInt32 sheetDocIndex = 0; - aDocument->GetIndexOfStyleSheet(sheet, &sheetDocIndex); + PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet); if (sheetDocIndex < newDocIndex) { mDocSheets->InsertElementAt(aSheet, index); index = count; // break loop diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 0563c4746d8..473f9fba688 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -758,8 +758,7 @@ nsBoxFrame::IsInitialReflowForPrintPreview(nsBoxLayoutState& aState, nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); if (!doc) return PR_FALSE; - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetDocumentURL(); if (!uri) return PR_FALSE; uri->SchemeIs("chrome", &aIsChrome); return PR_TRUE; diff --git a/mozilla/layout/xul/base/src/nsBoxObject.cpp b/mozilla/layout/xul/base/src/nsBoxObject.cpp index 61bc3dded6f..98399ca6910 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsBoxObject.cpp @@ -207,12 +207,11 @@ nsBoxObject::GetOffsetRect(nsRect& aRect) // Find the frame parent whose content's tagName either matches // the tagName passed in or is the document element. - nsCOMPtr docElement; - doc->GetRootContent(getter_AddRefs(docElement)); + nsIContent *docElement = doc->GetRootContent(); nsIFrame* parent = frame->GetParent(); while (parent) { // If we've hit the document element, break here - if (parent->GetContent() == docElement.get()) { + if (parent->GetContent() == docElement) { break; } @@ -636,17 +635,16 @@ nsBoxObject::GetDocShell(nsIDocShell** aResult) // No nsIFrameFrame available for mContent, try if there's a mapping // between mContent's document to mContent's subdocument. - nsCOMPtr doc, sub_doc; + nsCOMPtr doc; mPresShell->GetDocument(getter_AddRefs(doc)); - doc->GetSubDocumentFor(mContent, getter_AddRefs(sub_doc)); + nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent); if (!sub_doc) { return NS_OK; } - nsCOMPtr container; - sub_doc->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = sub_doc->GetContainer(); if (!container) { return NS_OK; diff --git a/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp b/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp index 341dc9f41ab..bd71aa00bdc 100644 --- a/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsDocElementBoxFrame.cpp @@ -123,12 +123,11 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsIPresContext* aPresContext, if (!elementFactory) return NS_ERROR_FAILURE; - nsCOMPtr nodeInfoManager; nsIDocument* doc = mContent->GetDocument(); if (!doc) // The page is currently being torn down. Why bother. return NS_ERROR_FAILURE; - doc->GetNodeInfoManager(getter_AddRefs(nodeInfoManager)); + nsINodeInfoManager *nodeInfoManager = doc->GetNodeInfoManager(); NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE); // create the top-secret popupgroup node. shhhhh! diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index c814ac0a04b..b01046d3342 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -455,12 +455,12 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize) GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); // Get the document URI for the referrer... - nsCOMPtr documentURI; + nsIURI *documentURI = nsnull; nsCOMPtr doc; if (mContent) { doc = mContent->GetDocument(); if (doc) { - doc->GetDocumentURL(getter_AddRefs(documentURI)); + documentURI = doc->GetDocumentURL(); } } @@ -709,7 +709,7 @@ nsImageBoxFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoad if (!doc) return; - doc->GetDocumentLoadGroup(aLoadGroup); + *aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed } diff --git a/mozilla/layout/xul/base/src/nsListBoxObject.cpp b/mozilla/layout/xul/base/src/nsListBoxObject.cpp index b3e1c816ed5..19ddcc11580 100644 --- a/mozilla/layout/xul/base/src/nsListBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxObject.cpp @@ -186,11 +186,8 @@ FindBodyContent(nsIContent* aParent, nsIContent** aResult) NS_IF_ADDREF(*aResult); } else { - nsIDocument* doc = aParent->GetDocument(); - nsCOMPtr bindingManager; - doc->GetBindingManager(getter_AddRefs(bindingManager)); nsCOMPtr kids; - bindingManager->GetXBLChildNodesFor(aParent, getter_AddRefs(kids)); + aParent->GetDocument()->GetBindingManager()->GetXBLChildNodesFor(aParent, getter_AddRefs(kids)); if (!kids) return; PRUint32 i; diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index 973cb2bdea8..34d0241e260 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -213,8 +213,7 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag) if (!document) break; - nsCOMPtr container; - document->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = document->GetContainer(); nsCOMPtr windowPrivate = do_GetInterface(container); if (!windowPrivate) break; diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 212130035d5..d3567d10b41 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -928,8 +928,6 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr document; presShell->GetDocument(getter_AddRefs(document)); - nsCOMPtr scriptGlobalObject; - document->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); nsCOMPtr tag; mContent->GetTag(getter_AddRefs(tag)); @@ -986,7 +984,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext, // Compute info about the screen dimensions. Because of multiple monitor systems, // the left or top sides of the screen may be in negative space (main monitor is on the // right, etc). We need to be sure to do the right thing. - nsCOMPtr window(do_QueryInterface(scriptGlobalObject)); + nsCOMPtr window(do_QueryInterface(document->GetScriptGlobalObject())); nsCOMPtr screen; window->GetScreen(getter_AddRefs(screen)); PRInt32 screenWidth = 0, screenHeight = 0; diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.cpp b/mozilla/layout/xul/base/src/nsResizerFrame.cpp index c6ef98b2972..0adb07d3d45 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.cpp +++ b/mozilla/layout/xul/base/src/nsResizerFrame.cpp @@ -156,8 +156,7 @@ nsResizerFrame::HandleEvent(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr document; presShell->GetDocument(getter_AddRefs(document)); - nsCOMPtr scriptGlobalObject; - document->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); + nsIScriptGlobalObject *scriptGlobalObject = document->GetScriptGlobalObject(); NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); nsCOMPtr docShell; diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index c1f3cb67510..35f55afccda 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -171,9 +171,7 @@ nsTitleBarFrame::HandleEvent(nsIPresContext* aPresContext, aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr document; presShell->GetDocument(getter_AddRefs(document)); - nsCOMPtr scriptGlobalObject; - document->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); - nsCOMPtr window(do_QueryInterface(scriptGlobalObject)); + nsCOMPtr window(do_QueryInterface(document->GetScriptGlobalObject())); diff --git a/mozilla/layout/xul/base/src/nsXULTooltipListener.cpp b/mozilla/layout/xul/base/src/nsXULTooltipListener.cpp index d3d596ef64b..8cc30150c3b 100644 --- a/mozilla/layout/xul/base/src/nsXULTooltipListener.cpp +++ b/mozilla/layout/xul/base/src/nsXULTooltipListener.cpp @@ -565,10 +565,9 @@ nsXULTooltipListener::GetTooltipFor(nsIContent* aTarget, nsIContent** aTooltip) NS_ERROR("Unable to retrieve the tooltip node document."); return NS_ERROR_FAILURE; } - nsCOMPtr context; - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = document->GetScriptGlobalObject(); if (global) { + nsCOMPtr context; if (NS_SUCCEEDED(global->GetContext(getter_AddRefs(context))) && context) { nsCOMPtr domWindow = do_QueryInterface(global); if (!domWindow) diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index c1478ce8394..c1155fb66ca 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1949,15 +1949,11 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID, PRBool aUs if (NS_FAILED(rv)) return rv; - // Get the documment URI for the referrer. - nsCOMPtr documentURI; - doc->GetDocumentURL(getter_AddRefs(documentURI)); - mImageGuard = PR_TRUE; // XXX: initialDocumentURI is NULL! - rv = il->LoadImage(srcURI, nsnull, documentURI, nsnull, imgDecoderObserver, - doc, nsIRequest::LOAD_NORMAL, nsnull, nsnull, - getter_AddRefs(imageRequest)); + rv = il->LoadImage(srcURI, nsnull, doc->GetDocumentURL(), nsnull, + imgDecoderObserver, doc, nsIRequest::LOAD_NORMAL, + nsnull, nsnull, getter_AddRefs(imageRequest)); mImageGuard = PR_FALSE; if (!imageRequest) diff --git a/mozilla/mailnews/compose/src/nsMsgSend.cpp b/mozilla/mailnews/compose/src/nsMsgSend.cpp index 131d2d5725c..9e0ac9847aa 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSend.cpp @@ -1508,8 +1508,7 @@ nsMsgComposeAndSend::GetEmbeddedObjectInfo(nsIDOMNode *node, nsMsgAttachmentData return NS_ERROR_OUT_OF_MEMORY; nsCAutoString spec; - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); + nsIURI *uri = doc->GetDocumentURL(); if (!uri) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp index 12b14b13f2c..bcdd6e77909 100644 --- a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp @@ -1336,9 +1336,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) nsCOMPtr doc; owner->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr globalScript; - doc->GetScriptGlobalObject(getter_AddRefs(globalScript)); - nsCOMPtr domWindow (do_QueryInterface(globalScript)); + nsCOMPtr domWindow (do_QueryInterface(doc->GetScriptGlobalObject())); if (domWindow) { NS_ADDREF(*(nsIDOMWindow**)result = domWindow.get()); return NPERR_NO_ERROR; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index dc60da9120f..d31acd56967 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1216,8 +1216,6 @@ public: nsresult OnFileAvailable(nsIFile* aFile); - nsILoadGroup* GetLoadGroup(); - nsresult ServeStreamAsFile(nsIRequest *request, nsISupports *ctxt); private: @@ -2513,21 +2511,6 @@ nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile) } -//////////////////////////////////////////////////////////////////////// -nsILoadGroup* -nsPluginStreamListenerPeer::GetLoadGroup() -{ - nsILoadGroup* loadGroup = nsnull; - nsIDocument* doc; - nsresult rv = mOwner->GetDocument(&doc); - if (NS_SUCCEEDED(rv)) { - doc->GetDocumentLoadGroup(&loadGroup); - NS_RELEASE(doc); - } - return loadGroup; -} - - //////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsPluginStreamListenerPeer::VisitHeader(const nsACString &header, const nsACString &value) @@ -2829,10 +2812,7 @@ nsresult nsPluginHostImpl:: GetPrompt(nsIPluginInstanceOwner *aOwner, nsIPrompt nsCOMPtr document; aOwner->GetDocument(getter_AddRefs(document)); if (document) { - nsCOMPtr globalScript; - document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (globalScript) - domWindow = do_QueryInterface(globalScript); + domWindow = do_QueryInterface(document->GetScriptGlobalObject()); } } @@ -5651,11 +5631,8 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, rv = owner->GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv) && doc) { - nsCOMPtr docURL; - doc->GetBaseURL(getter_AddRefs(docURL)); - // Create an absolute URL - rv = NS_MakeAbsoluteURI(absUrl, aURL, docURL); + rv = NS_MakeAbsoluteURI(absUrl, aURL, doc->GetBaseURL()); } } } @@ -5681,8 +5658,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, if (doc) { // Get the script global object owner and use that as the notification callback - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject* global = doc->GetScriptGlobalObject(); if (global) { @@ -5706,10 +5682,7 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, if (doc) { // Set the owner of channel to the document principal... - nsCOMPtr principal; - doc->GetPrincipal(getter_AddRefs(principal)); - - channel->SetOwner(principal); + channel->SetOwner(doc->GetPrincipal()); } // deal with headers and post data @@ -5765,7 +5738,6 @@ nsPluginHostImpl::DoURLLoadSecurityCheck(nsIPluginInstance *aInstance, // get the URL of the document that loaded the plugin nsCOMPtr doc; nsCOMPtr peer; - nsCOMPtr sourceURL; rv = aInstance->GetPeer(getter_AddRefs(peer)); if (NS_FAILED(rv) || !peer) return NS_ERROR_FAILURE; @@ -5780,16 +5752,13 @@ nsPluginHostImpl::DoURLLoadSecurityCheck(nsIPluginInstance *aInstance, if (!doc) return NS_ERROR_FAILURE; - rv = doc->GetDocumentURL(getter_AddRefs(sourceURL)); + nsIURI *sourceURL = doc->GetDocumentURL(); if (!sourceURL) return NS_ERROR_FAILURE; // Create an absolute URL for the target in case the target is relative - nsCOMPtr docBaseURL; - doc->GetBaseURL(getter_AddRefs(docBaseURL)); - nsCOMPtr targetURL; - rv = NS_NewURI(getter_AddRefs(targetURL), aURL, docBaseURL); + rv = NS_NewURI(getter_AddRefs(targetURL), aURL, doc->GetBaseURL()); if (!targetURL) return NS_ERROR_FAILURE; @@ -5945,7 +5914,7 @@ nsresult nsPluginHostImpl::NewEmbededPluginStream(nsIURI* aURL, if (aOwner) { rv = aOwner->GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv) && doc) { - doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup)); + loadGroup = doc->GetDocumentLoadGroup(); } } @@ -5956,11 +5925,8 @@ nsresult nsPluginHostImpl::NewEmbededPluginStream(nsIURI* aURL, // if this is http channel, set referrer, some servers are configured // to reject requests without referrer set, see bug 157796 nsCOMPtr httpChannel(do_QueryInterface(channel)); - if (httpChannel && doc) { - nsCOMPtr referrerURL; - if (NS_SUCCEEDED(doc->GetBaseURL(getter_AddRefs(referrerURL)))) - httpChannel->SetReferrer(referrerURL); - } + if (httpChannel && doc) + httpChannel->SetReferrer(doc->GetBaseURL()); rv = channel->AsyncOpen(listener, nsnull); if (NS_SUCCEEDED(rv)) diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index 1495d1603e2..091baa44a29 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -745,8 +745,7 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow) rv = mOwner->GetDocument(getter_AddRefs(document)); if (NS_SUCCEEDED(rv) && document) { - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = document->GetScriptGlobalObject(); if(global) { *outJSWindow = global->GetGlobalJSObject(); @@ -771,8 +770,7 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext) rv = mOwner->GetDocument(getter_AddRefs(document)); if (NS_SUCCEEDED(rv) && document) { - nsCOMPtr global; - document->GetScriptGlobalObject(getter_AddRefs(global)); + nsIScriptGlobalObject *global = document->GetScriptGlobalObject(); if (global) { nsCOMPtr context; diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 59b17505c64..fe7f2d7e3d0 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -1431,9 +1431,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) return; // Annihilate all XBL bindings. - nsCOMPtr bindingManager; - document->GetBindingManager(getter_AddRefs(bindingManager)); - bindingManager->FlushSkinBindings(); + document->GetBindingManager()->FlushSkinBindings(); } NS_IMETHODIMP nsChromeRegistry::RefreshSkins() @@ -1587,15 +1585,13 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) nsCOMArray oldSheets; nsCOMArray newSheets; - PRInt32 count = 0; - document->GetNumberOfStyleSheets(PR_FALSE, &count); + PRInt32 count = document->GetNumberOfStyleSheets(PR_FALSE); // Iterate over the style sheets. PRInt32 i; for (i = 0; i < count; i++) { // Get the style sheet - nsCOMPtr styleSheet; - document->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(styleSheet)); + nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i, PR_FALSE); if (!oldSheets.AppendObject(styleSheet)) { return NS_ERROR_OUT_OF_MEMORY; @@ -3110,10 +3106,9 @@ nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aRes while (token) { nsCOMPtr content(do_QueryInterface(elt)); nsCOMPtr doc = content->GetDocument(); - nsCOMPtr docURL; - doc->GetDocumentURL(getter_AddRefs(docURL)); nsCOMPtr url; - rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), nsnull, docURL); + rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), + nsnull, doc->GetDocumentURL()); nsCOMPtr sheet; // The CSSLoader handles all the prototype cache stuff for diff --git a/mozilla/security/manager/boot/src/nsSecureBrowserUIImpl.cpp b/mozilla/security/manager/boot/src/nsSecureBrowserUIImpl.cpp index 358696f6177..9a89d5fa33f 100644 --- a/mozilla/security/manager/boot/src/nsSecureBrowserUIImpl.cpp +++ b/mozilla/security/manager/boot/src/nsSecureBrowserUIImpl.cpp @@ -329,12 +329,9 @@ nsSecureBrowserUIImpl::Notify(nsIContent* formNode, nsCOMPtr document = formNode->GetDocument(); if (!document) return NS_OK; - nsCOMPtr formURL; - document->GetBaseURL(getter_AddRefs(formURL)); - - nsCOMPtr globalObject; - document->GetScriptGlobalObject(getter_AddRefs(globalObject)); - nsCOMPtr postingWindow(do_QueryInterface(globalObject)); + nsIURI *formURL = document->GetBaseURL(); + + nsCOMPtr postingWindow(do_QueryInterface(document->GetScriptGlobalObject())); PRBool isChild; IsChildOfDomWindow(mWindow, postingWindow, &isChild); diff --git a/mozilla/toolkit/components/passwordmgr/base/nsPasswordManager.cpp b/mozilla/toolkit/components/passwordmgr/base/nsPasswordManager.cpp index f851741a537..311198b73ff 100644 --- a/mozilla/toolkit/components/passwordmgr/base/nsPasswordManager.cpp +++ b/mozilla/toolkit/components/passwordmgr/base/nsPasswordManager.cpp @@ -608,11 +608,8 @@ nsPasswordManager::OnStateChange(nsIWebProgress* aWebProgress, nsCOMPtr doc = do_QueryInterface(domDoc); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - nsCAutoString realm; - if (!GetPasswordRealm(uri, realm)) + if (!GetPasswordRealm(doc->GetDocumentURL(), realm)) return NS_OK; SignonHashEntry* hashEnt; @@ -748,11 +745,8 @@ nsPasswordManager::Notify(nsIContent* aFormNode, return NS_OK; // Check the reject list - nsCOMPtr uri; - aFormNode->GetDocument()->GetDocumentURL(getter_AddRefs(uri)); - nsCAutoString realm; - if (!GetPasswordRealm(uri, realm)) + if (!GetPasswordRealm(aFormNode->GetDocument()->GetDocumentURL(), realm)) return NS_OK; PRInt32 rejectValue; @@ -1170,11 +1164,9 @@ nsPasswordManager::AutoCompleteSearch(const nsAString& aSearchString, aElement->GetOwnerDocument(getter_AddRefs(domDoc)); nsCOMPtr doc = do_QueryInterface(domDoc); - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); nsCAutoString realm; - if (!GetPasswordRealm(uri, realm)) { + if (!GetPasswordRealm(doc->GetDocumentURL(), realm)) { *aResult = nsnull; return NS_OK; } @@ -1650,13 +1642,9 @@ nsPasswordManager::FillPassword(nsIDOMEvent* aEvent) return NS_OK; nsCOMPtr fieldContent = do_QueryInterface(userField); - nsIDocument* doc = fieldContent->GetDocument(); - - nsCOMPtr documentURL; - doc->GetDocumentURL(getter_AddRefs(documentURL)); nsCAutoString realm; - if (!GetPasswordRealm(documentURL, realm)) + if (!GetPasswordRealm(fieldContent->GetDocument()->GetDocumentURL(), realm)) return NS_OK; nsAutoString userValue; diff --git a/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp b/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp index 199fe4b32be..ac25c165484 100644 --- a/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp +++ b/mozilla/toolkit/components/satchel/src/nsFormFillController.cpp @@ -44,6 +44,7 @@ #include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" #include "nsIDocShellTreeItem.h" #include "nsIChromeEventHandler.h" #include "nsPIDOMWindow.h" @@ -765,14 +766,7 @@ nsFormFillController::GetDocShellForInput(nsIDOMHTMLInputElement *aInput) aInput->GetOwnerDocument(getter_AddRefs(domDoc)); nsCOMPtr doc = do_QueryInterface(domDoc); - nsCOMPtr ourGlobal; - doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr domWindow = do_QueryInterface(ourGlobal); - - nsCOMPtr ifreq(do_QueryInterface(domWindow)); - NS_ENSURE_TRUE(ifreq, NS_OK); - nsCOMPtr webNav; - ifreq->GetInterface(NS_GET_IID(nsIWebNavigation), getter_AddRefs(webNav)); + nsCOMPtr webNav = do_GetInterface(doc->GetScriptGlobalObject()); nsCOMPtr docShell = do_QueryInterface(webNav); return docShell; } @@ -789,11 +783,7 @@ nsFormFillController::GetWindowForDocShell(nsIDocShell *aDocShell) nsCOMPtr doc = do_QueryInterface(domDoc); NS_ENSURE_TRUE(doc, nsnull); - nsCOMPtr global; - doc->GetScriptGlobalObject(getter_AddRefs(global)); - NS_ENSURE_TRUE(global, nsnull); - - nsCOMPtr domWindow = do_QueryInterface(global); + nsCOMPtr domWindow = do_QueryInterface(doc->GetScriptGlobalObject()); return domWindow; } diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index d6573ec5c71..fcd9e5e63fc 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -2410,11 +2410,9 @@ DumpContentRecurse(nsIDocShell* aDocShell, FILE* out) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsIContent* root = nsnull; - doc->GetRootContent(&root); + nsIContent *root = doc->GetRootContent(); if (nsnull != root) { root->List(out); - NS_RELEASE(root); } } NS_RELEASE(shell); diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 207787e3896..b8871efcf13 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -1088,9 +1088,7 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow) shell->GetDocument(getter_AddRefs(doc)); if (doc) { nsCAutoString str; - nsCOMPtr uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - nsresult rv = uri->GetSpec(str); + nsresult rv = doc->GetDocumentURL()->GetSpec(str); if (NS_FAILED(rv)) { return rv; } diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 6328d9bf555..1e3700c7b2b 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -767,10 +767,8 @@ nsWebCrawler::FindURLsIn(nsIDocument* aDocument, nsIContent* aNode) else { aNode->GetAttr(kNameSpaceID_None, mSrcAttr, src); } - nsCOMPtr docURL; - aDocument->GetDocumentURL(getter_AddRefs(docURL)); nsresult rv; - rv = NS_MakeAbsoluteURI(absURLSpec, src, docURL); + rv = NS_MakeAbsoluteURI(absURLSpec, src, aDocument->GetDocumentURL()); if (NS_OK == rv) { nsCOMPtr urlAtom = do_GetAtom(absURLSpec); if (0 == mVisited->Get(urlAtom)) { @@ -824,8 +822,7 @@ nsWebCrawler::FindMoreURLs() nsCOMPtr doc; docv->GetDocument(getter_AddRefs(doc)); if (doc) { - nsCOMPtr root; - doc->GetRootContent(getter_AddRefs(root)); + nsIContent *root = doc->GetRootContent(); if (root) { FindURLsIn(doc, root); } diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index 6d45c982101..cf49817249b 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -408,7 +408,7 @@ NS_IMETHODIMP nsXPBaseWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* a nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); if (doc) { - doc->GetRootContent(&mContentRoot); + NS_IF_ADDREF(mContentRoot = doc->GetRootContent()); mDocIsLoaded = PR_TRUE; if (nsnull != mWindowListener) { mWindowListener->Initialize(this); diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index f5d8548c0b3..d38f911c533 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1416,8 +1416,7 @@ void nsWebShellWindow::LoadContentAreas() { if (docViewer) { nsCOMPtr doc; docViewer->GetDocument(getter_AddRefs(doc)); - nsCOMPtr mainURL; - doc->GetDocumentURL(getter_AddRefs(mainURL)); + nsIURI *mainURL = doc->GetDocumentURL(); if (mainURL) { nsCAutoString search; nsCOMPtr url = do_QueryInterface(mainURL);