diff --git a/mozilla/accessible/src/base/nsAccessNode.cpp b/mozilla/accessible/src/base/nsAccessNode.cpp index cf00155ed86..d39c5b46056 100755 --- a/mozilla/accessible/src/base/nsAccessNode.cpp +++ b/mozilla/accessible/src/base/nsAccessNode.cpp @@ -415,8 +415,7 @@ nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt, const nsAString nsCOMPtr presContext(GetPresContext()); NS_ENSURE_TRUE(domElement && presContext, NS_ERROR_FAILURE); - nsCOMPtr container; - presContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = presContext->GetContainer(); nsCOMPtr domWin(do_GetInterface(container)); nsCOMPtr viewCSS(do_QueryInterface(domWin)); NS_ENSURE_TRUE(viewCSS, NS_ERROR_FAILURE); diff --git a/mozilla/content/base/src/nsContentSink.cpp b/mozilla/content/base/src/nsContentSink.cpp index 73a75437cb5..f6028e3d0c5 100644 --- a/mozilla/content/base/src/nsContentSink.cpp +++ b/mozilla/content/base/src/nsContentSink.cpp @@ -954,8 +954,7 @@ nsContentSink::StartLayout(PRBool aIsFrameset) // Resize-reflow this time nsCOMPtr cx; shell->GetPresContext(getter_AddRefs(cx)); - nsRect r; - cx->GetVisibleArea(r); + nsRect r = cx->GetVisibleArea(); shell->InitialReflow(r.width, r.height); // Now trigger a refresh diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 6db0e81842f..0d5f6a55a87 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -374,8 +374,7 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI, nsCOMPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); if (presContext) { - nsCOMPtr container; - presContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = presContext->GetContainer(); nsCOMPtr document = do_QueryInterface(*aReturn); if (document) { document->SetContainer(container); @@ -2557,9 +2556,8 @@ nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView) nsresult rv = shell->GetPresContext(getter_AddRefs(ctx)); NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && ctx, rv); - nsCOMPtr container; - rv = ctx->GetContainer(getter_AddRefs(container)); - NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv); + nsCOMPtr container = ctx->GetContainer(); + NS_ENSURE_TRUE(container, NS_OK); nsCOMPtr window = do_GetInterface(container); NS_ENSURE_TRUE(window, NS_OK); @@ -2603,10 +2601,7 @@ nsDocument::SetTitle(const nsAString& aTitle) nsresult rv = shell->GetPresContext(getter_AddRefs(context)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr container; - rv = context->GetContainer(getter_AddRefs(container)); - NS_ENSURE_SUCCESS(rv, rv); - + nsCOMPtr container = context->GetContainer(); if (!container) continue; diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index f9627725b2f..8bfb74f840b 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -2685,12 +2685,11 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - nsRect shellArea; PRInt32 width, height; float pixelScale; // so how big is it? - presContext->GetVisibleArea(shellArea); + nsRect shellArea = presContext->GetVisibleArea(); presContext->GetTwipsToPixels(&pixelScale); width = PRInt32((float)shellArea.width*pixelScale); height = PRInt32((float)shellArea.height*pixelScale); @@ -3591,8 +3590,7 @@ DocumentViewerImpl::ReturnToGalleyPresentation() } // Get the current size of what is being viewed - nsRect area; - mPresContext->GetVisibleArea(area); + nsRect area = mPresContext->GetVisibleArea(); nsRect bounds; mWindow->GetBounds(bounds); @@ -3697,8 +3695,7 @@ DocumentViewerImpl::InstallNewPresentation() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) // Get the current size of what is being viewed - nsRect area; - mPresContext->GetVisibleArea(area); + nsRect area = mPresContext->GetVisibleArea(); nsRect bounds; mWindow->GetBounds(bounds); diff --git a/mozilla/content/base/src/nsFrameLoader.cpp b/mozilla/content/base/src/nsFrameLoader.cpp index 93c32bc54a1..eaf7d03196a 100644 --- a/mozilla/content/base/src/nsFrameLoader.cpp +++ b/mozilla/content/base/src/nsFrameLoader.cpp @@ -411,8 +411,7 @@ nsFrameLoader::EnsureDocShell() // Bug 8065: Don't exceed some maximum depth in content frames // (MAX_DEPTH_CONTENT_FRAMES) PRInt32 depth = 0; - nsCOMPtr parentAsSupports; - presContext->GetContainer(getter_AddRefs(parentAsSupports)); + nsCOMPtr parentAsSupports = presContext->GetContainer(); if (parentAsSupports) { nsCOMPtr parentAsItem = @@ -459,8 +458,7 @@ nsFrameLoader::EnsureDocShell() // child. If it's not a web-shell then some things will not operate // properly. - nsCOMPtr container; - presContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = presContext->GetContainer(); nsCOMPtr parentAsNode(do_QueryInterface(container)); if (parentAsNode) { diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 6b7534d54b3..22c95043139 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -3053,10 +3053,9 @@ nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr) nsresult nsGenericElement::LeaveLink(nsIPresContext* aPresContext) { - nsCOMPtr handler; - nsresult rv = aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (NS_FAILED(rv) || !handler) { - return rv; + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (!handler) { + return NS_OK; } return handler->OnLeaveLink(); @@ -3071,9 +3070,10 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext, PRBool aClick) { NS_PRECONDITION(aLinkURI, "No link URI"); - nsCOMPtr handler; - nsresult rv = aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (NS_FAILED(rv) || !handler) return rv; + nsresult rv = NS_OK; + + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (!handler) return NS_OK; if (aClick) { nsresult proceed = NS_OK; diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 71258427a68..99286ec6351 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -1343,9 +1343,9 @@ static PRBool IsChrome(nsIPresContext* aPresContext) { PRBool isChrome = PR_FALSE; - nsCOMPtr container; - nsresult result = aPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { + nsresult result; nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell) { PRInt32 docShellType; diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 84fd97a1c98..498eb7f5109 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -503,9 +503,8 @@ nsDOMEvent::GetView(nsIDOMAbstractView** aView) nsresult rv = NS_OK; if (mPresContext) { - nsCOMPtr container; - rv = mPresContext->GetContainer(getter_AddRefs(container)); - NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && container, rv); + nsCOMPtr container = mPresContext->GetContainer(); + NS_ENSURE_TRUE(container, NS_OK); nsCOMPtr window = do_GetInterface(container); NS_ENSURE_TRUE(window, NS_OK); diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 2b72182a707..de6694a5888 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -948,8 +948,7 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, if (nsEventStatus_eConsumeNoDefault != *aStatus) { // checking all sub docshells - nsCOMPtr pcContainer; - aPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = aPresContext->GetContainer(); NS_ASSERTION(pcContainer, "no container for presContext"); nsCOMPtr docShell(do_QueryInterface(pcContainer)); @@ -997,8 +996,7 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, // bubble up the process to the parent docShell if necesary if (eAccessKeyProcessingDown != aAccessKeyState && nsEventStatus_eConsumeNoDefault != *aStatus) { - nsCOMPtr pcContainer; - aPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = aPresContext->GetContainer(); NS_ASSERTION(pcContainer, "no container for presContext"); nsCOMPtr docShell(do_QueryInterface(pcContainer)); @@ -1473,8 +1471,7 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) presShell->GetPresContext(getter_AddRefs(presContext)); if(!presContext) return NS_ERROR_FAILURE; - nsCOMPtr pcContainer; - presContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = presContext->GetContainer(); if(!pcContainer) return NS_ERROR_FAILURE; nsCOMPtr docshell(do_QueryInterface(pcContainer)); @@ -1923,8 +1920,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, case MOUSE_SCROLL_HISTORY: { - nsCOMPtr pcContainer; - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = mPresContext->GetContainer(); if (pcContainer) { nsCOMPtr webNav(do_QueryInterface(pcContainer)); if (webNav) { @@ -2101,7 +2097,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, case NS_APPCOMMAND_REFRESH: case NS_APPCOMMAND_STOP: // handle these commands using nsIWebNavigation - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + pcContainer = mPresContext->GetContainer(); if (pcContainer) { nsCOMPtr webNav(do_QueryInterface(pcContainer)); if (webNav) { @@ -2264,8 +2260,7 @@ nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext, } // Check whether or not to show the busy cursor - nsCOMPtr pcContainer; - aPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(pcContainer)); if (!docShell) return; PRUint32 busyFlags = nsIDocShell::BUSY_FLAGS_NONE; @@ -2960,8 +2955,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) nsCOMPtr rootContent = mDocument->GetRootContent(); - nsCOMPtr pcContainer; - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = mPresContext->GetContainer(); NS_ASSERTION(pcContainer, "no container for presContext"); nsCOMPtr docShell(do_QueryInterface(pcContainer)); @@ -4785,8 +4779,7 @@ nsEventStateManager::MoveCaretToFocus() PRInt32 itemType = nsIDocShellTreeItem::typeChrome; if (mPresContext) { - nsCOMPtr pcContainer; - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = mPresContext->GetContainer(); nsCOMPtr treeItem(do_QueryInterface(pcContainer)); if (treeItem) treeItem->GetItemType(&itemType); @@ -4936,8 +4929,7 @@ nsEventStateManager::ResetBrowseWithCaret(PRBool *aBrowseWithCaret) *aBrowseWithCaret = PR_FALSE; if (!mPresContext) return NS_ERROR_FAILURE; - nsCOMPtr pcContainer; - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = mPresContext->GetContainer(); PRInt32 itemType; nsCOMPtr shellItem(do_QueryInterface(pcContainer)); if (!shellItem) @@ -5254,8 +5246,7 @@ nsEventStateManager::ShiftFocusByDoc(PRBool aForward) NS_ASSERTION(mPresContext, "no prescontext"); - nsCOMPtr pcContainer; - mPresContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = mPresContext->GetContainer(); nsCOMPtr curNode = do_QueryInterface(pcContainer); // perform a depth first search (preorder) of the docshell tree diff --git a/mozilla/content/html/content/src/nsFormSubmission.cpp b/mozilla/content/html/content/src/nsFormSubmission.cpp index 0705326419e..0f083bb1429 100644 --- a/mozilla/content/html/content/src/nsFormSubmission.cpp +++ b/mozilla/content/html/content/src/nsFormSubmission.cpp @@ -1231,8 +1231,7 @@ nsFormSubmission::SubmitTo(nsIURI* aActionURI, const nsAString& aTarget, // // Actually submit the data // - nsCOMPtr handler; - aPresContext->GetLinkHandler(getter_AddRefs(handler)); + nsILinkHandler *handler = aPresContext->GetLinkHandler(); NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE); return handler->OnLinkClickSync(aSource, eLinkVerb_Replace, diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 8d8cc2d7dfe..39b9eeaf201 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1394,9 +1394,8 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext, case NS_MOUSE_LEFT_BUTTON_DOWN: { // don't make the link grab the focus if there is no link handler - nsCOMPtr handler; - nsresult rv = aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (NS_SUCCEEDED(rv) && handler && mDocument) { + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (handler && mDocument) { // If the window is not active, do not allow the focus to bring the // window to the front. We update the focus controller, but do // nothing else. diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index 0bb768cbe0b..a698e37974c 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -271,9 +271,8 @@ nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext) } // don't make the link grab the focus if there is no link handler - nsCOMPtr handler; - nsresult rv = aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (NS_SUCCEEDED(rv) && (nsnull != handler)) { + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (handler) { nsCOMPtr stateManager; aPresContext->GetEventStateManager(getter_AddRefs(stateManager)); diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 52a2e4f3cd9..2e91483f5be 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -238,8 +238,7 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData) // if marginwidth or marginheight is set in the and not set in the // reflect them as margin in the if (bodyMarginWidth == -1 || bodyMarginHeight == -1) { - nsCOMPtr container; - aData->mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aData->mPresContext->GetContainer(); if (container) { nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 0ac636c45f9..b241b26e262 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -3042,9 +3042,7 @@ nsHTMLDocument::GetSelection(nsAString& aReturn) shell->GetPresContext(getter_AddRefs(cx)); NS_ENSURE_TRUE(cx, NS_OK); - nsCOMPtr container; - - cx->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = cx->GetContainer(); NS_ENSURE_TRUE(container, NS_OK); nsCOMPtr window(do_GetInterface(container)); @@ -3775,8 +3773,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode) shell->GetPresContext(getter_AddRefs(cx)); NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE); - nsCOMPtr container; - cx->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = cx->GetContainer(); NS_ENSURE_TRUE(container, NS_OK); // get content root frame diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 575f43f8de4..fcdb2824ba0 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -529,8 +529,7 @@ nsImageDocument::CheckOverflowing() nsCOMPtr context; shell->GetPresContext(getter_AddRefs(context)); - nsRect visibleArea; - context->GetVisibleArea(visibleArea); + nsRect visibleArea = context->GetVisibleArea(); nsCOMPtr content = do_QueryInterface(mBodyContent); nsRefPtr styleContext = diff --git a/mozilla/content/html/document/src/nsMediaDocument.cpp b/mozilla/content/html/document/src/nsMediaDocument.cpp index d9244c91086..964516421c6 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -285,8 +285,7 @@ nsMediaDocument::StartLayout() // Initial-reflow this time. nsCOMPtr context; shell->GetPresContext(getter_AddRefs(context)); - nsRect visibleArea; - context->GetVisibleArea(visibleArea); + nsRect visibleArea = context->GetVisibleArea(); shell->InitialReflow(visibleArea.width, visibleArea.height); // Now trigger a refresh. diff --git a/mozilla/content/html/style/src/nsStyleUtil.cpp b/mozilla/content/html/style/src/nsStyleUtil.cpp index 71ab0f2ca78..7560ef1a700 100644 --- a/mozilla/content/html/style/src/nsStyleUtil.cpp +++ b/mozilla/content/html/style/src/nsStyleUtil.cpp @@ -447,8 +447,7 @@ PRBool nsStyleUtil::IsHTMLLink(nsIContent *aContent, nsIAtom *aTag, nsIPresConte link->GetHrefURI(getter_AddRefs(hrefURI)); if (hrefURI) { - nsCOMPtr linkHandler; - aPresContext->GetLinkHandler(getter_AddRefs(linkHandler)); + nsILinkHandler *linkHandler = aPresContext->GetLinkHandler(); if (linkHandler) { linkHandler->GetLinkState(hrefURI, linkState); } @@ -502,8 +501,7 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon // XXX should we make sure to get the right charset off the document? (void) NS_NewURI(getter_AddRefs(absURI), val, nsnull, baseURI); - nsCOMPtr linkHandler; - aPresContext->GetLinkHandler(getter_AddRefs(linkHandler)); + nsILinkHandler *linkHandler = aPresContext->GetLinkHandler(); if (linkHandler) { linkHandler->GetLinkState(absURI, *aState); } diff --git a/mozilla/content/shared/src/nsStyleStruct.cpp b/mozilla/content/shared/src/nsStyleStruct.cpp index 4157878cafc..8155f7aea2e 100644 --- a/mozilla/content/shared/src/nsStyleStruct.cpp +++ b/mozilla/content/shared/src/nsStyleStruct.cpp @@ -1100,7 +1100,7 @@ nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext) else mDirection = NS_STYLE_DIRECTION_LTR; - aPresContext->GetLanguage(getter_AddRefs(mLanguage)); + mLanguage = aPresContext->GetLanguage(); mVisible = NS_STYLE_VISIBILITY_VISIBLE; } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index ec2825d792c..4edea4b7639 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -2161,8 +2161,7 @@ nsXULDocument::StartLayout(void) if (! cx) return NS_ERROR_UNEXPECTED; - nsCOMPtr container; - cx->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = cx->GetContainer(); NS_ASSERTION(container != nsnull, "pres context has no container"); if (! container) return NS_ERROR_UNEXPECTED; @@ -2172,8 +2171,7 @@ nsXULDocument::StartLayout(void) if (! docShell) return NS_ERROR_UNEXPECTED; - nsRect r; - cx->GetVisibleArea(r); + nsRect r = cx->GetVisibleArea(); // Trigger a refresh before the call to InitialReflow(), // because the view manager's UpdateView() function is diff --git a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp index af90c4340b1..a83ed0fab59 100644 --- a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp @@ -135,9 +135,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName, rv = aParams->GetBooleanValue("plugins", &allowPlugins); if (NS_SUCCEEDED(rv)) { - nsCOMPtr container; - rv = presContext->GetContainer(getter_AddRefs(container)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr container = presContext->GetContainer(); if (!container) return NS_ERROR_FAILURE; nsCOMPtr docShell(do_QueryInterface(container, &rv)); @@ -190,9 +188,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName, rv = aParams->GetBooleanValue("plugins", &allowPlugins); if (NS_SUCCEEDED(rv)) { - nsCOMPtr container; - rv = presContext->GetContainer(getter_AddRefs(container)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr container = presContext->GetContainer(); if (!container) return NS_ERROR_FAILURE; nsCOMPtr docShell(do_QueryInterface(container, &rv)); diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 1895552b934..15eea2826c3 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -468,9 +468,8 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, NS_ENSURE_SUCCESS(presShell->ResizeReflow(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE), NS_ERROR_FAILURE); - nsRect shellArea; + nsRect shellArea = presContext->GetVisibleArea(); - presContext->GetVisibleArea(shellArea); float pixelScale; presContext->GetTwipsToPixels(&pixelScale); PRInt32 browserCX = PRInt32((float)shellArea.width*pixelScale); diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index e78f4d94f48..b04a688440a 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -1223,8 +1223,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, return NS_ERROR_FAILURE; } - nsCOMPtr currentContainer, startingContainer; - presContext->GetContainer(getter_AddRefs(startingContainer)); + nsCOMPtr startingContainer = presContext->GetContainer(); nsCOMPtr treeItem(do_QueryInterface(startingContainer)); NS_ASSERTION(treeItem, "Bug 175321 Crashes with Type Ahead Find [@ nsTypeAheadFind::FindItNow]"); if (!treeItem) { @@ -1249,7 +1248,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, getter_AddRefs(docShellEnumerator)); // Default: can start at the current document - currentContainer = startingContainer = + nsCOMPtr currentContainer = startingContainer = do_QueryInterface(rootContentDocShell); // Iterate up to current shell, if there's more than 1 that we're @@ -1737,8 +1736,7 @@ nsTypeAheadFind::FindNext(PRBool aFindBackwards, nsISupportsInterfacePointer *aC typeAheadPresShell->GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_OK); - nsCOMPtr container; - presContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = presContext->GetContainer(); nsCOMPtr treeItem(do_QueryInterface(container)); NS_ENSURE_TRUE(treeItem, NS_OK); @@ -2741,8 +2739,7 @@ nsTypeAheadFind::DisplayStatus(PRBool aSuccess, nsIContent *aFocusedContent, return; } - nsCOMPtr pcContainer; - presContext->GetContainer(getter_AddRefs(pcContainer)); + nsCOMPtr pcContainer = presContext->GetContainer(); nsCOMPtr treeItem(do_QueryInterface(pcContainer)); if (!treeItem) { return; diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp index fa1c1229103..5348854c6eb 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp @@ -386,10 +386,7 @@ NS_IMETHODIMP mozXMLTermStream::SizeToContentHeight(PRInt32 maxHeight) PRInt32 scrollBarHeight = PRInt32(sbHeight*pixelScale); // Determine docshell size in pixels - nsRect shellArea; - result = presContext->GetVisibleArea(shellArea); - if (NS_FAILED(result)) - return result; + nsRect shellArea = presContext->GetVisibleArea(); PRInt32 shellWidth = PRInt32((float)shellArea.width * pixelScale); PRInt32 shellHeight = PRInt32((float)shellArea.height * pixelScale); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 9001f1df331..3d5f18f523a 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -605,10 +605,7 @@ NS_IMETHODIMP mozXMLTerminal::ScreenSize(PRInt32* rows, PRInt32* cols, result = fontMetrics->GetMaxAdvance(fontWidth); // Determine docshell size in twips - nsRect shellArea; - result = presContext->GetVisibleArea(shellArea); - if (NS_FAILED(result)) - return result; + nsRect shellArea = presContext->GetVisibleArea(); // Determine twips to pixels conversion factor float pixelScale; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index b3c396ebfe3..d9aa496f8b1 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -798,8 +798,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon { mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) docShell->GetLayoutHistoryState(getter_AddRefs(mFrameState)); @@ -3628,10 +3627,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, #endif { nsresult rv; - nsCOMPtr container; - if (nsnull != aPresContext) { - aPresContext->GetContainer(getter_AddRefs(container)); - if (nsnull != container) { + if (aPresContext) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { nsCOMPtr scrollableContainer = do_QueryInterface(container, &rv); if (NS_SUCCEEDED(rv) && scrollableContainer) { PRInt32 scrolling = -1; @@ -4588,8 +4586,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -4607,8 +4604,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, isReplaced = PR_TRUE; PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -4635,8 +4631,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -5299,8 +5294,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // XXX should turning off frames allow XUL iframes? PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index f9627725b2f..8bfb74f840b 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -2685,12 +2685,11 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - nsRect shellArea; PRInt32 width, height; float pixelScale; // so how big is it? - presContext->GetVisibleArea(shellArea); + nsRect shellArea = presContext->GetVisibleArea(); presContext->GetTwipsToPixels(&pixelScale); width = PRInt32((float)shellArea.width*pixelScale); height = PRInt32((float)shellArea.height*pixelScale); @@ -3591,8 +3590,7 @@ DocumentViewerImpl::ReturnToGalleyPresentation() } // Get the current size of what is being viewed - nsRect area; - mPresContext->GetVisibleArea(area); + nsRect area = mPresContext->GetVisibleArea(); nsRect bounds; mWindow->GetBounds(bounds); @@ -3697,8 +3695,7 @@ DocumentViewerImpl::InstallNewPresentation() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) // Get the current size of what is being viewed - nsRect area; - mPresContext->GetVisibleArea(area); + nsRect area = mPresContext->GetVisibleArea(); nsRect bounds; mWindow->GetBounds(bounds); diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 44ebc12a012..b13a8a68f34 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -232,6 +232,7 @@ nsPresContext::~nsPresContext() NS_IF_RELEASE(mDeviceContext); NS_IF_RELEASE(mLookAndFeel); + NS_IF_RELEASE(mLanguage); } NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver) @@ -706,8 +707,8 @@ void nsPresContext::UpdateCharSet(const char* aCharSet) { if (mLangService) { - mLangService->LookupCharSet(aCharSet, - getter_AddRefs(mLanguage)); + NS_IF_RELEASE(mLanguage); + mLangService->LookupCharSet(aCharSet, &mLanguage); // addrefs GetFontPreferences(); if (mLanguage) { nsCOMPtr langGroupAtom; @@ -934,20 +935,6 @@ nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) } -NS_IMETHODIMP -nsPresContext::GetVisibleArea(nsRect& aResult) -{ - aResult = mVisibleArea; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetVisibleArea(const nsRect& r) -{ - mVisibleArea = r; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetPixelsToTwips(float* aResult) const { @@ -1032,7 +1019,7 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const return NS_OK; } -NS_IMETHODIMP +nsresult nsPresContext::LoadImage(nsIURI* aURL, nsIFrame* aTargetFrame,//may be null (precached image) imgIRequest **aRequest) @@ -1093,7 +1080,7 @@ nsPresContext::LoadImage(nsIURI* aURL, } -NS_IMETHODIMP +void nsPresContext::StopImagesFor(nsIFrame* aTargetFrame) { nsVoidKey key(aTargetFrame); @@ -1105,47 +1092,28 @@ nsPresContext::StopImagesFor(nsIFrame* aTargetFrame) mImageLoaders.Remove(&key); } - - return NS_OK; } -NS_IMETHODIMP -nsPresContext::SetLinkHandler(nsILinkHandler* aHandler) -{ - mLinkHandler = aHandler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetLinkHandler(nsILinkHandler** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mLinkHandler; - NS_IF_ADDREF(mLinkHandler); - return NS_OK; -} - -NS_IMETHODIMP +void nsPresContext::SetContainer(nsISupports* aHandler) { mContainer = do_GetWeakReference(aHandler); if (mContainer) { GetDocumentColorPreferences(); } - return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetContainer(nsISupports** aResult) +already_AddRefed +nsPresContext::GetContainer() { - NS_PRECONDITION(aResult, "null out param"); - if (!mContainer) { - *aResult = nsnull; - return NS_OK; - } + nsISupports *result; + if (mContainer) + CallQueryReferent(mContainer.get(), &result); + else + result = nsnull; - return CallQueryReferent(mContainer.get(), aResult); + return result; } nsIEventStateManager* @@ -1307,17 +1275,6 @@ nsPresContext::GetBidiCharset(nsACString &aCharSet) const #endif //IBMBIDI -NS_IMETHODIMP -nsPresContext::GetLanguage(nsILanguageAtom** aLanguage) -{ - NS_PRECONDITION(aLanguage, "null out param"); - - *aLanguage = mLanguage; - NS_IF_ADDREF(*aLanguage); - - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetLanguageSpecificTransformType( nsLanguageSpecificTransformType* aType) diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 5f80bce28f5..ea0ffe75d7f 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -45,6 +45,7 @@ #include "nsCompatibility.h" #include "nsCOMPtr.h" #include "nsIPresShell.h" +#include "nsRect.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -241,23 +242,23 @@ public: * method will be invoked (via the ViewManager) so that the * appropriate damage repair is done. */ - NS_IMETHOD LoadImage(nsIURI* aURL, - nsIFrame* aTargetFrame, - imgIRequest **aRequest) = 0; + virtual nsresult LoadImage(nsIURI* aURL, + nsIFrame* aTargetFrame, + imgIRequest **aRequest) = 0; /** * This method is called when a frame is being destroyed to * ensure that the image load gets disassociated from the prescontext */ - NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0; + virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0; - NS_IMETHOD SetContainer(nsISupports* aContainer) = 0; + virtual void SetContainer(nsISupports* aContainer) = 0; - NS_IMETHOD GetContainer(nsISupports** aResult) = 0; + virtual already_AddRefed GetContainer() = 0; // XXX this are going to be replaced with set/get container - NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler) = 0; - NS_IMETHOD GetLinkHandler(nsILinkHandler** aResult) = 0; + void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; } + nsILinkHandler* GetLinkHandler() { return mLinkHandler; } /** * Get the visible area associated with this presentation context. @@ -265,13 +266,13 @@ public: * presenting the document. The returned value is in the standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD GetVisibleArea(nsRect& aResult) = 0; + nsRect GetVisibleArea() { return mVisibleArea; } /** * Set the currently visible area. The units for r are standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD SetVisibleArea(const nsRect& r) = 0; + void SetVisibleArea(const nsRect& r) { mVisibleArea = r; } /** * Return true if this presentation context is a paginated @@ -300,7 +301,7 @@ public: * @param aActualRect returns the size of the actual device/surface * @param aRect returns the adjusted size */ - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; /** * Sets the "adjusted" rect for the page Dimimensions, @@ -309,7 +310,7 @@ public: * * @param aRect returns the adjusted size */ - NS_IMETHOD SetPageDim(nsRect* aRect) = 0; + virtual void SetPageDim(nsRect* aRect) = 0; NS_IMETHOD GetPixelsToTwips(float* aResult) const = 0; @@ -330,7 +331,7 @@ public: NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0; nsIEventStateManager* GetEventStateManager(); - NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0; + nsILanguageAtom* GetLanguage() { return mLanguage; } /** * Get the language-specific transform type for the current document. @@ -496,8 +497,13 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + nsILinkHandler* mLinkHandler; // [WEAK] + nsILanguageAtom* mLanguage; // [STRONG] + PRInt32 mFontScaler; + nsRect mVisibleArea; + nscolor mDefaultColor; nscolor mBackgroundColor; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 8c1b3858094..7420ea3635e 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1733,9 +1733,8 @@ PresShell::Init(nsIDocument* aDocument, //SetCaretEnabled(PR_TRUE); // make it show in browser windows #endif //set up selection to be displayed in document - nsCOMPtr container; - result = aPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell){ PRInt32 docShellType; @@ -2165,9 +2164,8 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) } // first, make sure this is not a chrome shell - nsCOMPtr container; - result = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell){ PRInt32 docShellType; @@ -2806,8 +2804,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) #ifdef DEBUG_kipp nsPresShell_ReflowStackPointerTop = (char*) &aWidth; #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -2946,8 +2943,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) #ifdef DEBUG_kipp nsPresShell_ReflowStackPointerTop = (char*) &aWidth; #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -3472,8 +3468,7 @@ PresShell::StyleChangeReflow() } } #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -3620,8 +3615,7 @@ PresShell::EndLoad(nsIDocument *aDocument) // Restore frame state for the root scroll frame nsIFrame* rootFrame = nsnull; GetRootFrame(&rootFrame); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (!container) return; @@ -4642,8 +4636,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa NS_PRECONDITION(nsnull != aState, "null state pointer"); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (!container) return NS_ERROR_FAILURE; @@ -4855,8 +4848,7 @@ PresShell::UnsuppressAndInvalidate() // causes us to blur incorrectly. focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads"); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (container) { nsCOMPtr cvc(do_QueryInterface(container)); if (cvc) { @@ -5764,8 +5756,7 @@ nsresult PresShell::RetargetEventToParent(nsIView *aView, // Next, update the display so the old focus ring is no longer visible - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); NS_ASSERTION(docShell, "No docshell for container."); @@ -6167,8 +6158,6 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, NS_IMETHODIMP PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, nsEvent* aEvent, nsEventStatus* aStatus) { - nsresult ret; - PushCurrentEventInfo(nsnull, aTargetContent); // Bug 41013: Check if the event should be dispatched to content. @@ -6176,12 +6165,12 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, nsEvent* aEvent, // and the js context is out of date. This check detects the case // that caused a crash in bug 41013, but there may be a better way // to handle this situation! - nsCOMPtr container; - ret = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(ret) && container) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { // Dispatch event to content - ret = aTargetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, NS_EVENT_FLAG_INIT, aStatus); + aTargetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, + NS_EVENT_FLAG_INIT, aStatus); } PopCurrentEventInfo(); @@ -7033,17 +7022,13 @@ PresShell::VerifyIncrementalReflow() rv = NS_NewGalleyContext(&cx); } - nsISupports* container; - if (NS_SUCCEEDED(mPresContext->GetContainer(&container)) && - (nsnull != container)) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { cx->SetContainer(container); - nsILinkHandler* lh; - if (NS_SUCCEEDED(container->QueryInterface(NS_GET_IID(nsILinkHandler), - (void**)&lh))) { + nsCOMPtr lh = do_QueryInterface(container); + if (lh) { cx->SetLinkHandler(lh); - NS_RELEASE(lh); } - NS_RELEASE(container); } NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context"); @@ -7074,8 +7059,7 @@ PresShell::VerifyIncrementalReflow() // Create a child window of the parent that is our "root view/window" // Create a view - nsRect tbounds; - mPresContext->GetVisibleArea(tbounds); + nsRect tbounds = mPresContext->GetVisibleArea(); nsIView* view; rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), @@ -7095,8 +7079,7 @@ PresShell::VerifyIncrementalReflow() // Make the new presentation context the same size as our // presentation context. - nsRect r; - mPresContext->GetVisibleArea(r); + nsRect r = mPresContext->GetVisibleArea(); cx->SetVisibleArea(r); // Create a new presentation shell to view the document. Use the diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 5f80bce28f5..ea0ffe75d7f 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -45,6 +45,7 @@ #include "nsCompatibility.h" #include "nsCOMPtr.h" #include "nsIPresShell.h" +#include "nsRect.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -241,23 +242,23 @@ public: * method will be invoked (via the ViewManager) so that the * appropriate damage repair is done. */ - NS_IMETHOD LoadImage(nsIURI* aURL, - nsIFrame* aTargetFrame, - imgIRequest **aRequest) = 0; + virtual nsresult LoadImage(nsIURI* aURL, + nsIFrame* aTargetFrame, + imgIRequest **aRequest) = 0; /** * This method is called when a frame is being destroyed to * ensure that the image load gets disassociated from the prescontext */ - NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0; + virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0; - NS_IMETHOD SetContainer(nsISupports* aContainer) = 0; + virtual void SetContainer(nsISupports* aContainer) = 0; - NS_IMETHOD GetContainer(nsISupports** aResult) = 0; + virtual already_AddRefed GetContainer() = 0; // XXX this are going to be replaced with set/get container - NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler) = 0; - NS_IMETHOD GetLinkHandler(nsILinkHandler** aResult) = 0; + void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; } + nsILinkHandler* GetLinkHandler() { return mLinkHandler; } /** * Get the visible area associated with this presentation context. @@ -265,13 +266,13 @@ public: * presenting the document. The returned value is in the standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD GetVisibleArea(nsRect& aResult) = 0; + nsRect GetVisibleArea() { return mVisibleArea; } /** * Set the currently visible area. The units for r are standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD SetVisibleArea(const nsRect& r) = 0; + void SetVisibleArea(const nsRect& r) { mVisibleArea = r; } /** * Return true if this presentation context is a paginated @@ -300,7 +301,7 @@ public: * @param aActualRect returns the size of the actual device/surface * @param aRect returns the adjusted size */ - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; /** * Sets the "adjusted" rect for the page Dimimensions, @@ -309,7 +310,7 @@ public: * * @param aRect returns the adjusted size */ - NS_IMETHOD SetPageDim(nsRect* aRect) = 0; + virtual void SetPageDim(nsRect* aRect) = 0; NS_IMETHOD GetPixelsToTwips(float* aResult) const = 0; @@ -330,7 +331,7 @@ public: NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0; nsIEventStateManager* GetEventStateManager(); - NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0; + nsILanguageAtom* GetLanguage() { return mLanguage; } /** * Get the language-specific transform type for the current document. @@ -496,8 +497,13 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + nsILinkHandler* mLinkHandler; // [WEAK] + nsILanguageAtom* mLanguage; // [STRONG] + PRInt32 mFontScaler; + nsRect mVisibleArea; + nscolor mDefaultColor; nscolor mBackgroundColor; diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 5f80bce28f5..ea0ffe75d7f 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -45,6 +45,7 @@ #include "nsCompatibility.h" #include "nsCOMPtr.h" #include "nsIPresShell.h" +#include "nsRect.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -241,23 +242,23 @@ public: * method will be invoked (via the ViewManager) so that the * appropriate damage repair is done. */ - NS_IMETHOD LoadImage(nsIURI* aURL, - nsIFrame* aTargetFrame, - imgIRequest **aRequest) = 0; + virtual nsresult LoadImage(nsIURI* aURL, + nsIFrame* aTargetFrame, + imgIRequest **aRequest) = 0; /** * This method is called when a frame is being destroyed to * ensure that the image load gets disassociated from the prescontext */ - NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0; + virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0; - NS_IMETHOD SetContainer(nsISupports* aContainer) = 0; + virtual void SetContainer(nsISupports* aContainer) = 0; - NS_IMETHOD GetContainer(nsISupports** aResult) = 0; + virtual already_AddRefed GetContainer() = 0; // XXX this are going to be replaced with set/get container - NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler) = 0; - NS_IMETHOD GetLinkHandler(nsILinkHandler** aResult) = 0; + void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; } + nsILinkHandler* GetLinkHandler() { return mLinkHandler; } /** * Get the visible area associated with this presentation context. @@ -265,13 +266,13 @@ public: * presenting the document. The returned value is in the standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD GetVisibleArea(nsRect& aResult) = 0; + nsRect GetVisibleArea() { return mVisibleArea; } /** * Set the currently visible area. The units for r are standard * nscoord units (as scaled by the device context). */ - NS_IMETHOD SetVisibleArea(const nsRect& r) = 0; + void SetVisibleArea(const nsRect& r) { mVisibleArea = r; } /** * Return true if this presentation context is a paginated @@ -300,7 +301,7 @@ public: * @param aActualRect returns the size of the actual device/surface * @param aRect returns the adjusted size */ - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; /** * Sets the "adjusted" rect for the page Dimimensions, @@ -309,7 +310,7 @@ public: * * @param aRect returns the adjusted size */ - NS_IMETHOD SetPageDim(nsRect* aRect) = 0; + virtual void SetPageDim(nsRect* aRect) = 0; NS_IMETHOD GetPixelsToTwips(float* aResult) const = 0; @@ -330,7 +331,7 @@ public: NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0; nsIEventStateManager* GetEventStateManager(); - NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage) = 0; + nsILanguageAtom* GetLanguage() { return mLanguage; } /** * Get the language-specific transform type for the current document. @@ -496,8 +497,13 @@ protected: nsIAtom* mMedium; // initialized by subclass ctors; // weak pointer to static atom + nsILinkHandler* mLinkHandler; // [WEAK] + nsILanguageAtom* mLanguage; // [STRONG] + PRInt32 mFontScaler; + nsRect mVisibleArea; + nscolor mDefaultColor; nscolor mBackgroundColor; diff --git a/mozilla/layout/base/src/nsGalleyContext.cpp b/mozilla/layout/base/src/nsGalleyContext.cpp index 06e114be1e8..865f4e67ee4 100644 --- a/mozilla/layout/base/src/nsGalleyContext.cpp +++ b/mozilla/layout/base/src/nsGalleyContext.cpp @@ -47,8 +47,8 @@ public: NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { return NS_ERROR_FAILURE; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); - NS_IMETHOD SetPageDim(nsRect* aRect); + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); + virtual void SetPageDim(nsRect* aRect); }; GalleyContext::GalleyContext() @@ -79,21 +79,18 @@ GalleyContext::GetPaginatedScrolling(PRBool* aResult) return NS_OK; } -NS_IMETHODIMP +void GalleyContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) { - NS_ENSURE_ARG_POINTER(aActualRect); - NS_ENSURE_ARG_POINTER(aAdjRect); - aActualRect->SetRect(0, 0, 0, 0); - aAdjRect->SetRect(0, 0, 0, 0); - return NS_ERROR_FAILURE; + if (aActualRect && aAdjRect) { + aActualRect->SetRect(0, 0, 0, 0); + aAdjRect->SetRect(0, 0, 0, 0); + } } -NS_IMETHODIMP +void GalleyContext::SetPageDim(nsRect* aPageDim) { - NS_ENSURE_ARG_POINTER(aPageDim); - return NS_ERROR_FAILURE; } nsresult diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 44ebc12a012..b13a8a68f34 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -232,6 +232,7 @@ nsPresContext::~nsPresContext() NS_IF_RELEASE(mDeviceContext); NS_IF_RELEASE(mLookAndFeel); + NS_IF_RELEASE(mLanguage); } NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver) @@ -706,8 +707,8 @@ void nsPresContext::UpdateCharSet(const char* aCharSet) { if (mLangService) { - mLangService->LookupCharSet(aCharSet, - getter_AddRefs(mLanguage)); + NS_IF_RELEASE(mLanguage); + mLangService->LookupCharSet(aCharSet, &mLanguage); // addrefs GetFontPreferences(); if (mLanguage) { nsCOMPtr langGroupAtom; @@ -934,20 +935,6 @@ nsPresContext::GetUseFocusColors(PRBool& aUseFocusColors) } -NS_IMETHODIMP -nsPresContext::GetVisibleArea(nsRect& aResult) -{ - aResult = mVisibleArea; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::SetVisibleArea(const nsRect& r) -{ - mVisibleArea = r; - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetPixelsToTwips(float* aResult) const { @@ -1032,7 +1019,7 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const return NS_OK; } -NS_IMETHODIMP +nsresult nsPresContext::LoadImage(nsIURI* aURL, nsIFrame* aTargetFrame,//may be null (precached image) imgIRequest **aRequest) @@ -1093,7 +1080,7 @@ nsPresContext::LoadImage(nsIURI* aURL, } -NS_IMETHODIMP +void nsPresContext::StopImagesFor(nsIFrame* aTargetFrame) { nsVoidKey key(aTargetFrame); @@ -1105,47 +1092,28 @@ nsPresContext::StopImagesFor(nsIFrame* aTargetFrame) mImageLoaders.Remove(&key); } - - return NS_OK; } -NS_IMETHODIMP -nsPresContext::SetLinkHandler(nsILinkHandler* aHandler) -{ - mLinkHandler = aHandler; - return NS_OK; -} - -NS_IMETHODIMP -nsPresContext::GetLinkHandler(nsILinkHandler** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mLinkHandler; - NS_IF_ADDREF(mLinkHandler); - return NS_OK; -} - -NS_IMETHODIMP +void nsPresContext::SetContainer(nsISupports* aHandler) { mContainer = do_GetWeakReference(aHandler); if (mContainer) { GetDocumentColorPreferences(); } - return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetContainer(nsISupports** aResult) +already_AddRefed +nsPresContext::GetContainer() { - NS_PRECONDITION(aResult, "null out param"); - if (!mContainer) { - *aResult = nsnull; - return NS_OK; - } + nsISupports *result; + if (mContainer) + CallQueryReferent(mContainer.get(), &result); + else + result = nsnull; - return CallQueryReferent(mContainer.get(), aResult); + return result; } nsIEventStateManager* @@ -1307,17 +1275,6 @@ nsPresContext::GetBidiCharset(nsACString &aCharSet) const #endif //IBMBIDI -NS_IMETHODIMP -nsPresContext::GetLanguage(nsILanguageAtom** aLanguage) -{ - NS_PRECONDITION(aLanguage, "null out param"); - - *aLanguage = mLanguage; - NS_IF_ADDREF(*aLanguage); - - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetLanguageSpecificTransformType( nsLanguageSpecificTransformType* aType) diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 7ccd8d9d31e..daee7c26605 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -84,22 +84,18 @@ public: NS_IMETHOD GetUseFocusColors(PRBool& useFocusColors); NS_IMETHOD GetFocusRingOnAnything(PRBool& focusRingOnAnything); - NS_IMETHOD LoadImage(nsIURI* aURL, - nsIFrame* aTargetFrame, - imgIRequest **aRequest); + virtual nsresult LoadImage(nsIURI* aURL, + nsIFrame* aTargetFrame, + imgIRequest **aRequest); - NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame); - NS_IMETHOD SetContainer(nsISupports* aContainer); - NS_IMETHOD GetContainer(nsISupports** aResult); - NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler); - NS_IMETHOD GetLinkHandler(nsILinkHandler** aResult); - NS_IMETHOD GetVisibleArea(nsRect& aResult); - NS_IMETHOD SetVisibleArea(const nsRect& r); + virtual void StopImagesFor(nsIFrame* aTargetFrame); + virtual void SetContainer(nsISupports* aContainer); + virtual already_AddRefed GetContainer(); NS_IMETHOD IsPaginated(PRBool* aResult) = 0; NS_IMETHOD SetPaginatedScrolling(PRBool aResult) = 0; NS_IMETHOD GetPaginatedScrolling(PRBool* aResult) = 0; - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; - NS_IMETHOD SetPageDim(nsRect* aRect) = 0; + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0; + virtual void SetPageDim(nsRect* aRect) = 0; NS_IMETHOD GetPixelsToTwips(float* aResult) const; NS_IMETHOD GetTwipsToPixels(float* aResult) const; NS_IMETHOD GetTwipsToPixelsForFonts(float* aResult) const; @@ -109,7 +105,6 @@ public: nsIEventStateManager* GetEventStateManager() { return nsIPresContext::GetEventStateManager(); } - NS_IMETHOD GetLanguage(nsILanguageAtom** aLanguage); NS_IMETHOD GetLanguageSpecificTransformType( nsLanguageSpecificTransformType* aType); @@ -163,11 +158,8 @@ protected: virtual ~nsPresContext(); nsCOMPtr mPrefs; - nsRect mVisibleArea; nsCOMPtr mLangService; - nsCOMPtr mLanguage; nsLanguageSpecificTransformType mLanguageSpecificTransformType; - nsILinkHandler* mLinkHandler; // [WEAK] nsWeakPtr mContainer; nsFont mDefaultVariableFont; diff --git a/mozilla/layout/base/src/nsPrintContext.cpp b/mozilla/layout/base/src/nsPrintContext.cpp index 18706438fa0..9ba51e16e21 100644 --- a/mozilla/layout/base/src/nsPrintContext.cpp +++ b/mozilla/layout/base/src/nsPrintContext.cpp @@ -62,8 +62,8 @@ public: NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { return NS_ERROR_FAILURE; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); - NS_IMETHOD SetPageDim(nsRect* aRect); + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); + virtual void SetPageDim(nsRect* aRect); virtual void SetImageAnimationMode(PRUint16 aMode); NS_IMETHOD SetPrintSettings(nsIPrintSettings* aPS); NS_IMETHOD GetPrintSettings(nsIPrintSettings** aPS); @@ -123,26 +123,24 @@ PrintContext::GetPaginatedScrolling(PRBool* aResult) return NS_OK; } -NS_IMETHODIMP +void PrintContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) { - NS_ENSURE_ARG_POINTER(aActualRect); - NS_ENSURE_ARG_POINTER(aAdjRect); + if (aActualRect && aAdjRect) { - PRInt32 width,height; - if (NS_SUCCEEDED(mDeviceContext->GetDeviceSurfaceDimensions(width, height))) { - aActualRect->SetRect(0, 0, width, height); + PRInt32 width,height; + nsresult rv = mDeviceContext->GetDeviceSurfaceDimensions(width, height); + if (NS_SUCCEEDED(rv)) + aActualRect->SetRect(0, 0, width, height); } *aAdjRect = mPageDim; - return NS_OK; } -NS_IMETHODIMP +void PrintContext::SetPageDim(nsRect* aPageDim) { - NS_ENSURE_ARG_POINTER(aPageDim); - mPageDim = *aPageDim; - return NS_OK; + if (aPageDim) + mPageDim = *aPageDim; } /** diff --git a/mozilla/layout/base/src/nsPrintPreviewContext.cpp b/mozilla/layout/base/src/nsPrintPreviewContext.cpp index 62f7b9b2ac6..26c4e8b5908 100644 --- a/mozilla/layout/base/src/nsPrintPreviewContext.cpp +++ b/mozilla/layout/base/src/nsPrintPreviewContext.cpp @@ -59,8 +59,8 @@ public: NS_IMETHOD IsPaginated(PRBool* aResult); NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { mCanPaginatedScroll = aResult; return NS_OK; } NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); - NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); - NS_IMETHOD SetPageDim(nsRect* aRect); + virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); + virtual void SetPageDim(nsRect* aRect); virtual void SetImageAnimationMode(PRUint16 aMode); NS_IMETHOD SetPrintSettings(nsIPrintSettings* aPS); NS_IMETHOD GetPrintSettings(nsIPrintSettings** aPS); @@ -124,26 +124,23 @@ PrintPreviewContext::GetPaginatedScrolling(PRBool* aResult) return NS_OK; } -NS_IMETHODIMP +void PrintPreviewContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) { - NS_ENSURE_ARG_POINTER(aActualRect); - NS_ENSURE_ARG_POINTER(aAdjRect); - - PRInt32 width,height; - if (NS_SUCCEEDED(mDeviceContext->GetDeviceSurfaceDimensions(width, height))) { - aActualRect->SetRect(0, 0, width, height); + if (aActualRect && aAdjRect) { + PRInt32 width,height; + nsresult rv = mDeviceContext->GetDeviceSurfaceDimensions(width, height); + if (NS_SUCCEEDED(rv)) + aActualRect->SetRect(0, 0, width, height); } *aAdjRect = mPageDim; - return NS_OK; } -NS_IMETHODIMP +void PrintPreviewContext::SetPageDim(nsRect* aPageDim) { - NS_ENSURE_ARG_POINTER(aPageDim); - mPageDim = *aPageDim; - return NS_OK; + if (aPageDim) + mPageDim = *aPageDim; } /** diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index 7ba40e09fa4..ef87d4428ee 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -406,91 +406,90 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) // End ProcessAsURLEncoded // make the url string - nsCOMPtr handler; - if (NS_OK == aPresContext->GetLinkHandler(getter_AddRefs(handler))) { - nsAutoString href; + nsILinkHandler *handler = aPresContext->GetLinkHandler(); - // Get the document. - // We'll need it now to form the URL we're submitting to. - // We'll also need it later to get the DOM window when notifying form submit observers (bug 33203) - nsCOMPtr document = mContent->GetDocument(); - if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 + nsAutoString href; - // Resolve url to an absolute url - nsIURI *docURL = document->GetBaseURI(); - if (!docURL) { - NS_ERROR("No Base URL found in Form Submit!\n"); - return NS_OK; // No base URL -> exit early, see Bug 30721 + // Get the document. + // We'll need it now to form the URL we're submitting to. + // We'll also need it later to get the DOM window when notifying form submit observers (bug 33203) + nsCOMPtr document = mContent->GetDocument(); + if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 + + // Resolve url to an absolute url + nsIURI *docURL = document->GetBaseURI(); + 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 + // compatible with 4.x browsers. + // If we are in some other type of document such as XML or + // XUL, do nothing. This prevents undesirable reloading of + // a document inside XUL. + + nsresult rv; + nsCOMPtr htmlDoc; + htmlDoc = do_QueryInterface(document, &rv); + if (NS_FAILED(rv)) { + // Must be a XML, XUL or other non-HTML document type + // so do nothing. + return NS_OK; + } + + // Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is + // passed a zero length rel path. + nsCAutoString relPath; + docURL->GetSpec(relPath); + if (!relPath.IsEmpty()) { + CopyUTF8toUTF16(relPath, href); + + // If re-using the same URL, chop off old query string (bug 25330) + PRInt32 queryStart = href.FindChar('?'); + if (kNotFound != queryStart) { + href.Truncate(queryStart); } + } else { + NS_ERROR("Rel path couldn't be formed in form submit!\n"); + return NS_ERROR_OUT_OF_MEMORY; + } - // If an action is not specified and we are inside - // a HTML document then reload the URL. This makes us - // compatible with 4.x browsers. - // If we are in some other type of document such as XML or - // XUL, do nothing. This prevents undesirable reloading of - // a document inside XUL. + // Add the URI encoded form values to the URI + // Get the scheme of the URI. + nsCOMPtr actionURL; + nsXPIDLCString scheme; + PRBool isJSURL = PR_FALSE; + const nsACString &docCharset = document->GetDocumentCharacterSet(); + const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); - nsresult rv; - nsCOMPtr htmlDoc; - htmlDoc = do_QueryInterface(document, &rv); - if (NS_FAILED(rv)) { - // Must be a XML, XUL or other non-HTML document type - // so do nothing. - return NS_OK; - } - - // Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is - // passed a zero length rel path. - nsCAutoString relPath; - docURL->GetSpec(relPath); - if (!relPath.IsEmpty()) { - CopyUTF8toUTF16(relPath, href); - - // If re-using the same URL, chop off old query string (bug 25330) - PRInt32 queryStart = href.FindChar('?'); - if (kNotFound != queryStart) { - href.Truncate(queryStart); + if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, + flatDocCharset.get(), + docURL))) { + result = actionURL->SchemeIs("javascript", &isJSURL); + } + // Append the URI encoded variable/value pairs for GET's + if (!isJSURL) { // Not for JS URIs, see bug 26917 + if (href.FindChar('?') == kNotFound) { // Add a ? if needed + href.Append(PRUnichar('?')); + } else { // Adding to existing query string + if (href.Last() != '&' && href.Last() != '?') { // Add a & if needed + href.Append(PRUnichar('&')); } - } else { - NS_ERROR("Rel path couldn't be formed in form submit!\n"); - return NS_ERROR_OUT_OF_MEMORY; } + href.Append(data); + } + nsCOMPtr uri; + result = NS_NewURI(getter_AddRefs(uri), href, + flatDocCharset.get(), docURL); + if (NS_FAILED(result)) return result; - // Add the URI encoded form values to the URI - // Get the scheme of the URI. - nsCOMPtr actionURL; - nsXPIDLCString scheme; - PRBool isJSURL = PR_FALSE; - const nsACString &docCharset = document->GetDocumentCharacterSet(); - const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); - - if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, - flatDocCharset.get(), - docURL))) { - result = actionURL->SchemeIs("javascript", &isJSURL); - } - // Append the URI encoded variable/value pairs for GET's - if (!isJSURL) { // Not for JS URIs, see bug 26917 - if (href.FindChar('?') == kNotFound) { // Add a ? if needed - href.Append(PRUnichar('?')); - } else { // Adding to existing query string - if (href.Last() != '&' && href.Last() != '?') { // Add a & if needed - href.Append(PRUnichar('&')); - } - } - href.Append(data); - } - nsCOMPtr uri; - result = NS_NewURI(getter_AddRefs(uri), href, - flatDocCharset.get(), docURL); - if (NS_FAILED(result)) return result; - - // Now pass on absolute url to the click handler - if (handler) { - handler->OnLinkClick(mContent, eLinkVerb_Replace, - uri, - nsnull, nsnull); - } + // Now pass on absolute url to the click handler + if (handler) { + handler->OnLinkClick(mContent, eLinkVerb_Replace, + uri, + nsnull, nsnull); } return result; } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 4b4f60504f0..1fa745a7cdb 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -502,9 +502,7 @@ nsSubDocumentFrame::AttributeChanged(nsIPresContext* aPresContext, // If our container is a web-shell, inform it that it has a new // child. If it's not a web-shell then some things will not operate // properly. - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); - + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr parentAsNode(do_QueryInterface(container)); if (parentAsNode) { diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 8b066359637..d988f123a8c 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -694,8 +694,7 @@ nsHTMLFramesetFrame::GetDesiredSize(nsIPresContext* aPresContext, { nsHTMLFramesetFrame* framesetParent = GetFramesetParent(this); if (nsnull == framesetParent) { - nsRect area; - aPresContext->GetVisibleArea(area); + nsRect area = aPresContext->GetVisibleArea(); aDesiredSize.width = area.width; aDesiredSize.height= area.height; diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 8f9f8f5d70e..1d2830bf1e0 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -1476,9 +1476,8 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, PRBool aClick) { // We get here with server side image map - nsCOMPtr handler; - aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (nsnull != handler) { + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (handler) { if (aClick) { // Check that this page is allowed to load this URI. // Almost a copy of the similarly named method in nsGenericElement diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 418978f39fc..b70dfb6f22b 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -2294,8 +2294,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER); // the container of the pres context will give us the link handler - nsCOMPtr container; - nsresult rv = mContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mContext->GetContainer(); NS_ENSURE_TRUE(container,NS_ERROR_FAILURE); nsCOMPtr lh = do_QueryInterface(container); NS_ENSURE_TRUE(lh, NS_ERROR_FAILURE); @@ -2304,7 +2303,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge nsCOMPtr baseURL; nsCOMPtr doc; - rv = GetDocument(getter_AddRefs(doc)); + nsresult rv = GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv) && doc) { // XXX should this really be the document base URL? Or the // content's base URL? @@ -2367,12 +2366,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg) if (!mContext) { return rv; } - nsCOMPtr cont; - nsCOMPtr treeOwner; - - rv = mContext->GetContainer(getter_AddRefs(cont)); - if (NS_FAILED(rv) || !cont) { - return rv; + nsCOMPtr cont = mContext->GetContainer(); + if (!cont) { + return NS_OK; } nsCOMPtr docShellItem(do_QueryInterface(cont, &rv)); @@ -2380,6 +2376,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg) return rv; } + nsCOMPtr treeOwner; rv = docShellItem->GetTreeOwner(getter_AddRefs(treeOwner)); if (NS_FAILED(rv) || !treeOwner) { return rv; @@ -3831,8 +3828,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject // is destroyed. Here we make sure the plugin instance in the old // document is destroyed before we try to create the new one. - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); if (container) { // We need to suppress the focus controller so that destroying the old // content viewer doesn't transfer focus to the toplevel window. diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 8f9f8f5d70e..1d2830bf1e0 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -1476,9 +1476,8 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, PRBool aClick) { // We get here with server side image map - nsCOMPtr handler; - aPresContext->GetLinkHandler(getter_AddRefs(handler)); - if (nsnull != handler) { + nsILinkHandler *handler = aPresContext->GetLinkHandler(); + if (handler) { if (aClick) { // Check that this page is allowed to load this URI. // Almost a copy of the similarly named method in nsGenericElement diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 418978f39fc..b70dfb6f22b 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -2294,8 +2294,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge NS_ENSURE_TRUE(mContext,NS_ERROR_NULL_POINTER); // the container of the pres context will give us the link handler - nsCOMPtr container; - nsresult rv = mContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mContext->GetContainer(); NS_ENSURE_TRUE(container,NS_ERROR_FAILURE); nsCOMPtr lh = do_QueryInterface(container); NS_ENSURE_TRUE(lh, NS_ERROR_FAILURE); @@ -2304,7 +2303,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge nsCOMPtr baseURL; nsCOMPtr doc; - rv = GetDocument(getter_AddRefs(doc)); + nsresult rv = GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv) && doc) { // XXX should this really be the document base URL? Or the // content's base URL? @@ -2367,12 +2366,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg) if (!mContext) { return rv; } - nsCOMPtr cont; - nsCOMPtr treeOwner; - - rv = mContext->GetContainer(getter_AddRefs(cont)); - if (NS_FAILED(rv) || !cont) { - return rv; + nsCOMPtr cont = mContext->GetContainer(); + if (!cont) { + return NS_OK; } nsCOMPtr docShellItem(do_QueryInterface(cont, &rv)); @@ -2380,6 +2376,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg) return rv; } + nsCOMPtr treeOwner; rv = docShellItem->GetTreeOwner(getter_AddRefs(treeOwner)); if (NS_FAILED(rv) || !treeOwner) { return rv; @@ -3831,8 +3828,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject // is destroyed. Here we make sure the plugin instance in the old // document is destroyed before we try to create the new one. - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); if (container) { // We need to suppress the focus controller so that destroying the old // content viewer doesn't transfer focus to the toplevel window. diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 8c1b3858094..7420ea3635e 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1733,9 +1733,8 @@ PresShell::Init(nsIDocument* aDocument, //SetCaretEnabled(PR_TRUE); // make it show in browser windows #endif //set up selection to be displayed in document - nsCOMPtr container; - result = aPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell){ PRInt32 docShellType; @@ -2165,9 +2164,8 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow) } // first, make sure this is not a chrome shell - nsCOMPtr container; - result = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell){ PRInt32 docShellType; @@ -2806,8 +2804,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) #ifdef DEBUG_kipp nsPresShell_ReflowStackPointerTop = (char*) &aWidth; #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -2946,8 +2943,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) #ifdef DEBUG_kipp nsPresShell_ReflowStackPointerTop = (char*) &aWidth; #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -3472,8 +3468,7 @@ PresShell::StyleChangeReflow() } } #endif - nsRect bounds; - mPresContext->GetVisibleArea(bounds); + nsRect bounds = mPresContext->GetVisibleArea(); nsSize maxSize(bounds.width, bounds.height); nsHTMLReflowMetrics desiredSize(nsnull); nsReflowStatus status; @@ -3620,8 +3615,7 @@ PresShell::EndLoad(nsIDocument *aDocument) // Restore frame state for the root scroll frame nsIFrame* rootFrame = nsnull; GetRootFrame(&rootFrame); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (!container) return; @@ -4642,8 +4636,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa NS_PRECONDITION(nsnull != aState, "null state pointer"); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (!container) return NS_ERROR_FAILURE; @@ -4855,8 +4848,7 @@ PresShell::UnsuppressAndInvalidate() // causes us to blur incorrectly. focusController->SetSuppressFocus(PR_TRUE, "PresShell suppression on Web page loads"); - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); if (container) { nsCOMPtr cvc(do_QueryInterface(container)); if (cvc) { @@ -5764,8 +5756,7 @@ nsresult PresShell::RetargetEventToParent(nsIView *aView, // Next, update the display so the old focus ring is no longer visible - nsCOMPtr container; - mPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = mPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); NS_ASSERTION(docShell, "No docshell for container."); @@ -6167,8 +6158,6 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, NS_IMETHODIMP PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, nsEvent* aEvent, nsEventStatus* aStatus) { - nsresult ret; - PushCurrentEventInfo(nsnull, aTargetContent); // Bug 41013: Check if the event should be dispatched to content. @@ -6176,12 +6165,12 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, nsEvent* aEvent, // and the js context is out of date. This check detects the case // that caused a crash in bug 41013, but there may be a better way // to handle this situation! - nsCOMPtr container; - ret = mPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(ret) && container) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { // Dispatch event to content - ret = aTargetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, NS_EVENT_FLAG_INIT, aStatus); + aTargetContent->HandleDOMEvent(mPresContext, aEvent, nsnull, + NS_EVENT_FLAG_INIT, aStatus); } PopCurrentEventInfo(); @@ -7033,17 +7022,13 @@ PresShell::VerifyIncrementalReflow() rv = NS_NewGalleyContext(&cx); } - nsISupports* container; - if (NS_SUCCEEDED(mPresContext->GetContainer(&container)) && - (nsnull != container)) { + nsCOMPtr container = mPresContext->GetContainer(); + if (container) { cx->SetContainer(container); - nsILinkHandler* lh; - if (NS_SUCCEEDED(container->QueryInterface(NS_GET_IID(nsILinkHandler), - (void**)&lh))) { + nsCOMPtr lh = do_QueryInterface(container); + if (lh) { cx->SetLinkHandler(lh); - NS_RELEASE(lh); } - NS_RELEASE(container); } NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context"); @@ -7074,8 +7059,7 @@ PresShell::VerifyIncrementalReflow() // Create a child window of the parent that is our "root view/window" // Create a view - nsRect tbounds; - mPresContext->GetVisibleArea(tbounds); + nsRect tbounds = mPresContext->GetVisibleArea(); nsIView* view; rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), @@ -7095,8 +7079,7 @@ PresShell::VerifyIncrementalReflow() // Make the new presentation context the same size as our // presentation context. - nsRect r; - mPresContext->GetVisibleArea(r); + nsRect r = mPresContext->GetVisibleArea(); cx->SetVisibleArea(r); // Create a new presentation shell to view the document. Use the diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 4b4f60504f0..1fa745a7cdb 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -502,9 +502,7 @@ nsSubDocumentFrame::AttributeChanged(nsIPresContext* aPresContext, // If our container is a web-shell, inform it that it has a new // child. If it's not a web-shell then some things will not operate // properly. - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); - + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr parentAsNode(do_QueryInterface(container)); if (parentAsNode) { diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 8b066359637..d988f123a8c 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -694,8 +694,7 @@ nsHTMLFramesetFrame::GetDesiredSize(nsIPresContext* aPresContext, { nsHTMLFramesetFrame* framesetParent = GetFramesetParent(this); if (nsnull == framesetParent) { - nsRect area; - aPresContext->GetVisibleArea(area); + nsRect area = aPresContext->GetVisibleArea(); aDesiredSize.width = area.width; aDesiredSize.height= area.height; diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index 7ba40e09fa4..ef87d4428ee 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -406,91 +406,90 @@ nsIsIndexFrame::OnSubmit(nsIPresContext* aPresContext) // End ProcessAsURLEncoded // make the url string - nsCOMPtr handler; - if (NS_OK == aPresContext->GetLinkHandler(getter_AddRefs(handler))) { - nsAutoString href; + nsILinkHandler *handler = aPresContext->GetLinkHandler(); - // Get the document. - // We'll need it now to form the URL we're submitting to. - // We'll also need it later to get the DOM window when notifying form submit observers (bug 33203) - nsCOMPtr document = mContent->GetDocument(); - if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 + nsAutoString href; - // Resolve url to an absolute url - nsIURI *docURL = document->GetBaseURI(); - if (!docURL) { - NS_ERROR("No Base URL found in Form Submit!\n"); - return NS_OK; // No base URL -> exit early, see Bug 30721 + // Get the document. + // We'll need it now to form the URL we're submitting to. + // We'll also need it later to get the DOM window when notifying form submit observers (bug 33203) + nsCOMPtr document = mContent->GetDocument(); + if (!document) return NS_OK; // No doc means don't submit, see Bug 28988 + + // Resolve url to an absolute url + nsIURI *docURL = document->GetBaseURI(); + 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 + // compatible with 4.x browsers. + // If we are in some other type of document such as XML or + // XUL, do nothing. This prevents undesirable reloading of + // a document inside XUL. + + nsresult rv; + nsCOMPtr htmlDoc; + htmlDoc = do_QueryInterface(document, &rv); + if (NS_FAILED(rv)) { + // Must be a XML, XUL or other non-HTML document type + // so do nothing. + return NS_OK; + } + + // Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is + // passed a zero length rel path. + nsCAutoString relPath; + docURL->GetSpec(relPath); + if (!relPath.IsEmpty()) { + CopyUTF8toUTF16(relPath, href); + + // If re-using the same URL, chop off old query string (bug 25330) + PRInt32 queryStart = href.FindChar('?'); + if (kNotFound != queryStart) { + href.Truncate(queryStart); } + } else { + NS_ERROR("Rel path couldn't be formed in form submit!\n"); + return NS_ERROR_OUT_OF_MEMORY; + } - // If an action is not specified and we are inside - // a HTML document then reload the URL. This makes us - // compatible with 4.x browsers. - // If we are in some other type of document such as XML or - // XUL, do nothing. This prevents undesirable reloading of - // a document inside XUL. + // Add the URI encoded form values to the URI + // Get the scheme of the URI. + nsCOMPtr actionURL; + nsXPIDLCString scheme; + PRBool isJSURL = PR_FALSE; + const nsACString &docCharset = document->GetDocumentCharacterSet(); + const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); - nsresult rv; - nsCOMPtr htmlDoc; - htmlDoc = do_QueryInterface(document, &rv); - if (NS_FAILED(rv)) { - // Must be a XML, XUL or other non-HTML document type - // so do nothing. - return NS_OK; - } - - // Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is - // passed a zero length rel path. - nsCAutoString relPath; - docURL->GetSpec(relPath); - if (!relPath.IsEmpty()) { - CopyUTF8toUTF16(relPath, href); - - // If re-using the same URL, chop off old query string (bug 25330) - PRInt32 queryStart = href.FindChar('?'); - if (kNotFound != queryStart) { - href.Truncate(queryStart); + if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, + flatDocCharset.get(), + docURL))) { + result = actionURL->SchemeIs("javascript", &isJSURL); + } + // Append the URI encoded variable/value pairs for GET's + if (!isJSURL) { // Not for JS URIs, see bug 26917 + if (href.FindChar('?') == kNotFound) { // Add a ? if needed + href.Append(PRUnichar('?')); + } else { // Adding to existing query string + if (href.Last() != '&' && href.Last() != '?') { // Add a & if needed + href.Append(PRUnichar('&')); } - } else { - NS_ERROR("Rel path couldn't be formed in form submit!\n"); - return NS_ERROR_OUT_OF_MEMORY; } + href.Append(data); + } + nsCOMPtr uri; + result = NS_NewURI(getter_AddRefs(uri), href, + flatDocCharset.get(), docURL); + if (NS_FAILED(result)) return result; - // Add the URI encoded form values to the URI - // Get the scheme of the URI. - nsCOMPtr actionURL; - nsXPIDLCString scheme; - PRBool isJSURL = PR_FALSE; - const nsACString &docCharset = document->GetDocumentCharacterSet(); - const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset); - - if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href, - flatDocCharset.get(), - docURL))) { - result = actionURL->SchemeIs("javascript", &isJSURL); - } - // Append the URI encoded variable/value pairs for GET's - if (!isJSURL) { // Not for JS URIs, see bug 26917 - if (href.FindChar('?') == kNotFound) { // Add a ? if needed - href.Append(PRUnichar('?')); - } else { // Adding to existing query string - if (href.Last() != '&' && href.Last() != '?') { // Add a & if needed - href.Append(PRUnichar('&')); - } - } - href.Append(data); - } - nsCOMPtr uri; - result = NS_NewURI(getter_AddRefs(uri), href, - flatDocCharset.get(), docURL); - if (NS_FAILED(result)) return result; - - // Now pass on absolute url to the click handler - if (handler) { - handler->OnLinkClick(mContent, eLinkVerb_Replace, - uri, - nsnull, nsnull); - } + // Now pass on absolute url to the click handler + if (handler) { + handler->OnLinkClick(mContent, eLinkVerb_Replace, + uri, + nsnull, nsnull); } return result; } diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index b3c396ebfe3..d9aa496f8b1 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -798,8 +798,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon { mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) docShell->GetLayoutHistoryState(getter_AddRefs(mFrameState)); @@ -3628,10 +3627,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell, #endif { nsresult rv; - nsCOMPtr container; - if (nsnull != aPresContext) { - aPresContext->GetContainer(getter_AddRefs(container)); - if (nsnull != container) { + if (aPresContext) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { nsCOMPtr scrollableContainer = do_QueryInterface(container, &rv); if (NS_SUCCEEDED(rv) && scrollableContainer) { PRInt32 scrolling = -1; @@ -4588,8 +4586,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -4607,8 +4604,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, isReplaced = PR_TRUE; PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -4635,8 +4631,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); @@ -5299,8 +5294,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, // XXX should turning off frames allow XUL iframes? PRBool allowSubframes = PR_TRUE; if (aPresContext) { - nsCOMPtr container; - aPresContext->GetContainer(getter_AddRefs(container)); + nsCOMPtr container = aPresContext->GetContainer(); nsCOMPtr docShell(do_QueryInterface(container)); if (docShell) { docShell->GetAllowSubframes(&allowSubframes); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 75caa17c830..c9d81142291 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -357,9 +357,8 @@ nsresult nsMathMLmactionFrame::ShowStatus(nsIPresContext* aPresContext, nsString& aStatusMsg) { - nsCOMPtr cont; - nsresult rv = aPresContext->GetContainer(getter_AddRefs(cont)); - if (NS_SUCCEEDED(rv) && cont) { + nsCOMPtr cont = aPresContext->GetContainer(); + if (cont) { nsCOMPtr docShellItem(do_QueryInterface(cont)); if (docShellItem) { nsCOMPtr treeOwner; @@ -372,7 +371,7 @@ nsMathMLmactionFrame::ShowStatus(nsIPresContext* aPresContext, } } } - return rv; + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 71258427a68..99286ec6351 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -1343,9 +1343,9 @@ static PRBool IsChrome(nsIPresContext* aPresContext) { PRBool isChrome = PR_FALSE; - nsCOMPtr container; - nsresult result = aPresContext->GetContainer(getter_AddRefs(container)); - if (NS_SUCCEEDED(result) && container) { + nsCOMPtr container = aPresContext->GetContainer(); + if (container) { + nsresult result; nsCOMPtr docShell(do_QueryInterface(container, &result)); if (NS_SUCCEEDED(result) && docShell) { PRInt32 docShellType; diff --git a/mozilla/layout/style/nsStyleStruct.cpp b/mozilla/layout/style/nsStyleStruct.cpp index 4157878cafc..8155f7aea2e 100644 --- a/mozilla/layout/style/nsStyleStruct.cpp +++ b/mozilla/layout/style/nsStyleStruct.cpp @@ -1100,7 +1100,7 @@ nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext) else mDirection = NS_STYLE_DIRECTION_LTR; - aPresContext->GetLanguage(getter_AddRefs(mLanguage)); + mLanguage = aPresContext->GetLanguage(); mVisible = NS_STYLE_VISIBILITY_VISIBLE; } diff --git a/mozilla/layout/style/nsStyleUtil.cpp b/mozilla/layout/style/nsStyleUtil.cpp index 71ab0f2ca78..7560ef1a700 100644 --- a/mozilla/layout/style/nsStyleUtil.cpp +++ b/mozilla/layout/style/nsStyleUtil.cpp @@ -447,8 +447,7 @@ PRBool nsStyleUtil::IsHTMLLink(nsIContent *aContent, nsIAtom *aTag, nsIPresConte link->GetHrefURI(getter_AddRefs(hrefURI)); if (hrefURI) { - nsCOMPtr linkHandler; - aPresContext->GetLinkHandler(getter_AddRefs(linkHandler)); + nsILinkHandler *linkHandler = aPresContext->GetLinkHandler(); if (linkHandler) { linkHandler->GetLinkState(hrefURI, linkState); } @@ -502,8 +501,7 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon // XXX should we make sure to get the right charset off the document? (void) NS_NewURI(getter_AddRefs(absURI), val, nsnull, baseURI); - nsCOMPtr linkHandler; - aPresContext->GetLinkHandler(getter_AddRefs(linkHandler)); + nsILinkHandler *linkHandler = aPresContext->GetLinkHandler(); if (linkHandler) { linkHandler->GetLinkState(absURI, *aState); } diff --git a/mozilla/modules/oji/src/nsJVMManager.cpp b/mozilla/modules/oji/src/nsJVMManager.cpp index 9fef2b88cc3..0327a541108 100644 --- a/mozilla/modules/oji/src/nsJVMManager.cpp +++ b/mozilla/modules/oji/src/nsJVMManager.cpp @@ -852,9 +852,9 @@ nsJVMManager::GetChrome(nsIWebBrowserChrome **theChrome) if (!presContext) { return rv; } - rv = presContext->GetContainer(getter_AddRefs(cont)); + cont = presContext->GetContainer(); if (!cont) { - return rv; + return NS_OK; } treeItem = do_QueryInterface(cont, &rv); if (!treeItem) { diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 20ea848c25d..96eb05a788e 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -426,8 +426,7 @@ nsDocLoaderImpl::GetContentViewerContainer(nsISupports* aDocumentID, nsCOMPtr presContext; pres->GetPresContext(getter_AddRefs(presContext)); if (presContext) { - nsCOMPtr supp; - presContext->GetContainer(getter_AddRefs(supp)); + nsCOMPtr supp = presContext->GetContainer(); if (supp) { return CallQueryInterface(supp, aResult); }